diff --git a/src/main/java/com/atsuishio/superbwarfare/client/layer/Mk42DamageLayer.java b/src/main/java/com/atsuishio/superbwarfare/client/layer/Mk42DamageLayer.java deleted file mode 100644 index 649d3994f..000000000 --- a/src/main/java/com/atsuishio/superbwarfare/client/layer/Mk42DamageLayer.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.atsuishio.superbwarfare.client.layer; - -import com.atsuishio.superbwarfare.ModUtils; -import com.atsuishio.superbwarfare.entity.vehicle.Mk42Entity; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexConsumer; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.Mth; -import software.bernie.geckolib.cache.object.BakedGeoModel; -import software.bernie.geckolib.renderer.GeoRenderer; -import software.bernie.geckolib.renderer.layer.GeoRenderLayer; - -public class Mk42DamageLayer extends GeoRenderLayer { - - private static final ResourceLocation LAYER = ModUtils.loc("textures/entity/sherman_damage.png"); - - public Mk42DamageLayer(GeoRenderer entityRenderer) { - super(entityRenderer); - } - - @Override - public void render(PoseStack poseStack, Mk42Entity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) { - RenderType glowRenderType = RenderType.entityTranslucent(LAYER); - float heal = Mth.clamp((0.3f * animatable.getMaxHealth() - animatable.getHealth()) * 0.00001f * animatable.getMaxHealth(), 0, 1); - getRenderer().reRender(getDefaultBakedModel(animatable), poseStack, bufferSource, animatable, glowRenderType, bufferSource.getBuffer(glowRenderType), partialTick, packedLight, OverlayTexture.NO_OVERLAY, 1, 1, 1, heal); - } -} diff --git a/src/main/java/com/atsuishio/superbwarfare/client/layer/Mle1934DamageLayer.java b/src/main/java/com/atsuishio/superbwarfare/client/layer/Mle1934DamageLayer.java deleted file mode 100644 index cb57091a4..000000000 --- a/src/main/java/com/atsuishio/superbwarfare/client/layer/Mle1934DamageLayer.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.atsuishio.superbwarfare.client.layer; - -import com.atsuishio.superbwarfare.ModUtils; -import com.atsuishio.superbwarfare.entity.vehicle.Mle1934Entity; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexConsumer; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.Mth; -import software.bernie.geckolib.cache.object.BakedGeoModel; -import software.bernie.geckolib.renderer.GeoRenderer; -import software.bernie.geckolib.renderer.layer.GeoRenderLayer; - -public class Mle1934DamageLayer extends GeoRenderLayer { - - private static final ResourceLocation LAYER = ModUtils.loc("textures/entity/mle1934_damage.png"); - - public Mle1934DamageLayer(GeoRenderer entityRenderer) { - super(entityRenderer); - } - - @Override - public void render(PoseStack poseStack, Mle1934Entity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) { - RenderType glowRenderType = RenderType.entityTranslucent(LAYER); - float heal = Mth.clamp((0.3f * animatable.getMaxHealth() - animatable.getHealth()) * 0.00001f * animatable.getMaxHealth(), 0, 1); - getRenderer().reRender(getDefaultBakedModel(animatable), poseStack, bufferSource, animatable, glowRenderType, bufferSource.getBuffer(glowRenderType), partialTick, packedLight, OverlayTexture.NO_OVERLAY, 1, 1, 1, heal); - } -} diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mk42Renderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mk42Renderer.java index 82e64622d..03d5dc0d4 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mk42Renderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mk42Renderer.java @@ -1,6 +1,5 @@ package com.atsuishio.superbwarfare.client.renderer.entity; -import com.atsuishio.superbwarfare.client.layer.Mk42DamageLayer; import com.atsuishio.superbwarfare.client.layer.Mk42Layer; import com.atsuishio.superbwarfare.client.model.entity.Mk42Model; import com.atsuishio.superbwarfare.entity.vehicle.Mk42Entity; @@ -21,7 +20,6 @@ public class Mk42Renderer extends GeoEntityRenderer { super(renderManager, new Mk42Model()); this.shadowRadius = 2f; this.addRenderLayer(new Mk42Layer(this)); - this.addRenderLayer(new Mk42DamageLayer(this)); } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mle1934Renderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mle1934Renderer.java index 54ce70f77..0095dd0d2 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mle1934Renderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mle1934Renderer.java @@ -1,6 +1,5 @@ package com.atsuishio.superbwarfare.client.renderer.entity; -import com.atsuishio.superbwarfare.client.layer.Mle1934DamageLayer; import com.atsuishio.superbwarfare.client.layer.Mle1934Layer; import com.atsuishio.superbwarfare.client.model.entity.Mle1934Model; import com.atsuishio.superbwarfare.entity.vehicle.Mle1934Entity; @@ -21,7 +20,6 @@ public class Mle1934Renderer extends GeoEntityRenderer { super(renderManager, new Mle1934Model()); this.shadowRadius = 2f; this.addRenderLayer(new Mle1934Layer(this)); - this.addRenderLayer(new Mle1934DamageLayer(this)); } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SmallCannonShellEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SmallCannonShellEntity.java index a515d81bb..82836155f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SmallCannonShellEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SmallCannonShellEntity.java @@ -84,7 +84,7 @@ public class SmallCannonShellEntity extends ThrowableItemProjectile implements G } } - entity.hurt(ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()), damage); + entity.hurt(ModDamageTypes.causeCannonFireDamage(this.level().registryAccess(), this, this.getOwner()), damage); if (entity instanceof LivingEntity) { entity.invulnerableTime = 0; 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 009d34ef0..0ab2d49f1 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java @@ -418,10 +418,31 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli living.hurt(ModDamageTypes.causeAirCrashDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); living.invulnerableTime = 0; living.hurt(ModDamageTypes.causeAirCrashDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeAirCrashDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeAirCrashDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); } } } + List passengers = this.getPassengers(); + for (var entity : passengers) { + if (entity instanceof LivingEntity living) { + var tempAttacker = living == attacker ? null : attacker; + + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + } + } + if (level() instanceof ServerLevel) { CustomExplosion explosion = new CustomExplosion(this.level(), this, ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), this, attacker), 300.0f, @@ -430,8 +451,9 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli ForgeEventFactory.onExplosionStart(this.level(), explosion); explosion.finalizeExplosion(false); ParticleTool.spawnHugeExplosionParticles(this.level(), this.position()); - this.discard(); } + + this.discard(); } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java index bb570e1cf..d03b21741 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java @@ -50,6 +50,7 @@ import software.bernie.geckolib.core.object.PlayState; import software.bernie.geckolib.util.GeckoLibUtil; import java.util.Comparator; +import java.util.List; public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity, ICannonEntity { @@ -305,17 +306,37 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity, @Override public void destroy() { + Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID)); + if (level() instanceof ServerLevel) { - Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID)); CustomExplosion explosion = new CustomExplosion(this.level(), this, - ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), attacker, attacker), 200f, - this.getX(), this.getY(), this.getZ(), 10f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); + ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), attacker, attacker), 600f, + this.getX(), this.getY(), this.getZ(), 15f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); explosion.explode(); net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); explosion.finalizeExplosion(false); - ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); - this.discard(); + ParticleTool.spawnHugeExplosionParticles(this.level(), this.position()); } + + + List passengers = this.getPassengers(); + for (var entity : passengers) { + if (entity instanceof LivingEntity living) { + var tempAttacker = living == attacker ? null : attacker; + + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + } + } + + this.discard(); } @Override 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 a5ad05851..aaf66fb50 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java @@ -28,6 +28,7 @@ import net.minecraft.util.Mth; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Explosion; @@ -55,6 +56,7 @@ import software.bernie.geckolib.core.object.PlayState; import software.bernie.geckolib.util.GeckoLibUtil; import java.util.Comparator; +import java.util.List; import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle; @@ -489,13 +491,35 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC @Override public void destroy() { Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID)); - CustomExplosion explosion = new CustomExplosion(this.level(), this, - ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), attacker, attacker), 75f, - this.getX(), this.getY(), this.getZ(), 5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); - explosion.explode(); - net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); - explosion.finalizeExplosion(false); - ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); + + if (level() instanceof ServerLevel) { + CustomExplosion explosion = new CustomExplosion(this.level(), this, + ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), attacker, attacker), 80f, + this.getX(), this.getY(), this.getZ(), 5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); + explosion.explode(); + net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); + explosion.finalizeExplosion(false); + ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); + } + + + List passengers = this.getPassengers(); + for (var entity : passengers) { + if (entity instanceof LivingEntity living) { + var tempAttacker = living == attacker ? null : attacker; + + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + } + } + this.discard(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java index 2e20b5b88..b232f1f21 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java @@ -44,6 +44,7 @@ import software.bernie.geckolib.core.object.PlayState; import software.bernie.geckolib.util.GeckoLibUtil; import java.util.Comparator; +import java.util.List; public class Mk42Entity extends VehicleEntity implements GeoEntity, ICannonEntity { public static final EntityDataAccessor COOL_DOWN = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT); @@ -136,22 +137,45 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, ICannonEntit this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.04, 0.0)); } + lowHealthWarning(); + this.refreshDimensions(); } @Override public void destroy() { + Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID)); + if (level() instanceof ServerLevel) { - Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID)); CustomExplosion explosion = new CustomExplosion(this.level(), this, - ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), attacker, attacker), 150f, - this.getX(), this.getY(), this.getZ(), 5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); + ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), attacker, attacker), 100f, + this.getX(), this.getY(), this.getZ(), 7f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); explosion.explode(); net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); explosion.finalizeExplosion(false); ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); - this.discard(); } + + + List passengers = this.getPassengers(); + for (var entity : passengers) { + if (entity instanceof LivingEntity living) { + var tempAttacker = living == attacker ? null : attacker; + + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + } + } + + this.discard(); + } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java index 26c3b96e3..d6bb5e328 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java @@ -45,6 +45,7 @@ import software.bernie.geckolib.core.object.PlayState; import software.bernie.geckolib.util.GeckoLibUtil; import java.util.Comparator; +import java.util.List; public class Mle1934Entity extends VehicleEntity implements GeoEntity, ICannonEntity { @@ -158,17 +159,36 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, ICannonEn @Override public void destroy() { + Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID)); + if (level() instanceof ServerLevel) { - Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID)); CustomExplosion explosion = new CustomExplosion(this.level(), this, - ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), attacker, attacker), 150f, - this.getX(), this.getY(), this.getZ(), 5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); + ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), attacker, attacker), 120f, + this.getX(), this.getY(), this.getZ(), 6f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); explosion.explode(); net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); explosion.finalizeExplosion(false); ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); - this.discard(); } + + List passengers = this.getPassengers(); + for (var entity : passengers) { + if (entity instanceof LivingEntity living) { + var tempAttacker = living == attacker ? null : attacker; + + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + } + } + + this.discard(); } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java index ce73e4266..dd6d47b8b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java @@ -27,6 +27,7 @@ import net.minecraft.util.Mth; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Explosion; @@ -51,6 +52,7 @@ import software.bernie.geckolib.core.object.PlayState; import software.bernie.geckolib.util.GeckoLibUtil; import java.util.Comparator; +import java.util.List; import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle; @@ -405,13 +407,34 @@ public class SpeedboatEntity extends ContainerMobileEntity implements GeoEntity, @Override public void destroy() { Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID)); - CustomExplosion explosion = new CustomExplosion(this.level(), this, - ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), attacker, attacker), 75f, - this.getX(), this.getY(), this.getZ(), 5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); - explosion.explode(); - net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); - explosion.finalizeExplosion(false); - ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); + + List passengers = this.getPassengers(); + for (var entity : passengers) { + if (entity instanceof LivingEntity living) { + var tempAttacker = living == attacker ? null : attacker; + + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + living.invulnerableTime = 0; + living.hurt(ModDamageTypes.causeVehicleExplosionDamage(this.level().registryAccess(), null, tempAttacker), Integer.MAX_VALUE); + } + } + + if (level() instanceof ServerLevel) { + CustomExplosion explosion = new CustomExplosion(this.level(), this, + ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), attacker, attacker), 80f, + this.getX(), this.getY(), this.getZ(), 5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); + explosion.explode(); + net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); + explosion.finalizeExplosion(false); + ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); + } + this.discard(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/VehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/VehicleEntity.java index 918e9ab27..f712721d8 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/VehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/VehicleEntity.java @@ -270,30 +270,30 @@ public class VehicleEntity extends Entity { public void lowHealthWarning() { if (this.getHealth() <= 0.4 * this.getMaxHealth()) { if (this.level() instanceof ServerLevel serverLevel) { - ParticleTool.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, false); + ParticleTool.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); } } if (this.getHealth() <= 0.25 * this.getMaxHealth()) { if (this.level() instanceof ServerLevel serverLevel) { - ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 1, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, false); - ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 1, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, false); + ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 1, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, true); + ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 1, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, true); } } if (this.getHealth() <= 0.15 * this.getMaxHealth()) { if (this.level() instanceof ServerLevel serverLevel) { - ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 1, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, false); - ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 1, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, false); + ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 1, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, true); + ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 1, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, true); } } if (this.getHealth() <= 0.1 * this.getMaxHealth()) { if (this.level() instanceof ServerLevel serverLevel) { - ParticleTool.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, false); - ParticleTool.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, false); - ParticleTool.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, false); - ParticleTool.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, false); + ParticleTool.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); + ParticleTool.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); + ParticleTool.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); + ParticleTool.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); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/WheelChairEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/WheelChairEntity.java index 58feb5294..35fda5311 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/WheelChairEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/WheelChairEntity.java @@ -1,13 +1,14 @@ package com.atsuishio.superbwarfare.entity.vehicle; +import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig; import com.atsuishio.superbwarfare.entity.MortarEntity; +import com.atsuishio.superbwarfare.init.ModDamageTypes; import com.atsuishio.superbwarfare.init.ModEntities; import com.atsuishio.superbwarfare.init.ModSounds; -import com.atsuishio.superbwarfare.item.ContainerBlockItem; +import com.atsuishio.superbwarfare.tools.CustomExplosion; +import com.atsuishio.superbwarfare.tools.EntityFindUtil; import com.atsuishio.superbwarfare.tools.ParticleTool; import net.minecraft.client.Minecraft; -import net.minecraft.core.BlockPos; -import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; @@ -20,9 +21,8 @@ import net.minecraft.util.Mth; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.*; import net.minecraft.world.entity.animal.WaterAnimal; -import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.network.NetworkHooks; @@ -262,19 +262,19 @@ public class WheelChairEntity extends MobileVehicleEntity implements GeoEntity { @Override public void destroy() { + Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID)); + if (level() instanceof ServerLevel) { - ParticleTool.sendParticle((ServerLevel) this.level(), ParticleTypes.EXPLOSION, this.getX(), this.getY() + 1, this.getZ(), 10, 0.5, 0.5, 0.5, 1, false); - this.level().playSound(null, BlockPos.containing(this.position()), SoundEvents.GENERIC_EXPLODE, SoundSource.BLOCKS, 2.0F, (1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F) * 0.7F); - this.setHealth(this.getMaxHealth()); - ItemStack container = ContainerBlockItem.createInstance(this); - if (this.level() instanceof ServerLevel level) { - ItemEntity itemEntity = new ItemEntity(level, this.getX(), this.getY(), this.getZ(), container); - itemEntity.setPickUpDelay(10); - level.addFreshEntity(itemEntity); - } - this.remove(RemovalReason.DISCARDED); - this.discard(); + CustomExplosion explosion = new CustomExplosion(this.level(), this, + ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), attacker, attacker), 10f, + this.getX(), this.getY(), this.getZ(), 2f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); + explosion.explode(); + net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); + explosion.finalizeExplosion(false); + ParticleTool.spawnSmallExplosionParticles(this.level(), this.position()); } + + this.discard(); } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java index df9adc28b..4d0a0096d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java @@ -57,7 +57,7 @@ public class LivingEventHandler { @SubscribeEvent public static void onEntityAttacked(LivingAttackEvent event) { - if (event.getEntity().getVehicle() instanceof ICannonEntity || event.getEntity().getVehicle() instanceof Lav150Entity) { + if (!event.getSource().is(ModDamageTypes.VEHICLE_EXPLOSION) && (event.getEntity().getVehicle() instanceof ICannonEntity || event.getEntity().getVehicle() instanceof Lav150Entity)) { event.setCanceled(true); } } @@ -97,7 +97,9 @@ public class LivingEventHandler { var vehicle = event.getEntity().getVehicle(); if (vehicle != null) { if (vehicle instanceof ICannonEntity || vehicle instanceof Lav150Entity) { - event.setCanceled(true); + if (!event.getSource().is(ModDamageTypes.VEHICLE_EXPLOSION)) { + event.setCanceled(true); + } } else if (vehicle instanceof IArmedVehicleEntity) { event.setAmount(0.3f * event.getAmount()); } diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModDamageTypes.java b/src/main/java/com/atsuishio/superbwarfare/init/ModDamageTypes.java index c46fd2aa4..38ec98115 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModDamageTypes.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModDamageTypes.java @@ -33,6 +33,7 @@ public class ModDamageTypes { public static final ResourceKey VEHICLE_STRIKE = ResourceKey.create(Registries.DAMAGE_TYPE, ModUtils.loc("vehicle_strike")); public static final ResourceKey AIR_CRASH = ResourceKey.create(Registries.DAMAGE_TYPE, ModUtils.loc("air_crash")); public static final ResourceKey LUNGE_MINE = ResourceKey.create(Registries.DAMAGE_TYPE, ModUtils.loc("lunge_mine")); + public static final ResourceKey VEHICLE_EXPLOSION = ResourceKey.create(Registries.DAMAGE_TYPE, ModUtils.loc("vehicle_explosion")); public static DamageSource causeGunFireDamage(RegistryAccess registryAccess, @Nullable Entity directEntity, @Nullable Entity attacker) { return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(GUN_FIRE), directEntity, attacker); @@ -98,6 +99,10 @@ public class ModDamageTypes { return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(LUNGE_MINE), directEntity, attacker); } + public static DamageSource causeVehicleExplosionDamage(RegistryAccess registryAccess, @Nullable Entity directEntity, @Nullable Entity attacker) { + return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(VEHICLE_EXPLOSION), directEntity, attacker); + } + private static class DamageMessages extends DamageSource { public DamageMessages(Holder.Reference typeReference) { diff --git a/src/main/resources/assets/superbwarfare/lang/en_us.json b/src/main/resources/assets/superbwarfare/lang/en_us.json index c190b92c1..508b29550 100644 --- a/src/main/resources/assets/superbwarfare/lang/en_us.json +++ b/src/main/resources/assets/superbwarfare/lang/en_us.json @@ -366,6 +366,9 @@ "death.attack.lunge_mine": "%1$s被突刺爆雷戳到了屁股", "death.attack.lunge_mine.entity": "%1$s被%2$s用突刺爆雷戳到了屁股", "death.attack.lunge_mine.item": "%1$s被%2$s用%3$s型突刺爆雷戳到了屁股", + "death.attack.vehicle_explosion": "%1$s的载具被击毁了", + "death.attack.vehicle_explosion.entity": "%1$s的载具被%2$s击毁了", + "death.attack.vehicle_explosion.item": "%1$s的载具被%2$s用%3$s击毁了", "entity.superbwarfare.projectile": "Bullet", "entity.superbwarfare.projectile_mortar_shell": "Mortar Shell", diff --git a/src/main/resources/assets/superbwarfare/lang/zh_cn.json b/src/main/resources/assets/superbwarfare/lang/zh_cn.json index 3e8a2fb30..ab0b9bb42 100644 --- a/src/main/resources/assets/superbwarfare/lang/zh_cn.json +++ b/src/main/resources/assets/superbwarfare/lang/zh_cn.json @@ -357,13 +357,16 @@ "death.attack.laser_headshot.item": "%1$s的脑子被%2$s用%3$s发射的激光洞穿了", "death.attack.vehicle_strike": "%1$s被创死了", "death.attack.vehicle_strike.entity": "%1$s被%2$s创死了", - "death.attack.vehicle_strike.item": "%1$s的被%2$s用%3$s创死了", + "death.attack.vehicle_strike.item": "%1$s被%2$s用%3$s创死了", "death.attack.air_crash": "%1$s坠机了", "death.attack.air_crash.entity": "%1$s坠机了,凶手是%2$s", "death.attack.air_crash.item": "%1$s坠机了,凶手是%2$s", "death.attack.lunge_mine": "%1$s被突刺爆雷戳到了屁股", "death.attack.lunge_mine.entity": "%1$s被%2$s用突刺爆雷戳到了屁股", "death.attack.lunge_mine.item": "%1$s被%2$s用%3$s型突刺爆雷戳到了屁股", + "death.attack.vehicle_explosion": "%1$s的载具被击毁了", + "death.attack.vehicle_explosion.entity": "%1$s的载具被%2$s击毁了", + "death.attack.vehicle_explosion.item": "%1$s的载具被%2$s用%3$s击毁了", "entity.superbwarfare.projectile": "子弹", "entity.superbwarfare.projectile_mortar_shell": "迫击炮弹", diff --git a/src/main/resources/assets/superbwarfare/textures/entity/mle1934_damage.png b/src/main/resources/assets/superbwarfare/textures/entity/mle1934_damage.png deleted file mode 100644 index 43af4aeb5..000000000 Binary files a/src/main/resources/assets/superbwarfare/textures/entity/mle1934_damage.png and /dev/null differ diff --git a/src/main/resources/assets/superbwarfare/textures/entity/sherman_damage.png b/src/main/resources/assets/superbwarfare/textures/entity/sherman_damage.png deleted file mode 100644 index 2b5e6806f..000000000 Binary files a/src/main/resources/assets/superbwarfare/textures/entity/sherman_damage.png and /dev/null differ diff --git a/src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json b/src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json index 1714584b5..919981b91 100644 --- a/src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json +++ b/src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json @@ -8,6 +8,7 @@ "superbwarfare:laser", "superbwarfare:laser_headshot", "superbwarfare:vehicle_strike", + "superbwarfare:vehicle_explosion", "superbwarfare:air_crash" ] } \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/damage_type/bypasses_effects.json b/src/main/resources/data/minecraft/tags/damage_type/bypasses_effects.json index 1714584b5..95a94ab48 100644 --- a/src/main/resources/data/minecraft/tags/damage_type/bypasses_effects.json +++ b/src/main/resources/data/minecraft/tags/damage_type/bypasses_effects.json @@ -9,5 +9,6 @@ "superbwarfare:laser_headshot", "superbwarfare:vehicle_strike", "superbwarfare:air_crash" + "superbwarfare:vehicle_explosion", ] } \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/damage_type/bypasses_enchantments.json b/src/main/resources/data/minecraft/tags/damage_type/bypasses_enchantments.json index 1714584b5..95a94ab48 100644 --- a/src/main/resources/data/minecraft/tags/damage_type/bypasses_enchantments.json +++ b/src/main/resources/data/minecraft/tags/damage_type/bypasses_enchantments.json @@ -9,5 +9,6 @@ "superbwarfare:laser_headshot", "superbwarfare:vehicle_strike", "superbwarfare:air_crash" + "superbwarfare:vehicle_explosion", ] } \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/damage_type/bypasses_resistance.json b/src/main/resources/data/minecraft/tags/damage_type/bypasses_resistance.json index 1714584b5..95a94ab48 100644 --- a/src/main/resources/data/minecraft/tags/damage_type/bypasses_resistance.json +++ b/src/main/resources/data/minecraft/tags/damage_type/bypasses_resistance.json @@ -9,5 +9,6 @@ "superbwarfare:laser_headshot", "superbwarfare:vehicle_strike", "superbwarfare:air_crash" + "superbwarfare:vehicle_explosion", ] } \ No newline at end of file diff --git a/src/main/resources/data/superbwarfare/damage_type/vehicle_explosion.json b/src/main/resources/data/superbwarfare/damage_type/vehicle_explosion.json new file mode 100644 index 000000000..fe579be8b --- /dev/null +++ b/src/main/resources/data/superbwarfare/damage_type/vehicle_explosion.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0, + "message_id": "vehicle_explosion", + "scaling": "never" +} \ No newline at end of file