summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit
diff options
context:
space:
mode:
authorErik Broes <erikbroes@ripe.net>2011-01-05 01:00:57 +0100
committerErik Broes <erikbroes@ripe.net>2011-01-05 01:00:57 +0100
commit25d519aaf2b0fcb13bbbd269980cb2e05be55ed3 (patch)
treeb390bb72bd25a3e715dde1ad95ac15526d31c367 /src/main/java/org/bukkit
parent3dbacbc2c3d534d27a6c0946010b36909d077d4c (diff)
downloadcraftbukkit-25d519aaf2b0fcb13bbbd269980cb2e05be55ed3.tar
craftbukkit-25d519aaf2b0fcb13bbbd269980cb2e05be55ed3.tar.gz
craftbukkit-25d519aaf2b0fcb13bbbd269980cb2e05be55ed3.tar.lz
craftbukkit-25d519aaf2b0fcb13bbbd269980cb2e05be55ed3.tar.xz
craftbukkit-25d519aaf2b0fcb13bbbd269980cb2e05be55ed3.zip
Initial implementation of inventory stuff, (read-)only for StorageMinecart sofar
Diffstat (limited to 'src/main/java/org/bukkit')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftItemStack.java61
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftStorageMinecart.java32
2 files changed, 91 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/CraftItemStack.java
new file mode 100644
index 00000000..ed800910
--- /dev/null
+++ b/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/src/main/java/org/bukkit/craftbukkit/CraftStorageMinecart.java b/src/main/java/org/bukkit/craftbukkit/CraftStorageMinecart.java
index 0adf0a18..7567529e 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftStorageMinecart.java
+++ b/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<ItemStack> getContents() {
+ ArrayList<ItemStack> items = new ArrayList<ItemStack>();
+ for (net.minecraft.server.ItemStack item: minecart.getContents()) {
+ ItemStack i = null;
+ if (item != null) {
+ i = new CraftItemStack( item );
+ }
+ items.add(i);
+ }
+
+ return items;
+ }
}