From c97614ca22d070f5f2bfebf6210e249425dc73b9 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 14 Mar 2019 20:26:48 +0000 Subject: + Added more Carbon based chemicals for future use. % Mild tweaks to some Carbon based chemistry. % Updated en_US.lang. $ Fixed NPE in BTF_Inventory.java. --- .../api/objects/minecraft/BTF_Inventory.java | 45 ++++++++++++++++------ 1 file changed, 33 insertions(+), 12 deletions(-) (limited to 'src/Java/gtPlusPlus/api') diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java b/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java index 43a325f190..04ce0dff19 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java @@ -3,8 +3,8 @@ package gtPlusPlus.api.objects.minecraft; import java.util.ArrayList; import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.tileentities.base.TileEntityBase; +import gtPlusPlus.core.util.data.ArrayUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -20,6 +20,7 @@ public class BTF_Inventory implements ISidedInventory{ } public ItemStack[] getRealInventory() { + purgeNulls(); return this.mInventory; } @@ -140,6 +141,7 @@ public class BTF_Inventory implements ISidedInventory{ public void markDirty() { if (mTile != null) { + purgeNulls(); mTile.markDirty(); } } @@ -184,24 +186,43 @@ public class BTF_Inventory implements ISidedInventory{ return true; } - public boolean addItemStack(ItemStack aInput) { - if (isEmpty() || !isFull()) { + public boolean addItemStack(ItemStack aInput) { + if (aInput != null & (isEmpty() || !isFull())) { for (int s = 0; s < this.getSizeInventory(); s++) { - ItemStack slot = mInventory[s]; - if (slot == null - || (GT_Utility.areStacksEqual(aInput, slot) && slot.stackSize != slot.getMaxStackSize())) { - if (slot == null) { - slot = aInput.copy(); - } else { - slot.stackSize++; + if (mInventory != null && mInventory[s] != null) { + ItemStack slot = mInventory[s]; + if (slot == null || (slot != null && GT_Utility.areStacksEqual(aInput, slot) && slot.stackSize != slot.getItem().getItemStackLimit(slot))) { + if (slot == null) { + slot = aInput.copy(); + } else { + slot.stackSize++; + } + this.setInventorySlotContents(s, slot); + return true; } - this.setInventorySlotContents(s, slot); - return true; } } } return false; } + + public final void purgeNulls() { + ItemStack[] aTemp = ArrayUtils.removeNulls(this.mInventory); + for (int g=0;g