From 2a3432560f4d08af817ca58e720929e2368553c1 Mon Sep 17 00:00:00 2001 From: Light_Quanta Date: Mon, 30 Jun 2025 04:05:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E6=A0=87=E9=9D=B6=E5=92=8CDPS?= =?UTF-8?q?=E5=8F=91=E7=94=B5=E6=9C=BA=E4=B8=8D=E5=86=8D=E5=85=8D=E7=96=AB?= =?UTF-8?q?/kill?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../superbwarfare/entity/DPSGeneratorEntity.java | 9 +++++++++ .../com/atsuishio/superbwarfare/entity/TargetEntity.java | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/DPSGeneratorEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/DPSGeneratorEntity.java index 0bdf2d15d..05651139d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/DPSGeneratorEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/DPSGeneratorEntity.java @@ -19,6 +19,7 @@ import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.damagesource.DamageTypes; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; @@ -115,6 +116,12 @@ public class DPSGeneratorEntity extends LivingEntity implements GeoEntity { @Override public boolean hurt(@NotNull DamageSource source, float amount) { + // 不处理/kill伤害 + if (source.is(DamageTypes.GENERIC_KILL)) { + this.remove(RemovalReason.KILLED); + return super.hurt(source, amount); + } + damageDealt += amount; if (this.getHealth() < 0.01) { @@ -132,6 +139,8 @@ public class DPSGeneratorEntity extends LivingEntity implements GeoEntity { @SubscribeEvent public static void onTargetDown(LivingDeathEvent event) { var entity = event.getEntity(); + // 不处理/kill伤害 + if (event.getSource().is(DamageTypes.GENERIC_KILL)) return; var sourceEntity = event.getSource().getEntity(); if (entity instanceof DPSGeneratorEntity generatorEntity) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/TargetEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/TargetEntity.java index 30aeb3478..4a39587dc 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/TargetEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/TargetEntity.java @@ -84,6 +84,12 @@ public class TargetEntity extends LivingEntity implements GeoEntity { @Override public boolean hurt(@NotNull DamageSource source, float amount) { + // 不处理/kill伤害 + if (source.is(DamageTypes.GENERIC_KILL)) { + this.remove(RemovalReason.KILLED); + return super.hurt(source, amount); + } + amount = DAMAGE_MODIFIER.compute(source, amount); if (amount <= 0 || this.entityData.get(DOWN_TIME) > 0) { return false; @@ -100,6 +106,8 @@ public class TargetEntity extends LivingEntity implements GeoEntity { @SubscribeEvent public static void onTargetDown(LivingDeathEvent event) { var entity = event.getEntity(); + // 不处理/kill伤害 + if (event.getSource().is(DamageTypes.GENERIC_KILL)) return; var sourceEntity = event.getSource().getEntity(); if (entity instanceof TargetEntity targetEntity) {