diff options
Diffstat (limited to 'src/Java/gtPlusPlus/core/util')
-rw-r--r-- | src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java | 26 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java | 15 |
2 files changed, 38 insertions, 3 deletions
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java index aaa81a0057..fe67c88d69 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java @@ -2,6 +2,11 @@ package gtPlusPlus.core.util.minecraft; import java.util.Random; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy_RTG; import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.inventory.IInventory; @@ -58,5 +63,26 @@ public class InventoryUtils { } } + + public static void sortInventoryItems(MetaTileEntity aTile) { + sortInventoryItems(aTile.getBaseMetaTileEntity()); + } + + public static void sortInventoryItems(IGregTechTileEntity aBaseMetaTileEntity) { + IInventory mInv = aBaseMetaTileEntity.getIInventory(aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord()); + AutoMap<ItemStack> aInvContents = new AutoMap<ItemStack>(); + int aSize = mInv.getSizeInventory(); + for (int slot=0; slot<aSize; slot++) { + aInvContents.put(mInv.getStackInSlot(slot)); + } + ItemStack[] mInventory = aInvContents.toArray(); + for (int i = 0; i < mInventory.length; i++) { + for (int j = i + 1; j < mInventory.length; j++) { + if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) { + GT_Utility.moveStackFromSlotAToSlotB(aBaseMetaTileEntity, aBaseMetaTileEntity, j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + } + } + } } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 3f939e6b4e..09e7f51e06 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -451,7 +451,8 @@ public class ItemUtils { final ItemStack smallDust = ItemUtils.getSimpleStack(output[1]); final ItemStack tinyDust = ItemUtils.getSimpleStack(output[2]); - + CORE.RA.addpackagerRecipe(ItemList.Schematic_Dust.get(1), smallDust, tinyDust, normalDust); + if (ItemUtils.checkForInvalidItems(tinyDust) && ItemUtils.checkForInvalidItems(normalDust)) { if (RecipeUtils.addShapedRecipe( tinyDust, tinyDust, tinyDust, @@ -1136,8 +1137,8 @@ public class ItemUtils { String aDisplay = null; try { aDisplay = (aStack.getUnlocalizedName()).trim(); - - } catch (Throwable t) { + } + catch (Throwable t) { aDisplay = aStack.getItem().getUnlocalizedName(); } if (aDisplay == null || aDisplay.length() <= 0) { @@ -1368,4 +1369,12 @@ public class ItemUtils { return aOther; } + public static boolean areItemsEqual(ItemStack aStack1, ItemStack aStack2) { + return areItemsEqual(aStack1, aStack2, true); + } + + public static boolean areItemsEqual(ItemStack aStack1, ItemStack aStack2, boolean aIgnoreNBT) { + return GT_Utility.areStacksEqual(aStack1, aStack2, aIgnoreNBT); + } + } |