Replace all emptiness checks == ItemStack.Empty with .isEmpty() (#1247)

Fixes #1157 and probably a few other things.
This commit is contained in:
David Vierra 2017-08-25 08:08:15 -10:00 committed by Modmuss50
parent df808760ad
commit a016a6dd49
24 changed files with 41 additions and 39 deletions

View file

@ -232,6 +232,8 @@ public class BuiltContainer extends Container {
slot.onTake(player, stackInSlot);
}
return originalStack;
}
protected boolean shiftItemStack(final ItemStack stackToShift, final int start, final int end) {
@ -240,7 +242,7 @@ public class BuiltContainer extends Container {
for (int slotIndex = start; stackToShift.getCount() > 0 && slotIndex < end; slotIndex++) {
final Slot slot = this.inventorySlots.get(slotIndex);
final ItemStack stackInSlot = slot.getStack();
if (stackInSlot != ItemStack.EMPTY && ItemUtils.isItemEqual(stackInSlot, stackToShift, true, true)
if (!stackInSlot.isEmpty() && ItemUtils.isItemEqual(stackInSlot, stackToShift, true, true)
&& slot.isItemValid(stackToShift)) {
final int resultingStackSize = stackInSlot.getCount() + stackToShift.getCount();
final int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
@ -262,7 +264,7 @@ public class BuiltContainer extends Container {
for (int slotIndex = start; stackToShift.getCount() > 0 && slotIndex < end; slotIndex++) {
final Slot slot = this.inventorySlots.get(slotIndex);
ItemStack stackInSlot = slot.getStack();
if (stackInSlot == ItemStack.EMPTY && slot.isItemValid(stackToShift)) {
if (stackInSlot.isEmpty() && slot.isItemValid(stackToShift)) {
final int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
stackInSlot = stackToShift.copy();
stackInSlot.setCount(Math.min(stackToShift.getCount(), max));

View file

@ -51,12 +51,12 @@ public class GuiDigitalChest extends GuiBase {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
final Layer layer = Layer.FOREGROUND;
if (this.digitalChest.storedItem != ItemStack.EMPTY && this.digitalChest.getStackInSlot(1) != null) {
if (!this.digitalChest.storedItem.isEmpty() && this.digitalChest.getStackInSlot(1) != null) {
this.builder.drawBigBlueBar(this, 31, 43,
this.digitalChest.storedItem.getCount() + this.digitalChest.getStackInSlot(1).getCount(),
this.digitalChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer);
}
if (this.digitalChest.storedItem == ItemStack.EMPTY && this.digitalChest.getStackInSlot(1) != null) {
if (this.digitalChest.storedItem.isEmpty() && this.digitalChest.getStackInSlot(1) != null) {
this.builder.drawBigBlueBar(this, 31, 43, this.digitalChest.getStackInSlot(1).getCount(),
this.digitalChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer);
}

View file

@ -51,10 +51,10 @@ public class GuiQuantumChest extends GuiBase {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
final Layer layer = Layer.FOREGROUND;
if (this.quantumChest.storedItem != ItemStack.EMPTY && this.quantumChest.getStackInSlot(1) != null) {
if (!this.quantumChest.storedItem.isEmpty() && this.quantumChest.getStackInSlot(1) != null) {
this.builder.drawBigBlueBar(this, 31, 43, this.quantumChest.storedItem.getCount() + this.quantumChest.getStackInSlot(1).getCount(), this.quantumChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer);
}
if (this.quantumChest.storedItem == ItemStack.EMPTY && this.quantumChest.getStackInSlot(1) != null) {
if (this.quantumChest.storedItem.isEmpty() && this.quantumChest.getStackInSlot(1) != null) {
this.builder.drawBigBlueBar(this, 31, 43, this.quantumChest.getStackInSlot(1).getCount(), this.quantumChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer);
}
}