From 1c266fc91a5b2d94900f960cf4a8b1f3389d41f6 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Thu, 31 Jul 2014 23:52:16 -0500 Subject: [PATCH] Check getAccessibleSlotsFromSide for null returns. --- helpers/DualityInterface.java | 9 +++++++-- util/Platform.java | 8 +++++++- util/inv/AdaptorISpecialInventory.java | 1 + util/inv/WrapperInventoryRange.java | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/helpers/DualityInterface.java b/helpers/DualityInterface.java index 8ada1eae..698eaee1 100644 --- a/helpers/DualityInterface.java +++ b/helpers/DualityInterface.java @@ -1052,8 +1052,13 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt if ( te instanceof IInventory && ((IInventory) te).getSizeInventory() == 0 ) continue; - if ( te instanceof ISidedInventory && ((ISidedInventory) te).getAccessibleSlotsFromSide( s.getOpposite().ordinal() ).length == 0 ) - continue; + if ( te instanceof ISidedInventory ) + { + int[] sides = ((ISidedInventory) te).getAccessibleSlotsFromSide( s.getOpposite().ordinal() ); + + if ( sides == null || sides.length == 0 ) + continue; + } if ( mop.blockX == te.xCoord && mop.blockY == te.yCoord && mop.blockZ == te.zCoord ) { diff --git a/util/Platform.java b/util/Platform.java index a451060e..c11bf1cb 100644 --- a/util/Platform.java +++ b/util/Platform.java @@ -1470,7 +1470,13 @@ public class Platform for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { int offset = 0; - for (Integer Side : ((ISidedInventory) target).getAccessibleSlotsFromSide( dir.ordinal() )) + + int[] sides = ((ISidedInventory) target).getAccessibleSlotsFromSide( dir.ordinal() ); + + if ( sides == null ) + return 0; + + for (Integer Side : sides) { int c = (Side << (offset++ % 8)) ^ (1 << dir.ordinal()); hash = c + (hash << 6) + (hash << 16) - hash; diff --git a/util/inv/AdaptorISpecialInventory.java b/util/inv/AdaptorISpecialInventory.java index 994b0485..d09b0b50 100644 --- a/util/inv/AdaptorISpecialInventory.java +++ b/util/inv/AdaptorISpecialInventory.java @@ -85,6 +85,7 @@ public class AdaptorISpecialInventory extends InventoryAdaptor { ISidedInventory sided = (ISidedInventory) i; int slots[] = sided.getAccessibleSlotsFromSide( d.ordinal() ); + if ( slots == null ) return false; diff --git a/util/inv/WrapperInventoryRange.java b/util/inv/WrapperInventoryRange.java index bd030558..e0e0cba8 100644 --- a/util/inv/WrapperInventoryRange.java +++ b/util/inv/WrapperInventoryRange.java @@ -30,6 +30,7 @@ public class WrapperInventoryRange implements IInventory public WrapperInventoryRange(IInventory a, int[] s, boolean ignoreValid) { src = a; slots = s; + if ( slots == null ) slots = new int[0];