Skip to content

Commit 1d71b16

Browse files
committed
Try fix some damage bug
1 parent 37e94a5 commit 1d71b16

1 file changed

Lines changed: 32 additions & 29 deletions

File tree

patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@
603603
this.f_19804_.m_135381_(f_20961_, Mth.m_14036_(p_21154_, 0.0F, this.m_21233_()));
604604
}
605605

606-
@@ -1036,35 +_,28 @@
606+
@@ -1036,36 +_,43 @@
607607
}
608608

609609
public boolean m_6469_(DamageSource p_21016_, float p_21017_) {
@@ -630,7 +630,7 @@
630630
+
631631
boolean flag = false;
632632
float f1 = 0.0F;
633-
if (p_21017_ > 0.0F && this.m_21275_(p_21016_)) {
633+
- if (p_21017_ > 0.0F && this.m_21275_(p_21016_)) {
634634
- this.m_7909_(p_21017_);
635635
- f1 = p_21017_;
636636
- p_21017_ = 0.0F;
@@ -639,12 +639,27 @@
639639
- if (entity instanceof LivingEntity) {
640640
- LivingEntity livingentity = (LivingEntity)entity;
641641
- this.m_6728_(livingentity);
642-
- }
642+
+ if (false && p_21017_ > 0.0F && this.m_21275_(p_21016_)) {
643+
+ net.minecraftforge.event.entity.living.ShieldBlockEvent ev = net.minecraftforge.common.ForgeHooks.onShieldBlock(this, p_21016_, p_21017_);
644+
+ if(!ev.isCanceled()) {
645+
+ if(ev.shieldTakesDamage()) this.m_7909_(p_21017_);
646+
+ f1 = ev.getBlockedDamage();
647+
+ p_21017_ -= ev.getBlockedDamage();
648+
+ if (!p_21016_.m_269533_(DamageTypeTags.f_268524_)) {
649+
+ Entity entity = p_21016_.m_7640_();
650+
+ if (entity instanceof LivingEntity) {
651+
+ LivingEntity livingentity = (LivingEntity)entity;
652+
+ this.m_6728_(livingentity);
653+
+ }
654+
}
643655
- }
644-
-
645-
flag = true;
656+
657+
- flag = true;
658+
+ flag = p_21017_ <= 0;
659+
+ }
646660
}
647661

662+
if (p_21016_.m_269533_(DamageTypeTags.f_268419_) && this.m_6095_().m_204039_(EntityTypeTags.f_144295_)) {
648663
@@ -1074,23 +_,39 @@
649664

650665
this.f_267362_.m_267771_(1.5F);
@@ -999,7 +1014,7 @@
9991014
}
10001015

10011016
if (p_21194_ <= 0.0F) {
1002-
@@ -1582,27 +_,250 @@
1017+
@@ -1582,27 +_,238 @@
10031018
}
10041019

10051020
protected void m_6475_(DamageSource p_21240_, float p_21241_) {
@@ -1037,10 +1052,10 @@
10371052
+ }
10381053
+
10391054
+ protected boolean injectedHurt = true;
1040-
+ public AtomicBoolean canDamage = new AtomicBoolean(true);
1055+
+ public AtomicBoolean canDamage = new AtomicBoolean(false);
10411056
+ public AtomicDouble damage = new AtomicDouble(-999);
10421057
+ public boolean canDamage() {
1043-
+ return canDamage.getAndSet(true);
1058+
+ return canDamage.getAndSet(false);
10441059
+ }
10451060
+ // Mohist end
10461061
+
@@ -1070,14 +1085,15 @@
10701085
+ p_21241_ = ForgeHooks.onLivingHurt(this, p_21240_, p_21241_);
10711086
+ // If the damage is negative return true
10721087
+ if (p_21241_ < 0) {
1088+
+ canDamage.set(true);
10731089
+ return true;
10741090
+ }
10751091
+ final float originalDamage = p_21241_;
10761092
+
10771093
+ Function<Double, Double> hardHat = new Function<Double, Double>() {
10781094
+ @Override
10791095
+ public Double apply(Double input) {
1080-
+ if (p_21240_.m_269533_(DamageTypeTags.f_268627_) && !LivingEntity.this.m_6844_(EquipmentSlot.HEAD).m_41619_()) {
1096+
+ if (p_21240_.m_269533_(DamageTypeTags.f_268627_) && !LivingEntity.this.m_6844_(EquipmentSlot.HEAD).m_41619_()) {
10811097
+ return -(input - (input * 0.75F));
10821098
+ }
10831099
+ return -0.0;
@@ -1093,27 +1109,12 @@
10931109
+ if (!shieldEvent.isCanceled()) {
10941110
+ var blocked = shieldEvent.getBlockedDamage();
10951111
+ shieldTakesDamage = shieldEvent.shieldTakesDamage();
1096-
+ blocking = new Function<Double, Double>() {
1097-
+ @Override
1098-
+ public Double apply(Double input) {
1099-
+ return -(double) blocked;
1100-
+ }
1101-
+ };
1112+
+ blocking = input -> -(double) blocked;
11021113
+ } else {
1103-
+ blocking = new Function<Double, Double>() {
1104-
+ @Override
1105-
+ public Double apply(Double input) {
1106-
+ return 0d;
1107-
+ }
1108-
+ };
1114+
+ blocking = input -> 0d;
11091115
+ }
11101116
+ } else {
1111-
+ blocking = new Function<Double, Double>() {
1112-
+ @Override
1113-
+ public Double apply(Double input) {
1114-
+ return 0d;
1115-
+ }
1116-
+ };
1117+
+ blocking = input -> 0d;
11171118
+ }
11181119
+ float blockingModifier = blocking.apply((double) p_21241_).floatValue();
11191120
+ p_21241_ += blockingModifier;
@@ -1256,9 +1257,11 @@
12561257
+ CriteriaTriggers.f_10573_.m_60112_(serverPlayer, this, p_21240_, p_21241_, originalDamage, true);
12571258
+ }
12581259
+ this.canDamage.set(false);
1259-
+ return false ;
1260+
+ return false;
12601261
+ } else {
1261-
+ return originalDamage > 0;
1262+
+ boolean eo = originalDamage > 0;
1263+
+ this.canDamage.set(eo);
1264+
+ return eo;
12621265
+ }
12631266
+ // CraftBukkit end
12641267
}

0 commit comments

Comments
 (0)