From 9885420b28a42160cad61ed1a73e78797f17ed32 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 28 Dec 2013 15:05:58 -0600 Subject: [PATCH] New Util Methods. --- util/Platform.java | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/util/Platform.java b/util/Platform.java index 37244512..77ee9ce1 100644 --- a/util/Platform.java +++ b/util/Platform.java @@ -17,6 +17,7 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.InventoryLargeChest; import net.minecraft.item.Item; @@ -1126,9 +1127,9 @@ public class Platform return 0; } - public static IAEItemStack poweredExtraction(IEnergySource energy, IMEInventory cell, IAEItemStack input) + public static IAEItemStack poweredExtraction(IEnergySource energy, IMEInventory cell, IAEItemStack request) { - IAEItemStack possible = cell.extractItems( input.copy(), Actionable.SIMULATE ); + IAEItemStack possible = cell.extractItems( request.copy(), Actionable.SIMULATE ); long retrieved = 0; if ( possible != null ) @@ -1247,4 +1248,29 @@ public class Platform } } + public static int generateTileHash(TileEntity target) + { + if ( target == null ) + return 0; + + int hash = target.hashCode(); + + if ( target instanceof IInventory ) + hash ^= ((IInventory) target).getSizeInventory(); + + if ( target instanceof ISidedInventory ) + { + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + { + int offset = 0; + for (Integer Side : ((ISidedInventory) target).getAccessibleSlotsFromSide( dir.ordinal() )) + { + hash ^= Side << (offset++ % 20); + } + } + } + + return hash; + } + }