More fixes.
This commit is contained in:
@@ -25,6 +25,7 @@ import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
import refinedstorage.api.storage.AccessType;
|
||||
import refinedstorage.apiimpl.API;
|
||||
import refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||
import refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||
@@ -37,6 +38,7 @@ public final class RSUtils {
|
||||
|
||||
private static final String NBT_INVENTORY = "Inventory_%d";
|
||||
private static final String NBT_SLOT = "Slot";
|
||||
private static final String NBT_ACCESS_TYPE = "AccessType";
|
||||
|
||||
public static void writeItemStack(ByteBuf buf, INetworkMaster network, ItemStack stack) {
|
||||
buf.writeInt(Item.getIdFromItem(stack.getItem()));
|
||||
@@ -141,6 +143,24 @@ public final class RSUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeAccessType(NBTTagCompound tag, AccessType type) {
|
||||
tag.setInteger(NBT_ACCESS_TYPE, type.getId());
|
||||
}
|
||||
|
||||
public static AccessType readAccessType(NBTTagCompound tag) {
|
||||
return tag.hasKey(NBT_ACCESS_TYPE) ? getAccessType(tag.getInteger(NBT_ACCESS_TYPE)) : AccessType.READ_WRITE;
|
||||
}
|
||||
|
||||
public static AccessType getAccessType(int id) {
|
||||
for (AccessType type : AccessType.values()) {
|
||||
if (type.getId() == id) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
return AccessType.READ_WRITE;
|
||||
}
|
||||
|
||||
public static IItemHandler getItemHandler(TileEntity tile, EnumFacing side) {
|
||||
if (tile == null) {
|
||||
return null;
|
||||
|
||||
35
src/main/java/refinedstorage/api/storage/AccessType.java
Executable file
35
src/main/java/refinedstorage/api/storage/AccessType.java
Executable file
@@ -0,0 +1,35 @@
|
||||
package refinedstorage.api.storage;
|
||||
|
||||
/**
|
||||
* The access type of a storage.
|
||||
*/
|
||||
public enum AccessType {
|
||||
/**
|
||||
* Read and write access.
|
||||
*/
|
||||
READ_WRITE(0),
|
||||
/**
|
||||
* Only read access.
|
||||
*/
|
||||
READ(1),
|
||||
/**
|
||||
* Only write access.
|
||||
*/
|
||||
WRITE(2);
|
||||
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* @param id the id of this access type
|
||||
*/
|
||||
AccessType(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id of this access type
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package refinedstorage.api.storage.fluid;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import refinedstorage.api.storage.AccessType;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -51,11 +52,9 @@ public interface IFluidStorage {
|
||||
int getPriority();
|
||||
|
||||
/**
|
||||
* READ(0) : Can see the fluid stored in this storage
|
||||
* WRITE(1) : Can insert and/or extract fluid from this storage
|
||||
* READ_WRITE(2) : Can see, insert and extract fluid from this storage
|
||||
*
|
||||
* @return the access type of this storage
|
||||
*/
|
||||
int getAccessType();
|
||||
default AccessType getAccessType() {
|
||||
return AccessType.READ_WRITE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ import java.util.List;
|
||||
*/
|
||||
public interface IFluidStorageCache {
|
||||
/**
|
||||
* Rebuilds the cache.
|
||||
* Invalidates the cache.
|
||||
* Typically called when a {@link IFluidStorageProvider} is added or removed from the network.
|
||||
*/
|
||||
void rebuild();
|
||||
void invalidate();
|
||||
|
||||
/**
|
||||
* Adds an item to the cache.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package refinedstorage.api.storage.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.api.storage.AccessType;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -51,11 +52,9 @@ public interface IItemStorage {
|
||||
int getPriority();
|
||||
|
||||
/**
|
||||
* READ(0) : Can see the items stored in this storage
|
||||
* WRITE(1) : Can insert and/or extract items from this storage
|
||||
* READ_WRITE(2) : Can see, insert and extract items from this storage
|
||||
*
|
||||
* @return the access type of this storage
|
||||
*/
|
||||
int getAccessType();
|
||||
default AccessType getAccessType() {
|
||||
return AccessType.READ_WRITE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ import java.util.List;
|
||||
*/
|
||||
public interface IItemStorageCache {
|
||||
/**
|
||||
* Rebuilds the cache.
|
||||
* Invalidates the cache.
|
||||
* Typically called when a {@link IItemStorageProvider} is added or removed from the network.
|
||||
*/
|
||||
void rebuild();
|
||||
void invalidate();
|
||||
|
||||
/**
|
||||
* Adds an item to the cache.
|
||||
|
||||
@@ -155,11 +155,11 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
}
|
||||
|
||||
if (node instanceof IItemStorageProvider) {
|
||||
controller.getItemStorageCache().rebuild();
|
||||
controller.getItemStorageCache().invalidate();
|
||||
}
|
||||
|
||||
if (node instanceof IFluidStorageProvider) {
|
||||
controller.getFluidStorageCache().rebuild();
|
||||
controller.getFluidStorageCache().invalidate();
|
||||
}
|
||||
|
||||
controller.getDataManager().sendParameterToWatchers(TileController.NODES);
|
||||
|
||||
@@ -2,12 +2,12 @@ package refinedstorage.apiimpl.storage.fluid;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
import refinedstorage.api.storage.AccessType;
|
||||
import refinedstorage.api.storage.fluid.IFluidStorage;
|
||||
import refinedstorage.api.storage.fluid.IFluidStorageCache;
|
||||
import refinedstorage.api.storage.fluid.IFluidStorageProvider;
|
||||
import refinedstorage.api.util.IFluidStackList;
|
||||
import refinedstorage.apiimpl.API;
|
||||
import refinedstorage.tile.config.IAccessType;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
@@ -23,7 +23,7 @@ public class FluidStorageCache implements IFluidStorageCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void rebuild() {
|
||||
public synchronized void invalidate() {
|
||||
storages.clear();
|
||||
|
||||
network.getNodeGraph().all().stream()
|
||||
@@ -33,7 +33,7 @@ public class FluidStorageCache implements IFluidStorageCache {
|
||||
list.clear();
|
||||
|
||||
for (IFluidStorage storage : storages) {
|
||||
if (storage.getAccessType() == IAccessType.WRITE) {
|
||||
if (storage.getAccessType() == AccessType.WRITE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@ package refinedstorage.apiimpl.storage.item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
import refinedstorage.api.storage.AccessType;
|
||||
import refinedstorage.api.storage.item.IItemStorage;
|
||||
import refinedstorage.api.storage.item.IItemStorageCache;
|
||||
import refinedstorage.api.storage.item.IItemStorageProvider;
|
||||
import refinedstorage.api.util.IItemStackList;
|
||||
import refinedstorage.apiimpl.API;
|
||||
import refinedstorage.tile.config.IAccessType;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
@@ -24,7 +24,7 @@ public class ItemStorageCache implements IItemStorageCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void rebuild() {
|
||||
public synchronized void invalidate() {
|
||||
storages.clear();
|
||||
|
||||
network.getNodeGraph().all().stream()
|
||||
@@ -34,7 +34,7 @@ public class ItemStorageCache implements IItemStorageCache {
|
||||
list.clear();
|
||||
|
||||
for (IItemStorage storage : storages) {
|
||||
if (storage.getAccessType() == IAccessType.WRITE) {
|
||||
if (storage.getAccessType() == AccessType.WRITE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ public class GuiHandler implements IGuiHandler {
|
||||
case RSGui.DETECTOR:
|
||||
return new GuiDetector((ContainerDetector) getContainer(ID, player, tile));
|
||||
case RSGui.SOLDERER:
|
||||
return new GuiSolderer((ContainerSolderer) getContainer(ID, player, tile), (TileSolderer) tile);
|
||||
return new GuiSolderer((ContainerSolderer) getContainer(ID, player, tile));
|
||||
case RSGui.DESTRUCTOR:
|
||||
return new GuiDestructor((ContainerDestructor) getContainer(ID, player, tile));
|
||||
case RSGui.CONSTRUCTOR:
|
||||
|
||||
@@ -18,7 +18,6 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import refinedstorage.RSItems;
|
||||
import refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||
import refinedstorage.block.EnumFluidStorageType;
|
||||
import refinedstorage.tile.config.IAccessType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -56,11 +55,6 @@ public class ItemFluidStorageDisk extends ItemBase {
|
||||
public int getPriority() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAccessType() {
|
||||
return IAccessType.READ_WRITE;
|
||||
}
|
||||
};
|
||||
|
||||
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) {
|
||||
|
||||
@@ -15,7 +15,6 @@ import net.minecraft.world.World;
|
||||
import refinedstorage.RSItems;
|
||||
import refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||
import refinedstorage.block.EnumItemStorageType;
|
||||
import refinedstorage.tile.config.IAccessType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@@ -68,11 +67,6 @@ public class ItemStorageDisk extends ItemBase {
|
||||
public int getPriority() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAccessType() {
|
||||
return IAccessType.READ_WRITE;
|
||||
}
|
||||
};
|
||||
|
||||
Iterator<Item> it = Item.REGISTRY.iterator();
|
||||
|
||||
@@ -34,6 +34,7 @@ import refinedstorage.api.network.INetworkNodeGraph;
|
||||
import refinedstorage.api.network.IWirelessGridHandler;
|
||||
import refinedstorage.api.network.grid.IFluidGridHandler;
|
||||
import refinedstorage.api.network.grid.IItemGridHandler;
|
||||
import refinedstorage.api.storage.AccessType;
|
||||
import refinedstorage.api.storage.fluid.IFluidStorage;
|
||||
import refinedstorage.api.storage.fluid.IFluidStorageCache;
|
||||
import refinedstorage.api.storage.item.IItemStorage;
|
||||
@@ -61,7 +62,6 @@ import refinedstorage.network.MessageGridFluidDelta;
|
||||
import refinedstorage.network.MessageGridFluidUpdate;
|
||||
import refinedstorage.network.MessageGridItemDelta;
|
||||
import refinedstorage.network.MessageGridItemUpdate;
|
||||
import refinedstorage.tile.config.IAccessType;
|
||||
import refinedstorage.tile.config.IRedstoneConfigurable;
|
||||
import refinedstorage.tile.config.RedstoneMode;
|
||||
import refinedstorage.tile.data.ITileDataProducer;
|
||||
@@ -459,7 +459,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
}
|
||||
}
|
||||
|
||||
itemStorage.rebuild();
|
||||
itemStorage.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -519,13 +519,13 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
}
|
||||
|
||||
int orginalSize = size;
|
||||
int accessType = IAccessType.READ_WRITE;
|
||||
AccessType accessType = AccessType.READ_WRITE;
|
||||
ItemStack remainder = stack;
|
||||
|
||||
for (IItemStorage storage : this.itemStorage.getStorages()) {
|
||||
accessType = storage.getAccessType();
|
||||
|
||||
if (accessType != IAccessType.READ) {
|
||||
if (accessType != AccessType.READ) {
|
||||
remainder = storage.insertItem(remainder, size, simulate);
|
||||
}
|
||||
|
||||
@@ -553,7 +553,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
inserted = orginalSize - remainder.stackSize;
|
||||
}
|
||||
|
||||
if (!simulate && inserted > 0 && accessType != IAccessType.WRITE) {
|
||||
if (!simulate && inserted > 0 && accessType != AccessType.WRITE) {
|
||||
itemStorage.add(ItemHandlerHelper.copyStackWithSize(stack, inserted), false);
|
||||
|
||||
for (int i = 0; i < inserted; ++i) {
|
||||
@@ -587,7 +587,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
for (IItemStorage storage : this.itemStorage.getStorages()) {
|
||||
ItemStack took = null;
|
||||
|
||||
if (storage.getAccessType() != IAccessType.READ) {
|
||||
if (storage.getAccessType() != AccessType.READ) {
|
||||
took = storage.extractItem(stack, requested - received, flags);
|
||||
}
|
||||
|
||||
@@ -625,13 +625,13 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
}
|
||||
|
||||
int orginalSize = size;
|
||||
int accessType = IAccessType.READ_WRITE;
|
||||
AccessType accessType = AccessType.READ_WRITE;
|
||||
FluidStack remainder = stack;
|
||||
|
||||
for (IFluidStorage storage : this.fluidStorage.getStorages()) {
|
||||
accessType = storage.getAccessType();
|
||||
|
||||
if (accessType != IAccessType.READ) {
|
||||
if (accessType != AccessType.READ) {
|
||||
remainder = storage.insertFluid(remainder, size, simulate);
|
||||
}
|
||||
|
||||
@@ -658,7 +658,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
inserted = orginalSize - remainder.amount;
|
||||
}
|
||||
|
||||
if (!simulate && inserted > 0 && accessType != IAccessType.WRITE) {
|
||||
if (!simulate && inserted > 0 && accessType != AccessType.WRITE) {
|
||||
fluidStorage.add(RSUtils.copyStackWithSize(stack, inserted), false);
|
||||
}
|
||||
|
||||
@@ -674,7 +674,8 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
|
||||
for (IFluidStorage storage : this.fluidStorage.getStorages()) {
|
||||
FluidStack took = null;
|
||||
if (storage.getAccessType() != IAccessType.READ) {
|
||||
|
||||
if (storage.getAccessType() != AccessType.READ) {
|
||||
took = storage.extractFluid(stack, requested - received, flags);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import refinedstorage.RS;
|
||||
import refinedstorage.RSItems;
|
||||
import refinedstorage.RSUtils;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
import refinedstorage.api.storage.AccessType;
|
||||
import refinedstorage.api.storage.fluid.IFluidStorage;
|
||||
import refinedstorage.api.storage.fluid.IFluidStorageProvider;
|
||||
import refinedstorage.api.storage.item.IItemStorage;
|
||||
@@ -66,7 +67,7 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAccessType() {
|
||||
public AccessType getAccessType() {
|
||||
return accessType;
|
||||
}
|
||||
}
|
||||
@@ -98,7 +99,7 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAccessType() {
|
||||
public AccessType getAccessType() {
|
||||
return accessType;
|
||||
}
|
||||
}
|
||||
@@ -108,7 +109,6 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
private static final String NBT_MODE = "Mode";
|
||||
private static final String NBT_TYPE = "Type";
|
||||
private static final String NBT_VOID_EXCESS = "VoidExcess";
|
||||
private static final String NBT_ACCESS_TYPE = "AccessType";
|
||||
|
||||
private ItemHandlerBasic disks = new ItemHandlerBasic(8, this, IItemValidator.STORAGE_DISK) {
|
||||
@Override
|
||||
@@ -119,8 +119,8 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
RSUtils.constructFromDrive(getStackInSlot(slot), slot, itemStorages, fluidStorages, ItemStorage::new, FluidStorage::new);
|
||||
|
||||
if (network != null) {
|
||||
network.getItemStorageCache().rebuild();
|
||||
network.getFluidStorageCache().rebuild();
|
||||
network.getItemStorageCache().invalidate();
|
||||
network.getFluidStorageCache().invalidate();
|
||||
}
|
||||
|
||||
if (worldObj != null) {
|
||||
@@ -149,7 +149,7 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
private ItemStorage itemStorages[] = new ItemStorage[8];
|
||||
private FluidStorage fluidStorages[] = new FluidStorage[8];
|
||||
|
||||
private int accessType = IAccessType.READ_WRITE;
|
||||
private AccessType accessType = AccessType.READ_WRITE;
|
||||
private int priority = 0;
|
||||
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
|
||||
private int mode = IFilterable.WHITELIST;
|
||||
@@ -200,8 +200,8 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
public void onConnectionChange(INetworkMaster network, boolean state) {
|
||||
super.onConnectionChange(network, state);
|
||||
|
||||
network.getItemStorageCache().rebuild();
|
||||
network.getFluidStorageCache().rebuild();
|
||||
network.getItemStorageCache().invalidate();
|
||||
network.getFluidStorageCache().invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -250,9 +250,7 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
voidExcess = tag.getBoolean(NBT_VOID_EXCESS);
|
||||
}
|
||||
|
||||
if (tag.hasKey(NBT_ACCESS_TYPE)) {
|
||||
accessType = tag.getInteger(NBT_ACCESS_TYPE);
|
||||
}
|
||||
accessType = RSUtils.readAccessType(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -278,7 +276,8 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
tag.setInteger(NBT_MODE, mode);
|
||||
tag.setInteger(NBT_TYPE, type);
|
||||
tag.setBoolean(NBT_VOID_EXCESS, voidExcess);
|
||||
tag.setInteger(NBT_ACCESS_TYPE, accessType);
|
||||
|
||||
RSUtils.writeAccessType(tag, accessType);
|
||||
|
||||
return tag;
|
||||
}
|
||||
@@ -353,16 +352,16 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAccessType() {
|
||||
public AccessType getAccessType() {
|
||||
return accessType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAccessType(int value) {
|
||||
accessType = value;
|
||||
public void setAccessType(AccessType value) {
|
||||
this.accessType = value;
|
||||
|
||||
network.getFluidStorageCache().rebuild();
|
||||
network.getItemStorageCache().rebuild();
|
||||
network.getFluidStorageCache().invalidate();
|
||||
network.getItemStorageCache().invalidate();
|
||||
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import refinedstorage.inventory.ItemHandlerBasic;
|
||||
import refinedstorage.inventory.ItemHandlerFluid;
|
||||
import refinedstorage.inventory.ItemHandlerUpgrade;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import refinedstorage.tile.config.IAccessType;
|
||||
import refinedstorage.tile.config.IComparable;
|
||||
import refinedstorage.tile.config.IFilterable;
|
||||
import refinedstorage.tile.config.IType;
|
||||
@@ -128,11 +127,6 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
||||
|
||||
return super.extractItem(stack, size, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAccessType() {
|
||||
return IAccessType.READ_WRITE;
|
||||
}
|
||||
}
|
||||
|
||||
public class FluidStorage extends FluidStorageNBT {
|
||||
@@ -162,11 +156,6 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
||||
|
||||
return super.extractFluid(stack, size, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAccessType() {
|
||||
return IAccessType.READ_WRITE;
|
||||
}
|
||||
}
|
||||
|
||||
private ItemHandlerBasic itemFilters = new ItemHandlerBasic(9, this);
|
||||
|
||||
@@ -7,6 +7,7 @@ import refinedstorage.RS;
|
||||
import refinedstorage.RSBlocks;
|
||||
import refinedstorage.RSUtils;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
import refinedstorage.api.storage.AccessType;
|
||||
import refinedstorage.api.storage.fluid.IFluidStorage;
|
||||
import refinedstorage.api.storage.fluid.IFluidStorageProvider;
|
||||
import refinedstorage.api.util.IComparer;
|
||||
@@ -60,7 +61,7 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider,
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAccessType() {
|
||||
public AccessType getAccessType() {
|
||||
return accessType;
|
||||
}
|
||||
}
|
||||
@@ -71,7 +72,6 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider,
|
||||
private static final String NBT_COMPARE = "Compare";
|
||||
private static final String NBT_MODE = "Mode";
|
||||
private static final String NBT_VOID_EXCESS = "VoidExcess";
|
||||
private static final String NBT_ACCESS_TYPE = "AccessType";
|
||||
|
||||
private ItemHandlerFluid filters = new ItemHandlerFluid(9, this);
|
||||
|
||||
@@ -81,7 +81,7 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider,
|
||||
|
||||
private EnumFluidStorageType type;
|
||||
|
||||
private int accessType = IAccessType.READ_WRITE;
|
||||
private AccessType accessType = AccessType.READ_WRITE;
|
||||
private int priority = 0;
|
||||
private int compare = IComparer.COMPARE_NBT;
|
||||
private int mode = IFilterable.WHITELIST;
|
||||
@@ -113,7 +113,7 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider,
|
||||
storage = new FluidStorage();
|
||||
|
||||
if (network != null) {
|
||||
network.getFluidStorageCache().rebuild();
|
||||
network.getFluidStorageCache().invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider,
|
||||
public void onConnectionChange(INetworkMaster network, boolean state) {
|
||||
super.onConnectionChange(network, state);
|
||||
|
||||
network.getFluidStorageCache().rebuild();
|
||||
network.getFluidStorageCache().invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -164,9 +164,7 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider,
|
||||
voidExcess = tag.getBoolean(NBT_VOID_EXCESS);
|
||||
}
|
||||
|
||||
if (tag.hasKey(NBT_ACCESS_TYPE)) {
|
||||
accessType = tag.getInteger(NBT_ACCESS_TYPE);
|
||||
}
|
||||
accessType = RSUtils.readAccessType(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -185,7 +183,8 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider,
|
||||
tag.setInteger(NBT_COMPARE, compare);
|
||||
tag.setInteger(NBT_MODE, mode);
|
||||
tag.setBoolean(NBT_VOID_EXCESS, voidExcess);
|
||||
tag.setInteger(NBT_ACCESS_TYPE, accessType);
|
||||
|
||||
RSUtils.writeAccessType(tag, accessType);
|
||||
|
||||
return tag;
|
||||
}
|
||||
@@ -284,15 +283,15 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider,
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAccessType() {
|
||||
public AccessType getAccessType() {
|
||||
return accessType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAccessType(int value) {
|
||||
accessType = value;
|
||||
public void setAccessType(AccessType value) {
|
||||
this.accessType = value;
|
||||
|
||||
network.getFluidStorageCache().rebuild();
|
||||
network.getFluidStorageCache().invalidate();
|
||||
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import refinedstorage.RS;
|
||||
import refinedstorage.RSBlocks;
|
||||
import refinedstorage.RSUtils;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
import refinedstorage.api.storage.AccessType;
|
||||
import refinedstorage.api.storage.item.IItemStorage;
|
||||
import refinedstorage.api.storage.item.IItemStorageProvider;
|
||||
import refinedstorage.api.util.IComparer;
|
||||
@@ -61,7 +62,7 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAccessType() {
|
||||
public AccessType getAccessType() {
|
||||
return accessType;
|
||||
}
|
||||
}
|
||||
@@ -81,7 +82,7 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
|
||||
|
||||
private EnumItemStorageType type;
|
||||
|
||||
private int accessType = IAccessType.READ_WRITE;
|
||||
private AccessType accessType = AccessType.READ_WRITE;
|
||||
private int priority = 0;
|
||||
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
|
||||
private int mode = IFilterable.WHITELIST;
|
||||
@@ -113,7 +114,7 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
|
||||
storage = new ItemStorage();
|
||||
|
||||
if (network != null) {
|
||||
network.getItemStorageCache().rebuild();
|
||||
network.getItemStorageCache().invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,7 +129,7 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
|
||||
public void onConnectionChange(INetworkMaster network, boolean state) {
|
||||
super.onConnectionChange(network, state);
|
||||
|
||||
network.getItemStorageCache().rebuild();
|
||||
network.getItemStorageCache().invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -163,6 +164,8 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
|
||||
if (tag.hasKey(NBT_VOID_EXCESS)) {
|
||||
voidExcess = tag.getBoolean(NBT_VOID_EXCESS);
|
||||
}
|
||||
|
||||
RSUtils.writeAccessType(tag, accessType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -182,6 +185,8 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
|
||||
tag.setInteger(NBT_MODE, mode);
|
||||
tag.setBoolean(NBT_VOID_EXCESS, voidExcess);
|
||||
|
||||
accessType = RSUtils.readAccessType(tag);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -291,15 +296,15 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAccessType() {
|
||||
public AccessType getAccessType() {
|
||||
return accessType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAccessType(int value) {
|
||||
accessType = value;
|
||||
public void setAccessType(AccessType value) {
|
||||
this.accessType = value;
|
||||
|
||||
network.getItemStorageCache().rebuild();
|
||||
network.getItemStorageCache().invalidate();
|
||||
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package refinedstorage.tile.config;
|
||||
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import refinedstorage.RSUtils;
|
||||
import refinedstorage.api.storage.AccessType;
|
||||
import refinedstorage.tile.data.ITileDataConsumer;
|
||||
import refinedstorage.tile.data.ITileDataProducer;
|
||||
import refinedstorage.tile.data.TileDataParameter;
|
||||
@@ -16,19 +18,17 @@ public interface IAccessType {
|
||||
return new TileDataParameter<>(DataSerializers.VARINT, READ_WRITE, new ITileDataProducer<Integer, T>() {
|
||||
@Override
|
||||
public Integer getValue(T tile) {
|
||||
return ((IAccessType) tile).getAccessType();
|
||||
return ((IAccessType) tile).getAccessType().getId();
|
||||
}
|
||||
}, new ITileDataConsumer<Integer, T>() {
|
||||
@Override
|
||||
public void setValue(T tile, Integer value) {
|
||||
if (value == READ || value == WRITE || value == READ_WRITE) {
|
||||
((IAccessType) tile).setAccessType(value);
|
||||
}
|
||||
((IAccessType) tile).setAccessType(RSUtils.getAccessType(value));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
int getAccessType();
|
||||
AccessType getAccessType();
|
||||
|
||||
void setAccessType(int accessType);
|
||||
void setAccessType(AccessType accessType);
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||
import refinedstorage.RSUtils;
|
||||
import refinedstorage.api.storage.AccessType;
|
||||
import refinedstorage.api.storage.fluid.IFluidStorage;
|
||||
import refinedstorage.api.util.IComparer;
|
||||
import refinedstorage.apiimpl.API;
|
||||
@@ -80,7 +81,7 @@ public class FluidStorageExternal implements IFluidStorage {
|
||||
return externalStorage.getPriority();
|
||||
}
|
||||
|
||||
public int getAccessType() {
|
||||
public AccessType getAccessType() {
|
||||
return externalStorage.getAccessType();
|
||||
}
|
||||
|
||||
@@ -89,7 +90,7 @@ public class FluidStorageExternal implements IFluidStorage {
|
||||
|
||||
if (cache == null) {
|
||||
cache = RSUtils.copyStack(stack);
|
||||
} else if (!API.instance().getComparer().isEqual(stack, cache, IComparer.COMPARE_NBT | API.instance().getComparer().COMPARE_QUANTITY)) {
|
||||
} else if (!API.instance().getComparer().isEqual(stack, cache, IComparer.COMPARE_NBT | IComparer.COMPARE_QUANTITY)) {
|
||||
cache = RSUtils.copyStack(stack);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -3,6 +3,7 @@ package refinedstorage.tile.externalstorage;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
|
||||
import refinedstorage.api.storage.AccessType;
|
||||
import refinedstorage.apiimpl.API;
|
||||
import refinedstorage.tile.config.IFilterable;
|
||||
|
||||
@@ -112,7 +113,7 @@ public class ItemStorageDSU extends ItemStorageExternal {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAccessType() {
|
||||
public AccessType getAccessType() {
|
||||
return externalStorage.getAccessType();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import refinedstorage.api.storage.AccessType;
|
||||
import refinedstorage.apiimpl.API;
|
||||
import refinedstorage.tile.config.IFilterable;
|
||||
|
||||
@@ -114,7 +115,7 @@ public class ItemStorageDrawer extends ItemStorageExternal {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAccessType() {
|
||||
public AccessType getAccessType() {
|
||||
return externalStorage.getAccessType();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package refinedstorage.tile.externalstorage;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import refinedstorage.api.storage.AccessType;
|
||||
import refinedstorage.apiimpl.API;
|
||||
import refinedstorage.tile.config.IFilterable;
|
||||
|
||||
@@ -95,7 +96,7 @@ public class ItemStorageItemHandler extends ItemStorageExternal {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAccessType() {
|
||||
public AccessType getAccessType() {
|
||||
return externalStorage.getAccessType();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
|
||||
import refinedstorage.RS;
|
||||
import refinedstorage.RSUtils;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
import refinedstorage.api.storage.AccessType;
|
||||
import refinedstorage.api.storage.fluid.IFluidStorage;
|
||||
import refinedstorage.api.storage.fluid.IFluidStorageProvider;
|
||||
import refinedstorage.api.storage.item.IItemStorage;
|
||||
@@ -74,7 +75,6 @@ public class TileExternalStorage extends TileMultipartNode implements IItemStora
|
||||
private static final String NBT_COMPARE = "Compare";
|
||||
private static final String NBT_MODE = "Mode";
|
||||
private static final String NBT_TYPE = "Type";
|
||||
private static final String NBT_ACCESS_TYPE = "AccessType";
|
||||
|
||||
private ItemHandlerBasic itemFilters = new ItemHandlerBasic(9, this);
|
||||
private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, this);
|
||||
@@ -83,7 +83,7 @@ public class TileExternalStorage extends TileMultipartNode implements IItemStora
|
||||
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
|
||||
private int mode = IFilterable.WHITELIST;
|
||||
private int type = IType.ITEMS;
|
||||
private int accessType = IAccessType.READ_WRITE;
|
||||
private AccessType accessType = AccessType.READ_WRITE;
|
||||
|
||||
private List<ItemStorageExternal> itemStorages = new ArrayList<>();
|
||||
private List<FluidStorageExternal> fluidStorages = new ArrayList<>();
|
||||
@@ -120,8 +120,8 @@ public class TileExternalStorage extends TileMultipartNode implements IItemStora
|
||||
|
||||
updateStorage(network);
|
||||
|
||||
network.getItemStorageCache().rebuild();
|
||||
network.getFluidStorageCache().rebuild();
|
||||
network.getItemStorageCache().invalidate();
|
||||
network.getFluidStorageCache().invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,11 +142,11 @@ public class TileExternalStorage extends TileMultipartNode implements IItemStora
|
||||
}
|
||||
|
||||
if (itemChangeDetected) {
|
||||
network.getItemStorageCache().rebuild();
|
||||
network.getItemStorageCache().invalidate();
|
||||
}
|
||||
|
||||
if (fluidChangeDetected) {
|
||||
network.getFluidStorageCache().rebuild();
|
||||
network.getFluidStorageCache().invalidate();
|
||||
}
|
||||
|
||||
if (getFacingTile() instanceof IDrawerGroup && lastDrawerCount != ((IDrawerGroup) getFacingTile()).getDrawerCount()) {
|
||||
@@ -182,9 +182,7 @@ public class TileExternalStorage extends TileMultipartNode implements IItemStora
|
||||
type = tag.getInteger(NBT_TYPE);
|
||||
}
|
||||
|
||||
if (tag.hasKey(NBT_ACCESS_TYPE)) {
|
||||
accessType = tag.getInteger(NBT_ACCESS_TYPE);
|
||||
}
|
||||
accessType = RSUtils.readAccessType(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -198,7 +196,8 @@ public class TileExternalStorage extends TileMultipartNode implements IItemStora
|
||||
tag.setInteger(NBT_COMPARE, compare);
|
||||
tag.setInteger(NBT_MODE, mode);
|
||||
tag.setInteger(NBT_TYPE, type);
|
||||
tag.setInteger(NBT_ACCESS_TYPE, accessType);
|
||||
|
||||
RSUtils.writeAccessType(tag, accessType);
|
||||
|
||||
return tag;
|
||||
}
|
||||
@@ -273,8 +272,8 @@ public class TileExternalStorage extends TileMultipartNode implements IItemStora
|
||||
}
|
||||
}
|
||||
|
||||
network.getItemStorageCache().rebuild();
|
||||
network.getFluidStorageCache().rebuild();
|
||||
network.getItemStorageCache().invalidate();
|
||||
network.getFluidStorageCache().invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -338,17 +337,16 @@ public class TileExternalStorage extends TileMultipartNode implements IItemStora
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAccessType() {
|
||||
public AccessType getAccessType() {
|
||||
return accessType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAccessType(int type) {
|
||||
accessType = type;
|
||||
public void setAccessType(AccessType type) {
|
||||
this.accessType = type;
|
||||
|
||||
// Refresh item/fluid cache
|
||||
network.getItemStorageCache().rebuild();
|
||||
network.getFluidStorageCache().rebuild();
|
||||
network.getItemStorageCache().invalidate();
|
||||
network.getFluidStorageCache().invalidate();
|
||||
|
||||
markDirty();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user