剩余载具添加引擎损毁

This commit is contained in:
Atsuishio 2025-06-22 11:55:02 +08:00 committed by Light_Quanta
parent 35d3679203
commit 48e740ff64
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
10 changed files with 154 additions and 85 deletions

View file

@ -222,11 +222,11 @@ public class WgMissileEntity extends FastThrowableProjectile implements GeoEntit
Entity shooter = this.getOwner(); Entity shooter = this.getOwner();
Vec3 lookVec = vehicle.getBarrelVec(1).normalize(); Vec3 lookVec = vehicle.getBarrelVec(1).normalize();
Entity lookingEntity = TraceTool.vehiclefFindLookingEntity(vehicle, vehicle.getNewEyePos(1), 512); Vec3 vec3 = TraceTool.vehicleFindLookingPos(this, vehicle, vehicle.getNewEyePos(1), 512);
Vec3 toVec; Vec3 toVec;
if (lookingEntity != null && lookingEntity != this) { if (vec3 != null) {
toVec = this.position().vectorTo(lookingEntity.getEyePosition()).normalize(); toVec = this.position().vectorTo(vec3).normalize();
} else { } else {
BlockHitResult result = level().clip(new ClipContext(vehicle.getNewEyePos(1), vehicle.getNewEyePos(1).add(lookVec.scale(512)), BlockHitResult result = level().clip(new ClipContext(vehicle.getNewEyePos(1), vehicle.getNewEyePos(1).add(lookVec.scale(512)),
ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, shooter)); ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, shooter));

View file

@ -29,7 +29,6 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
@ -106,8 +105,8 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(0.0625f, 1.09375f, 0.84375f), new Quaternionf(), OBB.Part.BODY); this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(0.0625f, 1.09375f, 0.84375f), new Quaternionf(), OBB.Part.BODY);
this.obb6 = new OBB(this.position().toVector3f(), new Vector3f(0.625f, 0.78125f, 1.09375f), new Quaternionf(), OBB.Part.BODY); this.obb6 = new OBB(this.position().toVector3f(), new Vector3f(0.625f, 0.78125f, 1.09375f), new Quaternionf(), OBB.Part.BODY);
this.obb7 = new OBB(this.position().toVector3f(), new Vector3f(0.6875f, 0.75f, 2.9375f), new Quaternionf(), OBB.Part.BODY); this.obb7 = new OBB(this.position().toVector3f(), new Vector3f(0.6875f, 0.75f, 2.9375f), new Quaternionf(), OBB.Part.BODY);
this.obb8 = new OBB(this.position().toVector3f(), new Vector3f(0.75f, 0.75f, 1.5625f), new Quaternionf(), OBB.Part.BODY); this.obb8 = new OBB(this.position().toVector3f(), new Vector3f(0.75f, 0.75f, 1.5625f), new Quaternionf(), OBB.Part.ENGINE);
this.obb9 = new OBB(this.position().toVector3f(), new Vector3f(0.75f, 0.75f, 1.5625f), new Quaternionf(), OBB.Part.BODY); this.obb9 = new OBB(this.position().toVector3f(), new Vector3f(0.75f, 0.75f, 1.5625f), new Quaternionf(), OBB.Part.ENGINE_LEFT);
this.obb10 = new OBB(this.position().toVector3f(), new Vector3f(0.34375f, 0.359375f, 1.78125f), new Quaternionf(), OBB.Part.BODY); this.obb10 = new OBB(this.position().toVector3f(), new Vector3f(0.34375f, 0.359375f, 1.78125f), new Quaternionf(), OBB.Part.BODY);
this.obb11 = new OBB(this.position().toVector3f(), new Vector3f(0.34375f, 0.359375f, 1.78125f), new Quaternionf(), OBB.Part.BODY); this.obb11 = new OBB(this.position().toVector3f(), new Vector3f(0.34375f, 0.359375f, 1.78125f), new Quaternionf(), OBB.Part.BODY);
} }
@ -275,65 +274,36 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
releaseDecoy(); releaseDecoy();
this.refreshDimensions(); this.refreshDimensions();
} }
@Override
public void engineDamagedEffect() {
if (entityData.get(ENGINE_DAMAGED) && level() instanceof ServerLevel serverLevel) {
var obbList = this.getOBBs();
for (var obb : obbList) {
if (obb.part() == OBB.Part.ENGINE) {
Vec3 position = new Vec3(obb.center());
sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, position.x, position.y, position.z, 5, 0.25, 0.25, 0.25, 0, true);
sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, position.x, position.y, position.z, 5, 0.25, 0.25, 0.25, 0, true);
sendParticle(serverLevel, ParticleTypes.FLAME, position.x, position.y, position.z, 5, 0.25, 0.25, 0.25, 0, true);
sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), position.x, position.y, position.z, 5, 0.25, 0.25, 0.25, 0.25, true);
}
}
}
}
@Override @Override
public void lowHealthWarning() { public void leftEngineDamagedEffect() {
Matrix4f transform = this.getVehicleTransform(1); if (entityData.get(L_ENGINE_DAMAGED) && level() instanceof ServerLevel serverLevel) {
if (this.getHealth() <= 0.4 * this.getMaxHealth()) { var obbList = this.getOBBs();
List<Entity> entities = getPlayer(level()); for (var obb : obbList) {
for (var e : entities) { if (obb.part() == OBB.Part.ENGINE_LEFT) {
if (e instanceof ServerPlayer player) { Vec3 position = new Vec3(obb.center());
if (player.level() instanceof ServerLevel serverLevel) { sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, position.x, position.y, position.z, 5, 0.25, 0.25, 0.25, 0, true);
Vector4f position = transformPosition(transform, -1.603125f, 0.875f, -5.0625f); sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, position.x, position.y, position.z, 5, 0.25, 0.25, 0.25, 0, true);
sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, position.x, position.y, position.z, 5, 0.25, 0.25, 0.25, 0, true); sendParticle(serverLevel, ParticleTypes.FLAME, position.x, position.y, position.z, 5, 0.25, 0.25, 0.25, 0, true);
} sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), position.x, position.y, position.z, 5, 0.25, 0.25, 0.25, 0.25, true);
} }
} }
} }
if (this.level() instanceof ServerLevel serverLevel) {
if (this.getHealth() <= 0.25 * this.getMaxHealth()) {
playLowHealthParticle(serverLevel);
}
if (this.getHealth() <= 0.15 * this.getMaxHealth()) {
playLowHealthParticle(serverLevel);
}
}
if (this.getHealth() <= 0.1 * this.getMaxHealth()) {
List<Entity> entities = getPlayer(level());
for (var e : entities) {
if (e instanceof ServerPlayer player) {
if (player.level() instanceof ServerLevel serverLevel) {
Vector4f position = transformPosition(transform, -1.603125f, 0.875f, -5.0625f);
sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, position.x, position.y, position.z, 5, 0.25, 0.25, 0.25, 0, true);
sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, position.x, position.y, position.z, 5, 0.25, 0.25, 0.25, 0, true);
sendParticle(serverLevel, ParticleTypes.FLAME, position.x, position.y, position.z, 5, 0.25, 0.25, 0.25, 0, true);
sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), position.x, position.y, position.z, 5, 0.25, 0.25, 0.25, 0, true);
Vector4f position2 = transformPosition(transform, 1.603125f, 0.875f, -5.0625f);
sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, position2.x, position2.y, position2.z, 5, 0.25, 0.25, 0.25, 0, true);
sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, position2.x, position2.y, position2.z, 5, 0.25, 0.25, 0.25, 0, true);
sendParticle(serverLevel, ParticleTypes.FLAME, position2.x, position2.y, position2.z, 5, 0.25, 0.25, 0.25, 0, true);
sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), position2.x, position2.y, position2.z, 5, 0.25, 0.25, 0.25, 0, true);
}
}
}
if (this.level() instanceof ServerLevel serverLevel) {
sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 2, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, true);
sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 2, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, true);
sendParticle(serverLevel, ParticleTypes.FLAME, this.getX(), this.getY() + 0.85f * getBbHeight(), this.getZ(), 4, 0.35 * this.getBbWidth(), 0.12 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.05, true);
sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 0.85f * getBbHeight(), this.getZ(), 4, 0.1 * this.getBbWidth(), 0.05 * this.getBbHeight(), 0.1 * this.getBbWidth(), 0.4, true);
}
if (this.tickCount % 15 == 0) {
this.level().playSound(null, this.getOnPos(), SoundEvents.FIRE_AMBIENT, SoundSource.PLAYERS, 1, 1);
}
}
if (this.getHealth() < 0.1f * this.getMaxHealth() && tickCount % 13 == 0) {
this.level().playSound(null, this.getOnPos(), ModSounds.NO_HEALTH.get(), SoundSource.PLAYERS, 1, 1);
} else if (this.getHealth() >= 0.1f && this.getHealth() < 0.4f * this.getMaxHealth() && tickCount % 10 == 0) {
this.level().playSound(null, this.getOnPos(), ModSounds.LOW_HEALTH.get(), SoundSource.PLAYERS, 1, 1);
}
} }
public void terrainCompactA10() { public void terrainCompactA10() {
@ -606,6 +576,14 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * 0.85f); this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * 0.85f);
this.entityData.set(PLANE_BREAK, this.entityData.get(PLANE_BREAK) * 0.8f); this.entityData.set(PLANE_BREAK, this.entityData.get(PLANE_BREAK) * 0.8f);
if (entityData.get(ENGINE_DAMAGED)) {
this.entityData.set(POWER, this.entityData.get(POWER) * 0.96f);
}
if (entityData.get(L_ENGINE_DAMAGED)) {
this.entityData.set(POWER, this.entityData.get(POWER) * 0.96f);
}
Matrix4f transform = getVehicleTransform(1); Matrix4f transform = getVehicleTransform(1);
double flapAngle = (getFlap1LRot() + getFlap1RRot() + getFlap1L2Rot() + getFlap1R2Rot()) / 4; double flapAngle = (getFlap1LRot() + getFlap1RRot() + getFlap1L2Rot() + getFlap1R2Rot()) / 4;

