Remove network item handlers
- If an Interface is configured to expose the entire network storage (by configuring no export slots), it will no longer expose the entire RS storage, due to performance issues - The Portable Grid no longer exposes a inventory for crossmod interaction, due to performance issues
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
- Removed Project E integration (raoulvdberge)
|
- Removed Project E integration (raoulvdberge)
|
||||||
- Removed Storage Drawers integration (you can still attach an External Storage to drawers, though) (raoulvdberge)
|
- Removed Storage Drawers integration (you can still attach an External Storage to drawers, though) (raoulvdberge)
|
||||||
- You can no longer put a Filter in filter slots to gain additional filter slots (raoulvdberge)
|
- You can no longer put a Filter in filter slots to gain additional filter slots (raoulvdberge)
|
||||||
|
- If an Interface is configured to expose the entire network storage (by configuring no export slots), it will no longer expose the entire RS storage, due to performance issues (raoulvdberge)
|
||||||
|
- The Portable Grid no longer exposes a inventory for crossmod interaction, due to performance issues (raoulvdberge)
|
||||||
- Updated Russian translation (kellixon)
|
- Updated Russian translation (kellixon)
|
||||||
|
|
||||||
### 1.5.34
|
### 1.5.34
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package com.raoulvdberge.refinedstorage.apiimpl.network.node;
|
package com.raoulvdberge.refinedstorage.apiimpl.network.node;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.externalstorage.StorageItemItemHandler;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.externalstorage.StorageItemItemHandler;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.*;
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
||||||
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
|
||||||
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerProxy;
|
||||||
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
|
||||||
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
|
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
||||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||||
@@ -23,24 +25,10 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
|
|||||||
|
|
||||||
private ItemHandlerBase importItems = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this));
|
private ItemHandlerBase importItems = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this));
|
||||||
|
|
||||||
private ItemHandlerBase exportSpecimenItems = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this)) {
|
private ItemHandlerBase exportFilterItems = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this));
|
||||||
@Override
|
|
||||||
protected void onContentsChanged(int slot) {
|
|
||||||
super.onContentsChanged(slot);
|
|
||||||
|
|
||||||
if (network != null) {
|
|
||||||
if (!isEmpty() && itemsStorage != null) {
|
|
||||||
removeItemStorage(network);
|
|
||||||
} else if (isEmpty() && itemsStorage == null) {
|
|
||||||
createItemStorage(network);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
private ItemHandlerBase exportItems = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this));
|
private ItemHandlerBase exportItems = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this));
|
||||||
|
|
||||||
private IItemHandler items = new ItemHandlerProxy(importItems, exportItems);
|
private IItemHandler items = new ItemHandlerProxy(importItems, exportItems);
|
||||||
private ItemHandlerInterface itemsStorage;
|
|
||||||
|
|
||||||
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerListenerNetworkNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_STACK, ItemUpgrade.TYPE_CRAFTING);
|
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerListenerNetworkNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_STACK, ItemUpgrade.TYPE_CRAFTING);
|
||||||
|
|
||||||
@@ -88,7 +76,7 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
ItemStack wanted = exportSpecimenItems.getStackInSlot(i);
|
ItemStack wanted = exportFilterItems.getStackInSlot(i);
|
||||||
ItemStack got = exportItems.getStackInSlot(i);
|
ItemStack got = exportItems.getStackInSlot(i);
|
||||||
|
|
||||||
if (wanted.isEmpty()) {
|
if (wanted.isEmpty()) {
|
||||||
@@ -131,29 +119,6 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onConnectedStateChange(INetwork network, boolean state) {
|
|
||||||
super.onConnectedStateChange(network, state);
|
|
||||||
|
|
||||||
if (state && exportSpecimenItems.isEmpty()) {
|
|
||||||
createItemStorage(network);
|
|
||||||
} else if (itemsStorage != null) {
|
|
||||||
removeItemStorage(network);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createItemStorage(INetwork network) {
|
|
||||||
itemsStorage = new ItemHandlerInterface(network, network.getItemStorageCache(), importItems);
|
|
||||||
|
|
||||||
network.getItemStorageCache().addListener(itemsStorage);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeItemStorage(INetwork network) {
|
|
||||||
network.getItemStorageCache().removeListener(itemsStorage);
|
|
||||||
|
|
||||||
itemsStorage = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCompare() {
|
public int getCompare() {
|
||||||
return compare;
|
return compare;
|
||||||
@@ -195,7 +160,7 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
|
|||||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||||
super.writeConfiguration(tag);
|
super.writeConfiguration(tag);
|
||||||
|
|
||||||
StackUtils.writeItems(exportSpecimenItems, 1, tag);
|
StackUtils.writeItems(exportFilterItems, 1, tag);
|
||||||
|
|
||||||
tag.setInteger(NBT_COMPARE, compare);
|
tag.setInteger(NBT_COMPARE, compare);
|
||||||
|
|
||||||
@@ -206,7 +171,7 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
|
|||||||
public void readConfiguration(NBTTagCompound tag) {
|
public void readConfiguration(NBTTagCompound tag) {
|
||||||
super.readConfiguration(tag);
|
super.readConfiguration(tag);
|
||||||
|
|
||||||
StackUtils.readItems(exportSpecimenItems, 1, tag);
|
StackUtils.readItems(exportFilterItems, 1, tag);
|
||||||
|
|
||||||
if (tag.hasKey(NBT_COMPARE)) {
|
if (tag.hasKey(NBT_COMPARE)) {
|
||||||
compare = tag.getInteger(NBT_COMPARE);
|
compare = tag.getInteger(NBT_COMPARE);
|
||||||
@@ -217,18 +182,14 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
|
|||||||
return importItems;
|
return importItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IItemHandler getExportSpecimenItems() {
|
public IItemHandler getExportFilterItems() {
|
||||||
return exportSpecimenItems;
|
return exportFilterItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IItemHandler getExportItems() {
|
public IItemHandler getExportItems() {
|
||||||
return exportItems;
|
return exportItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IItemHandler getItemsOrStorage() {
|
|
||||||
return itemsStorage != null ? itemsStorage : items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IItemHandler getItems() {
|
public IItemHandler getItems() {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class ContainerInterface extends ContainerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
addSlotToContainer(new SlotFilter(tile.getNode().getExportSpecimenItems(), i, 8 + (18 * i), 54, SlotFilter.FILTER_ALLOW_SIZE));
|
addSlotToContainer(new SlotFilter(tile.getNode().getExportFilterItems(), i, 8 + (18 * i), 54, SlotFilter.FILTER_ALLOW_SIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
|
|||||||
@@ -1,89 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage.inventory;
|
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageCacheListener;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
|
||||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class ItemHandlerInterface implements IItemHandler, IStorageCacheListener<ItemStack> {
|
|
||||||
private INetwork network;
|
|
||||||
private IStorageCache<ItemStack> storageCache;
|
|
||||||
private IItemHandler importItems;
|
|
||||||
private ItemStack[] storageCacheData;
|
|
||||||
|
|
||||||
public ItemHandlerInterface(INetwork network, IStorageCache<ItemStack> storageCache, IItemHandler importItems) {
|
|
||||||
this.network = network;
|
|
||||||
this.storageCache = storageCache;
|
|
||||||
this.importItems = importItems;
|
|
||||||
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSlots() {
|
|
||||||
return importItems.getSlots() + storageCacheData.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public ItemStack getStackInSlot(int slot) {
|
|
||||||
if (slot < importItems.getSlots()) {
|
|
||||||
return importItems.getStackInSlot(slot);
|
|
||||||
} else if (slot < importItems.getSlots() + storageCacheData.length) {
|
|
||||||
return storageCacheData[slot - importItems.getSlots()];
|
|
||||||
}
|
|
||||||
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
|
||||||
if (slot < importItems.getSlots()) {
|
|
||||||
return importItems.insertItem(slot, stack, simulate);
|
|
||||||
}
|
|
||||||
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
|
||||||
if (slot < importItems.getSlots()) {
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
} else if (slot < importItems.getSlots() + storageCacheData.length) {
|
|
||||||
return StackUtils.nullToEmpty(network.extractItem(storageCacheData[slot - importItems.getSlots()], amount, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT, simulate));
|
|
||||||
}
|
|
||||||
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSlotLimit(int slot) {
|
|
||||||
return 64;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void invalidate() {
|
|
||||||
this.storageCacheData = storageCache.getList().getStacks().toArray(new ItemStack[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttached() {
|
|
||||||
// NO OP
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInvalidated() {
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChanged(@Nonnull ItemStack stack, int size) {
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage.inventory;
|
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
|
||||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class ItemHandlerStorage implements IItemHandler {
|
|
||||||
private IStorage<ItemStack> storage;
|
|
||||||
private IStorageCache<ItemStack> storageCache;
|
|
||||||
private ItemStack[] storageCacheData;
|
|
||||||
|
|
||||||
public ItemHandlerStorage(IStorage<ItemStack> storage, IStorageCache<ItemStack> storageCache) {
|
|
||||||
this.storage = storage;
|
|
||||||
this.storageCache = storageCache;
|
|
||||||
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSlots() {
|
|
||||||
// Keep 1 slot extra for new items
|
|
||||||
return storageCacheData.length + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public ItemStack getStackInSlot(int slot) {
|
|
||||||
return slot >= storageCacheData.length ? ItemStack.EMPTY : storageCacheData[slot];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
|
||||||
return StackUtils.nullToEmpty(storage.insert(stack, stack.getCount(), simulate));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
|
||||||
return slot >= storageCacheData.length ? ItemStack.EMPTY : StackUtils.nullToEmpty(storage.extract(storageCacheData[slot], amount, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT, simulate));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSlotLimit(int slot) {
|
|
||||||
return 64;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void invalidate() {
|
|
||||||
this.storageCacheData = storageCache.getList().getStacks().toArray(new ItemStack[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -21,11 +21,7 @@ public class TileInterface extends TileNode<NetworkNodeInterface> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ? CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getNode().getItems()) : super.getCapability(capability, facing);
|
||||||
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getNode().getItemsOrStorage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getCapability(capability, facing);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import com.raoulvdberge.refinedstorage.integration.forgeenergy.EnergyForge;
|
|||||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFilter;
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFilter;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerTile;
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerTile;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerStorage;
|
|
||||||
import com.raoulvdberge.refinedstorage.item.ItemBlockPortableGrid;
|
import com.raoulvdberge.refinedstorage.item.ItemBlockPortableGrid;
|
||||||
import com.raoulvdberge.refinedstorage.item.ItemEnergyItem;
|
import com.raoulvdberge.refinedstorage.item.ItemEnergyItem;
|
||||||
import com.raoulvdberge.refinedstorage.item.ItemWirelessGrid;
|
import com.raoulvdberge.refinedstorage.item.ItemWirelessGrid;
|
||||||
@@ -50,7 +49,6 @@ import net.minecraftforge.common.util.Constants;
|
|||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@@ -58,7 +56,7 @@ import javax.annotation.Nullable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid, IRedstoneConfigurable, IStorageCacheListener<ItemStack> {
|
public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid, IRedstoneConfigurable {
|
||||||
public static final TileDataParameter<Integer, TilePortableGrid> REDSTONE_MODE = RedstoneMode.createParameter();
|
public static final TileDataParameter<Integer, TilePortableGrid> REDSTONE_MODE = RedstoneMode.createParameter();
|
||||||
public static final TileDataParameter<Integer, TilePortableGrid> ENERGY_STORED = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.energyStorage.getEnergyStored());
|
public static final TileDataParameter<Integer, TilePortableGrid> ENERGY_STORED = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.energyStorage.getEnergyStored());
|
||||||
public static final TileDataParameter<Integer, TilePortableGrid> SORTING_DIRECTION = new TileDataParameter<>(DataSerializers.VARINT, 0, TilePortableGrid::getSortingDirection, (t, v) -> {
|
public static final TileDataParameter<Integer, TilePortableGrid> SORTING_DIRECTION = new TileDataParameter<>(DataSerializers.VARINT, 0, TilePortableGrid::getSortingDirection, (t, v) -> {
|
||||||
@@ -127,10 +125,6 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
|
|||||||
super.onContentsChanged(slot);
|
super.onContentsChanged(slot);
|
||||||
|
|
||||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
|
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
|
||||||
if (itemHandler != null) {
|
|
||||||
cache.removeListener(TilePortableGrid.this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getStackInSlot(slot).isEmpty()) {
|
if (getStackInSlot(slot).isEmpty()) {
|
||||||
storage = null;
|
storage = null;
|
||||||
} else {
|
} else {
|
||||||
@@ -146,14 +140,6 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
|
|||||||
|
|
||||||
cache.invalidate();
|
cache.invalidate();
|
||||||
|
|
||||||
if (storage == null) {
|
|
||||||
itemHandler = null;
|
|
||||||
} else {
|
|
||||||
itemHandler = new ItemHandlerStorage(storage, cache);
|
|
||||||
|
|
||||||
cache.addListener(TilePortableGrid.this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
checkIfDiskStateChanged();
|
checkIfDiskStateChanged();
|
||||||
}
|
}
|
||||||
@@ -175,7 +161,6 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
|
|||||||
private IStorageDisk<ItemStack> storage;
|
private IStorageDisk<ItemStack> storage;
|
||||||
private StorageCacheItemPortable cache = new StorageCacheItemPortable(this);
|
private StorageCacheItemPortable cache = new StorageCacheItemPortable(this);
|
||||||
private ItemGridHandlerPortable handler = new ItemGridHandlerPortable(this, this);
|
private ItemGridHandlerPortable handler = new ItemGridHandlerPortable(this, this);
|
||||||
private ItemHandlerStorage itemHandler = null;
|
|
||||||
private PortableGridDiskState diskState = PortableGridDiskState.NONE;
|
private PortableGridDiskState diskState = PortableGridDiskState.NONE;
|
||||||
private boolean connected;
|
private boolean connected;
|
||||||
|
|
||||||
@@ -625,19 +610,13 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||||
return capability == CapabilityEnergy.ENERGY || (itemHandler != null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) || super.hasCapability(capability, facing);
|
return capability == CapabilityEnergy.ENERGY || super.hasCapability(capability, facing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||||
if (capability == CapabilityEnergy.ENERGY) {
|
return capability == CapabilityEnergy.ENERGY ? CapabilityEnergy.ENERGY.cast(energyStorage) : super.getCapability(capability, facing);
|
||||||
return CapabilityEnergy.ENERGY.cast(energyStorage);
|
|
||||||
} else if (itemHandler != null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
|
||||||
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(itemHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getCapability(capability, facing);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onOpened() {
|
public void onOpened() {
|
||||||
@@ -676,19 +655,4 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
|
|||||||
return PortableGridDiskState.NORMAL;
|
return PortableGridDiskState.NORMAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttached() {
|
|
||||||
// NO OP
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInvalidated() {
|
|
||||||
itemHandler.invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChanged(@Nonnull ItemStack stack, int size) {
|
|
||||||
itemHandler.invalidate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user