diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftItemStack.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftItemStack.java new file mode 100644 index 0000000000..ed80091064 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftItemStack.java @@ -0,0 +1,61 @@ +package org.bukkit.craftbukkit; + +import org.bukkit.ItemStack; +import org.bukkit.Material; + +public class CraftItemStack extends ItemStack { + protected net.minecraft.server.ItemStack item; + + public CraftItemStack(net.minecraft.server.ItemStack item) { + super(item.c, item.a); + this.item = item; + } + + /* + * Unsure if we have to syn before each of these calls the values in 'item' + * are all public. + */ + + @Override + public Material getType() { + super.setTypeID(item.c); // sync, needed? + return super.getType(); + } + + @Override + public int getTypeID() { + super.setTypeID(item.c); // sync, needed? + return item.c; + } + + @Override + public void setTypeID(int type) { + super.setTypeID(item.c); + item.c = type; + } + + @Override + public int getAmount() { + super.setAmount(item.a); // sync, needed? + return item.a; + } + + @Override + public void setAmount(int amount) { + super.setAmount(amount); + item.a = amount; + } + + @Override + public void setDamage(final byte damage) { + super.setDamage(damage); + item.d = damage; + } + + @Override + public byte getDamage() { + super.setDamage((byte) item.d); // sync, needed? + return (byte) item.d; + } + +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStorageMinecart.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStorageMinecart.java index 0adf0a180e..7567529e31 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStorageMinecart.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStorageMinecart.java @@ -1,6 +1,11 @@ package org.bukkit.craftbukkit; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.server.EntityMinecart; + +import org.bukkit.ItemStack; import org.bukkit.StorageMinecart; /** @@ -8,10 +13,33 @@ import org.bukkit.StorageMinecart; * * @author sk89q */ -public class CraftStorageMinecart extends CraftMinecart - implements StorageMinecart { +public class CraftStorageMinecart extends CraftMinecart implements StorageMinecart { public CraftStorageMinecart(CraftServer server, EntityMinecart entity) { super(server, entity); } + public int getSize() { + return minecart.c(); + } + + public String getName() { + return minecart.b(); + } + + public ItemStack getItem(int index) { + return new CraftItemStack(minecart.a(index)); + } + + public List getContents() { + ArrayList items = new ArrayList(); + for (net.minecraft.server.ItemStack item: minecart.getContents()) { + ItemStack i = null; + if (item != null) { + i = new CraftItemStack( item ); + } + items.add(i); + } + + return items; + } }