Fix incorrect usage of item stack checking
I have no idea how they worked without issue for this long :D
This commit is contained in:
parent
96d78c11a8
commit
d4a43d24a1
10 changed files with 21 additions and 21 deletions
|
@ -37,7 +37,7 @@ public class ClientEventHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void renderPlayer(RenderPlayerEvent.Pre event) {
|
public static void renderPlayer(RenderPlayerEvent.Pre event) {
|
||||||
EntityPlayer player = event.getEntityPlayer();
|
EntityPlayer player = event.getEntityPlayer();
|
||||||
Item chestslot = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != ItemStack.EMPTY
|
Item chestslot = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty()
|
||||||
? player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() : null;
|
? player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() : null;
|
||||||
if (chestslot != null && chestslot == ModItems.CLOAKING_DEVICE) {
|
if (chestslot != null && chestslot == ModItems.CLOAKING_DEVICE) {
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class TechRebornDevCommand extends CommandBase {
|
||||||
}
|
}
|
||||||
} else if ("getname".equals(args[0])) {
|
} else if ("getname".equals(args[0])) {
|
||||||
EntityPlayer player = (EntityPlayer) sender;
|
EntityPlayer player = (EntityPlayer) sender;
|
||||||
if (player.getHeldItem(EnumHand.MAIN_HAND) != ItemStack.EMPTY) {
|
if (!player.getHeldItem(EnumHand.MAIN_HAND).isEmpty()) {
|
||||||
sender.sendMessage(new TextComponentString(player.getHeldItem(EnumHand.MAIN_HAND).getItem().getRegistryName() + ":" + player.getHeldItem(EnumHand.MAIN_HAND).getItemDamage()));
|
sender.sendMessage(new TextComponentString(player.getHeldItem(EnumHand.MAIN_HAND).getItem().getRegistryName() + ":" + player.getHeldItem(EnumHand.MAIN_HAND).getItemDamage()));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(new TextComponentString("hold an item!"));
|
sender.sendMessage(new TextComponentString("hold an item!"));
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class TRTickHandler {
|
||||||
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
|
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
|
||||||
public void onPlayerTick(TickEvent.PlayerTickEvent e) {
|
public void onPlayerTick(TickEvent.PlayerTickEvent e) {
|
||||||
EntityPlayer player = e.player;
|
EntityPlayer player = e.player;
|
||||||
Item chestslot = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != ItemStack.EMPTY
|
Item chestslot = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty()
|
||||||
? player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() : null;
|
? player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() : null;
|
||||||
|
|
||||||
if (previouslyWearing != chestslot && previouslyWearing == ModItems.CLOAKING_DEVICE && player.isInvisible()
|
if (previouslyWearing != chestslot && previouslyWearing == ModItems.CLOAKING_DEVICE && player.isInvisible()
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class ItemLithiumBatpack extends ItemArmor implements IEnergyItemInfo {
|
||||||
IEnergyStorage capEnergy = itemStack.getCapability(CapabilityEnergy.ENERGY, null);
|
IEnergyStorage capEnergy = itemStack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||||
|
|
||||||
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
||||||
if (player.inventory.getStackInSlot(i) != ItemStack.EMPTY) {
|
if (!player.inventory.getStackInSlot(i).isEmpty()) {
|
||||||
ItemStack item = player.inventory.getStackInSlot(i);
|
ItemStack item = player.inventory.getStackInSlot(i);
|
||||||
if (!item.hasCapability(CapabilityEnergy.ENERGY, null)) {
|
if (!item.hasCapability(CapabilityEnergy.ENERGY, null)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -144,7 +144,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
||||||
if (!getStackInSlot(1).isEmpty()) {
|
if (!getStackInSlot(1).isEmpty()) {
|
||||||
outputStack = getStackInSlot(1);
|
outputStack = getStackInSlot(1);
|
||||||
}
|
}
|
||||||
if (getStackInSlot(0) != ItemStack.EMPTY
|
if (!getStackInSlot(0).isEmpty()
|
||||||
&& (storedItem.getCount() + outputStack.getCount()) < maxCapacity) {
|
&& (storedItem.getCount() + outputStack.getCount()) < maxCapacity) {
|
||||||
ItemStack inputStack = getStackInSlot(0);
|
ItemStack inputStack = getStackInSlot(0);
|
||||||
if (getStoredItemType().isEmpty()
|
if (getStoredItemType().isEmpty()
|
||||||
|
@ -167,7 +167,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!storedItem.isEmpty()) {
|
if (!storedItem.isEmpty()) {
|
||||||
if (outputStack == ItemStack.EMPTY) {
|
if (outputStack.isEmpty()) {
|
||||||
|
|
||||||
ItemStack delivered = storedItem.copy();
|
ItemStack delivered = storedItem.copy();
|
||||||
delivered.setCount(Math.min(storedItem.getCount(), delivered.getMaxStackSize()));
|
delivered.setCount(Math.min(storedItem.getCount(), delivered.getMaxStackSize()));
|
||||||
|
@ -257,7 +257,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
||||||
name = storedItem.getDisplayName();
|
name = storedItem.getDisplayName();
|
||||||
size += storedItem.getCount();
|
size += storedItem.getCount();
|
||||||
}
|
}
|
||||||
if (getStackInSlot(1) != ItemStack.EMPTY) {
|
if (!getStackInSlot(1).isEmpty()) {
|
||||||
name = getStackInSlot(1).getDisplayName();
|
name = getStackInSlot(1).getDisplayName();
|
||||||
size += getStackInSlot(1).getCount();
|
size += getStackInSlot(1).getCount();
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,12 +136,12 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase
|
||||||
--this.burnTime;
|
--this.burnTime;
|
||||||
}
|
}
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
if (this.burnTime != 0 || this.getStackInSlot(this.input1) != ItemStack.EMPTY && this.getStackInSlot(this.fuel) != ItemStack.EMPTY) {
|
if (this.burnTime != 0 || !this.getStackInSlot(this.input1).isEmpty()&& !this.getStackInSlot(this.fuel).isEmpty()) {
|
||||||
if (this.burnTime == 0 && this.canSmelt()) {
|
if (this.burnTime == 0 && this.canSmelt()) {
|
||||||
this.currentItemBurnTime = this.burnTime = TileIronAlloyFurnace.getItemBurnTime(this.getStackInSlot(this.fuel));
|
this.currentItemBurnTime = this.burnTime = TileIronAlloyFurnace.getItemBurnTime(this.getStackInSlot(this.fuel));
|
||||||
if (this.burnTime > 0) {
|
if (this.burnTime > 0) {
|
||||||
flag1 = true;
|
flag1 = true;
|
||||||
if (this.getStackInSlot(this.fuel) != ItemStack.EMPTY) {
|
if (!this.getStackInSlot(this.fuel).isEmpty()) {
|
||||||
this.decrStackSize(this.fuel, 1);
|
this.decrStackSize(this.fuel, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canSmelt() {
|
private boolean canSmelt() {
|
||||||
if (this.getStackInSlot(this.input1) == ItemStack.EMPTY || this.getStackInSlot(this.input2) == ItemStack.EMPTY) {
|
if (this.getStackInSlot(this.input1).isEmpty() || this.getStackInSlot(this.input2).isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
ItemStack itemstack = null;
|
ItemStack itemstack = null;
|
||||||
|
@ -204,7 +204,7 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase
|
||||||
|
|
||||||
if (itemstack == null)
|
if (itemstack == null)
|
||||||
return false;
|
return false;
|
||||||
if (this.getStackInSlot(this.output) == ItemStack.EMPTY)
|
if (this.getStackInSlot(this.output).isEmpty())
|
||||||
return true;
|
return true;
|
||||||
if (!this.getStackInSlot(this.output).isItemEqual(itemstack))
|
if (!this.getStackInSlot(this.output).isItemEqual(itemstack))
|
||||||
return false;
|
return false;
|
||||||
|
@ -237,7 +237,7 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getStackInSlot(this.output) == ItemStack.EMPTY) {
|
if (this.getStackInSlot(this.output).isEmpty()) {
|
||||||
this.setInventorySlotContents(this.output, itemstack.copy());
|
this.setInventorySlotContents(this.output, itemstack.copy());
|
||||||
} else if (this.getStackInSlot(this.output).getItem() == itemstack.getItem()) {
|
} else if (this.getStackInSlot(this.output).getItem() == itemstack.getItem()) {
|
||||||
this.decrStackSize(this.output, -itemstack.getCount());
|
this.decrStackSize(this.output, -itemstack.getCount());
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class TileIronFurnace extends TileLegacyMachineBase
|
||||||
if (this.canSmelt()) {
|
if (this.canSmelt()) {
|
||||||
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1));
|
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1));
|
||||||
|
|
||||||
if (this.getStackInSlot(this.output) == ItemStack.EMPTY) {
|
if (this.getStackInSlot(this.output).isEmpty()) {
|
||||||
this.setInventorySlotContents(this.output, itemstack.copy());
|
this.setInventorySlotContents(this.output, itemstack.copy());
|
||||||
} else if (this.getStackInSlot(this.output).isItemEqual(itemstack)) {
|
} else if (this.getStackInSlot(this.output).isItemEqual(itemstack)) {
|
||||||
this.getStackInSlot(this.output).grow(itemstack.getCount());
|
this.getStackInSlot(this.output).grow(itemstack.getCount());
|
||||||
|
@ -129,12 +129,12 @@ public class TileIronFurnace extends TileLegacyMachineBase
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSmelt() {
|
public boolean canSmelt() {
|
||||||
if (this.getStackInSlot(this.input1) == ItemStack.EMPTY)
|
if (this.getStackInSlot(this.input1).isEmpty())
|
||||||
return false;
|
return false;
|
||||||
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1));
|
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1));
|
||||||
if (itemstack.isEmpty())
|
if (itemstack.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
if (this.getStackInSlot(this.output) == ItemStack.EMPTY)
|
if (this.getStackInSlot(this.output).isEmpty())
|
||||||
return true;
|
return true;
|
||||||
if (!this.getStackInSlot(this.output).isItemEqual(itemstack))
|
if (!this.getStackInSlot(this.output).isItemEqual(itemstack))
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class TileElectricFurnace extends TilePowerAcceptor
|
||||||
if (canSmelt()) {
|
if (canSmelt()) {
|
||||||
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
|
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
|
||||||
|
|
||||||
if (getStackInSlot(output) == ItemStack.EMPTY) {
|
if (getStackInSlot(output).isEmpty()) {
|
||||||
setInventorySlotContents(output, itemstack.copy());
|
setInventorySlotContents(output, itemstack.copy());
|
||||||
} else if (getStackInSlot(output).isItemEqual(itemstack)) {
|
} else if (getStackInSlot(output).isItemEqual(itemstack)) {
|
||||||
getStackInSlot(output).grow(itemstack.getCount());
|
getStackInSlot(output).grow(itemstack.getCount());
|
||||||
|
@ -85,14 +85,14 @@ public class TileElectricFurnace extends TilePowerAcceptor
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSmelt() {
|
public boolean canSmelt() {
|
||||||
if (getStackInSlot(input1) == ItemStack.EMPTY) {
|
if (getStackInSlot(input1).isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
|
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
|
||||||
if (itemstack.isEmpty()) {
|
if (itemstack.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getStackInSlot(output) == ItemStack.EMPTY) {
|
if (getStackInSlot(output).isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!getStackInSlot(output).isItemEqual(itemstack)) {
|
if (!getStackInSlot(output).isItemEqual(itemstack)) {
|
||||||
|
|
|
@ -90,11 +90,11 @@ public class TileRecycler extends TilePowerAcceptor
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canRecycle() {
|
public boolean canRecycle() {
|
||||||
return getStackInSlot(0) != ItemStack.EMPTY && hasSlotGotSpace(1);
|
return !getStackInSlot(0) .isEmpty() && hasSlotGotSpace(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSlotGotSpace(int slot) {
|
public boolean hasSlotGotSpace(int slot) {
|
||||||
if (getStackInSlot(slot) == ItemStack.EMPTY) {
|
if (getStackInSlot(slot).isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
} else if (getStackInSlot(slot).getCount() < getStackInSlot(slot).getMaxStackSize()) {
|
} else if (getStackInSlot(slot).getCount() < getStackInSlot(slot).getMaxStackSize()) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class TileRollingMachine extends TilePowerAcceptor
|
||||||
currentRecipeOutput = RollingMachineRecipe.instance.findMatchingRecipeOutput(craftMatrix, world);
|
currentRecipeOutput = RollingMachineRecipe.instance.findMatchingRecipeOutput(craftMatrix, world);
|
||||||
if (!currentRecipeOutput.isEmpty()) {
|
if (!currentRecipeOutput.isEmpty()) {
|
||||||
boolean hasCrafted = false;
|
boolean hasCrafted = false;
|
||||||
if (inventory.getStackInSlot(outputSlot) == ItemStack.EMPTY) {
|
if (inventory.getStackInSlot(outputSlot).isEmpty()) {
|
||||||
inventory.setInventorySlotContents(outputSlot, currentRecipeOutput);
|
inventory.setInventorySlotContents(outputSlot, currentRecipeOutput);
|
||||||
tickTime = 0;
|
tickTime = 0;
|
||||||
hasCrafted = true;
|
hasCrafted = true;
|
||||||
|
|
Loading…
Reference in a new issue