|
466 | 466 | } else if (this.level().isClientSide) { |
467 | 467 | return false; |
468 | 468 | - } else if (this.isDeadOrDying()) { |
469 | | -+ } else if (this.isRemoved() || this.dead || this.getHealth() <= 0.0F) { // CraftBukkit - Don't allow entities that got set to dead/killed elsewhere to get damaged and die |
| 469 | ++ } else if (this.isRemoved() || this.dead || this.isDeadOrDying()) { // CraftBukkit - Don't allow entities that got set to dead/killed elsewhere to get damaged and die |
470 | 470 | return false; |
471 | 471 | } else if (p_21016_.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { |
472 | 472 | return false; |
|
941 | 941 | } |
942 | 942 |
|
943 | 943 | return p_21194_; |
944 | | -@@ -1677,13 +_,192 @@ |
| 944 | +@@ -1677,13 +_,221 @@ |
945 | 945 | } |
946 | 946 | } |
947 | 947 |
|
948 | 948 | - protected void actuallyHurt(DamageSource p_21240_, float p_21241_) { |
949 | 949 | + // Magma - rewriten this method to work with neoforge without breaking the original code and to many patches |
950 | 950 | + private org.bukkit.event.entity.EntityDamageEvent handleEntityDamage(final DamageSource damagesource, float f) { |
951 | 951 | + float originalDamage = f; |
952 | | -+ com.google.common.base.Function<Double, Double> freezing = f4 -> { |
953 | | -+ if (damagesource.is(net.minecraft.tags.DamageTypeTags.IS_FREEZING) && net.minecraft.world.entity.LivingEntity.this.getType().is(net.minecraft.tags.EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES)) { |
954 | | -+ return -(f4 - (f4 * 5.0F)); |
| 952 | ++ com.google.common.base.Function<Double, Double> freezing = new com.google.common.base.Function<Double, Double>() { |
| 953 | ++ @Override |
| 954 | ++ public Double apply(Double f4) { |
| 955 | ++ if (damagesource.is(net.minecraft.tags.DamageTypeTags.IS_FREEZING) && net.minecraft.world.entity.LivingEntity.this.getType().is(net.minecraft.tags.EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES)) { |
| 956 | ++ return Double.valueOf(-(f4 - (f4 * 5.0F))); |
| 957 | ++ } |
| 958 | ++ return Double.valueOf(-0.0); |
955 | 959 | + } |
956 | | -+ return -0.0; |
957 | 960 | + }; |
958 | 961 | + float freezingModifier = freezing.apply((double) f).floatValue(); |
959 | 962 | + f += freezingModifier; |
960 | | -+ com.google.common.base.Function<Double, Double> hardHat = f5 -> { |
961 | | -+ if (damagesource.is(net.minecraft.tags.DamageTypeTags.DAMAGES_HELMET) && !net.minecraft.world.entity.LivingEntity.this.getItemBySlot(net.minecraft.world.entity.EquipmentSlot.HEAD).isEmpty()) { |
962 | | -+ return -(f5 - (f5 * 0.75F)); |
| 963 | ++ com.google.common.base.Function<Double, Double> hardHat = new com.google.common.base.Function<Double, Double>() { |
| 964 | ++ @Override |
| 965 | ++ public Double apply(Double f5) { |
| 966 | ++ if (damagesource.is(net.minecraft.tags.DamageTypeTags.DAMAGES_HELMET) && !net.minecraft.world.entity.LivingEntity.this.getItemBySlot(net.minecraft.world.entity.EquipmentSlot.HEAD).isEmpty()) { |
| 967 | ++ return Double.valueOf(-(f5 - (f5 * 0.75F))); |
| 968 | ++ } |
| 969 | ++ return Double.valueOf(-0.0); |
963 | 970 | + } |
964 | | -+ return -0.0; |
965 | 971 | + }; |
966 | 972 | + float hardHatModifier = hardHat.apply((double) f).floatValue(); |
967 | 973 | + f += hardHatModifier; |
968 | | -+ com.google.common.base.Function<Double, Double> blocking = f6 -> -((net.minecraft.world.entity.LivingEntity.this.isDamageSourceBlocked(damagesource)) ? f6 : 0.0); |
| 974 | ++ com.google.common.base.Function<Double, Double> blocking = new com.google.common.base.Function<Double, Double>() { |
| 975 | ++ @Override |
| 976 | ++ public Double apply(Double f6) { |
| 977 | ++ return Double.valueOf(-((net.minecraft.world.entity.LivingEntity.this.isDamageSourceBlocked(damagesource)) ? f6 : 0.0)); |
| 978 | ++ } |
| 979 | ++ }; |
969 | 980 | + float blockingModifier = blocking.apply((double) f).floatValue(); |
970 | 981 | + f += blockingModifier; |
971 | | -+ com.google.common.base.Function<Double, Double> armor = f7 -> -(f7 - net.minecraft.world.entity.LivingEntity.this.getDamageAfterArmorAbsorb(damagesource, f7.floatValue())); |
| 982 | ++ com.google.common.base.Function<Double, Double> armor = new com.google.common.base.Function<Double, Double>() { |
| 983 | ++ @Override |
| 984 | ++ public Double apply(Double f7) { |
| 985 | ++ return Double.valueOf(-(f7 - net.minecraft.world.entity.LivingEntity.this.getDamageAfterArmorAbsorb(damagesource, f7.floatValue()))); |
| 986 | ++ } |
| 987 | ++ }; |
972 | 988 | + float armorModifier = armor.apply((double) f).floatValue(); |
973 | 989 | + f += armorModifier; |
974 | | -+ com.google.common.base.Function<Double, Double> resistance = f8 -> { |
975 | | -+ if (!damagesource.is(net.minecraft.tags.DamageTypeTags.BYPASSES_EFFECTS) && net.minecraft.world.entity.LivingEntity.this.hasEffect(net.minecraft.world.effect.MobEffects.DAMAGE_RESISTANCE) && !damagesource.is(net.minecraft.tags.DamageTypeTags.BYPASSES_RESISTANCE)) { |
976 | | -+ int i = (net.minecraft.world.entity.LivingEntity.this.getEffect(net.minecraft.world.effect.MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; |
977 | | -+ int j = 25 - i; |
978 | | -+ float f1 = f8.floatValue() * (float) j; |
979 | | -+ return -(f8 - (f1 / 25.0F)); |
| 990 | ++ com.google.common.base.Function<Double, Double> resistance = new com.google.common.base.Function<Double, Double>() { |
| 991 | ++ @Override |
| 992 | ++ public Double apply(Double f8) { |
| 993 | ++ if (!damagesource.is(net.minecraft.tags.DamageTypeTags.BYPASSES_EFFECTS) && net.minecraft.world.entity.LivingEntity.this.hasEffect(net.minecraft.world.effect.MobEffects.DAMAGE_RESISTANCE) && !damagesource.is(net.minecraft.tags.DamageTypeTags.BYPASSES_RESISTANCE)) { |
| 994 | ++ int i = (net.minecraft.world.entity.LivingEntity.this.getEffect(net.minecraft.world.effect.MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; |
| 995 | ++ int j = 25 - i; |
| 996 | ++ float f1 = f8.floatValue() * (float) j; |
| 997 | ++ return Double.valueOf(-(f8 - (f1 / 25.0F))); |
| 998 | ++ } |
| 999 | ++ return Double.valueOf(-0.0); |
980 | 1000 | + } |
981 | | -+ return -0.0; |
982 | 1001 | + }; |
983 | 1002 | + float resistanceModifier = resistance.apply((double) f).floatValue(); |
984 | 1003 | + f += resistanceModifier; |
985 | | -+ com.google.common.base.Function<Double, Double> magic = f9 -> -(f9 - net.minecraft.world.entity.LivingEntity.this.getDamageAfterMagicAbsorb(damagesource, f9.floatValue())); |
| 1004 | ++ com.google.common.base.Function<Double, Double> magic = new com.google.common.base.Function<Double, Double>() { |
| 1005 | ++ @Override |
| 1006 | ++ public Double apply(Double f9) { |
| 1007 | ++ return Double.valueOf(-(f9 - net.minecraft.world.entity.LivingEntity.this.getDamageAfterMagicAbsorb(damagesource, f9.floatValue()))); |
| 1008 | ++ } |
| 1009 | ++ }; |
986 | 1010 | + float magicModifier = magic.apply((double) f).floatValue(); |
987 | 1011 | + f += magicModifier; |
988 | | -+ com.google.common.base.Function<Double, Double> absorption = f10 -> -(Math.max(f10 - Math.max(f10 - net.minecraft.world.entity.LivingEntity.this.getAbsorptionAmount(), 0.0F), 0.0F)); |
| 1012 | ++ com.google.common.base.Function<Double, Double> absorption = new com.google.common.base.Function<Double, Double>() { |
| 1013 | ++ @Override |
| 1014 | ++ public Double apply(Double f10) { |
| 1015 | ++ return Double.valueOf(-(Math.max(f10 - Math.max(f10 - net.minecraft.world.entity.LivingEntity.this.getAbsorptionAmount(), 0.0F), 0.0F))); |
| 1016 | ++ } |
| 1017 | ++ }; |
989 | 1018 | + float absorptionModifier = absorption.apply((double) f).floatValue(); |
990 | 1019 | + |
991 | 1020 | + return org.bukkit.craftbukkit.event.CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, freezingModifier, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, freezing, hardHat, blocking, armor, resistance, magic, absorption); |
|
0 commit comments