diff --git a/CHANGELOG.md b/CHANGELOG.md index e44e5c413..6bf3f9848 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ - Exposed the Network Card inventory of the Network Transmitter so other tiles can interact with it (raoulvdberge) - Increased size of Detector textbox (way2muchnoise) - Fixed stack upgrades not working in exporter when stack size is 16 (way2muchnoise) +- Fixed crash when rotating External Storage (raoulvdberge) ### 1.3.5 - Fixed TPS lag on very large crafting tasks (way2muchnoise) diff --git a/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/node/externalstorage/NetworkNodeExternalStorage.java b/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/node/externalstorage/NetworkNodeExternalStorage.java index f06841393..f87fa72e2 100755 --- a/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/node/externalstorage/NetworkNodeExternalStorage.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/node/externalstorage/NetworkNodeExternalStorage.java @@ -5,11 +5,11 @@ import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup; import com.raoulvdberge.refinedstorage.RS; import com.raoulvdberge.refinedstorage.RSUtils; import com.raoulvdberge.refinedstorage.api.network.INetworkMaster; -import com.raoulvdberge.refinedstorage.apiimpl.network.node.INetworkNodeHolder; import com.raoulvdberge.refinedstorage.api.storage.AccessType; import com.raoulvdberge.refinedstorage.api.storage.IStorage; import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider; import com.raoulvdberge.refinedstorage.api.util.IComparer; +import com.raoulvdberge.refinedstorage.apiimpl.network.node.INetworkNodeHolder; import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode; import com.raoulvdberge.refinedstorage.integration.cyclopscore.IntegrationCyclopsCore; import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic; @@ -192,11 +192,23 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP if (type == IType.ITEMS) { if (facing instanceof IDrawerGroup) { - itemStorages.add(new StorageItemDrawerGroup(this, () -> (IDrawerGroup) getFacingTile())); + itemStorages.add(new StorageItemDrawerGroup(this, () -> { + TileEntity f = getFacingTile(); + + return f instanceof IDrawerGroup ? (IDrawerGroup) f : null; + })); } else if (facing instanceof IDrawer) { - itemStorages.add(new StorageItemDrawer(this, () -> (IDrawer) getFacingTile())); + itemStorages.add(new StorageItemDrawer(this, () -> { + TileEntity f = getFacingTile(); + + return f instanceof IDrawer ? (IDrawer) f : null; + })); } else if (facing instanceof IDeepStorageUnit) { - itemStorages.add(new StorageItemDSU(this, () -> (IDeepStorageUnit) getFacingTile())); + itemStorages.add(new StorageItemDSU(this, () -> { + TileEntity f = getFacingTile(); + + return f instanceof IDeepStorageUnit ? (IDeepStorageUnit) f : null; + })); } else if (IntegrationCyclopsCore.isLoaded() && StorageItemCyclops.isValid(facing, holder.getDirection().getOpposite())) { itemStorages.add(new StorageItemCyclops(this)); } else if (!(facing instanceof TileNode)) { diff --git a/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/node/externalstorage/StorageItemCyclops.java b/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/node/externalstorage/StorageItemCyclops.java index 3fac97c6e..b06455f04 100644 --- a/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/node/externalstorage/StorageItemCyclops.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/node/externalstorage/StorageItemCyclops.java @@ -15,7 +15,7 @@ import org.cyclops.cyclopscore.tileentity.InventoryTileEntityBase; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.util.*; +import java.util.Arrays; import java.util.function.Supplier; public class StorageItemCyclops extends StorageItemExternal { @@ -27,7 +27,11 @@ public class StorageItemCyclops extends StorageItemExternal { public StorageItemCyclops(NetworkNodeExternalStorage externalStorage) { this.externalStorage = externalStorage; this.opposite = externalStorage.getHolder().getDirection().getOpposite(); - this.cyclopsInv = () -> (InventoryTileEntityBase) externalStorage.getFacingTile(); + this.cyclopsInv = () -> { + TileEntity f = externalStorage.getFacingTile(); + + return f instanceof InventoryTileEntityBase ? (InventoryTileEntityBase) f : null; + }; } @Override @@ -87,9 +91,9 @@ public class StorageItemCyclops extends StorageItemExternal { if (inv != null) { if (inv.getInventory() instanceof IndexedSlotlessItemHandlerWrapper.IInventoryIndexReference) { return ((IndexedSlotlessItemHandlerWrapper.IInventoryIndexReference) inv.getInventory()) - .getIndex().values().stream().flatMap(m -> m.valueCollection().stream()).map(ItemStack::copy).collect(RSUtils.toNonNullList()); + .getIndex().values().stream().flatMap(m -> m.valueCollection().stream()).map(ItemStack::copy).collect(RSUtils.toNonNullList()); } else { - return Arrays.stream(((SimpleInventory)inv.getInventory()).getItemStacks()).map(ItemStack::copy).collect(RSUtils.toNonNullList()); + return Arrays.stream(((SimpleInventory) inv.getInventory()).getItemStacks()).map(ItemStack::copy).collect(RSUtils.toNonNullList()); } } else { return RSUtils.emptyNonNullList(); @@ -98,7 +102,7 @@ public class StorageItemCyclops extends StorageItemExternal { public static boolean isValid(TileEntity facingTE, EnumFacing facing) { return facingTE instanceof InventoryTileEntityBase - && (SlotlessItemHandlerHelper.isSlotless(facingTE, facing) - || ((InventoryTileEntityBase) facingTE).getInventory() instanceof SimpleInventory); + && (SlotlessItemHandlerHelper.isSlotless(facingTE, facing) + || ((InventoryTileEntityBase) facingTE).getInventory() instanceof SimpleInventory); } }