View file

@ -78,14 +78,18 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
public OBB obb3; public OBB obb3;
public OBB obb4; public OBB obb4;
public OBB obb5; public OBB obb5;
public OBB obb6;
public OBB obb7;
public Ah6Entity(EntityType<Ah6Entity> type, Level world) { public Ah6Entity(EntityType<Ah6Entity> type, Level world) {
super(type, world); super(type, world);
this.obb = new OBB(this.position().toVector3f(), new Vector3f(1.0625f, 1.28125f, 1.625f), new Quaternionf(), OBB.Part.BODY); this.obb = new OBB(this.position().toVector3f(), new Vector3f(1.0625f, 1.18125f, 1.625f), new Quaternionf(), OBB.Part.BODY);
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(0.875f, 0.6875f, 0.59375f), new Quaternionf(), OBB.Part.BODY); this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(0.875f, 0.6875f, 0.59375f), new Quaternionf(), OBB.Part.BODY);
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.25f, 0.3125f, 2.25f), new Quaternionf(), OBB.Part.BODY); this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.25f, 0.3125f, 2.25f), new Quaternionf(), OBB.Part.BODY);
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.0625f, 1.15625f, 0.40625f), new Quaternionf(), OBB.Part.BODY); this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.0625f, 1.15625f, 0.40625f), new Quaternionf(), OBB.Part.BODY);
this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(1f, 0.25f, 0.21875f), new Quaternionf(), OBB.Part.BODY); this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(1f, 0.25f, 0.21875f), new Quaternionf(), OBB.Part.BODY);
this.obb6 = new OBB(this.position().toVector3f(), new Vector3f(0.3125f, 0.40625f, 0.84375f), new Quaternionf(), OBB.Part.ENGINE);
this.obb7 = new OBB(this.position().toVector3f(), new Vector3f(0.3125f, 0.40625f, 0.40625f), new Quaternionf(), OBB.Part.ENGINE_LEFT);
} }
@Override @Override
@ -263,7 +267,7 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
} }
delta_x = ((this.onGround()) ? 0 : 1.5f) * entityData.get(MOUSE_SPEED_Y) * this.entityData.get(PROPELLER_ROT); delta_x = ((this.onGround()) ? 0 : 1.5f) * entityData.get(MOUSE_SPEED_Y) * this.entityData.get(PROPELLER_ROT);
delta_y = Mth.clamp((this.onGround() ? 0.1f : 2f) * entityData.get(MOUSE_SPEED_X) * this.entityData.get(PROPELLER_ROT), -10f, 10f); delta_y = Mth.clamp((this.onGround() ? 0.1f : 2f) * entityData.get(MOUSE_SPEED_X) * this.entityData.get(PROPELLER_ROT) + (this.entityData.get(L_ENGINE_DAMAGED) ? 25 : 0) * this.entityData.get(PROPELLER_ROT), -10f, 10f);
this.setYRot(this.getYRot() + delta_y); this.setYRot(this.getYRot() + delta_y);
this.setXRot(this.getXRot() + delta_x); this.setXRot(this.getXRot() + delta_x);
@ -331,6 +335,10 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
setDeltaMovement(getDeltaMovement().add(0, -destroyRot * 0.004, 0)); setDeltaMovement(getDeltaMovement().add(0, -destroyRot * 0.004, 0));
} }
if (entityData.get(ENGINE_DAMAGED)) {
this.entityData.set(POWER, this.entityData.get(POWER) * 0.98f);
}
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * 0.9f); this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * 0.9f);
this.entityData.set(PROPELLER_ROT, Mth.lerp(0.18f, this.entityData.get(PROPELLER_ROT), this.entityData.get(POWER))); this.entityData.set(PROPELLER_ROT, Mth.lerp(0.18f, this.entityData.get(PROPELLER_ROT), this.entityData.get(POWER)));
this.setPropellerRot(this.getPropellerRot() + 30 * this.entityData.get(PROPELLER_ROT)); this.setPropellerRot(this.getPropellerRot() + 30 * this.entityData.get(PROPELLER_ROT));
@ -347,7 +355,7 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
Vec3 force = new Vec3(force0.x, force0.y, force0.z).vectorTo(new Vec3(force1.x, force1.y, force1.z)); Vec3 force = new Vec3(force0.x, force0.y, force0.z).vectorTo(new Vec3(force1.x, force1.y, force1.z));
setDeltaMovement(getDeltaMovement().add(force.scale(this.entityData.get(POWER)))); setDeltaMovement(getDeltaMovement().add(force.scale(this.entityData.get(PROPELLER_ROT))));
if (this.entityData.get(POWER) > 0.04f) { if (this.entityData.get(POWER) > 0.04f) {
engineStartOver = true; engineStartOver = true;
@ -769,14 +777,14 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
@Override @Override
public List<OBB> getOBBs() { public List<OBB> getOBBs() {
return List.of(this.obb, this.obb2, this.obb3, this.obb4, this.obb5); return List.of(this.obb, this.obb2, this.obb3, this.obb4, this.obb5, this.obb6, this.obb7);
} }
@Override @Override
public void updateOBB() { public void updateOBB() {
Matrix4f transform = getVehicleTransform(1); Matrix4f transform = getVehicleTransform(1);
Vector4f worldPosition = transformPosition(transform, 0, 1.96875f - 1.45f, -0.15625f); Vector4f worldPosition = transformPosition(transform, 0, 1.86875f - 1.45f, -0.15625f);
this.obb.center().set(new Vector3f(worldPosition.x, worldPosition.y, worldPosition.z)); this.obb.center().set(new Vector3f(worldPosition.x, worldPosition.y, worldPosition.z));
this.obb.setRotation(VectorTool.combineRotations(1, this)); this.obb.setRotation(VectorTool.combineRotations(1, this));
@ -795,5 +803,13 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
Vector4f worldPosition5 = transformPosition(transform, -0.125f, 3.5625f - 1.45f, -6.65625f); Vector4f worldPosition5 = transformPosition(transform, -0.125f, 3.5625f - 1.45f, -6.65625f);
this.obb5.center().set(new Vector3f(worldPosition5.x, worldPosition5.y, worldPosition5.z)); this.obb5.center().set(new Vector3f(worldPosition5.x, worldPosition5.y, worldPosition5.z));
this.obb5.setRotation(VectorTool.combineRotations(1, this)); this.obb5.setRotation(VectorTool.combineRotations(1, this));
Vector4f worldPosition6 = transformPosition(transform, 0, 3.28125f - 1.45f, -0.53125f);
this.obb6.center().set(new Vector3f(worldPosition6.x, worldPosition6.y, worldPosition6.z));
this.obb6.setRotation(VectorTool.combineRotations(1, this));
Vector4f worldPosition7 = transformPosition(transform, 0.1875f, 2.09375f - 1.45f, -6.15625f);
this.obb7.center().set(new Vector3f(worldPosition7.x, worldPosition7.y, worldPosition7.z));
this.obb7.setRotation(VectorTool.combineRotations(1, this));
} }
} }

View file

@ -76,6 +76,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
public OBB obb2; public OBB obb2;
public OBB obb3; public OBB obb3;
public OBB obb4; public OBB obb4;
public OBB obb5;
public OBB obbTurret; public OBB obbTurret;
public Bmp2Entity(EntityType<Bmp2Entity> type, Level world) { public Bmp2Entity(EntityType<Bmp2Entity> type, Level world) {
@ -84,6 +85,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(2.1875f, 0.5f, 0.65625f), new Quaternionf(), OBB.Part.BODY); this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(2.1875f, 0.5f, 0.65625f), new Quaternionf(), OBB.Part.BODY);
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.375f, 0.78125f, 3.46875f), new Quaternionf(), OBB.Part.WHEEL_LEFT); this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.375f, 0.78125f, 3.46875f), new Quaternionf(), OBB.Part.WHEEL_LEFT);
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.375f, 0.78125f, 3.46875f), new Quaternionf(), OBB.Part.WHEEL_RIGHT); this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.375f, 0.78125f, 3.46875f), new Quaternionf(), OBB.Part.WHEEL_RIGHT);
this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(1.15625f, 0.375f, 1.125f), new Quaternionf(), OBB.Part.ENGINE);
this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(1.5f, 0.34375f, 1.5f), new Quaternionf(), OBB.Part.TURRET); this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(1.5f, 0.34375f, 1.5f), new Quaternionf(), OBB.Part.TURRET);
} }
@ -459,6 +461,10 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
i = 0; i = 0;
} }
if (entityData.get(ENGINE_DAMAGED)) {
this.entityData.set(POWER, this.entityData.get(POWER) * 0.85f);
}
this.setYRot((float) (this.getYRot() - (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT) - i * s0)); this.setYRot((float) (this.getYRot() - (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT) - i * s0));
if (this.isInWater() || onGround()) { if (this.isInWater() || onGround()) {
float power = this.entityData.get(POWER) * Mth.clamp(1 + (s0 > 0 ? 1 : -1) * getXRot() / 35, 0, 2); float power = this.entityData.get(POWER) * Mth.clamp(1 + (s0 > 0 ? 1 : -1) * getXRot() / 35, 0, 2);
@ -799,7 +805,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
@Override @Override
public List<OBB> getOBBs() { public List<OBB> getOBBs() {
return List.of(this.obb, this.obb2, this.obb3, this.obb4, this.obbTurret); return List.of(this.obb, this.obb2, this.obb3, this.obb4, this.obb5, this.obbTurret);
} }
@Override @Override
@ -822,6 +828,10 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
this.obb4.center().set(new Vector3f(worldPosition4.x, worldPosition4.y, worldPosition4.z)); this.obb4.center().set(new Vector3f(worldPosition4.x, worldPosition4.y, worldPosition4.z));
this.obb4.setRotation(VectorTool.combineRotations(1, this)); this.obb4.setRotation(VectorTool.combineRotations(1, this));
Vector4f worldPosition5 = transformPosition(transform, -1.09375f, 2.0625f, 1.75f);
this.obb5.center().set(new Vector3f(worldPosition5.x, worldPosition5.y, worldPosition5.z));
this.obb5.setRotation(VectorTool.combineRotations(1, this));
Matrix4f transformT = getTurretTransform(1); Matrix4f transformT = getTurretTransform(1);
Vector4f worldPositionT = transformPosition(transformT, 0, 0.46875f, 0f); Vector4f worldPositionT = transformPosition(transformT, 0, 0.46875f, 0f);

View file

@ -65,6 +65,7 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
public OBB obb5; public OBB obb5;
public OBB obb6; public OBB obb6;
public OBB obb7; public OBB obb7;
public OBB obb8;
public OBB obbTurret; public OBB obbTurret;
public Lav150Entity(EntityType<Lav150Entity> type, Level world) { public Lav150Entity(EntityType<Lav150Entity> type, Level world) {
@ -76,6 +77,7 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(1.3125f, 0.90625f, 2.4375f), new Quaternionf(), OBB.Part.BODY); this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(1.3125f, 0.90625f, 2.4375f), new Quaternionf(), OBB.Part.BODY);
this.obb6 = new OBB(this.position().toVector3f(), new Vector3f(1.3125f, 0.53125f, 0.34375f), new Quaternionf(), OBB.Part.BODY); this.obb6 = new OBB(this.position().toVector3f(), new Vector3f(1.3125f, 0.53125f, 0.34375f), new Quaternionf(), OBB.Part.BODY);
this.obb7 = new OBB(this.position().toVector3f(), new Vector3f(1.3125f, 0.625f, 0.53125f), new Quaternionf(), OBB.Part.BODY); this.obb7 = new OBB(this.position().toVector3f(), new Vector3f(1.3125f, 0.625f, 0.53125f), new Quaternionf(), OBB.Part.BODY);
this.obb8 = new OBB(this.position().toVector3f(), new Vector3f(0.71875f, 0.46875f, 0.875f), new Quaternionf(), OBB.Part.ENGINE);
this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(0.875f, 0.3625f, 1.25f), new Quaternionf(), OBB.Part.TURRET); this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(0.875f, 0.3625f, 1.25f), new Quaternionf(), OBB.Part.TURRET);
} }
@ -341,6 +343,10 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
i = 0; i = 0;
} }
if (entityData.get(ENGINE_DAMAGED)) {
this.entityData.set(POWER, this.entityData.get(POWER) * 0.875f);
}
this.setYRot((float) (this.getYRot() - Math.max((isInWater() && !onGround() ? 5 : 10) * this.getDeltaMovement().horizontalDistance(), 0) * this.getRudderRot() * (this.entityData.get(POWER) > 0 ? 1 : -1) - i * s0)); this.setYRot((float) (this.getYRot() - Math.max((isInWater() && !onGround() ? 5 : 10) * this.getDeltaMovement().horizontalDistance(), 0) * this.getRudderRot() * (this.entityData.get(POWER) > 0 ? 1 : -1) - i * s0));
if (this.isInWater() || onGround()) { if (this.isInWater() || onGround()) {
float power = this.entityData.get(POWER) * Mth.clamp(1 + (s0 > 0 ? 1 : -1) * getXRot() / 35, 0, 2); float power = this.entityData.get(POWER) * Mth.clamp(1 + (s0 > 0 ? 1 : -1) * getXRot() / 35, 0, 2);
@ -658,7 +664,7 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
@Override @Override
public List<OBB> getOBBs() { public List<OBB> getOBBs() {
return List.of(this.obb, this.obb2, this.obb3, this.obb4, this.obb5, this.obb6, this.obb7, this.obbTurret); return List.of(this.obb, this.obb2, this.obb3, this.obb4, this.obb5, this.obb6, this.obb7, this.obb8, this.obbTurret);
} }
@Override @Override
@ -693,6 +699,10 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
this.obb7.center().set(new Vector3f(worldPosition7.x, worldPosition7.y, worldPosition7.z)); this.obb7.center().set(new Vector3f(worldPosition7.x, worldPosition7.y, worldPosition7.z));
this.obb7.setRotation(VectorTool.combineRotations(1, this)); this.obb7.setRotation(VectorTool.combineRotations(1, this));
Vector4f worldPosition8 = transformPosition(transform, 0.65625f, 2.03125f, -2.0625f);
this.obb8.center().set(new Vector3f(worldPosition8.x, worldPosition8.y, worldPosition8.z));
this.obb8.setRotation(VectorTool.combineRotations(1, this));
Matrix4f transformT = getTurretTransform(1); Matrix4f transformT = getTurretTransform(1);
Vector4f worldPositionT = transformPosition(transformT, 0, 0.3625f, 0f); Vector4f worldPositionT = transformPosition(transformT, 0, 0.3625f, 0f);
this.obbTurret.center().set(new Vector3f(worldPositionT.x, worldPositionT.y, worldPositionT.z)); this.obbTurret.center().set(new Vector3f(worldPositionT.x, worldPositionT.y, worldPositionT.z));

View file

@ -84,16 +84,18 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo
public OBB obb3; public OBB obb3;
public OBB obb4; public OBB obb4;
public OBB obb5; public OBB obb5;
public OBB obb6;
public OBB obbTurret; public OBB obbTurret;
public PrismTankEntity(EntityType<PrismTankEntity> type, Level world) { public PrismTankEntity(EntityType<PrismTankEntity> type, Level world) {
super(type, world); super(type, world);
this.noCulling = true; this.noCulling = true;
this.obb = new OBB(this.position().toVector3f(), new Vector3f(2.5f, 0.8125f, 3.96875f), new Quaternionf(), OBB.Part.BODY); this.obb = new OBB(this.position().toVector3f(), new Vector3f(2.4f, 0.8125f, 3.71875f), new Quaternionf(), OBB.Part.BODY);
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(2.5f, 0.5f, 0.375f), new Quaternionf(), OBB.Part.BODY); this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(2.4f, 0.5f, 0.375f), new Quaternionf(), OBB.Part.BODY);
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.46875f, 0.78125f, 3.3125f), new Quaternionf(), OBB.Part.WHEEL_LEFT); this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.46875f, 0.78125f, 3.3125f), new Quaternionf(), OBB.Part.WHEEL_LEFT);
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.46875f, 0.78125f, 3.3125f), new Quaternionf(), OBB.Part.WHEEL_RIGHT); this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.46875f, 0.78125f, 3.3125f), new Quaternionf(), OBB.Part.WHEEL_RIGHT);
this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(1.375f, 0.28125f, 1.375f), new Quaternionf(), OBB.Part.BODY); this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(1.375f, 0.28125f, 1.375f), new Quaternionf(), OBB.Part.BODY);
this.obb6 = new OBB(this.position().toVector3f(), new Vector3f(2.0625f, 0.78125f, 0.8125f), new Quaternionf(), OBB.Part.ENGINE);
this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(0.4375f, 0.90625f, 1.21875f), new Quaternionf(), OBB.Part.TURRET); this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(0.4375f, 0.90625f, 1.21875f), new Quaternionf(), OBB.Part.TURRET);
} }
@ -523,6 +525,10 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo
i = 0; i = 0;
} }
if (entityData.get(ENGINE_DAMAGED)) {
this.entityData.set(POWER, this.entityData.get(POWER) * 0.85f);
}
this.setYRot((float) (this.getYRot() - (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT) - i * s0)); this.setYRot((float) (this.getYRot() - (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT) - i * s0));
if (this.isInWater() || onGround()) { if (this.isInWater() || onGround()) {
@ -853,16 +859,26 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo
return Mod.loc("textures/gui/vehicle/type/land.png"); return Mod.loc("textures/gui/vehicle/type/land.png");
} }
@Override
public float getWheelMaxHealth() {
return 100;
}
@Override
public float getEngineMaxHealth() {
return 150;
}
@Override @Override
public List<OBB> getOBBs() { public List<OBB> getOBBs() {
return List.of(this.obb, this.obb2, this.obb3, this.obb4, this.obb5, this.obbTurret); return List.of(this.obb, this.obb2, this.obb3, this.obb4, this.obb5, this.obb6, this.obbTurret);
} }
@Override @Override
public void updateOBB() { public void updateOBB() {
Matrix4f transform = getVehicleTransform(1); Matrix4f transform = getVehicleTransform(1);
Vector4f worldPosition = transformPosition(transform, 0, 1.4375f, -0.21875f); Vector4f worldPosition = transformPosition(transform, 0, 1.4375f, 0.03125f);
this.obb.center().set(new Vector3f(worldPosition.x, worldPosition.y, worldPosition.z)); this.obb.center().set(new Vector3f(worldPosition.x, worldPosition.y, worldPosition.z));
this.obb.setRotation(VectorTool.combineRotations(1, this)); this.obb.setRotation(VectorTool.combineRotations(1, this));
@ -882,6 +898,10 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo
this.obb5.center().set(new Vector3f(worldPosition5.x, worldPosition5.y, worldPosition5.z)); this.obb5.center().set(new Vector3f(worldPosition5.x, worldPosition5.y, worldPosition5.z));
this.obb5.setRotation(VectorTool.combineRotations(1, this)); this.obb5.setRotation(VectorTool.combineRotations(1, this));
Vector4f worldPosition6 = transformPosition(transform, 0, 1.53125f, -3.125f);
this.obb6.center().set(new Vector3f(worldPosition6.x, worldPosition6.y, worldPosition6.z));
this.obb6.setRotation(VectorTool.combineRotations(1, this));
Matrix4f transformT = getTurretTransform(1); Matrix4f transformT = getTurretTransform(1);
Vector4f worldPositionT = transformPosition(transformT, 0, 1.59375f, -0.390625f); Vector4f worldPositionT = transformPosition(transformT, 0, 1.59375f, -0.390625f);

View file

@ -739,7 +739,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
} }
if (entityData.get(ENGINE_DAMAGED)) { if (entityData.get(ENGINE_DAMAGED)) {
this.entityData.set(POWER, this.entityData.get(POWER) * 0.875f); this.entityData.set(POWER, this.entityData.get(POWER) * 0.85f);
} }
this.setYRot((float) (this.getYRot() - (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT) - i * s0)); this.setYRot((float) (this.getYRot() - (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT) - i * s0));
@ -1318,7 +1318,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
@Override @Override
public float getEngineMaxHealth() { public float getEngineMaxHealth() {
return 100; return 150;
} }
@Override @Override

