SPIGOT-3324: Best effort fix for shoulder Parrots + cancelled damage event

This commit is contained in:
md_5 2017-06-11 12:20:18 +10:00
parent 639aa0cf48
commit 202da9777d

View File

@ -131,8 +131,12 @@
} }
@@ -685,7 +743,7 @@ @@ -682,10 +740,10 @@
this.releaseShoulderEntities(); this.a(true, true, false);
}
- this.releaseShoulderEntities();
+ // this.releaseShoulderEntities(); // CraftBukkit - moved down
if (damagesource.r()) { if (damagesource.r()) {
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL) { if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL) {
- f = 0.0F; - f = 0.0F;
@ -140,16 +144,22 @@
} }
if (this.world.getDifficulty() == EnumDifficulty.EASY) { if (this.world.getDifficulty() == EnumDifficulty.EASY) {
@@ -697,7 +755,7 @@ @@ -697,7 +755,13 @@
} }
} }
- return f == 0.0F ? false : super.damageEntity(damagesource, f); - return f == 0.0F ? false : super.damageEntity(damagesource, f);
+ return super.damageEntity(damagesource, f); // CraftBukkit - Don't filter out 0 damage + // CraftBukkit start - Don't filter out 0 damage
+ boolean damaged = super.damageEntity(damagesource, f);
+ if (damaged) {
+ this.releaseShoulderEntities();
+ }
+ return damaged;
+ // CraftBukkit end
} }
} }
} }
@@ -711,10 +769,29 @@ @@ -711,10 +775,29 @@
} }
public boolean a(EntityHuman entityhuman) { public boolean a(EntityHuman entityhuman) {
@ -182,7 +192,7 @@
} }
protected void damageArmor(float f) { protected void damageArmor(float f) {
@@ -757,7 +834,12 @@ @@ -757,7 +840,12 @@
return (float) i / (float) this.inventory.armor.size(); return (float) i / (float) this.inventory.armor.size();
} }
@ -196,7 +206,7 @@
if (!this.isInvulnerable(damagesource)) { if (!this.isInvulnerable(damagesource)) {
f = this.applyArmorModifier(damagesource, f); f = this.applyArmorModifier(damagesource, f);
f = this.applyMagicModifier(damagesource, f); f = this.applyMagicModifier(damagesource, f);
@@ -777,6 +859,7 @@ @@ -777,6 +865,7 @@
} }
} }
@ -204,7 +214,7 @@
} }
public void openSign(TileEntitySign tileentitysign) {} public void openSign(TileEntitySign tileentitysign) {}
@@ -898,8 +981,15 @@ @@ -898,8 +987,15 @@
if (entity instanceof EntityLiving) { if (entity instanceof EntityLiving) {
f3 = ((EntityLiving) entity).getHealth(); f3 = ((EntityLiving) entity).getHealth();
if (j > 0 && !entity.isBurning()) { if (j > 0 && !entity.isBurning()) {
@ -222,7 +232,7 @@
} }
} }
@@ -930,8 +1020,11 @@ @@ -930,8 +1026,11 @@
EntityLiving entityliving = (EntityLiving) iterator.next(); EntityLiving entityliving = (EntityLiving) iterator.next();
if (entityliving != this && entityliving != entity && !this.r(entityliving) && this.h(entityliving) < 9.0D) { if (entityliving != this && entityliving != entity && !this.r(entityliving) && this.h(entityliving) < 9.0D) {
@ -235,7 +245,7 @@
} }
} }
@@ -940,11 +1033,28 @@ @@ -940,11 +1039,28 @@
} }
if (entity instanceof EntityPlayer && entity.velocityChanged) { if (entity instanceof EntityPlayer && entity.velocityChanged) {
@ -264,7 +274,7 @@
} }
if (flag2) { if (flag2) {
@@ -993,7 +1103,14 @@ @@ -993,7 +1109,14 @@
this.a(StatisticList.y, Math.round(f5 * 10.0F)); this.a(StatisticList.y, Math.round(f5 * 10.0F));
if (j > 0) { if (j > 0) {
@ -280,7 +290,7 @@
} }
if (this.world instanceof WorldServer && f5 > 2.0F) { if (this.world instanceof WorldServer && f5 > 2.0F) {
@@ -1009,6 +1126,11 @@ @@ -1009,6 +1132,11 @@
if (flag4) { if (flag4) {
entity.extinguish(); entity.extinguish();
} }
@ -292,7 +302,7 @@
} }
} }
@@ -1099,6 +1221,20 @@ @@ -1099,6 +1227,20 @@
this.stopRiding(); this.stopRiding();
} }
@ -313,7 +323,7 @@
this.releaseShoulderEntities(); this.releaseShoulderEntities();
this.setSize(0.2F, 0.2F); this.setSize(0.2F, 0.2F);
if (this.world.isLoaded(blockposition)) { if (this.world.isLoaded(blockposition)) {
@@ -1159,6 +1295,23 @@ @@ -1159,6 +1301,23 @@
this.world.everyoneSleeping(); this.world.everyoneSleeping();
} }
@ -337,7 +347,7 @@
this.sleepTicks = flag ? 0 : 100; this.sleepTicks = flag ? 0 : 100;
if (flag2) { if (flag2) {
this.setRespawnPosition(this.bedPosition, false); this.setRespawnPosition(this.bedPosition, false);
@@ -1210,9 +1363,11 @@ @@ -1210,9 +1369,11 @@
if (blockposition != null) { if (blockposition != null) {
this.d = blockposition; this.d = blockposition;
this.e = flag; this.e = flag;
@ -349,7 +359,7 @@
} }
} }
@@ -1540,13 +1695,17 @@ @@ -1540,13 +1701,17 @@
} }
protected void releaseShoulderEntities() { protected void releaseShoulderEntities() {
@ -372,7 +382,7 @@
if (!this.world.isClientSide && !nbttagcompound.isEmpty()) { if (!this.world.isClientSide && !nbttagcompound.isEmpty()) {
Entity entity = EntityTypes.a(nbttagcompound, this.world); Entity entity = EntityTypes.a(nbttagcompound, this.world);
@@ -1555,9 +1714,10 @@ @@ -1555,9 +1720,10 @@
} }
entity.setPosition(this.locX, this.locY + 0.699999988079071D, this.locZ); entity.setPosition(this.locX, this.locY + 0.699999988079071D, this.locZ);
@ -384,7 +394,7 @@
} }
public abstract boolean isSpectator(); public abstract boolean isSpectator();
@@ -1759,7 +1919,7 @@ @@ -1759,7 +1925,7 @@
return entitymonster.c(this.a); return entitymonster.c(this.a);
} }