diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/WgMissileEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/WgMissileEntity.java index b65a78c6e..def264b5e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/WgMissileEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/WgMissileEntity.java @@ -222,11 +222,11 @@ public class WgMissileEntity extends FastThrowableProjectile implements GeoEntit Entity shooter = this.getOwner(); 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; - if (lookingEntity != null && lookingEntity != this) { - toVec = this.position().vectorTo(lookingEntity.getEyePosition()).normalize(); + if (vec3 != null) { + toVec = this.position().vectorTo(vec3).normalize(); } else { BlockHitResult result = level().clip(new ClipContext(vehicle.getNewEyePos(1), vehicle.getNewEyePos(1).add(lookVec.scale(512)), ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, shooter)); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java index 1f4d145e8..c78b66a82 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java @@ -29,7 +29,6 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; -import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; 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.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.obb8 = 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.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.ENGINE_LEFT); 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); } @@ -275,65 +274,36 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity releaseDecoy(); 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 - public void lowHealthWarning() { - Matrix4f transform = this.getVehicleTransform(1); - if (this.getHealth() <= 0.4 * this.getMaxHealth()) { - List 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); - } + public void leftEngineDamagedEffect() { + if (entityData.get(L_ENGINE_DAMAGED) && level() instanceof ServerLevel serverLevel) { + var obbList = this.getOBBs(); + for (var obb : obbList) { + if (obb.part() == OBB.Part.ENGINE_LEFT) { + 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); } } } - - 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 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() { @@ -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(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); double flapAngle = (getFlap1LRot() + getFlap1RRot() + getFlap1L2Rot() + getFlap1R2Rot()) / 4; diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java index b2d649595..ad66dc3b6 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java @@ -78,14 +78,18 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity public OBB obb3; public OBB obb4; public OBB obb5; + public OBB obb6; + public OBB obb7; public Ah6Entity(EntityType type, Level 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.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.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 @@ -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_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.setXRot(this.getXRot() + delta_x); @@ -331,6 +335,10 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity 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(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)); @@ -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)); - 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) { engineStartOver = true; @@ -769,14 +777,14 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity @Override public List 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 public void updateOBB() { 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.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); this.obb5.center().set(new Vector3f(worldPosition5.x, worldPosition5.y, worldPosition5.z)); 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)); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java index 90668753d..5ecc55780 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java @@ -76,6 +76,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit public OBB obb2; public OBB obb3; public OBB obb4; + public OBB obb5; public OBB obbTurret; public Bmp2Entity(EntityType 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.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.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); } @@ -459,6 +461,10 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit 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)); if (this.isInWater() || onGround()) { 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 public List 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 @@ -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.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); Vector4f worldPositionT = transformPosition(transformT, 0, 0.46875f, 0f); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java index d2cd34dfd..60d49f087 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java @@ -65,6 +65,7 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt public OBB obb5; public OBB obb6; public OBB obb7; + public OBB obb8; public OBB obbTurret; public Lav150Entity(EntityType 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.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.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); } @@ -341,6 +343,10 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt 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)); if (this.isInWater() || onGround()) { 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 public List 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 @@ -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.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); Vector4f worldPositionT = transformPosition(transformT, 0, 0.3625f, 0f); this.obbTurret.center().set(new Vector3f(worldPositionT.x, worldPositionT.y, worldPositionT.z)); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java index 15895b327..165330c68 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java @@ -84,16 +84,18 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo public OBB obb3; public OBB obb4; public OBB obb5; + public OBB obb6; public OBB obbTurret; public PrismTankEntity(EntityType type, Level world) { super(type, world); this.noCulling = true; - this.obb = new OBB(this.position().toVector3f(), new Vector3f(2.5f, 0.8125f, 3.96875f), 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.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.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.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.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); } @@ -523,6 +525,10 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo 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)); if (this.isInWater() || onGround()) { @@ -853,16 +859,26 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo return Mod.loc("textures/gui/vehicle/type/land.png"); } + @Override + public float getWheelMaxHealth() { + return 100; + } + + @Override + public float getEngineMaxHealth() { + return 150; + } + @Override public List 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 public void updateOBB() { 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.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.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); Vector4f worldPositionT = transformPosition(transformT, 0, 1.59375f, -0.390625f); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java index ed4ead520..926dd01c3 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java @@ -739,7 +739,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti } 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)); @@ -1318,7 +1318,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti @Override public float getEngineMaxHealth() { - return 100; + return 150; } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java index 2dcd05484..7bbcc304a 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java @@ -93,11 +93,13 @@ public abstract class VehicleEntity extends Entity { public static final EntityDataAccessor L_WHEEL_HEALTH = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor R_WHEEL_HEALTH = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor ENGINE_HEALTH = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.FLOAT); + public static final EntityDataAccessor L_ENGINE_HEALTH = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor TURRET_DAMAGED = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.BOOLEAN); public static final EntityDataAccessor L_WHEEL_DAMAGED = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.BOOLEAN); public static final EntityDataAccessor R_WHEEL_DAMAGED = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.BOOLEAN); public static final EntityDataAccessor ENGINE_DAMAGED = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.BOOLEAN); + public static final EntityDataAccessor L_ENGINE_DAMAGED = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.BOOLEAN); public VehicleWeapon[][] availableWeapons; @@ -313,12 +315,14 @@ public abstract class VehicleEntity extends Entity { .define(L_WHEEL_HEALTH, getWheelMaxHealth()) .define(R_WHEEL_HEALTH, getWheelMaxHealth()) .define(ENGINE_HEALTH, getEngineMaxHealth()) + .define(L_ENGINE_HEALTH, getEngineMaxHealth()) .define(TURRET_DAMAGED, false) .define(L_WHEEL_DAMAGED, false) .define(R_WHEEL_DAMAGED, false) .define(ENGINE_DAMAGED, false) + .define(L_ENGINE_DAMAGED, false) + // 怎么还不给玩动态注册了(恼) .define(SELECTED_WEAPON, IntList.of(new int[this.getMaxPassengers()])); - // 怎么还不给玩动态注册了(恼) } 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(R_WHEEL_HEALTH, compound.getFloat("RightWheelHealth")); 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(L_WHEEL_DAMAGED, compound.getBoolean("LeftDamaged")); this.entityData.set(R_WHEEL_DAMAGED, compound.getBoolean("RightDamaged")); 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) { 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("RightWheelHealth", this.entityData.get(R_WHEEL_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("LeftWheelDamaged", this.entityData.get(L_WHEEL_DAMAGED)); compound.putBoolean("RightWheelDamaged", this.entityData.get(R_WHEEL_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) { 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) { 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()); } @@ -710,6 +722,7 @@ public abstract class VehicleEntity extends Entity { // 引擎损毁特效 engineDamagedEffect(); + leftEngineDamagedEffect(); // 左轮损毁特效 leftWheelDamagedEffect(); @@ -727,35 +740,43 @@ public abstract class VehicleEntity extends Entity { if (entityData.get(TURRET_HEALTH) < 0) { 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); } if (entityData.get(L_WHEEL_HEALTH) < 0) { 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); } if (entityData.get(R_WHEEL_HEALTH) < 0) { 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); } if (entityData.get(ENGINE_HEALTH) < 0) { 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(TURRET_HEALTH, Math.min(entityData.get(TURRET_HEALTH) + 0.003f * getTurretMaxHealth(), getTurretMaxHealth())); - entityData.set(L_WHEEL_HEALTH, Math.min(entityData.get(L_WHEEL_HEALTH) + 0.003f * getWheelMaxHealth(), getWheelMaxHealth())); - 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) { + entityData.set(L_ENGINE_DAMAGED, true); + } + 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() { @@ -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() { if (entityData.get(L_WHEEL_DAMAGED) && this instanceof OBBEntity obbEntity && level() instanceof ServerLevel serverLevel) { var obbList = obbEntity.getOBBs(); diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/OBB.java b/src/main/java/com/atsuishio/superbwarfare/tools/OBB.java index b8c716478..c74232ef2 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/OBB.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/OBB.java @@ -448,6 +448,7 @@ public record OBB(Vector3f center, Vector3f extents, Quaternionf rotation, Part WHEEL_RIGHT, TURRET, ENGINE, + ENGINE_LEFT, BODY } } diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/TraceTool.java b/src/main/java/com/atsuishio/superbwarfare/tools/TraceTool.java index a84a2d005..fff1ef322 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/TraceTool.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/TraceTool.java @@ -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; } - 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; 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); AABB aabb = vehicle.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D); 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) { hitResult = entityhitresult; } if (hitResult.getType() == HitResult.Type.ENTITY) { - return ((EntityHitResult) hitResult).getEntity(); + return hitResult.getLocation(); } return null; }