From 5d93ab3e54bddf4babf03b99d1745bd57dc5deaf Mon Sep 17 00:00:00 2001 From: sk89q Date: Sat, 15 Jan 2011 19:33:28 -0800 Subject: [PATCH] Added item-in-hand related API. --- .../org/bukkit/craftbukkit/entity/CraftHumanEntity.java | 4 ++++ .../craftbukkit/inventory/CraftInventoryPlayer.java | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index ef09a416ab..38b9f575ce 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -40,6 +40,10 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { return getInventory().getItemInHand(); } + public void setItemInHand(ItemStack item) { + getInventory().setItemInHand(item); + } + @Override public String toString() { return "CraftHumanEntity{" + "id=" + getEntityId() + "name=" + getName() + '}'; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java index 7140d36f15..af222f3c63 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java @@ -22,6 +22,14 @@ public class CraftInventoryPlayer extends CraftInventory implements PlayerInvent return new CraftItemStack( getInventory().e() ); } + public void setItemInHand(ItemStack stack) { + setItem( getHeldItemSlot(), stack ); + } + + public int getHeldItemSlot() { + return getInventory().c; + } + public CraftItemStack getHelmet() { return getItem( getSize() + 0 ); }