Update to Minecraft 1.13.1

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2018-08-26 12:00:00 +10:00
parent 034c12d001
commit f578d94680
182 changed files with 1891 additions and 1879 deletions

View File

@@ -101,14 +101,14 @@
- if (!this.world.isClientSide && (this.alwaysGivesExp() || this.lastDamageByPlayerTime > 0 && this.isDropExperience() && this.world.getGameRules().getBoolean("doMobLoot"))) {
- i = this.getExpValue(this.killer);
-
- while (i > 0) {
- int j = EntityExperienceOrb.getOrbValue(i);
+ // CraftBukkit start - Update getExpReward() above if the removed if() changes!
+ i = this.expToDrop;
+ while (i > 0) {
+ int j = EntityExperienceOrb.getOrbValue(i);
- while (i > 0) {
- int j = EntityExperienceOrb.getOrbValue(i);
-
- i -= j;
- this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j));
- }
@@ -375,69 +375,70 @@
this.datawatcher.set(EntityLiving.HEALTH, Float.valueOf(MathHelper.a(f, 0.0F, this.getMaxHealth())));
}
@@ -712,14 +912,16 @@
} else {
float f1 = f;
@@ -711,15 +911,17 @@
this.ticksFarFromPlayer = 0;
float f1 = f;
- if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
+ // CraftBukkit - Moved into damageEntity0(DamageSource, float)
+ if (false && (damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
this.getEquipment(EnumItemSlot.HEAD).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this);
f *= 0.75F;
}
- boolean flag = false;
+ boolean flag = f > 0.0F && this.applyBlockingModifier(damagesource); // Copied from below
- if (f > 0.0F && this.applyBlockingModifier(damagesource)) {
+ // CraftBukkit - Moved into damageEntity0(DamageSource, float)
+ if (false && f > 0.0F && this.applyBlockingModifier(damagesource)) {
this.damageShield(f);
f = 0.0F;
if (!damagesource.b()) {
@@ -738,20 +940,39 @@
if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) {
if (f <= this.lastDamage) {
+ this.forceExplosionKnockback = true; // CraftBukkit - SPIGOT-949 - for vanilla consistency, cooldown does not prevent explosion knockback
return false;
}
- this.damageEntity0(damagesource, f - this.lastDamage);
+ // CraftBukkit start
+ if (!this.damageEntity0(damagesource, f - this.lastDamage)) {
+ return false;
+ }
+ // CraftBukkit end
this.lastDamage = f;
flag1 = false;
} else {
+ // CraftBukkit start
+ if (!this.damageEntity0(damagesource, f)) {
+ return false;
+ }
this.lastDamage = f;
this.noDamageTicks = this.maxNoDamageTicks;
- this.damageEntity0(damagesource, f);
+ // this.damageEntity0(damagesource, f);
+ // CraftBukkit end
this.aC = 10;
this.hurtTicks = this.aC;
- if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
+ // CraftBukkit - Moved into damageEntity0(DamageSource, float)
+ if (false && (damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
this.getEquipment(EnumItemSlot.HEAD).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this);
f *= 0.75F;
}
- boolean flag = false;
+ boolean flag = f > 0.0F && this.applyBlockingModifier(damagesource); // Copied from below
float f2 = 0.0F;
- if (f > 0.0F && this.applyBlockingModifier(damagesource)) {
+ // CraftBukkit - Moved into damageEntity0(DamageSource, float)
+ if (false && f > 0.0F && this.applyBlockingModifier(damagesource)) {
this.damageShield(f);
f2 = f;
f = 0.0F;
@@ -739,20 +941,39 @@
if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) {
if (f <= this.lastDamage) {
+ this.forceExplosionKnockback = true; // CraftBukkit - SPIGOT-949 - for vanilla consistency, cooldown does not prevent explosion knockback
return false;
}
- this.damageEntity0(damagesource, f - this.lastDamage);
+ // CraftBukkit start
+ if (this instanceof EntityAnimal) {
+ ((EntityAnimal) this).resetLove();
+ if (this instanceof EntityTameableAnimal) {
+ ((EntityTameableAnimal) this).getGoalSit().setSitting(false);
+ }
+ if (!this.damageEntity0(damagesource, f - this.lastDamage)) {
+ return false;
+ }
+ // CraftBukkit end
+
this.aD = 0.0F;
Entity entity1 = damagesource.getEntity();
this.lastDamage = f;
flag1 = false;
} else {
+ // CraftBukkit start
+ if (!this.damageEntity0(damagesource, f)) {
+ return false;
+ }
this.lastDamage = f;
this.noDamageTicks = this.maxNoDamageTicks;
- this.damageEntity0(damagesource, f);
+ // this.damageEntity0(damagesource, f);
+ // CraftBukkit end
this.aC = 10;
this.hurtTicks = this.aC;
}
@@ -858,19 +1079,29 @@
+ // CraftBukkit start
+ if (this instanceof EntityAnimal) {
+ ((EntityAnimal) this).resetLove();
+ if (this instanceof EntityTameableAnimal) {
+ ((EntityTameableAnimal) this).getGoalSit().setSitting(false);
+ }
+ }
+ // CraftBukkit end
+
this.aD = 0.0F;
Entity entity1 = damagesource.getEntity();
@@ -861,19 +1082,29 @@
EnumHand[] aenumhand = EnumHand.values();
int i = aenumhand.length;
@@ -471,7 +472,7 @@
EntityPlayer entityplayer = (EntityPlayer) this;
entityplayer.b(StatisticList.ITEM_USED.b(Items.TOTEM_OF_UNDYING));
@@ -878,13 +1109,15 @@
@@ -881,13 +1112,15 @@
}
this.setHealth(1.0F);
@@ -491,7 +492,7 @@
}
}
@@ -955,6 +1188,12 @@
@@ -958,6 +1191,12 @@
boolean flag = this.lastDamageByPlayerTime > 0;
this.a(flag, i, damagesource);
@@ -504,7 +505,7 @@
}
}
@@ -1044,8 +1283,13 @@
@@ -1047,8 +1286,13 @@
int i = MathHelper.f((f - 3.0F - f2) * f1);
if (i > 0) {
@@ -513,13 +514,13 @@
+ return;
+ }
+ // CraftBukkit end
this.a(this.n(i), 1.0F, 1.0F);
this.a(this.m(i), 1.0F, 1.0F);
- this.damageEntity(DamageSource.FALL, (float) i);
+ // this.damageEntity(DamageSource.FALL, (float) i); // CraftBukkit - moved up
int j = MathHelper.floor(this.locX);
int k = MathHelper.floor(this.locY - 0.20000000298023224D);
int l = MathHelper.floor(this.locZ);
@@ -1072,7 +1316,7 @@
@@ -1075,7 +1319,7 @@
protected float applyArmorModifier(DamageSource damagesource, float f) {
if (!damagesource.ignoresArmor()) {
@@ -528,7 +529,7 @@
f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.getAttributeInstance(GenericAttributes.i).getValue());
}
@@ -1085,7 +1329,8 @@
@@ -1088,7 +1332,8 @@
} else {
int i;
@@ -538,7 +539,7 @@
i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
int j = 25 - i;
float f1 = f * (float) j;
@@ -1106,22 +1351,142 @@
@@ -1119,28 +1364,164 @@
}
}
@@ -547,10 +548,6 @@
- f = this.applyArmorModifier(damagesource, f);
- f = this.applyMagicModifier(damagesource, f);
- float f1 = f;
-
- f = Math.max(f - this.getAbsorptionHearts(), 0.0F);
- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f));
- if (f != 0.0F) {
+ // CraftBukkit start
+ protected boolean damageEntity0(final DamageSource damagesource, float f) { // void -> boolean, add final
+ if (!this.isInvulnerable(damagesource)) {
@@ -623,9 +620,24 @@
+ if (event.isCancelled()) {
+ return false;
+ }
+
- f = Math.max(f - this.getAbsorptionHearts(), 0.0F);
- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f));
- float f2 = f1 - f;
+ f = (float) event.getFinalDamage();
+
+ // Resistance
+ if (event.getDamage(DamageModifier.RESISTANCE) < 0) {
+ float f3 = (float) -event.getDamage(DamageModifier.RESISTANCE);
+ if (f3 > 0.0F && f3 < 3.4028235E37F) {
+ if (this instanceof EntityPlayer) {
+ ((EntityPlayer) this).a(StatisticList.DAMAGE_RESISTED, Math.round(f3 * 10.0F));
+ } else if (damagesource.getEntity() instanceof EntityPlayer) {
+ ((EntityPlayer) damagesource.getEntity()).a(StatisticList.DAMAGE_DEALT_RESISTED, Math.round(f3 * 10.0F));
+ }
+ }
+ }
+
+ // Apply damage to helmet
+ if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(EnumItemSlot.HEAD) != null) {
+ this.getEquipment(EnumItemSlot.HEAD).damage((int) (event.getDamage() * 4.0F + this.random.nextFloat() * event.getDamage() * 2.0F), this);
@@ -649,6 +661,13 @@
+
+ absorptionModifier = (float) -event.getDamage(DamageModifier.ABSORPTION);
+ this.setAbsorptionHearts(Math.max(this.getAbsorptionHearts() - absorptionModifier, 0.0F));
+ float f2 = absorptionModifier;
if (f2 > 0.0F && f2 < 3.4028235E37F && damagesource.getEntity() instanceof EntityPlayer) {
((EntityPlayer) damagesource.getEntity()).a(StatisticList.DAMAGE_DEALT_ABSORBED, Math.round(f2 * 10.0F));
}
- if (f != 0.0F) {
+ if (f > 0 || !human) {
+ if (human) {
+ // PAIL: Be sure to drag all this code from the EntityHuman subclass each update.
@@ -658,10 +677,10 @@
+ }
+ }
+ // CraftBukkit end
float f2 = this.getHealth();
float f3 = this.getHealth();
this.setHealth(f2 - f);
this.getCombatTracker().trackDamage(damagesource, f2, f);
this.setHealth(f3 - f);
this.getCombatTracker().trackDamage(damagesource, f3, f);
- this.setAbsorptionHearts(this.getAbsorptionHearts() - f);
+ // CraftBukkit start
+ if (!human) {
@@ -674,6 +693,10 @@
+ if (event.getDamage(DamageModifier.BLOCKING) < 0) {
+ if (this instanceof EntityPlayer) {
+ CriterionTriggers.h.a((EntityPlayer) this, damagesource, f, originalDamage, true);
+ f2 = (float) -event.getDamage(DamageModifier.BLOCKING);
+ if (f2 > 0.0F && f2 < 3.4028235E37F) {
+ ((EntityPlayer) this).a(StatisticList.DAMAGE_BLOCKED_BY_SHIELD, Math.round(originalDamage * 10.0F));
+ }
+ }
+
+ if (damagesource.getEntity() instanceof EntityPlayer) {
@@ -691,7 +714,7 @@
}
public CombatTracker getCombatTracker() {
@@ -1188,6 +1553,7 @@
@@ -1207,6 +1588,7 @@
public AttributeMapBase getAttributeMap() {
if (this.attributeMap == null) {
this.attributeMap = new AttributeMapServer();
@@ -699,7 +722,7 @@
}
return this.attributeMap;
@@ -1490,6 +1856,7 @@
@@ -1509,6 +1891,7 @@
}
if (this.onGround && !this.world.isClientSide) {
@@ -707,7 +730,7 @@
this.setFlag(7, false);
}
} else {
@@ -1891,6 +2258,7 @@
@@ -1910,6 +2293,7 @@
}
if (!this.world.isClientSide) {
@@ -715,7 +738,7 @@
this.setFlag(7, flag);
}
@@ -2018,11 +2386,11 @@
@@ -2037,11 +2421,11 @@
}
public boolean isInteractable() {
@@ -729,7 +752,7 @@
}
protected void aA() {
@@ -2182,7 +2550,27 @@
@@ -2201,7 +2585,27 @@
protected void q() {
if (!this.activeItem.isEmpty() && this.isHandRaised()) {
this.b(this.activeItem, 16);
@@ -758,7 +781,7 @@
this.da();
}
@@ -2261,10 +2649,18 @@
@@ -2280,10 +2684,18 @@
}
if (flag1) {