summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorsk89q <the.sk89q@gmail.com>2011-01-15 14:56:35 -0800
committersk89q <the.sk89q@gmail.com>2011-01-15 14:56:35 -0800
commit44ae0531e72871775be20bdc557e1933cc2a71dd (patch)
treef3c59641ebefb2cc7df80158a5e392148186bbc1 /src/main/java
parentf78b8c12a6c728e77d3567602754645207870818 (diff)
downloadcraftbukkit-44ae0531e72871775be20bdc557e1933cc2a71dd.tar
craftbukkit-44ae0531e72871775be20bdc557e1933cc2a71dd.tar.gz
craftbukkit-44ae0531e72871775be20bdc557e1933cc2a71dd.tar.lz
craftbukkit-44ae0531e72871775be20bdc557e1933cc2a71dd.tar.xz
craftbukkit-44ae0531e72871775be20bdc557e1933cc2a71dd.zip
Added CraftInventory.setContents(); made CraftInventory.setItem(), CraftInventory.getItem(), and CraftItemStack() damage-aware.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java22
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java3
2 files changed, 23 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
index a96b1b83..173e2658 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
@@ -41,8 +41,28 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
return items;
}
+ public void setContents(ItemStack[] items) {
+ if (getInventory().getContents().length != items.length) {
+ throw new IllegalArgumentException("Invalid inventory size; expected "
+ + getInventory().getContents().length);
+ }
+
+ net.minecraft.server.ItemStack[] mcItems = getInventory().getContents();
+
+ for (int i = 0; i < items.length; i++ ) {
+ ItemStack item = items[i];
+ if (item == null) {
+ mcItems[i] = null;
+ } else {
+ mcItems[i] = new net.minecraft.server.ItemStack(
+ item.getTypeId(), item.getAmount(), item.getDamage());
+ }
+ }
+ }
+
public void setItem(int index, ItemStack item) {
- getInventory().a( index, new net.minecraft.server.ItemStack( item.getTypeId(), item.getAmount(), 0));
+ getInventory().a(index, new net.minecraft.server.ItemStack(
+ item.getTypeId(), item.getAmount(), item.getDamage()));
}
public boolean contains(int materialId) {
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
index 17aa9296..a08fa55d 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
@@ -7,7 +7,8 @@ public class CraftItemStack extends ItemStack {
protected net.minecraft.server.ItemStack item;
public CraftItemStack(net.minecraft.server.ItemStack item) {
- super(item != null ? item.c : 0, item != null ? item.a : 0);
+ super(item != null ? item.c : 0, item != null ? item.a : 0,
+ (byte)(item != null ? item.d : 0));
this.item = item;
}