Implement armor stand event.
Dieser Commit ist enthalten in:
Ursprung
9648edfa61
Commit
116514c162
@ -1,6 +1,45 @@
|
|||||||
--- ../work/decompile-8eb82bde/net/minecraft/server/EntityArmorStand.java 2015-02-01 18:12:22.718390345 +1100
|
--- ../work/decompile-8eb82bde/net/minecraft/server/EntityArmorStand.java 2015-02-15 12:22:56.729511128 +1100
|
||||||
+++ src/main/java/net/minecraft/server/EntityArmorStand.java 2015-02-01 18:12:22.718390345 +1100
|
+++ src/main/java/net/minecraft/server/EntityArmorStand.java 2015-02-15 12:22:56.729511128 +1100
|
||||||
@@ -343,6 +343,11 @@
|
@@ -2,6 +2,15 @@
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
+// CraftBukkit start
|
||||||
|
+import org.bukkit.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);
|
||||||
|
@@ -323,6 +332,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;
|
||||||
|
@@ -343,6 +368,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean damageEntity(DamageSource damagesource, float f) {
|
public boolean damageEntity(DamageSource damagesource, float f) {
|
||||||
@ -12,7 +51,7 @@
|
|||||||
if (!this.world.isStatic && !this.h) {
|
if (!this.world.isStatic && !this.h) {
|
||||||
if (DamageSource.OUT_OF_WORLD.equals(damagesource)) {
|
if (DamageSource.OUT_OF_WORLD.equals(damagesource)) {
|
||||||
this.die();
|
this.die();
|
||||||
@@ -542,6 +547,8 @@
|
@@ -542,6 +572,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.datawatcher.watch(10, Byte.valueOf(b0));
|
this.datawatcher.watch(10, Byte.valueOf(b0));
|
||||||
|
35
src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java
Normale Datei
35
src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java
Normale Datei
@ -0,0 +1,35 @@
|
|||||||
|
package org.bukkit.craftbukkit;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
|
||||||
|
public class CraftEquipmentSlot {
|
||||||
|
|
||||||
|
private static final int[] slots = new int[EquipmentSlot.values().length];
|
||||||
|
private static final EquipmentSlot[] enums = new EquipmentSlot[EquipmentSlot.values().length];
|
||||||
|
|
||||||
|
static {
|
||||||
|
set(EquipmentSlot.HAND, 0);
|
||||||
|
set(EquipmentSlot.FEET, 1);
|
||||||
|
set(EquipmentSlot.LEGS, 2);
|
||||||
|
set(EquipmentSlot.CHEST, 3);
|
||||||
|
set(EquipmentSlot.HEAD, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void set(EquipmentSlot type, int value) {
|
||||||
|
slots[type.ordinal()] = value;
|
||||||
|
if (value < enums.length) {
|
||||||
|
enums[value] = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EquipmentSlot getSlot(int magic) {
|
||||||
|
if (magic > 0 && magic < enums.length) {
|
||||||
|
return enums[magic];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getSlotIndex(EquipmentSlot slot) {
|
||||||
|
return slots[slot.ordinal()];
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren