PaperMC/nms-patches/EntityArmorStand.patch

163 lines
6.5 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityArmorStand.java
+++ b/net/minecraft/server/EntityArmorStand.java
2016-05-10 13:47:39 +02:00
@@ -5,6 +5,15 @@
2018-07-15 02:00:00 +02:00
import java.util.function.Predicate;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
2015-02-15 02:24:14 +01:00
+// CraftBukkit start
2015-02-15 02:48:56 +01:00
+import org.bukkit.inventory.EquipmentSlot;
2015-02-15 02:24:14 +01:00
+import org.bukkit.craftbukkit.CraftEquipmentSlot;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.entity.ArmorStand;
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
+// CraftBukkit end
+
public class EntityArmorStand extends EntityLiving {
2019-12-10 23:00:00 +01:00
private static final Vector3f br = new Vector3f(0.0F, 0.0F, 0.0F);
2019-04-23 04:00:00 +02:00
@@ -53,6 +62,13 @@
2017-11-07 07:21:38 +01:00
this.setPosition(d0, d1, d2);
}
+ // CraftBukkit start - SPIGOT-3607, SPIGOT-3637
+ @Override
+ public float getBukkitYaw() {
+ return this.yaw;
+ }
+ // CraftBukkit end
+
2019-04-23 04:00:00 +02:00
@Override
2020-01-21 22:00:00 +01:00
public void updateSize() {
double d0 = this.locX();
@@ -381,6 +397,21 @@
2019-12-10 23:00:00 +01:00
return false;
} else {
ItemStack itemstack2;
+ // CraftBukkit start
+ org.bukkit.inventory.ItemStack armorStandItem = CraftItemStack.asCraftMirror(itemstack1);
+ org.bukkit.inventory.ItemStack playerHeldItem = CraftItemStack.asCraftMirror(itemstack);
2015-02-15 02:24:14 +01:00
+
2019-12-10 23:00:00 +01:00
+ Player player = (Player) entityhuman.getBukkitEntity();
+ ArmorStand self = (ArmorStand) this.getBukkitEntity();
2015-02-15 02:24:14 +01:00
+
2019-12-10 23:00:00 +01:00
+ EquipmentSlot slot = CraftEquipmentSlot.getSlot(enumitemslot);
+ PlayerArmorStandManipulateEvent armorStandManipulateEvent = new PlayerArmorStandManipulateEvent(player,self,playerHeldItem,armorStandItem,slot);
+ this.world.getServer().getPluginManager().callEvent(armorStandManipulateEvent);
2015-02-15 02:24:14 +01:00
+
2019-12-10 23:00:00 +01:00
+ if (armorStandManipulateEvent.isCancelled()) {
+ return true;
+ }
+ // CraftBukkit end
2016-02-29 22:32:46 +01:00
2019-12-10 23:00:00 +01:00
if (entityhuman.abilities.canInstantlyBuild && itemstack1.isEmpty() && !itemstack.isEmpty()) {
itemstack2 = itemstack.cloneItemStack();
2020-01-21 22:00:00 +01:00
@@ -409,12 +440,22 @@
public boolean damageEntity(DamageSource damagesource, float f) {
2016-02-29 22:32:46 +01:00
if (!this.world.isClientSide && !this.dead) {
if (DamageSource.OUT_OF_WORLD.equals(damagesource)) {
- this.die();
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
+ return false;
+ }
+ // CraftBukkit end
2017-05-14 04:00:00 +02:00
+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity()
return false;
2019-12-10 23:00:00 +01:00
- } else if (!this.isInvulnerable(damagesource) && !this.armorStandInvisible && !this.isMarker()) {
+ } else if (!this.isInvulnerable(damagesource) && (true || !this.armorStandInvisible) && !this.isMarker()) { // CraftBukkit
+ // CraftBukkit start
2019-12-10 23:00:00 +01:00
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, true, this.armorStandInvisible)) {
+ return false;
+ }
+ // CraftBukkit end
if (damagesource.isExplosion()) {
2019-04-23 04:00:00 +02:00
this.g(damagesource);
- this.die();
2017-05-14 04:00:00 +02:00
+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity()
return false;
} else if (DamageSource.FIRE.equals(damagesource)) {
if (this.isBurning()) {
2020-01-21 22:00:00 +01:00
@@ -439,7 +480,7 @@
2018-07-15 02:00:00 +02:00
} else if (damagesource.v()) {
this.F();
2019-04-23 04:00:00 +02:00
this.D();
2018-07-15 02:00:00 +02:00
- this.die();
+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity()
2019-04-23 04:00:00 +02:00
return flag1;
2018-07-15 02:00:00 +02:00
} else {
long i = this.world.getTime();
2020-01-21 22:00:00 +01:00
@@ -450,7 +491,7 @@
2018-07-15 02:00:00 +02:00
} else {
2019-04-23 04:00:00 +02:00
this.f(damagesource);
this.D();
- this.die();
+ this.die(); // CraftBukkit - SPIGOT-4890: remain as this.die() since above damagesource method will call death event
2018-07-15 02:00:00 +02:00
}
2018-07-15 02:00:00 +02:00
return true;
2020-01-21 22:00:00 +01:00
@@ -477,7 +518,7 @@
f1 -= f;
if (f1 <= 0.5F) {
2019-04-23 04:00:00 +02:00
this.g(damagesource);
- this.die();
2017-05-14 04:00:00 +02:00
+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity()
} else {
this.setHealth(f1);
}
2020-01-21 22:00:00 +01:00
@@ -485,13 +526,13 @@
}
2019-04-23 04:00:00 +02:00
private void f(DamageSource damagesource) {
- Block.a(this.world, new BlockPosition(this), new ItemStack(Items.ARMOR_STAND));
+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(new ItemStack(Items.ARMOR_STAND))); // CraftBukkit - add to drops
2019-04-23 04:00:00 +02:00
this.g(damagesource);
}
private void g(DamageSource damagesource) {
this.F();
- this.d(damagesource);
+ // this.d(damagesource); // CraftBukkit - moved down
ItemStack itemstack;
int i;
2020-01-21 22:00:00 +01:00
@@ -499,7 +540,7 @@
2019-04-23 04:00:00 +02:00
for (i = 0; i < this.handItems.size(); ++i) {
itemstack = (ItemStack) this.handItems.get(i);
if (!itemstack.isEmpty()) {
- Block.a(this.world, (new BlockPosition(this)).up(), itemstack);
+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops
2019-04-23 04:00:00 +02:00
this.handItems.set(i, ItemStack.a);
}
}
2020-01-21 22:00:00 +01:00
@@ -507,10 +548,11 @@
2019-04-23 04:00:00 +02:00
for (i = 0; i < this.armorItems.size(); ++i) {
itemstack = (ItemStack) this.armorItems.get(i);
if (!itemstack.isEmpty()) {
- Block.a(this.world, (new BlockPosition(this)).up(), itemstack);
+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops
2019-04-23 04:00:00 +02:00
this.armorItems.set(i, ItemStack.a);
}
}
+ this.d(damagesource); // CraftBukkit - moved from above
}
2020-01-21 22:00:00 +01:00
@@ -611,8 +653,16 @@
return this.isSmall();
}
+ // CraftBukkit start
+ @Override
+ protected boolean isDropExperience() {
+ return true; // MC-157395, SPIGOT-5193 even baby (small) armor stands should drop
+ }
+ // CraftBukkit end
+
2019-04-23 04:00:00 +02:00
@Override
public void killEntity() {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, drops); // CraftBukkit - call event
this.die();
}