#1209: Clean up various patches

By: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
This commit is contained in:
CraftBukkit/Spigot
2023-06-24 17:15:05 +10:00
parent 0f9e7a497e
commit b97cc9b99f
71 changed files with 662 additions and 719 deletions

View File

@@ -382,7 +382,7 @@
this.hurtCurrentlyUsedShield(f);
f2 = f;
f = 0.0F;
@@ -1163,27 +1371,46 @@
@@ -1163,23 +1371,33 @@
this.walkAnimation.setSpeed(1.5F);
boolean flag1 = true;
@@ -421,20 +421,7 @@
this.hurtHelmet(damagesource, f);
f *= 0.75F;
}
+ // CraftBukkit start
+ if (this instanceof EntityAnimal) {
+ ((EntityAnimal) this).resetLove();
+ if (this instanceof EntityTameableAnimal) {
+ ((EntityTameableAnimal) this).setOrderedToSit(false);
+ }
+ }
+ // CraftBukkit end
+
Entity entity1 = damagesource.getEntity();
if (entity1 != null) {
@@ -1297,19 +1524,32 @@
@@ -1297,19 +1515,32 @@
EnumHand[] aenumhand = EnumHand.values();
int i = aenumhand.length;
@@ -471,7 +458,7 @@
EntityPlayer entityplayer = (EntityPlayer) this;
entityplayer.awardStat(StatisticList.ITEM_USED.get(Items.TOTEM_OF_UNDYING));
@@ -1317,14 +1557,16 @@
@@ -1317,14 +1548,16 @@
}
this.setHealth(1.0F);
@@ -493,7 +480,7 @@
}
}
@@ -1433,14 +1675,22 @@
@@ -1433,14 +1666,22 @@
IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState();
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
@@ -518,7 +505,7 @@
this.level().addFreshEntity(entityitem);
}
}
@@ -1460,21 +1710,40 @@
@@ -1460,21 +1701,40 @@
boolean flag = this.lastHurtByPlayerTime > 0;
@@ -548,7 +535,7 @@
+ return i;
+ } else {
+ return 0;
}
+ }
+ }
+ // CraftBukkit end
+
@@ -557,12 +544,12 @@
+ if (true && !(this instanceof net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon)) { // CraftBukkit - SPIGOT-2420: Special case ender dragon will drop the xp over time
+ EntityExperienceOrb.award((WorldServer) this.level(), this.position(), this.expToDrop);
+ this.expToDrop = 0;
+ }
}
+ // CraftBukkit end
}
@@ -1565,6 +1834,28 @@
@@ -1565,6 +1825,28 @@
return itemstack.getEatingSound();
}
@@ -591,7 +578,7 @@
public Optional<BlockPosition> getLastClimbablePos() {
return this.lastClimbablePos;
}
@@ -1611,9 +1902,14 @@
@@ -1611,9 +1893,14 @@
int i = this.calculateFallDamage(f, f1);
if (i > 0) {
@@ -607,7 +594,7 @@
return true;
} else {
return flag;
@@ -1665,7 +1961,7 @@
@@ -1665,7 +1952,7 @@
protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) {
if (!damagesource.is(DamageTypeTags.BYPASSES_ARMOR)) {
@@ -616,7 +603,7 @@
f = CombatMath.getDamageAfterAbsorb(f, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS));
}
@@ -1678,7 +1974,8 @@
@@ -1678,7 +1965,8 @@
} else {
int i;
@@ -626,7 +613,7 @@
i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
int j = 25 - i;
float f1 = f * (float) j;
@@ -1711,16 +2008,125 @@
@@ -1711,16 +1999,125 @@
}
}
@@ -645,7 +632,10 @@
+ public Double apply(Double f) {
+ if (damagesource.is(DamageTypeTags.DAMAGES_HELMET) && !EntityLiving.this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) {
+ return -(f - (f * 0.75F));
+
- f = Math.max(f - this.getAbsorptionAmount(), 0.0F);
- this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - f));
- float f2 = f1 - f;
+ }
+ return -0.0;
+ }
@@ -713,9 +703,6 @@
+
+ f = (float) event.getFinalDamage();
- f = Math.max(f - this.getAbsorptionAmount(), 0.0F);
- this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - f));
- float f2 = f1 - f;
+ // Resistance
+ if (event.getDamage(DamageModifier.RESISTANCE) < 0) {
+ float f3 = (float) -event.getDamage(DamageModifier.RESISTANCE);
@@ -727,7 +714,7 @@
+ }
+ }
+ }
+
+ // Apply damage to helmet
+ if (damagesource.is(DamageTypeTags.DAMAGES_HELMET) && !this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) {
+ this.hurtHelmet(damagesource, f);
@@ -760,7 +747,7 @@
if (f2 > 0.0F && f2 < 3.4028235E37F) {
Entity entity = damagesource.getEntity();
@@ -1731,13 +2137,47 @@
@@ -1731,13 +2128,47 @@
}
}
@@ -810,7 +797,7 @@
}
public CombatTracker getCombatTracker() {
@@ -1758,8 +2198,18 @@
@@ -1758,8 +2189,18 @@
}
public final void setArrowCount(int i) {
@@ -830,7 +817,7 @@
public final int getStingerCount() {
return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID);
@@ -2001,6 +2451,12 @@
@@ -2001,6 +2442,12 @@
public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot);
@@ -843,7 +830,7 @@
@Override
public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack);
@@ -2238,6 +2694,7 @@
@@ -2238,6 +2685,7 @@
}
if (this.onGround() && !this.level().isClientSide) {
@@ -851,7 +838,7 @@
this.setSharedFlag(7, false);
}
} else {
@@ -2809,6 +3266,7 @@
@@ -2809,6 +3257,7 @@
}
if (!this.level().isClientSide) {
@@ -859,7 +846,7 @@
this.setSharedFlag(7, flag);
}
@@ -2968,14 +3426,21 @@
@@ -2968,14 +3417,21 @@
@Override
public boolean isPickable() {
@@ -883,7 +870,7 @@
@Override
public float getYHeadRot() {
return this.yHeadRot;
@@ -3170,7 +3635,26 @@
@@ -3170,7 +3626,26 @@
} else {
if (!this.useItem.isEmpty() && this.isUsingItem()) {
this.triggerItemUseEffects(this.useItem, 16);
@@ -911,7 +898,7 @@
if (itemstack != this.useItem) {
this.setItemInHand(enumhand, itemstack);
@@ -3248,6 +3732,12 @@
@@ -3248,6 +3723,12 @@
}
public boolean randomTeleport(double d0, double d1, double d2, boolean flag) {
@@ -924,7 +911,7 @@
double d3 = this.getX();
double d4 = this.getY();
double d5 = this.getZ();
@@ -3272,16 +3762,41 @@
@@ -3272,16 +3753,41 @@
}
if (flag2) {
@@ -969,7 +956,7 @@
} else {
if (flag) {
world.broadcastEntityEvent(this, (byte) 46);
@@ -3291,7 +3806,7 @@
@@ -3291,7 +3797,7 @@
((EntityCreature) this).getNavigation().stop();
}
@@ -978,7 +965,7 @@
}
}
@@ -3374,7 +3889,7 @@
@@ -3374,7 +3880,7 @@
}
public void stopSleeping() {
@@ -987,7 +974,7 @@
World world = this.level();
java.util.Objects.requireNonNull(world);
@@ -3408,7 +3923,7 @@
@@ -3408,7 +3914,7 @@
@Nullable
public EnumDirection getBedOrientation() {
@@ -996,7 +983,7 @@
return blockposition != null ? BlockBed.getBedOrientation(this.level(), blockposition) : null;
}
@@ -3456,7 +3971,7 @@
@@ -3456,7 +3962,7 @@
Pair<MobEffect, Float> pair = (Pair) iterator.next();
if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) {