#772: Add API to set equipment silently
By: Parker Hawke <hawkeboyz2@hotmail.com>
This commit is contained in:
@@ -85,7 +85,22 @@
|
||||
this.die();
|
||||
|
||||
for (int i = 0; i < 20; ++i) {
|
||||
@@ -567,6 +611,17 @@
|
||||
@@ -497,7 +541,13 @@
|
||||
}
|
||||
|
||||
protected void b(ItemStack itemstack) {
|
||||
- if (!itemstack.isEmpty()) {
|
||||
+ // CraftBukkit start
|
||||
+ this.b(itemstack, false);
|
||||
+ }
|
||||
+
|
||||
+ protected void b(ItemStack itemstack, boolean silent) {
|
||||
+ if (!itemstack.isEmpty() && !silent) {
|
||||
+ // CraftBukkit end
|
||||
SoundEffect soundeffect = SoundEffects.ITEM_ARMOR_EQUIP_GENERIC;
|
||||
Item item = itemstack.getItem();
|
||||
|
||||
@@ -567,6 +617,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +118,7 @@
|
||||
if (nbttagcompound.hasKeyOfType("Health", 99)) {
|
||||
this.setHealth(nbttagcompound.getFloat("Health"));
|
||||
}
|
||||
@@ -604,9 +659,32 @@
|
||||
@@ -604,9 +665,32 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -136,7 +151,7 @@
|
||||
try {
|
||||
while (iterator.hasNext()) {
|
||||
MobEffectList mobeffectlist = (MobEffectList) iterator.next();
|
||||
@@ -616,6 +694,12 @@
|
||||
@@ -616,6 +700,12 @@
|
||||
this.a(mobeffect, true);
|
||||
})) {
|
||||
if (!this.world.isClientSide) {
|
||||
@@ -149,7 +164,7 @@
|
||||
iterator.remove();
|
||||
this.b(mobeffect);
|
||||
}
|
||||
@@ -626,6 +710,17 @@
|
||||
@@ -626,6 +716,17 @@
|
||||
} catch (ConcurrentModificationException concurrentmodificationexception) {
|
||||
;
|
||||
}
|
||||
@@ -167,7 +182,7 @@
|
||||
|
||||
if (this.updateEffects) {
|
||||
if (!this.world.isClientSide) {
|
||||
@@ -735,7 +830,13 @@
|
||||
@@ -735,7 +836,13 @@
|
||||
this.datawatcher.set(EntityLiving.f, 0);
|
||||
}
|
||||
|
||||
@@ -181,7 +196,7 @@
|
||||
if (this.world.isClientSide) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -744,7 +845,14 @@
|
||||
@@ -744,7 +851,14 @@
|
||||
boolean flag;
|
||||
|
||||
for (flag = false; iterator.hasNext(); flag = true) {
|
||||
@@ -197,7 +212,7 @@
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
@@ -769,18 +877,44 @@
|
||||
@@ -769,18 +883,44 @@
|
||||
return (MobEffect) this.effects.get(mobeffectlist);
|
||||
}
|
||||
|
||||
@@ -243,7 +258,7 @@
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -804,13 +938,39 @@
|
||||
@@ -804,13 +944,39 @@
|
||||
return this.getMonsterType() == EnumMonsterType.UNDEAD;
|
||||
}
|
||||
|
||||
@@ -284,7 +299,7 @@
|
||||
|
||||
if (mobeffect != null) {
|
||||
this.b(mobeffect);
|
||||
@@ -847,20 +1007,55 @@
|
||||
@@ -847,20 +1013,55 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -341,7 +356,7 @@
|
||||
this.datawatcher.set(EntityLiving.HEALTH, MathHelper.a(f, 0.0F, this.getMaxHealth()));
|
||||
}
|
||||
|
||||
@@ -874,7 +1069,7 @@
|
||||
@@ -874,7 +1075,7 @@
|
||||
return false;
|
||||
} else if (this.world.isClientSide) {
|
||||
return false;
|
||||
@@ -350,7 +365,7 @@
|
||||
return false;
|
||||
} else if (damagesource.isFire() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
|
||||
return false;
|
||||
@@ -886,17 +1081,19 @@
|
||||
@@ -886,17 +1087,19 @@
|
||||
this.ticksFarFromPlayer = 0;
|
||||
float f1 = f;
|
||||
|
||||
@@ -373,7 +388,7 @@
|
||||
this.damageShield(f);
|
||||
f2 = f;
|
||||
f = 0.0F;
|
||||
@@ -916,20 +1113,39 @@
|
||||
@@ -916,20 +1119,39 @@
|
||||
|
||||
if ((float) this.noDamageTicks > 10.0F) {
|
||||
if (f <= this.lastDamage) {
|
||||
@@ -415,7 +430,7 @@
|
||||
this.ap = 0.0F;
|
||||
Entity entity1 = damagesource.getEntity();
|
||||
|
||||
@@ -1050,19 +1266,29 @@
|
||||
@@ -1050,19 +1272,29 @@
|
||||
EnumHand[] aenumhand = EnumHand.values();
|
||||
int i = aenumhand.length;
|
||||
|
||||
@@ -449,7 +464,7 @@
|
||||
EntityPlayer entityplayer = (EntityPlayer) this;
|
||||
|
||||
entityplayer.b(StatisticList.ITEM_USED.b(Items.TOTEM_OF_UNDYING));
|
||||
@@ -1070,14 +1296,16 @@
|
||||
@@ -1070,14 +1302,16 @@
|
||||
}
|
||||
|
||||
this.setHealth(1.0F);
|
||||
@@ -471,7 +486,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1194,28 +1422,46 @@
|
||||
@@ -1194,28 +1428,46 @@
|
||||
|
||||
boolean flag = this.lastDamageByPlayerTime > 0;
|
||||
|
||||
@@ -520,7 +535,7 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -1336,9 +1582,14 @@
|
||||
@@ -1336,9 +1588,14 @@
|
||||
int i = this.e(f, f1);
|
||||
|
||||
if (i > 0) {
|
||||
@@ -536,7 +551,7 @@
|
||||
return true;
|
||||
} else {
|
||||
return flag;
|
||||
@@ -1378,7 +1629,7 @@
|
||||
@@ -1378,7 +1635,7 @@
|
||||
|
||||
protected float applyArmorModifier(DamageSource damagesource, float f) {
|
||||
if (!damagesource.ignoresArmor()) {
|
||||
@@ -545,7 +560,7 @@
|
||||
f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.b(GenericAttributes.ARMOR_TOUGHNESS));
|
||||
}
|
||||
|
||||
@@ -1391,7 +1642,8 @@
|
||||
@@ -1391,7 +1648,8 @@
|
||||
} else {
|
||||
int i;
|
||||
|
||||
@@ -555,7 +570,7 @@
|
||||
i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
|
||||
int j = 25 - i;
|
||||
float f1 = f * (float) j;
|
||||
@@ -1422,28 +1674,173 @@
|
||||
@@ -1422,28 +1680,173 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,7 +589,10 @@
|
||||
+ public Double apply(Double f) {
|
||||
+ if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !EntityLiving.this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
|
||||
+ return -(f - (f * 0.75F));
|
||||
+
|
||||
|
||||
- f = Math.max(f - this.getAbsorptionHearts(), 0.0F);
|
||||
- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f));
|
||||
- float f2 = f1 - f;
|
||||
+ }
|
||||
+ return -0.0;
|
||||
+ }
|
||||
@@ -666,21 +684,18 @@
|
||||
+ float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT));
|
||||
+ this.damageArmor(damagesource, armorDamage);
|
||||
+ }
|
||||
+
|
||||
|
||||
+ // Apply blocking code // PAIL: steal from above
|
||||
+ if (event.getDamage(DamageModifier.BLOCKING) < 0) {
|
||||
+ this.world.broadcastEntityEffect(this, (byte) 29); // SPIGOT-4635 - shield damage sound
|
||||
+ this.damageShield((float) -event.getDamage(DamageModifier.BLOCKING));
|
||||
+ Entity entity = damagesource.j();
|
||||
|
||||
- f = Math.max(f - this.getAbsorptionHearts(), 0.0F);
|
||||
- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f));
|
||||
- float f2 = f1 - f;
|
||||
+
|
||||
+ 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;
|
||||
@@ -739,7 +754,7 @@
|
||||
}
|
||||
|
||||
public CombatTracker getCombatTracker() {
|
||||
@@ -1464,9 +1861,19 @@
|
||||
@@ -1464,9 +1867,19 @@
|
||||
}
|
||||
|
||||
public final void setArrowCount(int i) {
|
||||
@@ -760,7 +775,7 @@
|
||||
public final int dz() {
|
||||
return (Integer) this.datawatcher.get(EntityLiving.bi);
|
||||
}
|
||||
@@ -1816,6 +2223,7 @@
|
||||
@@ -1816,6 +2229,7 @@
|
||||
}
|
||||
|
||||
if (this.onGround && !this.world.isClientSide) {
|
||||
@@ -768,7 +783,7 @@
|
||||
this.setFlag(7, false);
|
||||
}
|
||||
} else {
|
||||
@@ -2321,6 +2729,7 @@
|
||||
@@ -2321,6 +2735,7 @@
|
||||
}
|
||||
|
||||
if (!this.world.isClientSide) {
|
||||
@@ -776,7 +791,7 @@
|
||||
this.setFlag(7, flag);
|
||||
}
|
||||
|
||||
@@ -2441,6 +2850,7 @@
|
||||
@@ -2441,6 +2856,7 @@
|
||||
}
|
||||
|
||||
public boolean hasLineOfSight(Entity entity) {
|
||||
@@ -784,7 +799,7 @@
|
||||
Vec3D vec3d = new Vec3D(this.locX(), this.getHeadY(), this.locZ());
|
||||
Vec3D vec3d1 = new Vec3D(entity.locX(), entity.getHeadY(), entity.locZ());
|
||||
|
||||
@@ -2458,14 +2868,21 @@
|
||||
@@ -2458,14 +2874,21 @@
|
||||
|
||||
@Override
|
||||
public boolean isInteractable() {
|
||||
@@ -808,7 +823,7 @@
|
||||
@Override
|
||||
protected void velocityChanged() {
|
||||
this.velocityChanged = this.random.nextDouble() >= this.b(GenericAttributes.KNOCKBACK_RESISTANCE);
|
||||
@@ -2658,7 +3075,25 @@
|
||||
@@ -2658,7 +3081,25 @@
|
||||
} else {
|
||||
if (!this.activeItem.isEmpty() && this.isHandRaised()) {
|
||||
this.b(this.activeItem, 16);
|
||||
@@ -835,7 +850,7 @@
|
||||
|
||||
if (itemstack != this.activeItem) {
|
||||
this.a(enumhand, itemstack);
|
||||
@@ -2750,10 +3185,18 @@
|
||||
@@ -2750,10 +3191,18 @@
|
||||
}
|
||||
|
||||
if (flag2) {
|
||||
@@ -857,7 +872,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2850,7 +3293,7 @@
|
||||
@@ -2850,7 +3299,7 @@
|
||||
}
|
||||
|
||||
public void entityWakeup() {
|
||||
@@ -866,7 +881,7 @@
|
||||
World world = this.world;
|
||||
|
||||
this.world.getClass();
|
||||
@@ -2921,7 +3364,7 @@
|
||||
@@ -2921,7 +3370,7 @@
|
||||
Pair<MobEffect, Float> pair = (Pair) iterator.next();
|
||||
|
||||
if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) {
|
||||
|
||||
Reference in New Issue
Block a user