View file

@ -93,11 +93,13 @@ public abstract class VehicleEntity extends Entity {
public static final EntityDataAccessor<Float> L_WHEEL_HEALTH = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor<Float> L_WHEEL_HEALTH = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Float> R_WHEEL_HEALTH = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor<Float> R_WHEEL_HEALTH = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Float> ENGINE_HEALTH = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor<Float> ENGINE_HEALTH = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Float> L_ENGINE_HEALTH = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Boolean> TURRET_DAMAGED = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.BOOLEAN); public static final EntityDataAccessor<Boolean> TURRET_DAMAGED = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.BOOLEAN);
public static final EntityDataAccessor<Boolean> L_WHEEL_DAMAGED = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.BOOLEAN); public static final EntityDataAccessor<Boolean> L_WHEEL_DAMAGED = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.BOOLEAN);
public static final EntityDataAccessor<Boolean> R_WHEEL_DAMAGED = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.BOOLEAN); public static final EntityDataAccessor<Boolean> R_WHEEL_DAMAGED = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.BOOLEAN);
public static final EntityDataAccessor<Boolean> ENGINE_DAMAGED = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.BOOLEAN); public static final EntityDataAccessor<Boolean> ENGINE_DAMAGED = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.BOOLEAN);
public static final EntityDataAccessor<Boolean> L_ENGINE_DAMAGED = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.BOOLEAN);
public VehicleWeapon[][] availableWeapons; public VehicleWeapon[][] availableWeapons;
@ -313,12 +315,14 @@ public abstract class VehicleEntity extends Entity {
.define(L_WHEEL_HEALTH, getWheelMaxHealth()) .define(L_WHEEL_HEALTH, getWheelMaxHealth())
.define(R_WHEEL_HEALTH, getWheelMaxHealth()) .define(R_WHEEL_HEALTH, getWheelMaxHealth())
.define(ENGINE_HEALTH, getEngineMaxHealth()) .define(ENGINE_HEALTH, getEngineMaxHealth())
.define(L_ENGINE_HEALTH, getEngineMaxHealth())
.define(TURRET_DAMAGED, false) .define(TURRET_DAMAGED, false)
.define(L_WHEEL_DAMAGED, false) .define(L_WHEEL_DAMAGED, false)
.define(R_WHEEL_DAMAGED, false) .define(R_WHEEL_DAMAGED, false)
.define(ENGINE_DAMAGED, false) .define(ENGINE_DAMAGED, false)
.define(L_ENGINE_DAMAGED, false)
// 怎么还不给玩动态注册了
.define(SELECTED_WEAPON, IntList.of(new int[this.getMaxPassengers()])); .define(SELECTED_WEAPON, IntList.of(new int[this.getMaxPassengers()]));
// 怎么还不给玩动态注册了
} }
private int[] initSelectedWeaponArray(WeaponVehicleEntity weaponVehicle) { private int[] initSelectedWeaponArray(WeaponVehicleEntity weaponVehicle) {
@ -343,11 +347,13 @@ public abstract class VehicleEntity extends Entity {
this.entityData.set(L_WHEEL_HEALTH, compound.getFloat("LeftWheelHealth")); this.entityData.set(L_WHEEL_HEALTH, compound.getFloat("LeftWheelHealth"));
this.entityData.set(R_WHEEL_HEALTH, compound.getFloat("RightWheelHealth")); this.entityData.set(R_WHEEL_HEALTH, compound.getFloat("RightWheelHealth"));
this.entityData.set(ENGINE_HEALTH, compound.getFloat("EngineHealth")); this.entityData.set(ENGINE_HEALTH, compound.getFloat("EngineHealth"));
this.entityData.set(L_ENGINE_HEALTH, compound.getFloat("LeftEngineHealth"));
this.entityData.set(TURRET_DAMAGED, compound.getBoolean("TurretDamaged")); this.entityData.set(TURRET_DAMAGED, compound.getBoolean("TurretDamaged"));
this.entityData.set(L_WHEEL_DAMAGED, compound.getBoolean("LeftDamaged")); this.entityData.set(L_WHEEL_DAMAGED, compound.getBoolean("LeftDamaged"));
this.entityData.set(R_WHEEL_DAMAGED, compound.getBoolean("RightDamaged")); this.entityData.set(R_WHEEL_DAMAGED, compound.getBoolean("RightDamaged"));
this.entityData.set(ENGINE_DAMAGED, compound.getBoolean("EngineDamaged")); this.entityData.set(ENGINE_DAMAGED, compound.getBoolean("EngineDamaged"));
this.entityData.set(L_ENGINE_DAMAGED, compound.getBoolean("LeftEngineDamaged"));
if (this instanceof WeaponVehicleEntity weaponVehicle && weaponVehicle.getAllWeapons().length > 0) { if (this instanceof WeaponVehicleEntity weaponVehicle && weaponVehicle.getAllWeapons().length > 0) {
var selected = compound.getIntArray("SelectedWeapon"); var selected = compound.getIntArray("SelectedWeapon");
@ -371,11 +377,13 @@ public abstract class VehicleEntity extends Entity {
compound.putFloat("LeftWheelHealth", this.entityData.get(L_WHEEL_HEALTH)); compound.putFloat("LeftWheelHealth", this.entityData.get(L_WHEEL_HEALTH));
compound.putFloat("RightWheelHealth", this.entityData.get(R_WHEEL_HEALTH)); compound.putFloat("RightWheelHealth", this.entityData.get(R_WHEEL_HEALTH));
compound.putFloat("EngineHealth", this.entityData.get(ENGINE_HEALTH)); compound.putFloat("EngineHealth", this.entityData.get(ENGINE_HEALTH));
compound.putFloat("LeftEngineHealth", this.entityData.get(L_ENGINE_HEALTH));
compound.putBoolean("TurretDamaged", this.entityData.get(TURRET_DAMAGED)); compound.putBoolean("TurretDamaged", this.entityData.get(TURRET_DAMAGED));
compound.putBoolean("LeftWheelDamaged", this.entityData.get(L_WHEEL_DAMAGED)); compound.putBoolean("LeftWheelDamaged", this.entityData.get(L_WHEEL_DAMAGED));
compound.putBoolean("RightWheelDamaged", this.entityData.get(R_WHEEL_DAMAGED)); compound.putBoolean("RightWheelDamaged", this.entityData.get(R_WHEEL_DAMAGED));
compound.putBoolean("EngineDamaged", this.entityData.get(ENGINE_DAMAGED)); compound.putBoolean("EngineDamaged", this.entityData.get(ENGINE_DAMAGED));
compound.putBoolean("LeftEngineDamaged", this.entityData.get(L_ENGINE_DAMAGED));
if (this instanceof WeaponVehicleEntity weaponVehicle && weaponVehicle.getAllWeapons().length > 0) { if (this instanceof WeaponVehicleEntity weaponVehicle && weaponVehicle.getAllWeapons().length > 0) {
compound.putIntArray("SelectedWeapon", this.entityData.get(SELECTED_WEAPON)); compound.putIntArray("SelectedWeapon", this.entityData.get(SELECTED_WEAPON));
@ -490,6 +498,10 @@ public abstract class VehicleEntity extends Entity {
if (this instanceof OBBEntity && accessor.sbw$getCurrentHitPart() == OBB.Part.ENGINE) { if (this instanceof OBBEntity && accessor.sbw$getCurrentHitPart() == OBB.Part.ENGINE) {
entityData.set(ENGINE_HEALTH, entityData.get(ENGINE_HEALTH) - computedAmount); entityData.set(ENGINE_HEALTH, entityData.get(ENGINE_HEALTH) - computedAmount);
} }
if (this instanceof OBBEntity && accessor.sbw$getCurrentHitPart() == OBB.Part.ENGINE_LEFT) {
entityData.set(L_ENGINE_HEALTH, entityData.get(L_ENGINE_HEALTH) - computedAmount);
}
// System.out.println(accessor.sbw$getCurrentHitPart()); // System.out.println(accessor.sbw$getCurrentHitPart());
} }
@ -710,6 +722,7 @@ public abstract class VehicleEntity extends Entity {
// 引擎损毁特效 // 引擎损毁特效
engineDamagedEffect(); engineDamagedEffect();
leftEngineDamagedEffect();
// 左轮损毁特效 // 左轮损毁特效
leftWheelDamagedEffect(); leftWheelDamagedEffect();
@ -727,35 +740,43 @@ public abstract class VehicleEntity extends Entity {
if (entityData.get(TURRET_HEALTH) < 0) { if (entityData.get(TURRET_HEALTH) < 0) {
entityData.set(TURRET_DAMAGED, true); entityData.set(TURRET_DAMAGED, true);
} }
if (entityData.get(TURRET_HEALTH) > 0.8 * getTurretMaxHealth()) { if (entityData.get(TURRET_HEALTH) > 0.95 * getTurretMaxHealth()) {
entityData.set(TURRET_DAMAGED, false); entityData.set(TURRET_DAMAGED, false);
} }
if (entityData.get(L_WHEEL_HEALTH) < 0) { if (entityData.get(L_WHEEL_HEALTH) < 0) {
entityData.set(L_WHEEL_DAMAGED, true); entityData.set(L_WHEEL_DAMAGED, true);
} }
if (entityData.get(L_WHEEL_HEALTH) > 0.8 * getWheelMaxHealth()) { if (entityData.get(L_WHEEL_HEALTH) > 0.95 * getWheelMaxHealth()) {
entityData.set(L_WHEEL_DAMAGED, false); entityData.set(L_WHEEL_DAMAGED, false);
} }
if (entityData.get(R_WHEEL_HEALTH) < 0) { if (entityData.get(R_WHEEL_HEALTH) < 0) {
entityData.set(R_WHEEL_DAMAGED, true); entityData.set(R_WHEEL_DAMAGED, true);
} }
if (entityData.get(R_WHEEL_HEALTH) > 0.8 * getWheelMaxHealth()) { if (entityData.get(R_WHEEL_HEALTH) > 0.95 * getWheelMaxHealth()) {
entityData.set(R_WHEEL_DAMAGED, false); entityData.set(R_WHEEL_DAMAGED, false);
} }
if (entityData.get(ENGINE_HEALTH) < 0) { if (entityData.get(ENGINE_HEALTH) < 0) {
entityData.set(ENGINE_DAMAGED, true); entityData.set(ENGINE_DAMAGED, true);
} }
if (entityData.get(ENGINE_HEALTH) > 0.8 * getEngineMaxHealth()) { if (entityData.get(ENGINE_HEALTH) > 0.95 * getEngineMaxHealth()) {
entityData.set(ENGINE_DAMAGED, false); entityData.set(ENGINE_DAMAGED, false);
} }
entityData.set(TURRET_HEALTH, Math.min(entityData.get(TURRET_HEALTH) + 0.003f * getTurretMaxHealth(), getTurretMaxHealth())); if (entityData.get(L_ENGINE_HEALTH) < 0) {
entityData.set(L_WHEEL_HEALTH, Math.min(entityData.get(L_WHEEL_HEALTH) + 0.003f * getWheelMaxHealth(), getWheelMaxHealth())); entityData.set(L_ENGINE_DAMAGED, true);
entityData.set(R_WHEEL_HEALTH, Math.min(entityData.get(R_WHEEL_HEALTH) + 0.003f * getWheelMaxHealth(), getWheelMaxHealth())); }
entityData.set(ENGINE_HEALTH, Math.min(entityData.get(ENGINE_HEALTH) + 0.003f * getEngineMaxHealth(), getEngineMaxHealth())); if (entityData.get(L_ENGINE_HEALTH) > 0.95 * getEngineMaxHealth()) {
entityData.set(L_ENGINE_DAMAGED, false);
}
entityData.set(TURRET_HEALTH, Math.min(entityData.get(TURRET_HEALTH) + 0.0025f * getTurretMaxHealth(), getTurretMaxHealth()));
entityData.set(L_WHEEL_HEALTH, Math.min(entityData.get(L_WHEEL_HEALTH) + 0.0025f * getWheelMaxHealth(), getWheelMaxHealth()));
entityData.set(R_WHEEL_HEALTH, Math.min(entityData.get(R_WHEEL_HEALTH) + 0.0025f * getWheelMaxHealth(), getWheelMaxHealth()));
entityData.set(ENGINE_HEALTH, Math.min(entityData.get(ENGINE_HEALTH) + 0.0025f * getEngineMaxHealth(), getEngineMaxHealth()));
entityData.set(L_ENGINE_HEALTH, Math.min(entityData.get(L_ENGINE_HEALTH) + 0.0025f * getEngineMaxHealth(), getEngineMaxHealth()));
} }
public void turretDamagedEffect() { public void turretDamagedEffect() {
@ -784,6 +805,19 @@ public abstract class VehicleEntity extends Entity {
} }
} }
public void leftEngineDamagedEffect() {
if (entityData.get(L_ENGINE_DAMAGED) && this instanceof OBBEntity obbEntity && level() instanceof ServerLevel serverLevel) {
var obbList = obbEntity.getOBBs();
for (var obb : obbList) {
if (obb.part() == OBB.Part.ENGINE_LEFT) {
Vec3 pos = new Vec3(obb.center());
sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), pos.x, pos.y, pos.z, 5, 0.25, 0.25, 0.25, 0.25, true);
sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, pos.x, pos.y, pos.z, 1, 1, 0.5, 1, 0.01, true);
}
}
}
}
public void leftWheelDamagedEffect() { public void leftWheelDamagedEffect() {
if (entityData.get(L_WHEEL_DAMAGED) && this instanceof OBBEntity obbEntity && level() instanceof ServerLevel serverLevel) { if (entityData.get(L_WHEEL_DAMAGED) && this instanceof OBBEntity obbEntity && level() instanceof ServerLevel serverLevel) {
var obbList = obbEntity.getOBBs(); var obbList = obbEntity.getOBBs();

View file

@ -448,6 +448,7 @@ public record OBB(Vector3f center, Vector3f extents, Quaternionf rotation, Part
WHEEL_RIGHT, WHEEL_RIGHT,
TURRET, TURRET,
ENGINE, ENGINE,
ENGINE_LEFT,
BODY BODY
} }
} }

View file

@ -104,7 +104,7 @@ public class TraceTool {
return entity.level().clip(new ClipContext(entity.getEyePosition(), target, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType() != HitResult.Type.BLOCK; return entity.level().clip(new ClipContext(entity.getEyePosition(), target, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType() != HitResult.Type.BLOCK;
} }
public static Entity vehiclefFindLookingEntity(VehicleEntity vehicle, Vec3 eye, double entityReach) { public static Vec3 vehicleFindLookingPos(Projectile projectile, VehicleEntity vehicle, Vec3 eye, double entityReach) {
double distance = entityReach * entityReach; double distance = entityReach * entityReach;
HitResult hitResult = pickNew(eye, 512, vehicle); HitResult hitResult = pickNew(eye, 512, vehicle);
@ -112,13 +112,13 @@ public class TraceTool {
Vec3 toVec = eye.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach); Vec3 toVec = eye.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
AABB aabb = vehicle.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D); AABB aabb = vehicle.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(vehicle, eye, toVec, aabb, EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(vehicle, eye, toVec, aabb,
p -> !p.isSpectator() && p.isAlive() && SeekTool.baseFilter(p) && !p.getType().is(ModTags.EntityTypes.DECOY) && smokeFilter(p), distance); p -> !p.isSpectator() && p.isAlive() && SeekTool.baseFilter(p) && !p.getType().is(ModTags.EntityTypes.DECOY) && smokeFilter(p) && p != projectile, distance);
if (entityhitresult != null) { if (entityhitresult != null) {
hitResult = entityhitresult; hitResult = entityhitresult;
} }
if (hitResult.getType() == HitResult.Type.ENTITY) { if (hitResult.getType() == HitResult.Type.ENTITY) {
return ((EntityHitResult) hitResult).getEntity(); return hitResult.getLocation();
} }
return null; return null;
} }