summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorErik Broes <erikbroes@grum.nl>2011-01-16 14:34:31 +0100
committerErik Broes <erikbroes@grum.nl>2011-01-16 14:34:31 +0100
commit0ae550a11c5eb7db6ce92ee6afb4588e038faa25 (patch)
treedf9605070e4a5aba6413296873a4f9ddff5be69c /src
parentceaf94d5bb761b54249d22de08226167319099be (diff)
downloadcraftbukkit-0ae550a11c5eb7db6ce92ee6afb4588e038faa25.tar
craftbukkit-0ae550a11c5eb7db6ce92ee6afb4588e038faa25.tar.gz
craftbukkit-0ae550a11c5eb7db6ce92ee6afb4588e038faa25.tar.lz
craftbukkit-0ae550a11c5eb7db6ce92ee6afb4588e038faa25.tar.xz
craftbukkit-0ae550a11c5eb7db6ce92ee6afb4588e038faa25.zip
Fixed NPE while clearing a slot
Diffstat (limited to 'src')
-rw-r--r--src/main/java/net/minecraft/server/EntityPlayerMP.java10
-rwxr-xr-x[-rw-r--r--]src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java9
2 files changed, 13 insertions, 6 deletions
diff --git a/src/main/java/net/minecraft/server/EntityPlayerMP.java b/src/main/java/net/minecraft/server/EntityPlayerMP.java
index adb2f6fe..a8916689 100644
--- a/src/main/java/net/minecraft/server/EntityPlayerMP.java
+++ b/src/main/java/net/minecraft/server/EntityPlayerMP.java
@@ -209,6 +209,7 @@ public class EntityPlayerMP extends EntityPlayer implements ICrafting {
public void a(int i, int j, int k) {
U();
+ System.out.println("OPEN_WINDOW for WorkBench");
a.b(((Packet) (new Packet100(bG, 1, "Crafting", 9))));
ap = ((CraftingInventoryCB) (new CraftingInventoryWorkbenchCB(an, l, i, j, k)));
ap.f = bG;
@@ -217,6 +218,7 @@ public class EntityPlayerMP extends EntityPlayer implements ICrafting {
public void a(IInventory iinventory) {
U();
+ System.out.println("OPEN_WINDOW for Chest");
a.b(((Packet) (new Packet100(bG, 0, iinventory.b(), iinventory.h_()))));
ap = ((CraftingInventoryCB) (new CraftingInventoryChestCB(((IInventory) (an)), iinventory)));
ap.f = bG;
@@ -225,6 +227,7 @@ public class EntityPlayerMP extends EntityPlayer implements ICrafting {
public void a(TileEntityFurnace tileentityfurnace) {
U();
+ System.out.println("OPEN_WINDOW for Furnace");
a.b(((Packet) (new Packet100(bG, 2, tileentityfurnace.b(), tileentityfurnace.h_()))));
ap = ((CraftingInventoryCB) (new CraftingInventoryFurnaceCB(((IInventory) (an)), tileentityfurnace)));
ap.f = bG;
@@ -233,6 +236,7 @@ public class EntityPlayerMP extends EntityPlayer implements ICrafting {
public void a(TileEntityDispenser tileentitydispenser) {
U();
+ System.out.println("OPEN_WINDOW for Dispenser");
a.b(((Packet) (new Packet100(bG, 3, tileentitydispenser.b(), tileentitydispenser.h_()))));
ap = ((CraftingInventoryCB) (new CraftingInventoryDispenserCB(((IInventory) (an)), tileentitydispenser)));
ap.f = bG;
@@ -243,20 +247,26 @@ public class EntityPlayerMP extends EntityPlayer implements ICrafting {
if (craftinginventorycb.a(i) instanceof SlotCrafting) {
return;
}
+ System.out.print("SET_SLOT for window: "+craftinginventorycb.f+" index: "+i+"and stack: "+itemstack);
if (am) {
+ System.out.println(" -- NOT SEND!");
return;
} else {
+ System.out.println(" -- SEND!");
a.b(((Packet) (new Packet103(craftinginventorycb.f, i, itemstack))));
return;
}
}
public void a(CraftingInventoryCB craftinginventorycb, List list) {
+ System.out.println("WINDOW_SLOTS for window: "+craftinginventorycb.f );
a.b(((Packet) (new Packet104(craftinginventorycb.f, list))));
+ System.out.println("SET_SLOT for item in hand: "+i+"and stack: "+an.i());
a.b(((Packet) (new Packet103(-1, -1, an.i()))));
}
public void a(CraftingInventoryCB craftinginventorycb, int i, int j) {
+ System.out.println(String.format("UPDATE_PROGRESS_BAR for window: %d [%d;%d]", craftinginventorycb.f, i, j));
a.b(((Packet) (new Packet105(craftinginventorycb.f, i, j))));
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
index 173e2658..6773ea35 100644..100755
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
@@ -43,8 +43,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
public void setContents(ItemStack[] items) {
if (getInventory().getContents().length != items.length) {
- throw new IllegalArgumentException("Invalid inventory size; expected "
- + getInventory().getContents().length);
+ throw new IllegalArgumentException("Invalid inventory size; expected " + getInventory().getContents().length);
}
net.minecraft.server.ItemStack[] mcItems = getInventory().getContents();
@@ -54,15 +53,13 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
if (item == null) {
mcItems[i] = null;
} else {
- mcItems[i] = new net.minecraft.server.ItemStack(
- item.getTypeId(), item.getAmount(), item.getDamage());
+ 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(), item.getDamage()));
+ getInventory().a(index, (item == null ? null : new net.minecraft.server.ItemStack( item.getTypeId(), item.getAmount(), item.getDamage())));
}
public boolean contains(int materialId) {