Update to Minecraft 1.16.1

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2020-06-25 10:00:00 +10:00
parent 3862d2811e
commit 50503fd516
424 changed files with 5960 additions and 5636 deletions

View File

@@ -1,13 +1,12 @@
--- a/net/minecraft/server/EntityLiving.java
+++ b/net/minecraft/server/EntityLiving.java
@@ -18,6 +18,25 @@
@@ -21,6 +21,24 @@
import javax.annotation.Nullable;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import java.util.ArrayList;
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.attribute.CraftAttributeMap;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@@ -26,16 +25,16 @@
public abstract class EntityLiving extends Entity {
private static final UUID b = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
@@ -100,6 +119,20 @@
private float bH;
@@ -106,6 +124,20 @@
private float bI;
protected BehaviorController<?> bo;
private float bJ;
protected BehaviorController<?> bn;
+ // CraftBukkit start
+ public int expToDrop;
+ public int maxAirTicks = 300;
+ boolean forceDrops;
+ ArrayList<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
+ public org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes;
+ public final org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes;
+ public boolean collides = true;
+ public boolean canPickUpLoot;
+
@@ -47,17 +46,18 @@
protected EntityLiving(EntityTypes<? extends EntityLiving> entitytypes, World world) {
super(entitytypes, world);
@@ -110,7 +143,8 @@
this.updateEffects = true;
this.activeItem = ItemStack.a;
this.initAttributes();
@@ -117,7 +149,9 @@
this.activeItem = ItemStack.b;
this.bF = Optional.empty();
this.attributeMap = new AttributeMapBase(AttributeDefaults.a(entitytypes));
- this.setHealth(this.getMaxHealth());
+ this.craftAttributes = new CraftAttributeMap(attributeMap); // CraftBukkit
+ // CraftBukkit - setHealth(getMaxHealth()) inlined and simplified to skip the instanceof check for EntityPlayer, as getBukkitEntity() is not initialized in constructor
+ this.datawatcher.set(EntityLiving.HEALTH, (float) this.getAttributeInstance(GenericAttributes.MAX_HEALTH).getValue());
this.i = true;
this.aH = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
this.Z();
@@ -170,7 +204,13 @@
this.aG = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
this.ac();
@@ -184,7 +218,13 @@
double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D);
int i = (int) (150.0D * d1);
@@ -72,16 +72,16 @@
}
}
@@ -318,7 +358,7 @@
@@ -406,7 +446,7 @@
protected void cD() {
protected void cT() {
++this.deathTicks;
- if (this.deathTicks == 20) {
+ if (this.deathTicks >= 20 && !this.dead) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead)
this.die();
for (int i = 0; i < 20; ++i) {
@@ -464,6 +504,17 @@
@@ -567,6 +607,17 @@
}
}
@@ -99,7 +99,7 @@
if (nbttagcompound.hasKeyOfType("Health", 99)) {
this.setHealth(nbttagcompound.getFloat("Health"));
}
@@ -501,9 +552,32 @@
@@ -604,9 +655,32 @@
}
@@ -132,7 +132,7 @@
try {
while (iterator.hasNext()) {
MobEffectList mobeffectlist = (MobEffectList) iterator.next();
@@ -513,6 +587,12 @@
@@ -616,6 +690,12 @@
this.a(mobeffect, true);
})) {
if (!this.world.isClientSide) {
@@ -145,7 +145,7 @@
iterator.remove();
this.b(mobeffect);
}
@@ -523,6 +603,17 @@
@@ -626,6 +706,17 @@
} catch (ConcurrentModificationException concurrentmodificationexception) {
;
}
@@ -163,8 +163,8 @@
if (this.updateEffects) {
if (!this.world.isClientSide) {
@@ -632,7 +723,13 @@
this.datawatcher.set(EntityLiving.e, 0);
@@ -735,7 +826,13 @@
this.datawatcher.set(EntityLiving.f, 0);
}
+ // CraftBukkit start
@@ -177,7 +177,7 @@
if (this.world.isClientSide) {
return false;
} else {
@@ -641,7 +738,14 @@
@@ -744,7 +841,14 @@
boolean flag;
for (flag = false; iterator.hasNext(); flag = true) {
@@ -193,7 +193,7 @@
iterator.remove();
}
@@ -666,18 +770,44 @@
@@ -769,18 +873,44 @@
return (MobEffect) this.effects.get(mobeffectlist);
}
@@ -239,7 +239,7 @@
return true;
} else {
return false;
@@ -701,13 +831,39 @@
@@ -804,13 +934,39 @@
return this.getMonsterType() == EnumMonsterType.UNDEAD;
}
@@ -280,7 +280,7 @@
if (mobeffect != null) {
this.b(mobeffect);
@@ -744,20 +900,55 @@
@@ -847,20 +1003,55 @@
}
@@ -337,16 +337,16 @@
this.datawatcher.set(EntityLiving.HEALTH, MathHelper.a(f, 0.0F, this.getMaxHealth()));
}
@@ -767,7 +958,7 @@
@@ -874,7 +1065,7 @@
return false;
} else if (this.world.isClientSide) {
return false;
- } else if (this.getHealth() <= 0.0F) {
- } else if (this.dk()) {
+ } else if (this.dead || this.killed || this.getHealth() <= 0.0F) { // CraftBukkit - Don't allow entities that got set to dead/killed elsewhere to get damaged and die
return false;
} else if (damagesource.isFire() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
return false;
@@ -779,17 +970,19 @@
@@ -886,17 +1077,19 @@
this.ticksFarFromPlayer = 0;
float f1 = f;
@@ -369,7 +369,7 @@
this.damageShield(f);
f2 = f;
f = 0.0F;
@@ -809,20 +1002,39 @@
@@ -916,20 +1109,39 @@
if ((float) this.noDamageTicks > 10.0F) {
if (f <= this.lastDamage) {
@@ -403,20 +403,20 @@
+ if (this instanceof EntityAnimal) {
+ ((EntityAnimal) this).resetLove();
+ if (this instanceof EntityTameableAnimal) {
+ ((EntityTameableAnimal) this).getGoalSit().setSitting(false);
+ ((EntityTameableAnimal) this).setWillSit(false);
+ }
+ }
+ // CraftBukkit end
+
this.ax = 0.0F;
this.aw = 0.0F;
Entity entity1 = damagesource.getEntity();
@@ -943,19 +1155,29 @@
@@ -1050,19 +1262,29 @@
EnumHand[] aenumhand = EnumHand.values();
int i = aenumhand.length;
+ // CraftBukkit start
+ ItemStack itemstack1 = ItemStack.a;
+ ItemStack itemstack1 = ItemStack.b;
for (int j = 0; j < i; ++j) {
EnumHand enumhand = aenumhand[j];
- ItemStack itemstack1 = this.b(enumhand);
@@ -445,7 +445,7 @@
EntityPlayer entityplayer = (EntityPlayer) this;
entityplayer.b(StatisticList.ITEM_USED.b(Items.TOTEM_OF_UNDYING));
@@ -963,13 +1185,15 @@
@@ -1070,13 +1292,15 @@
}
this.setHealth(1.0F);
@@ -465,12 +465,12 @@
}
}
@@ -1086,28 +1310,48 @@
@@ -1193,28 +1417,48 @@
boolean flag = this.lastDamageByPlayerTime > 0;
+ this.dropInventory(); // CraftBukkit - from below
if (this.isDropExperience() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
if (this.cV() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
this.a(damagesource, flag);
this.dropDeathLoot(damagesource, i, flag);
+ // CraftBukkit start - Call death event
@@ -516,7 +516,7 @@
}
@@ -1205,9 +1449,14 @@
@@ -1335,9 +1579,14 @@
int i = this.e(f, f1);
if (i > 0) {
@@ -525,23 +525,23 @@
+ return true;
+ }
+ // CraftBukkit end
this.a(this.getSoundFall(i), 1.0F, 1.0F);
this.cZ();
this.playSound(this.getSoundFall(i), 1.0F, 1.0F);
this.playBlockStepSound();
- this.damageEntity(DamageSource.FALL, (float) i);
+ // this.damageEntity(DamageSource.FALL, (float) i); // CraftBukkit - moved up
return true;
} else {
return flag;
@@ -1249,7 +1498,7 @@
@@ -1377,7 +1626,7 @@
protected float applyArmorModifier(DamageSource damagesource, float f) {
if (!damagesource.ignoresArmor()) {
- this.damageArmor(f);
+ // this.damageArmor(f); // CraftBukkit - Moved into damageEntity0(DamageSource, float)
f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.getAttributeInstance(GenericAttributes.ARMOR_TOUGHNESS).getValue());
- this.damageArmor(damagesource, f);
+ // this.damageArmor(damagesource, f); // CraftBukkit - Moved into damageEntity0(DamageSource, float)
f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.b(GenericAttributes.ARMOR_TOUGHNESS));
}
@@ -1262,7 +1511,8 @@
@@ -1390,7 +1639,8 @@
} else {
int i;
@@ -551,7 +551,7 @@
i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
int j = 25 - i;
float f1 = f * (float) j;
@@ -1293,28 +1543,173 @@
@@ -1421,28 +1671,173 @@
}
}
@@ -630,7 +630,7 @@
+
+ EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption);
+ if (damagesource.getEntity() instanceof EntityHuman) {
+ ((EntityHuman) damagesource.getEntity()).ey(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired
+ ((EntityHuman) damagesource.getEntity()).resetAttackCooldown(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired
+ }
+ if (event.isCancelled()) {
+ return false;
@@ -660,7 +660,7 @@
+ // Apply damage to armor
+ if (!damagesource.ignoresArmor()) {
+ float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT));
+ this.damageArmor(armorDamage);
+ this.damageArmor(damagesource, armorDamage);
+ }
- f = Math.max(f - this.getAbsorptionHearts(), 0.0F);
@@ -671,12 +671,12 @@
+ 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);
+ }
+ }
+
+ absorptionModifier = (float) -event.getDamage(DamageModifier.ABSORPTION);
+ this.setAbsorptionHearts(Math.max(this.getAbsorptionHearts() - absorptionModifier, 0.0F));
+ float f2 = absorptionModifier;
@@ -735,15 +735,7 @@
}
public CombatTracker getCombatTracker() {
@@ -1401,6 +1796,7 @@
public AttributeMapBase getAttributeMap() {
if (this.attributeMap == null) {
this.attributeMap = new AttributeMapServer();
+ this.craftAttributes = new CraftAttributeMap(attributeMap); // CraftBukkit
}
return this.attributeMap;
@@ -1771,6 +2167,7 @@
@@ -1814,6 +2209,7 @@
}
if (this.onGround && !this.world.isClientSide) {
@@ -751,7 +743,7 @@
this.setFlag(7, false);
}
} else {
@@ -2168,6 +2565,7 @@
@@ -2319,6 +2715,7 @@
}
if (!this.world.isClientSide) {
@@ -759,7 +751,7 @@
this.setFlag(7, flag);
}
@@ -2279,6 +2677,7 @@
@@ -2439,6 +2836,7 @@
}
public boolean hasLineOfSight(Entity entity) {
@@ -767,7 +759,7 @@
Vec3D vec3d = new Vec3D(this.locX(), this.getHeadY(), this.locZ());
Vec3D vec3d1 = new Vec3D(entity.locX(), entity.getHeadY(), entity.locZ());
@@ -2296,12 +2695,12 @@
@@ -2456,12 +2854,12 @@
@Override
public boolean isInteractable() {
@@ -782,7 +774,7 @@
}
@Override
@@ -2484,7 +2883,27 @@
@@ -2645,7 +3043,27 @@
} else {
if (!this.activeItem.isEmpty() && this.isHandRaised()) {
this.b(this.activeItem, 16);
@@ -808,10 +800,10 @@
+
+ this.a(this.getRaisedHand(), itemstack);
+ // CraftBukkit end
this.dH();
this.clearActiveItem();
}
@@ -2571,10 +2990,18 @@
@@ -2732,10 +3150,18 @@
}
if (flag2) {
@@ -833,7 +825,7 @@
}
}
@@ -2661,7 +3088,7 @@
@@ -2832,7 +3258,7 @@
}
public void entityWakeup() {
@@ -842,12 +834,12 @@
World world = this.world;
this.world.getClass();
@@ -2725,7 +3152,7 @@
@@ -2899,7 +3325,7 @@
Pair<MobEffect, Float> pair = (Pair) iterator.next();
if (!world.isClientSide && pair.getLeft() != null && world.random.nextFloat() < (Float) pair.getRight()) {
- entityliving.addEffect(new MobEffect((MobEffect) pair.getLeft()));
+ entityliving.addEffect(new MobEffect((MobEffect) pair.getLeft()), EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit
if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) {
- entityliving.addEffect(new MobEffect((MobEffect) pair.getFirst()));
+ entityliving.addEffect(new MobEffect((MobEffect) pair.getFirst()), EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit
}
}
}