SPIGOT-6289: Fix setting entity equipment

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2020-12-23 07:53:45 +11:00
parent 9f19f0b9c4
commit 59490dfe12
2 changed files with 37 additions and 33 deletions

View File

@@ -589,10 +589,7 @@
+ public Double apply(Double f) {
+ if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !EntityLiving.this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
+ return -(f - (f * 0.75F));
- f = Math.max(f - this.getAbsorptionHearts(), 0.0F);
- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f));
- float f2 = f1 - f;
+
+ }
+ return -0.0;
+ }
@@ -685,12 +682,15 @@
+ this.damageArmor(damagesource, armorDamage);
+ }
- f = Math.max(f - this.getAbsorptionHearts(), 0.0F);
- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f));
- float f2 = f1 - f;
+ // Apply blocking code // PAIL: steal from above
+ if (event.getDamage(DamageModifier.BLOCKING) < 0) {
+ this.world.broadcastEntityEffect(this, (byte) 29); // SPIGOT-4635 - shield damage sound
+ this.damageShield((float) -event.getDamage(DamageModifier.BLOCKING));
+ Entity entity = damagesource.j();
+
+ if (entity instanceof EntityLiving) {
+ this.shieldBlock((EntityLiving) entity);
+ }
@@ -775,7 +775,20 @@
public final int dz() {
return (Integer) this.datawatcher.get(EntityLiving.bi);
}
@@ -1816,6 +2229,7 @@
@@ -1594,6 +2007,12 @@
public abstract ItemStack getEquipment(EnumItemSlot enumitemslot);
+ // CraftBukkit start
+ public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) {
+ this.setSlot(enumitemslot, itemstack);
+ }
+ // CraftBukkit end
+
@Override
public abstract void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack);
@@ -1816,6 +2235,7 @@
}
if (this.onGround && !this.world.isClientSide) {
@@ -783,7 +796,7 @@
this.setFlag(7, false);
}
} else {
@@ -2321,6 +2735,7 @@
@@ -2321,6 +2741,7 @@
}
if (!this.world.isClientSide) {
@@ -791,7 +804,7 @@
this.setFlag(7, flag);
}
@@ -2441,6 +2856,7 @@
@@ -2441,6 +2862,7 @@
}
public boolean hasLineOfSight(Entity entity) {
@@ -799,7 +812,7 @@
Vec3D vec3d = new Vec3D(this.locX(), this.getHeadY(), this.locZ());
Vec3D vec3d1 = new Vec3D(entity.locX(), entity.getHeadY(), entity.locZ());
@@ -2458,14 +2874,21 @@
@@ -2458,14 +2880,21 @@
@Override
public boolean isInteractable() {
@@ -823,7 +836,7 @@
@Override
protected void velocityChanged() {
this.velocityChanged = this.random.nextDouble() >= this.b(GenericAttributes.KNOCKBACK_RESISTANCE);
@@ -2658,7 +3081,25 @@
@@ -2658,7 +3087,25 @@
} else {
if (!this.activeItem.isEmpty() && this.isHandRaised()) {
this.b(this.activeItem, 16);
@@ -850,7 +863,7 @@
if (itemstack != this.activeItem) {
this.a(enumhand, itemstack);
@@ -2750,10 +3191,18 @@
@@ -2750,10 +3197,18 @@
}
if (flag2) {
@@ -872,7 +885,7 @@
}
}
@@ -2850,7 +3299,7 @@
@@ -2850,7 +3305,7 @@
}
public void entityWakeup() {
@@ -881,7 +894,7 @@
World world = this.world;
this.world.getClass();
@@ -2921,7 +3370,7 @@
@@ -2921,7 +3376,7 @@
Pair<MobEffect, Float> pair = (Pair) iterator.next();
if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) {