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

@ -76,10 +76,10 @@ public class BlockDigitalChest extends BlockMachineBase {
for (int i = 0; i < droppables.size(); i++) {
final ItemStack itemStack = droppables.get(i);
if (itemStack == ItemStack.EMPTY) {
if (itemStack.isEmpty()) {
continue;
}
if (itemStack != ItemStack.EMPTY && itemStack.getCount() > 0) {
if (!itemStack.isEmpty() && itemStack.getCount() > 0) {
if (itemStack.getItem() instanceof ItemBlock) {
if (((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockFluidBase
|| ((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockStaticLiquid

View file

@ -80,10 +80,10 @@ public class BlockQuantumChest extends BlockMachineBase {
for (int i = 0; i < droppables.size(); i++) {
final ItemStack itemStack = droppables.get(i);
if (itemStack == ItemStack.EMPTY) {
if (itemStack.isEmpty()) {
continue;
}
if (itemStack != ItemStack.EMPTY && itemStack.getCount() > 0) {
if (!itemStack.isEmpty() && itemStack.getCount() > 0) {
if (itemStack.getItem() instanceof ItemBlock) {
if (((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockFluidBase
|| ((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockStaticLiquid

View file

@ -158,7 +158,7 @@ public class BlockRubberLog extends Block {
EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND);
if (stack != ItemStack.EMPTY)
if (!stack.isEmpty())
if ((stack.getItem() instanceof ItemElectricTreetap && PoweredItem.canUseEnergy(20, stack)) || stack.getItem() instanceof ItemTreeTap)
if (state.getValue(HAS_SAP)) {
if (state.getValue(SAP_SIDE) == side) {

View file

@ -140,10 +140,10 @@ public abstract class BlockTransformer extends BaseTileBlock {
for (int i = 0; i < inventory.getSizeInventory(); i++) {
ItemStack itemStack = inventory.getStackInSlot(i);
if (itemStack == ItemStack.EMPTY) {
if (itemStack.isEmpty()) {
continue;
}
if (itemStack != ItemStack.EMPTY && itemStack.getCount() > 0) {
if (!itemStack.isEmpty() && itemStack.getCount() > 0) {
if (itemStack.getItem() instanceof ItemBlock) {
if (((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockFluidBase
|| ((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockStaticLiquid

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);
}
}

View file

@ -213,13 +213,13 @@ public class ModRecipes {
data[1].equals("aluminium") ||
data[1].equals("iridium") ||
data[1].equals("saltpeter")) ||
oreStack == ItemStack.EMPTY)
oreStack.isEmpty())
continue;
boolean ore = data[0].equals("ore");
Core.logHelper.debug("Ore: " + data[1]);
ItemStack dust = getDictOreOrEmpty(joinDictName("dust", data[1]), ore ? 2 : 1);
if (dust == ItemStack.EMPTY || dust.getItem() == null) {
if (dust.isEmpty() || dust.getItem() == null) {
continue;
}
dust = dust.copy();

View file

@ -54,7 +54,7 @@ public class ItemBlockAdjustableSU extends ItemBlock {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flag) {
if (stack != ItemStack.EMPTY && stack.hasTagCompound()) {
if (!stack.isEmpty() && stack.hasTagCompound()) {
if (stack.getTagCompound().getCompoundTag("tileEntity") != null)
list.add(PowerSystem
.getLocaliszedPower(stack.getTagCompound().getCompoundTag("tileEntity").getInteger("energy")));
@ -72,7 +72,7 @@ public class ItemBlockAdjustableSU extends ItemBlock {
// world.getBlockState(pos).getBlock().onPostBlockPlaced(world, x,
// y, z, metadata);
}
if (stack != ItemStack.EMPTY && stack.hasTagCompound()) {
if (!stack.isEmpty() && stack.hasTagCompound()) {
((TileAdjustableSU) world.getTileEntity(pos))
.readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity"));
}

View file

@ -49,7 +49,7 @@ public class ItemBlockDigitalChest extends ItemBlock {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flag) {
if (stack != ItemStack.EMPTY && stack.hasTagCompound()) {
if (!stack.isEmpty() && stack.hasTagCompound()) {
if (stack.getTagCompound().getCompoundTag("tileEntity") != null)
list.add(stack.getTagCompound().getCompoundTag("tileEntity").getInteger("storedQuantity") + " items");
}
@ -66,7 +66,7 @@ public class ItemBlockDigitalChest extends ItemBlock {
// world.getBlockState(pos).getBlock().onPostBlockPlaced(world, x,
// y, z, metadata);
}
if (stack != ItemStack.EMPTY && stack.hasTagCompound()) {
if (!stack.isEmpty() && stack.hasTagCompound()) {
((TileDigitalChest) world.getTileEntity(pos))
.readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity"));
}

View file

@ -49,7 +49,7 @@ public class ItemBlockQuantumChest extends ItemBlock {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flag) {
if (stack != ItemStack.EMPTY && stack.hasTagCompound()) {
if (!stack.isEmpty() && stack.hasTagCompound()) {
if (stack.getTagCompound().getCompoundTag("tileEntity") != null)
list.add(stack.getTagCompound().getCompoundTag("tileEntity").getInteger("storedQuantity") + " items");
}
@ -66,7 +66,7 @@ public class ItemBlockQuantumChest extends ItemBlock {
// world.getBlockState(pos).getBlock().onPostBlockPlaced(world, x,
// y, z, metadata);
}
if (stack != ItemStack.EMPTY && stack.hasTagCompound()) {
if (!stack.isEmpty() && stack.hasTagCompound()) {
((TileQuantumChest) world.getTileEntity(pos))
.readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity"));
}

View file

@ -51,7 +51,7 @@ public class ItemBlockQuantumTank extends ItemBlock {
// world.getBlockState(pos).getBlock().onPostBlockPlaced(world, x,
// y, z, metadata);
}
if (stack != ItemStack.EMPTY && stack.hasTagCompound()) {
if (!stack.isEmpty() && stack.hasTagCompound()) {
((TileQuantumTank) world.getTileEntity(pos))
.readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity"));
}

View file

@ -61,7 +61,7 @@ public class ItemFrequencyTransmitter extends ItemTR {
World worldIn,
@Nullable
EntityLivingBase entityIn) {
if (stack != ItemStack.EMPTY && stack.hasTagCompound() && stack.getTagCompound() != null && stack.getTagCompound().hasKey("x") && stack.getTagCompound().hasKey("y") && stack.getTagCompound().hasKey("z") && stack.getTagCompound().hasKey("dim")) {
if (!stack.isEmpty() && stack.hasTagCompound() && stack.getTagCompound() != null && stack.getTagCompound().hasKey("x") && stack.getTagCompound().hasKey("y") && stack.getTagCompound().hasKey("z") && stack.getTagCompound().hasKey("dim")) {
return 1.0F;
}
return 0.0F;

View file

@ -63,7 +63,7 @@ public class ItemBattery extends ItemTR implements IEnergyItemInfo, IEnergyInter
World worldIn,
@Nullable
EntityLivingBase entityIn) {
if (stack != ItemStack.EMPTY && PoweredItem.getEnergy(stack) == 0.0) {
if (!stack.isEmpty() && PoweredItem.getEnergy(stack) == 0.0) {
return 1.0F;
}
return 0.0F;

View file

@ -74,7 +74,7 @@ public class ItemChainsaw extends ItemAxe implements IEnergyItemInfo, IEnergyInt
World worldIn,
@Nullable
EntityLivingBase entityIn) {
if (stack != ItemStack.EMPTY && PoweredItem.canUseEnergy(cost, stack) && entityIn != null && entityIn.getHeldItemMainhand().equals(stack)) {
if (!stack.isEmpty() && PoweredItem.canUseEnergy(cost, stack) && entityIn != null && entityIn.getHeldItemMainhand().equals(stack)) {
return 1.0F;
}
return 0.0F;

View file

@ -102,7 +102,7 @@ public class ItemCloakingDevice extends ItemTR implements IEnergyItemInfo, IEner
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
ItemStack itemstack1 = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (itemstack1 == ItemStack.EMPTY) {
if (itemstack1.isEmpty()) {
player.setItemStackToSlot(EntityEquipmentSlot.CHEST, itemStack.copy());
itemStack.setCount(0);
}

View file

@ -74,7 +74,7 @@ public class ItemNanosaber extends ItemSword implements IEnergyItemInfo, IEnergy
World worldIn,
@Nullable
EntityLivingBase entityIn) {
if (stack != ItemStack.EMPTY && stack.hasTagCompound() && stack.getTagCompound().hasKey("isActive") && stack.getTagCompound().getBoolean("isActive")) {
if (!stack.isEmpty() && stack.hasTagCompound() && stack.getTagCompound().hasKey("isActive") && stack.getTagCompound().getBoolean("isActive")) {
if (PoweredItem.getMaxPower(stack) - PoweredItem.getEnergy(stack) >= 0.9 * PoweredItem.getMaxPower(stack))
return 0.5F;
return 1.0F;

View file

@ -221,7 +221,7 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase
itemstack = recipeType.getOutput(0);
break;
}
if (itemstack != ItemStack.EMPTY) {
if (!itemstack.isEmpty()) {
break;
}
}

View file

@ -135,7 +135,7 @@ public class TileIronFurnace extends TileLegacyMachineBase
if (this.getStackInSlot(this.input1) == ItemStack.EMPTY)
return false;
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1));
if (itemstack == ItemStack.EMPTY)
if (itemstack.isEmpty())
return false;
if (this.getStackInSlot(this.output) == ItemStack.EMPTY)
return true;
@ -151,7 +151,7 @@ public class TileIronFurnace extends TileLegacyMachineBase
public ItemStack getResultFor(final ItemStack stack) {
final ItemStack result = FurnaceRecipes.instance().getSmeltingResult(stack);
if (result != ItemStack.EMPTY) {
if (!result.isEmpty()) {
return result.copy();
}
return ItemStack.EMPTY;

View file

@ -76,7 +76,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase
}
}
if (this.storedItem != ItemStack.EMPTY) {
if (!this.storedItem.isEmpty()) {
if (this.getStackInSlot(1) == ItemStack.EMPTY) {
ItemStack delivered = this.storedItem.copy();
@ -127,7 +127,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase
storedItem = new ItemStack((NBTTagCompound) tagCompound.getTag("storedStack"));
}
if (storedItem != ItemStack.EMPTY) {
if (!storedItem.isEmpty()) {
storedItem.setCount(tagCompound.getInteger("storedQuantity"));
}
}
@ -140,7 +140,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase
}
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) {
if (storedItem != ItemStack.EMPTY) {
if (!storedItem.isEmpty()) {
tagCompound.setTag("storedStack", storedItem.writeToNBT(new NBTTagCompound()));
tagCompound.setInteger("storedQuantity", storedItem.getCount());
} else {
@ -237,7 +237,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase
if (isRealTile) {
int size = 0;
String name = "of nothing";
if (storedItem != ItemStack.EMPTY) {
if (!storedItem.isEmpty()) {
name = storedItem.getDisplayName();
size += storedItem.getCount();
}

View file

@ -287,7 +287,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor implements IInv
}
public boolean canFitStack(final ItemStack stack, final int slot, final boolean oreDic) {// Checks to see if it can fit the stack
if (stack == ItemStack.EMPTY) {
if (stack.isEmpty()) {
return true;
}
if (this.inventory.getStackInSlot(slot) == ItemStack.EMPTY) {

View file

@ -146,7 +146,7 @@ public class TileIndustrialSawmill extends TilePowerAcceptor
public boolean canAddOutput(final int slot, final int amount) {
final ItemStack stack = this.getStackInSlot(slot);
return stack == ItemStack.EMPTY || this.getInventoryStackLimit() - stack.getCount() >= amount;
return stack.isEmpty() || this.getInventoryStackLimit() - stack.getCount() >= amount;
}
@Override

View file

@ -113,7 +113,7 @@ public class TileElectricFurnace extends TilePowerAcceptor
return false;
}
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1));
if (itemstack == ItemStack.EMPTY)
if (itemstack.isEmpty())
return false;
if (this.getStackInSlot(this.output) == ItemStack.EMPTY)
return true;
@ -129,7 +129,7 @@ public class TileElectricFurnace extends TilePowerAcceptor
public ItemStack getResultFor(final ItemStack stack) {
final ItemStack result = FurnaceRecipes.instance().getSmeltingResult(stack);
if (result != ItemStack.EMPTY) {
if (!result.isEmpty()) {
return result.copy();
}
return ItemStack.EMPTY;

View file

@ -106,7 +106,7 @@ public class OreDictUtils {
public static boolean isOre(
@Nonnull
ItemStack stack, String oreName) {
if (stack != ItemStack.EMPTY && !stack.isEmpty() && oreName != null) {
if (!stack.isEmpty() && !stack.isEmpty() && oreName != null) {
int id = OreDictionary.getOreID(oreName);
int[] ids = OreDictionary.getOreIDs(stack);