summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityArmorStand.patch
blob: 15f929174a193f0581c5eb67e7165851d2b935a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
--- a/net/minecraft/server/EntityArmorStand.java
+++ b/net/minecraft/server/EntityArmorStand.java
@@ -2,6 +2,15 @@
 
 import java.util.List;
 
+// CraftBukkit start
+import org.bukkit.inventory.EquipmentSlot;
+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 {
 
     private static final Vector3f a = new Vector3f(0.0F, 0.0F, 0.0F);
@@ -15,12 +24,14 @@
     private long i;
     private int bi;
     private boolean bj;
-    private Vector3f headPose;
-    private Vector3f bodyPose;
-    private Vector3f leftArmPose;
-    private Vector3f rightArmPose;
-    private Vector3f leftLegPose;
-    private Vector3f rightLegPose;
+    // CraftBukkit start - public all the things!
+    public Vector3f headPose;
+    public Vector3f bodyPose;
+    public Vector3f leftArmPose;
+    public Vector3f rightArmPose;
+    public Vector3f leftLegPose;
+    public Vector3f rightLegPose;
+    // CraftBukkit end
 
     public EntityArmorStand(World world) {
         super(world);
@@ -332,6 +343,22 @@
                 ItemStack itemstack1 = entityhuman.inventory.getItem(j);
                 ItemStack itemstack2;
 
+                // CraftBukkit start
+                org.bukkit.inventory.ItemStack armorStandItem = CraftItemStack.asCraftMirror(itemstack);
+                org.bukkit.inventory.ItemStack playerHeldItem = CraftItemStack.asCraftMirror(itemstack1);
+
+                Player player = (Player) entityhuman.getBukkitEntity();
+                ArmorStand self = (ArmorStand) this.getBukkitEntity();
+
+                EquipmentSlot slot = CraftEquipmentSlot.getSlot(i);
+                PlayerArmorStandManipulateEvent armorStandManipulateEvent = new PlayerArmorStandManipulateEvent(player,self,playerHeldItem,armorStandItem,slot);
+                this.world.getServer().getPluginManager().callEvent(armorStandManipulateEvent);
+
+                if (armorStandManipulateEvent.isCancelled()) {
+                    return;
+                }
+                // CraftBukkit end
+
                 if (entityhuman.abilities.canInstantlyBuild && (itemstack == null || itemstack.getItem() == Item.getItemOf(Blocks.AIR)) && itemstack1 != null) {
                     itemstack2 = itemstack1.cloneItemStack();
                     itemstack2.count = 1;
@@ -352,6 +379,11 @@
     }
 
     public boolean damageEntity(DamageSource damagesource, float f) {
+        // CraftBukkit start
+        if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
+            return false;
+        }
+        // CraftBukkit end
         if (this.world.isClientSide) {
             return false;
         } else if (DamageSource.OUT_OF_WORLD.equals(damagesource)) {
@@ -552,7 +584,7 @@
         return this.isInvisible();
     }
 
-    private void setSmall(boolean flag) {
+    public void setSmall(boolean flag) { // CraftBukkit - public
         byte b0 = this.datawatcher.getByte(10);
 
         if (flag) {
@@ -568,7 +600,7 @@
         return (this.datawatcher.getByte(10) & 1) != 0;
     }
 
-    private void setGravity(boolean flag) {
+    public void setGravity(boolean flag) { // CraftBukkit - public
         byte b0 = this.datawatcher.getByte(10);
 
         if (flag) {
@@ -578,13 +610,14 @@
         }
 
         this.datawatcher.watch(10, Byte.valueOf(b0));
+        this.noclip = flag; // CraftBukkit.
     }
 
     public boolean hasGravity() {
         return (this.datawatcher.getByte(10) & 2) != 0;
     }
 
-    private void setArms(boolean flag) {
+    public void setArms(boolean flag) { // CraftBukkit - public
         byte b0 = this.datawatcher.getByte(10);
 
         if (flag) {
@@ -600,7 +633,7 @@
         return (this.datawatcher.getByte(10) & 4) != 0;
     }
 
-    private void setBasePlate(boolean flag) {
+    public void setBasePlate(boolean flag) { // CraftBukkit - public
         byte b0 = this.datawatcher.getByte(10);
 
         if (flag) {