SPIGOT-6907: Oxygen does not restore up to value set by LivingEntity#setMaximumAir()
By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
@@ -31,13 +31,12 @@
|
||||
public abstract class EntityLiving extends Entity {
|
||||
|
||||
private static final UUID SPEED_MODIFIER_SPRINTING_UUID = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
|
||||
@@ -224,6 +248,21 @@
|
||||
@@ -224,6 +248,20 @@
|
||||
private float swimAmount;
|
||||
private float swimAmountO;
|
||||
protected BehaviorController<?> brain;
|
||||
+ // CraftBukkit start
|
||||
+ public int expToDrop;
|
||||
+ public int maxAirTicks = 300;
|
||||
+ public boolean forceDrops;
|
||||
+ public ArrayList<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
|
||||
+ public final org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes;
|
||||
@@ -53,7 +52,7 @@
|
||||
|
||||
protected EntityLiving(EntityTypes<? extends EntityLiving> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -236,7 +275,9 @@
|
||||
@@ -236,7 +274,9 @@
|
||||
this.useItem = ItemStack.EMPTY;
|
||||
this.lastClimbablePos = Optional.empty();
|
||||
this.attributes = new AttributeMapBase(AttributeDefaults.getSupplier(entitytypes));
|
||||
@@ -64,7 +63,7 @@
|
||||
this.blocksBuilding = true;
|
||||
this.rotA = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
|
||||
this.reapplyPosition();
|
||||
@@ -303,7 +344,13 @@
|
||||
@@ -303,7 +343,13 @@
|
||||
double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D);
|
||||
int i = (int) (150.0D * d1);
|
||||
|
||||
@@ -79,7 +78,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -561,7 +608,7 @@
|
||||
@@ -561,7 +607,7 @@
|
||||
|
||||
protected void tickDeath() {
|
||||
++this.deathTime;
|
||||
@@ -88,7 +87,7 @@
|
||||
this.level.broadcastEntityEvent(this, (byte) 60);
|
||||
this.remove(Entity.RemovalReason.KILLED);
|
||||
}
|
||||
@@ -653,9 +700,15 @@
|
||||
@@ -653,9 +699,15 @@
|
||||
}
|
||||
|
||||
protected void equipEventAndSound(ItemStack itemstack) {
|
||||
@@ -105,7 +104,7 @@
|
||||
this.gameEvent(GameEvent.EQUIP);
|
||||
this.playSound(soundeffect, 1.0F, 1.0F);
|
||||
}
|
||||
@@ -717,6 +770,17 @@
|
||||
@@ -717,6 +769,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +122,7 @@
|
||||
if (nbttagcompound.contains("Health", 99)) {
|
||||
this.setHealth(nbttagcompound.getFloat("Health"));
|
||||
}
|
||||
@@ -754,9 +818,32 @@
|
||||
@@ -754,9 +817,32 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -156,7 +155,7 @@
|
||||
try {
|
||||
while (iterator.hasNext()) {
|
||||
MobEffectList mobeffectlist = (MobEffectList) iterator.next();
|
||||
@@ -766,6 +853,12 @@
|
||||
@@ -766,6 +852,12 @@
|
||||
this.onEffectUpdated(mobeffect, true, (Entity) null);
|
||||
})) {
|
||||
if (!this.level.isClientSide) {
|
||||
@@ -169,7 +168,7 @@
|
||||
iterator.remove();
|
||||
this.onEffectRemoved(mobeffect);
|
||||
}
|
||||
@@ -776,6 +869,17 @@
|
||||
@@ -776,6 +868,17 @@
|
||||
} catch (ConcurrentModificationException concurrentmodificationexception) {
|
||||
;
|
||||
}
|
||||
@@ -187,7 +186,7 @@
|
||||
|
||||
if (this.effectsDirty) {
|
||||
if (!this.level.isClientSide) {
|
||||
@@ -902,7 +1006,13 @@
|
||||
@@ -902,7 +1005,13 @@
|
||||
this.entityData.set(EntityLiving.DATA_EFFECT_COLOR_ID, 0);
|
||||
}
|
||||
|
||||
@@ -201,7 +200,7 @@
|
||||
if (this.level.isClientSide) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -911,7 +1021,14 @@
|
||||
@@ -911,7 +1020,14 @@
|
||||
boolean flag;
|
||||
|
||||
for (flag = false; iterator.hasNext(); flag = true) {
|
||||
@@ -217,7 +216,7 @@
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
@@ -940,18 +1057,48 @@
|
||||
@@ -940,18 +1056,48 @@
|
||||
return this.addEffect(mobeffect, (Entity) null);
|
||||
}
|
||||
|
||||
@@ -267,7 +266,7 @@
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -988,13 +1135,39 @@
|
||||
@@ -988,13 +1134,39 @@
|
||||
return this.getMobType() == EnumMonsterType.UNDEAD;
|
||||
}
|
||||
|
||||
@@ -308,7 +307,7 @@
|
||||
|
||||
if (mobeffect != null) {
|
||||
this.onEffectRemoved(mobeffect);
|
||||
@@ -1031,20 +1204,55 @@
|
||||
@@ -1031,20 +1203,55 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -365,7 +364,7 @@
|
||||
this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.clamp(f, 0.0F, this.getMaxHealth()));
|
||||
}
|
||||
|
||||
@@ -1058,7 +1266,7 @@
|
||||
@@ -1058,7 +1265,7 @@
|
||||
return false;
|
||||
} else if (this.level.isClientSide) {
|
||||
return false;
|
||||
@@ -374,7 +373,7 @@
|
||||
return false;
|
||||
} else if (damagesource.isFire() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
|
||||
return false;
|
||||
@@ -1069,10 +1277,11 @@
|
||||
@@ -1069,10 +1276,11 @@
|
||||
|
||||
this.noActionTime = 0;
|
||||
float f1 = f;
|
||||
@@ -388,7 +387,7 @@
|
||||
this.hurtCurrentlyUsedShield(f);
|
||||
f2 = f;
|
||||
f = 0.0F;
|
||||
@@ -1090,27 +1299,46 @@
|
||||
@@ -1090,27 +1298,46 @@
|
||||
this.animationSpeed = 1.5F;
|
||||
boolean flag1 = true;
|
||||
|
||||
@@ -440,7 +439,7 @@
|
||||
this.hurtDir = 0.0F;
|
||||
Entity entity1 = damagesource.getEntity();
|
||||
|
||||
@@ -1233,19 +1461,29 @@
|
||||
@@ -1233,19 +1460,29 @@
|
||||
EnumHand[] aenumhand = EnumHand.values();
|
||||
int i = aenumhand.length;
|
||||
|
||||
@@ -474,7 +473,7 @@
|
||||
EntityPlayer entityplayer = (EntityPlayer) this;
|
||||
|
||||
entityplayer.awardStat(StatisticList.ITEM_USED.get(Items.TOTEM_OF_UNDYING));
|
||||
@@ -1253,14 +1491,16 @@
|
||||
@@ -1253,14 +1490,16 @@
|
||||
}
|
||||
|
||||
this.setHealth(1.0F);
|
||||
@@ -496,7 +495,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1365,14 +1605,22 @@
|
||||
@@ -1365,14 +1604,22 @@
|
||||
IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState();
|
||||
|
||||
if (this.level.getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level, blockposition)) {
|
||||
@@ -521,7 +520,7 @@
|
||||
this.level.addFreshEntity(entityitem);
|
||||
}
|
||||
}
|
||||
@@ -1392,21 +1640,40 @@
|
||||
@@ -1392,21 +1639,40 @@
|
||||
|
||||
boolean flag = this.lastHurtByPlayerTime > 0;
|
||||
|
||||
@@ -565,7 +564,7 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -1526,9 +1793,14 @@
|
||||
@@ -1526,9 +1792,14 @@
|
||||
int i = this.calculateFallDamage(f, f1);
|
||||
|
||||
if (i > 0) {
|
||||
@@ -581,7 +580,7 @@
|
||||
return true;
|
||||
} else {
|
||||
return flag;
|
||||
@@ -1577,7 +1849,7 @@
|
||||
@@ -1577,7 +1848,7 @@
|
||||
|
||||
protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) {
|
||||
if (!damagesource.isBypassArmor()) {
|
||||
@@ -590,7 +589,7 @@
|
||||
f = CombatMath.getDamageAfterAbsorb(f, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS));
|
||||
}
|
||||
|
||||
@@ -1590,7 +1862,8 @@
|
||||
@@ -1590,7 +1861,8 @@
|
||||
} else {
|
||||
int i;
|
||||
|
||||
@@ -600,7 +599,7 @@
|
||||
i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
|
||||
int j = 25 - i;
|
||||
float f1 = f * (float) j;
|
||||
@@ -1621,29 +1894,172 @@
|
||||
@@ -1621,29 +1893,172 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -783,7 +782,7 @@
|
||||
}
|
||||
|
||||
public CombatTracker getCombatTracker() {
|
||||
@@ -1664,8 +2080,18 @@
|
||||
@@ -1664,8 +2079,18 @@
|
||||
}
|
||||
|
||||
public final void setArrowCount(int i) {
|
||||
@@ -803,7 +802,7 @@
|
||||
|
||||
public final int getStingerCount() {
|
||||
return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID);
|
||||
@@ -1961,6 +2387,12 @@
|
||||
@@ -1961,6 +2386,12 @@
|
||||
|
||||
public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot);
|
||||
|
||||
@@ -816,7 +815,7 @@
|
||||
@Override
|
||||
public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack);
|
||||
|
||||
@@ -2204,6 +2636,7 @@
|
||||
@@ -2204,6 +2635,7 @@
|
||||
}
|
||||
|
||||
if (this.onGround && !this.level.isClientSide) {
|
||||
@@ -824,7 +823,7 @@
|
||||
this.setSharedFlag(7, false);
|
||||
}
|
||||
} else {
|
||||
@@ -2734,6 +3167,7 @@
|
||||
@@ -2734,6 +3166,7 @@
|
||||
}
|
||||
|
||||
if (!this.level.isClientSide) {
|
||||
@@ -832,7 +831,7 @@
|
||||
this.setSharedFlag(7, flag);
|
||||
}
|
||||
|
||||
@@ -2901,14 +3335,21 @@
|
||||
@@ -2901,14 +3334,21 @@
|
||||
|
||||
@Override
|
||||
public boolean isPickable() {
|
||||
@@ -856,7 +855,7 @@
|
||||
@Override
|
||||
protected void markHurt() {
|
||||
this.hurtMarked = this.random.nextDouble() >= this.getAttributeValue(GenericAttributes.KNOCKBACK_RESISTANCE);
|
||||
@@ -3107,7 +3548,25 @@
|
||||
@@ -3107,7 +3547,25 @@
|
||||
} else {
|
||||
if (!this.useItem.isEmpty() && this.isUsingItem()) {
|
||||
this.triggerItemUseEffects(this.useItem, 16);
|
||||
@@ -883,7 +882,7 @@
|
||||
|
||||
if (itemstack != this.useItem) {
|
||||
this.setItemInHand(enumhand, itemstack);
|
||||
@@ -3180,6 +3639,12 @@
|
||||
@@ -3180,6 +3638,12 @@
|
||||
}
|
||||
|
||||
public boolean randomTeleport(double d0, double d1, double d2, boolean flag) {
|
||||
@@ -896,7 +895,7 @@
|
||||
double d3 = this.getX();
|
||||
double d4 = this.getY();
|
||||
double d5 = this.getZ();
|
||||
@@ -3204,16 +3669,41 @@
|
||||
@@ -3204,16 +3668,41 @@
|
||||
}
|
||||
|
||||
if (flag2) {
|
||||
@@ -941,7 +940,7 @@
|
||||
} else {
|
||||
if (flag) {
|
||||
world.broadcastEntityEvent(this, (byte) 46);
|
||||
@@ -3223,7 +3713,7 @@
|
||||
@@ -3223,7 +3712,7 @@
|
||||
((EntityCreature) this).getNavigation().stop();
|
||||
}
|
||||
|
||||
@@ -950,7 +949,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3306,7 +3796,7 @@
|
||||
@@ -3306,7 +3795,7 @@
|
||||
}
|
||||
|
||||
public void stopSleeping() {
|
||||
@@ -959,7 +958,7 @@
|
||||
World world = this.level;
|
||||
|
||||
java.util.Objects.requireNonNull(this.level);
|
||||
@@ -3338,7 +3828,7 @@
|
||||
@@ -3338,7 +3827,7 @@
|
||||
|
||||
@Nullable
|
||||
public EnumDirection getBedOrientation() {
|
||||
@@ -968,7 +967,7 @@
|
||||
|
||||
return blockposition != null ? BlockBed.getBedOrientation(this.level, blockposition) : null;
|
||||
}
|
||||
@@ -3387,7 +3877,7 @@
|
||||
@@ -3387,7 +3876,7 @@
|
||||
Pair<MobEffect, Float> pair = (Pair) iterator.next();
|
||||
|
||||
if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) {
|
||||
@@ -977,7 +976,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3490,8 +3980,10 @@
|
||||
@@ -3490,8 +3979,10 @@
|
||||
this.setDeltaMovement((double) ((float) packetplayoutspawnentityliving.getXd() / 8000.0F), (double) ((float) packetplayoutspawnentityliving.getYd() / 8000.0F), (double) ((float) packetplayoutspawnentityliving.getZd() / 8000.0F));
|
||||
}
|
||||
|
||||
@@ -989,7 +988,7 @@
|
||||
private final SoundEffect small;
|
||||
private final SoundEffect big;
|
||||
|
||||
@@ -3507,5 +3999,7 @@
|
||||
@@ -3507,5 +3998,7 @@
|
||||
public SoundEffect big() {
|
||||
return this.big;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user