aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/util
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2019-01-06 18:18:27 +0000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2019-01-06 18:18:27 +0000
commit05d2066fd364ddff525b9ac4b38771d196641a5e (patch)
tree11abbdf56d18c4cc542b9edeb6c73274c1675eee /src/Java/gtPlusPlus/core/util
parentae46cb2fab01f82ab49b1e63172da88e0adde212 (diff)
downloadGT5-Unofficial-05d2066fd364ddff525b9ac4b38771d196641a5e.tar.gz
GT5-Unofficial-05d2066fd364ddff525b9ac4b38771d196641a5e.tar.bz2
GT5-Unofficial-05d2066fd364ddff525b9ac4b38771d196641a5e.zip
+ Added a new Alloy.
+ Added Recipes for the Fusion MK4 Components and the Deep Earth Drilling Platform components. + Added additional feature support to all Assembly Line recipes when TecTech is found. + Added initial work for future particle science. % Initial functions added for Multiblock Requirements. % More work on Multiblock Blueprints and Layers. % Updated lead lined chest significantly. % Improved Fish trap inventory handling and general logic, it's now slightly faster with slightly better loot rates. % Changed texture of Fish trap.
Diffstat (limited to 'src/Java/gtPlusPlus/core/util')
-rw-r--r--src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java
index fe344c70ed..d00f35f41f 100644
--- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java
+++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java
@@ -7,6 +7,7 @@ import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
import net.minecraft.block.Block;
import net.minecraft.init.Items;
+import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemStack;
@@ -17,6 +18,7 @@ import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
+import gregtech.api.util.GT_Utility;
import gtPlusPlus.GTplusplus;
import gtPlusPlus.api.objects.GregtechException;
import gtPlusPlus.api.objects.Logger;
@@ -895,5 +897,76 @@ public class ItemUtils {
return true;
}
+
+
+ public static IInventory organiseInventory(IInventory aInputInventory) {
+ ItemStack[] p = new ItemStack[aInputInventory.getSizeInventory()];
+ for (int o = 0; o < aInputInventory.getSizeInventory(); o++) {
+ p[o] = aInputInventory.getStackInSlot(o);
+ }
+ ItemStack[] g = organiseInventory(p);
+ IInventory aTemp = aInputInventory;
+ for (int o = 0; o < aInputInventory.getSizeInventory(); o++) {
+ aTemp.setInventorySlotContents(o, g[o]);
+ }
+ return aTemp;
+ }
+
+
+ public static ItemStack[] organiseInventory(ItemStack[] aInputs) {
+
+ //Update Slots
+ int aInvSize = aInputs.length;
+ ItemStack[] newArray = new ItemStack[aInvSize];
+
+
+ //Try merge stacks
+ for (int i = 0; i < aInvSize; i++) {
+ for (int i2 = 0; i2 < aInvSize; i2++) {
+ if (i != i2) {
+ ItemStack[] t1 = new ItemStack[] {aInputs[i], aInputs[i2]};
+ if (t1[0] == null || t1[1] == null) {
+ continue;
+ }
+ else if (!GT_Utility.areStacksEqual(t1[0], t1[1])) {
+ continue;
+ }
+ //Try Merge
+ else {
+
+ if (GT_Utility.areStacksEqual(t1[0], t1[1])) {
+ while ((t1[0].stackSize < 64 && t1[1].stackSize > 0)) {
+ t1[0].stackSize++;
+ t1[1].stackSize--;
+ if (t1[1].stackSize <= 0) {
+ t1[1] = null;
+ break;
+ }
+ if (t1[0].stackSize == 64) {
+ break;
+ }
+ }
+ newArray[i] = t1[1];
+ newArray[i2] = t1[0];
+ }
+ }
+ }
+ }
+ }
+
+ ItemStack[] newArray2 = new ItemStack[aInvSize];
+
+ //Move nulls to end
+ int count2 = 0;
+ for (int i = 0; i < aInvSize; i++)
+ if (newArray[i] != null)
+ newArray2[count2++] = newArray[i];
+ while (count2 < aInvSize)
+ newArray2[count2++] = null;
+
+ return newArray2;
+
+
+ }
}