aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/api
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2019-03-14 20:26:48 +0000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2019-03-14 20:26:48 +0000
commitc97614ca22d070f5f2bfebf6210e249425dc73b9 (patch)
treedff09d4f2f296ab97e077dd1a6780c5d8ab90628 /src/Java/gtPlusPlus/api
parent0cb924d25dd80c22d000898fb27ab3ed0e0f80fb (diff)
downloadGT5-Unofficial-c97614ca22d070f5f2bfebf6210e249425dc73b9.tar.gz
GT5-Unofficial-c97614ca22d070f5f2bfebf6210e249425dc73b9.tar.bz2
GT5-Unofficial-c97614ca22d070f5f2bfebf6210e249425dc73b9.zip
+ 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.
Diffstat (limited to 'src/Java/gtPlusPlus/api')
-rw-r--r--src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java45
1 files changed, 33 insertions, 12 deletions
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<this.getSizeInventory();g++) {
+ if (aTemp.length < this.getSizeInventory()) {
+ if (g <= aTemp.length-1) {
+ this.mInventory[g] = aTemp[g];
+ }
+ else {
+ this.mInventory[g] = null;
+ }
+ }
+ else {
+ this.mInventory[g] = aTemp[g];
+ }
+ }
+
+ }
}