summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/PlayerInventory.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/minecraft/server/PlayerInventory.java')
-rw-r--r--src/main/java/net/minecraft/server/PlayerInventory.java92
1 files changed, 58 insertions, 34 deletions
diff --git a/src/main/java/net/minecraft/server/PlayerInventory.java b/src/main/java/net/minecraft/server/PlayerInventory.java
index f40b1e98..63da3ad4 100644
--- a/src/main/java/net/minecraft/server/PlayerInventory.java
+++ b/src/main/java/net/minecraft/server/PlayerInventory.java
@@ -1,5 +1,7 @@
package net.minecraft.server;
+import java.util.concurrent.Callable;
+
// CraftBukkit start
import java.util.List;
@@ -97,7 +99,7 @@ public class PlayerInventory implements IInventory {
}
// CraftBukkit end
- public int i() {
+ public int j() {
for (int i = 0; i < this.items.length; ++i) {
if (this.items[i] == null) {
return i;
@@ -138,7 +140,7 @@ public class PlayerInventory implements IInventory {
int k;
if (itemstack.getMaxStackSize() == 1) {
- k = this.i();
+ k = this.j();
if (k < 0) {
return j;
} else {
@@ -151,7 +153,7 @@ public class PlayerInventory implements IInventory {
} else {
k = this.firstPartial(itemstack);
if (k < 0) {
- k = this.i();
+ k = this.j();
}
if (k < 0) {
@@ -186,7 +188,7 @@ public class PlayerInventory implements IInventory {
}
}
- public void j() {
+ public void k() {
for (int i = 0; i < this.items.length; ++i) {
if (this.items[i] != null) {
this.items[i].a(this.player.world, this.player, i, this.itemInHandIndex == i);
@@ -215,32 +217,46 @@ public class PlayerInventory implements IInventory {
}
public boolean pickup(ItemStack itemstack) {
- int i;
-
- if (itemstack.h()) {
- i = this.i();
- if (i >= 0) {
- this.items[i] = ItemStack.b(itemstack);
- this.items[i].b = 5;
- itemstack.count = 0;
- return true;
- } else if (this.player.abilities.canInstantlyBuild) {
- itemstack.count = 0;
- return true;
- } else {
- return false;
- }
+ if (itemstack == null) {
+ return false;
} else {
- do {
- i = itemstack.count;
- itemstack.count = this.e(itemstack);
- } while (itemstack.count > 0 && itemstack.count < i);
-
- if (itemstack.count == i && this.player.abilities.canInstantlyBuild) {
- itemstack.count = 0;
- return true;
- } else {
- return itemstack.count < i;
+ try {
+ int i;
+
+ if (itemstack.i()) {
+ i = this.j();
+ if (i >= 0) {
+ this.items[i] = ItemStack.b(itemstack);
+ this.items[i].b = 5;
+ itemstack.count = 0;
+ return true;
+ } else if (this.player.abilities.canInstantlyBuild) {
+ itemstack.count = 0;
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ do {
+ i = itemstack.count;
+ itemstack.count = this.e(itemstack);
+ } while (itemstack.count > 0 && itemstack.count < i);
+
+ if (itemstack.count == i && this.player.abilities.canInstantlyBuild) {
+ itemstack.count = 0;
+ return true;
+ } else {
+ return itemstack.count < i;
+ }
+ }
+ } catch (Throwable throwable) {
+ CrashReport crashreport = CrashReport.a(throwable, "Adding item to inventory");
+ CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Item being added");
+
+ crashreportsystemdetails.a("Item ID", Integer.valueOf(itemstack.id));
+ crashreportsystemdetails.a("Item data", Integer.valueOf(itemstack.getData()));
+ crashreportsystemdetails.a("Item name", (Callable) (new CrashReportItemName(this, itemstack)));
+ throw new ReportedException(crashreport);
}
}
}
@@ -377,6 +393,10 @@ public class PlayerInventory implements IInventory {
return "container.inventory";
}
+ public boolean c() {
+ return false;
+ }
+
public int getMaxStackSize() {
return maxStack;
}
@@ -401,12 +421,12 @@ public class PlayerInventory implements IInventory {
return this.armor[i];
}
- public int k() {
+ public int l() {
int i = 0;
for (int j = 0; j < this.armor.length; ++j) {
if (this.armor[j] != null && this.armor[j].getItem() instanceof ItemArmor) {
- int k = ((ItemArmor) this.armor[j].getItem()).b;
+ int k = ((ItemArmor) this.armor[j].getItem()).c;
i += k;
}
@@ -431,7 +451,7 @@ public class PlayerInventory implements IInventory {
}
}
- public void l() {
+ public void m() {
int i;
for (i = 0; i < this.items.length; ++i) {
@@ -466,7 +486,7 @@ public class PlayerInventory implements IInventory {
return this.g;
}
- public boolean a_(EntityHuman entityhuman) {
+ public boolean a(EntityHuman entityhuman) {
return this.player.dead ? false : entityhuman.e(this.player) <= 64.0D;
}
@@ -490,7 +510,11 @@ public class PlayerInventory implements IInventory {
public void startOpen() {}
- public void f() {}
+ public void g() {}
+
+ public boolean b(int i, ItemStack itemstack) {
+ return true;
+ }
public void b(PlayerInventory playerinventory) {
int i;