Rename and reorganize some API packages and classes.

This commit is contained in:
raoulvdberge
2019-10-09 14:19:44 +02:00
parent 68a568e10e
commit 4f4aaf420f
55 changed files with 387 additions and 360 deletions

View File

@@ -11,8 +11,8 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskdrive.DiskDriveNetworkNode; import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskdrive.DiskDriveNetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.storage.FluidStorageType; import com.raoulvdberge.refinedstorage.apiimpl.storage.FluidStorageType;
import com.raoulvdberge.refinedstorage.apiimpl.storage.ItemStorageType; import com.raoulvdberge.refinedstorage.apiimpl.storage.ItemStorageType;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFactoryFluid; import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.factory.FluidStorageDiskFactory;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFactoryItem; import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.factory.ItemStorageDiskFactory;
import com.raoulvdberge.refinedstorage.block.*; import com.raoulvdberge.refinedstorage.block.*;
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability; import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
import com.raoulvdberge.refinedstorage.config.ServerConfig; import com.raoulvdberge.refinedstorage.config.ServerConfig;
@@ -85,8 +85,8 @@ public final class RS {
MinecraftForge.EVENT_BUS.register(new NetworkNodeListener()); MinecraftForge.EVENT_BUS.register(new NetworkNodeListener());
API.instance().getStorageDiskRegistry().add(StorageDiskFactoryItem.ID, new StorageDiskFactoryItem()); API.instance().getStorageDiskRegistry().add(ItemStorageDiskFactory.ID, new ItemStorageDiskFactory());
API.instance().getStorageDiskRegistry().add(StorageDiskFactoryFluid.ID, new StorageDiskFactoryFluid()); API.instance().getStorageDiskRegistry().add(FluidStorageDiskFactory.ID, new FluidStorageDiskFactory());
API.instance().getNetworkNodeRegistry().add(DiskDriveNetworkNode.ID, (tag, world, pos) -> readAndReturn(tag, new DiskDriveNetworkNode(world, pos))); API.instance().getNetworkNodeRegistry().add(DiskDriveNetworkNode.ID, (tag, world, pos) -> readAndReturn(tag, new DiskDriveNetworkNode(world, pos)));
API.instance().getNetworkNodeRegistry().add(CableNetworkNode.ID, (tag, world, pos) -> readAndReturn(tag, new CableNetworkNode(world, pos))); API.instance().getNetworkNodeRegistry().add(CableNetworkNode.ID, (tag, world, pos) -> readAndReturn(tag, new CableNetworkNode(world, pos)));

View File

@@ -8,8 +8,8 @@ import com.raoulvdberge.refinedstorage.api.network.item.INetworkItemHandler;
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterManager; import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterManager;
import com.raoulvdberge.refinedstorage.api.network.security.ISecurityManager; import com.raoulvdberge.refinedstorage.api.network.security.ISecurityManager;
import com.raoulvdberge.refinedstorage.api.storage.IStorage; import com.raoulvdberge.refinedstorage.api.storage.IStorage;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
import com.raoulvdberge.refinedstorage.api.storage.IStorageTracker; import com.raoulvdberge.refinedstorage.api.storage.tracker.IStorageTracker;
import com.raoulvdberge.refinedstorage.api.util.Action; import com.raoulvdberge.refinedstorage.api.util.Action;
import com.raoulvdberge.refinedstorage.api.util.IComparer; import com.raoulvdberge.refinedstorage.api.util.IComparer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View File

@@ -2,8 +2,8 @@ package com.raoulvdberge.refinedstorage.api.network.grid;
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler; import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler; import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCacheListener; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
import com.raoulvdberge.refinedstorage.api.util.IFilter; import com.raoulvdberge.refinedstorage.api.util.IFilter;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity;

View File

@@ -1,6 +1,8 @@
package com.raoulvdberge.refinedstorage.api.storage; package com.raoulvdberge.refinedstorage.api.storage.cache;
import com.raoulvdberge.refinedstorage.api.network.INetwork; import com.raoulvdberge.refinedstorage.api.network.INetwork;
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
import com.raoulvdberge.refinedstorage.api.util.IStackList; import com.raoulvdberge.refinedstorage.api.util.IStackList;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;

View File

@@ -1,4 +1,4 @@
package com.raoulvdberge.refinedstorage.api.storage; package com.raoulvdberge.refinedstorage.api.storage.cache;
import com.raoulvdberge.refinedstorage.api.util.StackListResult; import com.raoulvdberge.refinedstorage.api.util.StackListResult;

View File

@@ -4,7 +4,7 @@ import javax.annotation.Nullable;
import java.util.UUID; import java.util.UUID;
/** /**
* Used to send requests to the server to get storage disk information ({@link IStorageDiskSyncData}). * Used to send requests to the server to get storage disk information ({@link StorageDiskSyncData}).
*/ */
public interface IStorageDiskSync { public interface IStorageDiskSync {
/** /**
@@ -15,7 +15,7 @@ public interface IStorageDiskSync {
* @return the disk data, or null if there was no response from the server yet * @return the disk data, or null if there was no response from the server yet
*/ */
@Nullable @Nullable
IStorageDiskSyncData getData(UUID id); StorageDiskSyncData getData(UUID id);
/** /**
* Sends a request to the server to get information from a storage disk. * Sends a request to the server to get information from a storage disk.

View File

@@ -1,16 +0,0 @@
package com.raoulvdberge.refinedstorage.api.storage.disk;
/**
* Contains storage disk data.
*/
public interface IStorageDiskSyncData {
/**
* @return the amount stored
*/
int getStored();
/**
* @return the capacity, or -1 if infinite capacity
*/
int getCapacity();
}

View File

@@ -1,8 +1,9 @@
package com.raoulvdberge.refinedstorage.apiimpl.storage.disk; package com.raoulvdberge.refinedstorage.api.storage.disk;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSyncData; /**
* Contains synced info about a storage disk.
public class StorageDiskSyncData implements IStorageDiskSyncData { */
public class StorageDiskSyncData {
private int stored; private int stored;
private int capacity; private int capacity;
@@ -11,12 +12,16 @@ public class StorageDiskSyncData implements IStorageDiskSyncData {
this.capacity = capacity; this.capacity = capacity;
} }
@Override /**
* @return the amount stored
*/
public int getStored() { public int getStored() {
return stored; return stored;
} }
@Override /**
* @return the capacity
*/
public int getCapacity() { public int getCapacity() {
return capacity; return capacity;
} }

View File

@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.api.storage.externalstorage;
import com.raoulvdberge.refinedstorage.api.network.INetwork; import com.raoulvdberge.refinedstorage.api.network.INetwork;
import com.raoulvdberge.refinedstorage.api.storage.IStorage; import com.raoulvdberge.refinedstorage.api.storage.IStorage;
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
/** /**
* An external storage handler. * An external storage handler.
@@ -10,9 +11,9 @@ import com.raoulvdberge.refinedstorage.api.storage.IStorage;
*/ */
public interface IStorageExternal<T> extends IStorage<T> { public interface IStorageExternal<T> extends IStorage<T> {
/** /**
* For storage disks and blocks, the network detects changes and updates the {@link com.raoulvdberge.refinedstorage.api.storage.IStorageCache} accordingly. * For storage disks and blocks, the network detects changes and updates the {@link IStorageCache} accordingly.
* However, for blocks connected to an external storage the external storage itself is responsible for bookkeeping the changes * However, for blocks connected to an external storage the external storage itself is responsible for bookkeeping the changes
* and submitting them to the {@link com.raoulvdberge.refinedstorage.api.storage.IStorageCache}. That bookkeeping is supposed to happen in this method. * and submitting them to the {@link IStorageCache}. That bookkeeping is supposed to happen in this method.
* <p> * <p>
* It's called every external storage tick. * It's called every external storage tick.
* *

View File

@@ -1,4 +1,4 @@
package com.raoulvdberge.refinedstorage.api.storage; package com.raoulvdberge.refinedstorage.api.storage.tracker;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@@ -8,18 +8,6 @@ import javax.annotation.Nullable;
* Keeps track of when a stack is changed in the system. * Keeps track of when a stack is changed in the system.
*/ */
public interface IStorageTracker<T> { public interface IStorageTracker<T> {
interface IStorageTrackerEntry {
/**
* @return the modification time
*/
long getTime();
/**
* @return the name of the player who last modified the stack
*/
String getName();
}
/** /**
* Updates the storage tracker entry for a stack, changing it's player name and modification time. * Updates the storage tracker entry for a stack, changing it's player name and modification time.
* *
@@ -33,5 +21,5 @@ public interface IStorageTracker<T> {
* @return the entry, or null if the stack hasn't been modified yet * @return the entry, or null if the stack hasn't been modified yet
*/ */
@Nullable @Nullable
IStorageTrackerEntry get(T stack); StorageTrackerEntry get(T stack);
} }

View File

@@ -0,0 +1,28 @@
package com.raoulvdberge.refinedstorage.api.storage.tracker;
/**
* Represents a storage tracker entry.
*/
public class StorageTrackerEntry {
private final long time;
private final String name;
public StorageTrackerEntry(long time, String name) {
this.time = time;
this.name = name;
}
/**
* @return the modification time
*/
public long getTime() {
return time;
}
/**
* @return the name of the player who modified this item
*/
public String getName() {
return name;
}
}

View File

@@ -2,6 +2,11 @@ package com.raoulvdberge.refinedstorage.api.util;
import java.util.UUID; import java.util.UUID;
/**
* Contains the result of a stack list manipulation.
*
* @param <T> the stack type
*/
public class StackListResult<T> { public class StackListResult<T> {
private T stack; private T stack;
private UUID id; private UUID id;
@@ -13,14 +18,23 @@ public class StackListResult<T> {
this.change = change; this.change = change;
} }
/**
* @return the stack
*/
public T getStack() { public T getStack() {
return stack; return stack;
} }
/**
* @return the id of the {@link StackListEntry}
*/
public UUID getId() { public UUID getId() {
return id; return id;
} }
/**
* @return the change/delta value, is positive if this was a stack addition, or negative if it's a stack removal
*/
public int getChange() { public int getChange() {
return change; return change;
} }

View File

@@ -210,13 +210,13 @@ public class API implements IRSAPI {
@Override @Override
@Nonnull @Nonnull
public IStorageDisk<ItemStack> createDefaultItemDisk(ServerWorld world, int capacity) { public IStorageDisk<ItemStack> createDefaultItemDisk(ServerWorld world, int capacity) {
return new StorageDiskItem(world, capacity); return new ItemStorageDisk(world, capacity);
} }
@Override @Override
@Nonnull @Nonnull
public IStorageDisk<FluidStack> createDefaultFluidDisk(ServerWorld world, int capacity) { public IStorageDisk<FluidStack> createDefaultFluidDisk(ServerWorld world, int capacity) {
return new StorageDiskFluid(world, capacity); return new FluidStorageDisk(world, capacity);
} }
@Override @Override

View File

@@ -20,10 +20,10 @@ import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor.Craf
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementItemRender; import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementItemRender;
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewElementFluidStack; import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewElementFluidStack;
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewElementItemStack; import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewElementItemStack;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFactoryFluid; import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.FluidStorageDisk;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFactoryItem; import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.ItemStorageDisk;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFluid; import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.factory.FluidStorageDiskFactory;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskItem; import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.factory.ItemStorageDiskFactory;
import com.raoulvdberge.refinedstorage.util.StackUtils; import com.raoulvdberge.refinedstorage.util.StackUtils;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
@@ -103,8 +103,8 @@ public class CraftingTask implements ICraftingTask {
this.quantity = quantity; this.quantity = quantity;
this.pattern = pattern; this.pattern = pattern;
this.internalStorage = new StorageDiskItem(null, -1); this.internalStorage = new ItemStorageDisk(null, -1);
this.internalFluidStorage = new StorageDiskFluid(null, -1); this.internalFluidStorage = new FluidStorageDisk(null, -1);
} }
public CraftingTask(INetwork network, CompoundNBT tag) throws CraftingTaskReadException { public CraftingTask(INetwork network, CompoundNBT tag) throws CraftingTaskReadException {
@@ -121,8 +121,8 @@ public class CraftingTask implements ICraftingTask {
this.totalSteps = tag.getInt(NBT_TOTAL_STEPS); this.totalSteps = tag.getInt(NBT_TOTAL_STEPS);
} }
StorageDiskFactoryItem factoryItem = new StorageDiskFactoryItem(); ItemStorageDiskFactory factoryItem = new ItemStorageDiskFactory();
StorageDiskFactoryFluid factoryFluid = new StorageDiskFactoryFluid(); FluidStorageDiskFactory factoryFluid = new FluidStorageDiskFactory();
this.internalStorage = factoryItem.createFromNbt(null, tag.getCompound(NBT_INTERNAL_STORAGE)); this.internalStorage = factoryItem.createFromNbt(null, tag.getCompound(NBT_INTERNAL_STORAGE));
this.internalFluidStorage = factoryFluid.createFromNbt(null, tag.getCompound(NBT_INTERNAL_FLUID_STORAGE)); this.internalFluidStorage = factoryFluid.createFromNbt(null, tag.getCompound(NBT_INTERNAL_FLUID_STORAGE));

View File

@@ -6,14 +6,14 @@ import com.raoulvdberge.refinedstorage.api.network.grid.*;
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler; import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler; import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler;
import com.raoulvdberge.refinedstorage.api.network.security.Permission; import com.raoulvdberge.refinedstorage.api.network.security.Permission;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCacheListener; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
import com.raoulvdberge.refinedstorage.api.util.Action; import com.raoulvdberge.refinedstorage.api.util.Action;
import com.raoulvdberge.refinedstorage.api.util.IComparer; import com.raoulvdberge.refinedstorage.api.util.IComparer;
import com.raoulvdberge.refinedstorage.api.util.IFilter; import com.raoulvdberge.refinedstorage.api.util.IFilter;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheListenerGridFluid; import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.listener.FluidGridStorageCacheListener;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheListenerGridItem; import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.listener.ItemGridStorageCacheListener;
import com.raoulvdberge.refinedstorage.block.NodeBlock; import com.raoulvdberge.refinedstorage.block.NodeBlock;
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory; import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase; import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase;
@@ -235,7 +235,7 @@ public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, I
@Override @Override
public IStorageCacheListener createListener(ServerPlayerEntity player) { public IStorageCacheListener createListener(ServerPlayerEntity player) {
return getGridType() == GridType.FLUID ? new StorageCacheListenerGridFluid(player, network) : new StorageCacheListenerGridItem(player, network); return getGridType() == GridType.FLUID ? new FluidGridStorageCacheListener(player, network) : new ItemGridStorageCacheListener(player, network);
} }
@Nullable @Nullable

View File

@@ -12,8 +12,8 @@ import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExter
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.cover.CoverManager; import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheFluid; import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.FluidStorageCache;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheItem; import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.ItemStorageCache;
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory; import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase; import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.listener.ListenerNetworkNode; import com.raoulvdberge.refinedstorage.inventory.listener.ListenerNetworkNode;
@@ -245,8 +245,8 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
} }
} }
network.getNodeGraph().runActionWhenPossible(StorageCacheItem.INVALIDATE); network.getNodeGraph().runActionWhenPossible(ItemStorageCache.INVALIDATE);
network.getNodeGraph().runActionWhenPossible(StorageCacheFluid.INVALIDATE); network.getNodeGraph().runActionWhenPossible(FluidStorageCache.INVALIDATE);
} }
@Override @Override

View File

@@ -10,8 +10,8 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerCon
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider;
import com.raoulvdberge.refinedstorage.api.util.IComparer; import com.raoulvdberge.refinedstorage.api.util.IComparer;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode; import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheFluid; import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.FluidStorageCache;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheItem; import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.ItemStorageCache;
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory; import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase; import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.listener.ListenerNetworkNode; import com.raoulvdberge.refinedstorage.inventory.listener.ListenerNetworkNode;
@@ -162,8 +162,8 @@ public class DiskDriveNetworkNode extends NetworkNode implements IStorageProvide
public void onConnectedStateChange(INetwork network, boolean state) { public void onConnectedStateChange(INetwork network, boolean state) {
super.onConnectedStateChange(network, state); super.onConnectedStateChange(network, state);
network.getNodeGraph().runActionWhenPossible(StorageCacheItem.INVALIDATE); network.getNodeGraph().runActionWhenPossible(ItemStorageCache.INVALIDATE);
network.getNodeGraph().runActionWhenPossible(StorageCacheFluid.INVALIDATE); network.getNodeGraph().runActionWhenPossible(FluidStorageCache.INVALIDATE);
WorldUtils.updateBlock(world, pos); WorldUtils.updateBlock(world, pos);
} }

View File

@@ -12,7 +12,7 @@ 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.IStorageScreen; import com.raoulvdberge.refinedstorage.apiimpl.network.node.IStorageScreen;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode; import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheFluid; import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.FluidStorageCache;
import com.raoulvdberge.refinedstorage.block.BlockFluidStorage; import com.raoulvdberge.refinedstorage.block.BlockFluidStorage;
import com.raoulvdberge.refinedstorage.block.enums.FluidStorageType; import com.raoulvdberge.refinedstorage.block.enums.FluidStorageType;
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory; import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory;
@@ -69,7 +69,7 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IStorageScre
public void onConnectedStateChange(INetwork network, boolean state) { public void onConnectedStateChange(INetwork network, boolean state) {
super.onConnectedStateChange(network, state); super.onConnectedStateChange(network, state);
network.getNodeGraph().runActionWhenPossible(StorageCacheFluid.INVALIDATE); network.getNodeGraph().runActionWhenPossible(FluidStorageCache.INVALIDATE);
} }
@Override @Override

View File

@@ -12,7 +12,7 @@ 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.IStorageScreen; import com.raoulvdberge.refinedstorage.apiimpl.network.node.IStorageScreen;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode; import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheItem; import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.ItemStorageCache;
import com.raoulvdberge.refinedstorage.block.BlockStorage; import com.raoulvdberge.refinedstorage.block.BlockStorage;
import com.raoulvdberge.refinedstorage.block.enums.ItemStorageType; import com.raoulvdberge.refinedstorage.block.enums.ItemStorageType;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase; import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase;
@@ -69,7 +69,7 @@ public class NetworkNodeStorage extends NetworkNode implements IStorageScreen, I
public void onConnectedStateChange(INetwork network, boolean state) { public void onConnectedStateChange(INetwork network, boolean state) {
super.onConnectedStateChange(network, state); super.onConnectedStateChange(network, state);
network.getNodeGraph().runActionWhenPossible(StorageCacheItem.INVALIDATE); network.getNodeGraph().runActionWhenPossible(ItemStorageCache.INVALIDATE);
} }
@Override @Override

View File

@@ -1,31 +0,0 @@
package com.raoulvdberge.refinedstorage.apiimpl.storage;
import com.raoulvdberge.refinedstorage.api.storage.IStorageTracker;
import io.netty.buffer.ByteBuf;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.common.network.ByteBufUtils;
public class StorageTrackerEntry implements IStorageTracker.IStorageTrackerEntry {
private long time;
private String name;
public StorageTrackerEntry(long time, String name) {
this.time = time;
this.name = name;
}
public StorageTrackerEntry(PacketBuffer buf) {
this.time = buf.readLong();
this.name = buf.readString();
}
@Override
public long getTime() {
return time;
}
@Override
public String getName() {
return name;
}
}

View File

@@ -1,79 +0,0 @@
package com.raoulvdberge.refinedstorage.apiimpl.storage;
import com.raoulvdberge.refinedstorage.api.storage.IStorageTracker;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraftforge.fluids.FluidStack;
import java.util.HashMap;
import java.util.Map;
public class StorageTrackerFluid implements IStorageTracker<FluidStack> {
private static final String NBT_STACK = "Stack";
private static final String NBT_NAME = "Name";
private static final String NBT_TIME = "Time";
private Map<FluidStack, IStorageTrackerEntry> changes = new HashMap<>(); // TODO broken
/*
private Map<FluidStack, IStorageTrackerEntry> changes = new TCustomHashMap<>(new HashingStrategy<FluidStack>() {
@Override
public int computeHashCode(FluidStack stack) {
return API.instance().getFluidStackHashCode(stack);
}
@Override
public boolean equals(FluidStack left, FluidStack right) {
return API.instance().getComparer().isEqual(left, right, IComparer.COMPARE_NBT);
}
});*/
private Runnable listener;
public StorageTrackerFluid(Runnable listener) {
this.listener = listener;
}
@Override
public void changed(PlayerEntity player, FluidStack stack) {
changes.put(stack, new StorageTrackerEntry(System.currentTimeMillis(), player.getName().getString())); // TODO: correct?
listener.run();
}
@Override
public IStorageTrackerEntry get(FluidStack stack) {
return changes.get(stack);
}
public void readFromNbt(ListNBT list) {
for (int i = 0; i < list.size(); ++i) {
CompoundNBT tag = list.getCompound(i);
FluidStack stack = FluidStack.loadFluidStackFromNBT(tag.getCompound(NBT_STACK));
if (stack != null) {
changes.put(
stack,
new StorageTrackerEntry(tag.getLong(NBT_TIME), tag.getString(NBT_NAME))
);
}
}
}
public ListNBT serializeNbt() {
ListNBT list = new ListNBT();
for (Map.Entry<FluidStack, IStorageTrackerEntry> entry : changes.entrySet()) {
CompoundNBT tag = new CompoundNBT();
tag.putLong(NBT_TIME, entry.getValue().getTime());
tag.putString(NBT_NAME, entry.getValue().getName());
tag.put(NBT_STACK, entry.getKey().writeToNBT(new CompoundNBT()));
list.add(tag);
}
return list;
}
}

View File

@@ -1,7 +1,11 @@
package com.raoulvdberge.refinedstorage.apiimpl.storage; package com.raoulvdberge.refinedstorage.apiimpl.storage.cache;
import com.raoulvdberge.refinedstorage.api.network.INetwork; import com.raoulvdberge.refinedstorage.api.network.INetwork;
import com.raoulvdberge.refinedstorage.api.storage.*; 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.storage.cache.IStorageCache;
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
import com.raoulvdberge.refinedstorage.api.util.IStackList; import com.raoulvdberge.refinedstorage.api.util.IStackList;
import com.raoulvdberge.refinedstorage.api.util.StackListResult; import com.raoulvdberge.refinedstorage.api.util.StackListResult;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
@@ -14,7 +18,7 @@ import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Consumer; import java.util.function.Consumer;
public class StorageCacheFluid implements IStorageCache<FluidStack> { public class FluidStorageCache implements IStorageCache<FluidStack> {
public static final Consumer<INetwork> INVALIDATE = n -> n.getFluidStorageCache().invalidate(); public static final Consumer<INetwork> INVALIDATE = n -> n.getFluidStorageCache().invalidate();
private INetwork network; private INetwork network;
@@ -23,7 +27,7 @@ public class StorageCacheFluid implements IStorageCache<FluidStack> {
private List<IStorageCacheListener<FluidStack>> listeners = new LinkedList<>(); private List<IStorageCacheListener<FluidStack>> listeners = new LinkedList<>();
private List<StackListResult<FluidStack>> batchedChanges = new ArrayList<>(); private List<StackListResult<FluidStack>> batchedChanges = new ArrayList<>();
public StorageCacheFluid(INetwork network) { public FluidStorageCache(INetwork network) {
this.network = network; this.network = network;
} }

View File

@@ -1,7 +1,11 @@
package com.raoulvdberge.refinedstorage.apiimpl.storage; package com.raoulvdberge.refinedstorage.apiimpl.storage.cache;
import com.raoulvdberge.refinedstorage.api.network.INetwork; import com.raoulvdberge.refinedstorage.api.network.INetwork;
import com.raoulvdberge.refinedstorage.api.storage.*; 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.storage.cache.IStorageCache;
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
import com.raoulvdberge.refinedstorage.api.util.IStackList; import com.raoulvdberge.refinedstorage.api.util.IStackList;
import com.raoulvdberge.refinedstorage.api.util.StackListResult; import com.raoulvdberge.refinedstorage.api.util.StackListResult;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
@@ -14,7 +18,7 @@ import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Consumer; import java.util.function.Consumer;
public class StorageCacheItem implements IStorageCache<ItemStack> { public class ItemStorageCache implements IStorageCache<ItemStack> {
public static final Consumer<INetwork> INVALIDATE = network -> network.getItemStorageCache().invalidate(); public static final Consumer<INetwork> INVALIDATE = network -> network.getItemStorageCache().invalidate();
private INetwork network; private INetwork network;
@@ -23,7 +27,7 @@ public class StorageCacheItem implements IStorageCache<ItemStack> {
private List<IStorageCacheListener<ItemStack>> listeners = new LinkedList<>(); private List<IStorageCacheListener<ItemStack>> listeners = new LinkedList<>();
private List<StackListResult<ItemStack>> batchedChanges = new ArrayList<>(); private List<StackListResult<ItemStack>> batchedChanges = new ArrayList<>();
public StorageCacheItem(INetwork network) { public ItemStorageCache(INetwork network) {
this.network = network; this.network = network;
} }

View File

@@ -1,8 +1,8 @@
package com.raoulvdberge.refinedstorage.apiimpl.storage; package com.raoulvdberge.refinedstorage.apiimpl.storage.cache;
import com.raoulvdberge.refinedstorage.api.storage.IStorage; import com.raoulvdberge.refinedstorage.api.storage.IStorage;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCacheListener; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
import com.raoulvdberge.refinedstorage.api.util.IStackList; import com.raoulvdberge.refinedstorage.api.util.IStackList;
import com.raoulvdberge.refinedstorage.api.util.StackListResult; import com.raoulvdberge.refinedstorage.api.util.StackListResult;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
@@ -14,12 +14,12 @@ import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
public class StorageCacheFluidPortable implements IStorageCache<FluidStack> { public class PortableFluidStorageCache implements IStorageCache<FluidStack> {
private IPortableGrid portableGrid; private IPortableGrid portableGrid;
private IStackList<FluidStack> list = API.instance().createFluidStackList(); private IStackList<FluidStack> list = API.instance().createFluidStackList();
private List<IStorageCacheListener<FluidStack>> listeners = new LinkedList<>(); private List<IStorageCacheListener<FluidStack>> listeners = new LinkedList<>();
public StorageCacheFluidPortable(IPortableGrid portableGrid) { public PortableFluidStorageCache(IPortableGrid portableGrid) {
this.portableGrid = portableGrid; this.portableGrid = portableGrid;
} }

View File

@@ -1,8 +1,8 @@
package com.raoulvdberge.refinedstorage.apiimpl.storage; package com.raoulvdberge.refinedstorage.apiimpl.storage.cache;
import com.raoulvdberge.refinedstorage.api.storage.IStorage; import com.raoulvdberge.refinedstorage.api.storage.IStorage;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCacheListener; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
import com.raoulvdberge.refinedstorage.api.util.IStackList; import com.raoulvdberge.refinedstorage.api.util.IStackList;
import com.raoulvdberge.refinedstorage.api.util.StackListResult; import com.raoulvdberge.refinedstorage.api.util.StackListResult;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
@@ -14,12 +14,12 @@ import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
public class StorageCacheItemPortable implements IStorageCache<ItemStack> { public class PortableItemStorageCache implements IStorageCache<ItemStack> {
private IPortableGrid portableGrid; private IPortableGrid portableGrid;
private IStackList<ItemStack> list = API.instance().createItemStackList(); private IStackList<ItemStack> list = API.instance().createItemStackList();
private List<IStorageCacheListener<ItemStack>> listeners = new LinkedList<>(); private List<IStorageCacheListener<ItemStack>> listeners = new LinkedList<>();
public StorageCacheItemPortable(IPortableGrid portableGrid) { public PortableItemStorageCache(IPortableGrid portableGrid) {
this.portableGrid = portableGrid; this.portableGrid = portableGrid;
} }

View File

@@ -1,18 +1,18 @@
package com.raoulvdberge.refinedstorage.apiimpl.storage; package com.raoulvdberge.refinedstorage.apiimpl.storage.cache.listener;
import com.raoulvdberge.refinedstorage.api.network.INetwork; import com.raoulvdberge.refinedstorage.api.network.INetwork;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCacheListener; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
import com.raoulvdberge.refinedstorage.api.util.StackListResult; import com.raoulvdberge.refinedstorage.api.util.StackListResult;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import java.util.List; import java.util.List;
public class StorageCacheListenerGridFluid implements IStorageCacheListener<FluidStack> { public class FluidGridStorageCacheListener implements IStorageCacheListener<FluidStack> {
private ServerPlayerEntity player; private ServerPlayerEntity player;
private INetwork network; private INetwork network;
public StorageCacheListenerGridFluid(ServerPlayerEntity player, INetwork network) { public FluidGridStorageCacheListener(ServerPlayerEntity player, INetwork network) {
this.player = player; this.player = player;
this.network = network; this.network = network;
} }

View File

@@ -1,9 +1,9 @@
package com.raoulvdberge.refinedstorage.apiimpl.storage; package com.raoulvdberge.refinedstorage.apiimpl.storage.cache.listener;
import com.raoulvdberge.refinedstorage.RS; import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.api.network.INetwork; import com.raoulvdberge.refinedstorage.api.network.INetwork;
import com.raoulvdberge.refinedstorage.api.network.security.Permission; import com.raoulvdberge.refinedstorage.api.network.security.Permission;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCacheListener; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
import com.raoulvdberge.refinedstorage.api.util.StackListResult; import com.raoulvdberge.refinedstorage.api.util.StackListResult;
import com.raoulvdberge.refinedstorage.network.grid.GridItemDeltaMessage; import com.raoulvdberge.refinedstorage.network.grid.GridItemDeltaMessage;
import com.raoulvdberge.refinedstorage.network.grid.GridItemUpdateMessage; import com.raoulvdberge.refinedstorage.network.grid.GridItemUpdateMessage;
@@ -13,11 +13,11 @@ import net.minecraft.item.ItemStack;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class StorageCacheListenerGridItem implements IStorageCacheListener<ItemStack> { public class ItemGridStorageCacheListener implements IStorageCacheListener<ItemStack> {
private ServerPlayerEntity player; private ServerPlayerEntity player;
private INetwork network; private INetwork network;
public StorageCacheListenerGridItem(ServerPlayerEntity player, INetwork network) { public ItemGridStorageCacheListener(ServerPlayerEntity player, INetwork network) {
this.player = player; this.player = player;
this.network = network; this.network = network;
} }

View File

@@ -1,6 +1,6 @@
package com.raoulvdberge.refinedstorage.apiimpl.storage; package com.raoulvdberge.refinedstorage.apiimpl.storage.cache.listener;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCacheListener; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
import com.raoulvdberge.refinedstorage.api.util.StackListResult; import com.raoulvdberge.refinedstorage.api.util.StackListResult;
import com.raoulvdberge.refinedstorage.tile.grid.portable.IPortableGrid; import com.raoulvdberge.refinedstorage.tile.grid.portable.IPortableGrid;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity;
@@ -8,11 +8,11 @@ import net.minecraftforge.fluids.FluidStack;
import java.util.List; import java.util.List;
public class StorageCacheListenerGridPortableFluid implements IStorageCacheListener<FluidStack> { public class PortableFluidGridStorageCacheListener implements IStorageCacheListener<FluidStack> {
private IPortableGrid portableGrid; private IPortableGrid portableGrid;
private ServerPlayerEntity player; private ServerPlayerEntity player;
public StorageCacheListenerGridPortableFluid(IPortableGrid portableGrid, ServerPlayerEntity player) { public PortableFluidGridStorageCacheListener(IPortableGrid portableGrid, ServerPlayerEntity player) {
this.portableGrid = portableGrid; this.portableGrid = portableGrid;
this.player = player; this.player = player;
} }

View File

@@ -1,6 +1,6 @@
package com.raoulvdberge.refinedstorage.apiimpl.storage; package com.raoulvdberge.refinedstorage.apiimpl.storage.cache.listener;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCacheListener; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
import com.raoulvdberge.refinedstorage.api.util.StackListResult; import com.raoulvdberge.refinedstorage.api.util.StackListResult;
import com.raoulvdberge.refinedstorage.tile.grid.portable.IPortableGrid; import com.raoulvdberge.refinedstorage.tile.grid.portable.IPortableGrid;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity;
@@ -8,11 +8,11 @@ import net.minecraft.item.ItemStack;
import java.util.List; import java.util.List;
public class StorageCacheListenerGridPortable implements IStorageCacheListener<ItemStack> { public class PortableItemGridStorageCacheListener implements IStorageCacheListener<ItemStack> {
private IPortableGrid portableGrid; private IPortableGrid portableGrid;
private ServerPlayerEntity player; private ServerPlayerEntity player;
public StorageCacheListenerGridPortable(IPortableGrid portableGrid, ServerPlayerEntity player) { public PortableItemGridStorageCacheListener(IPortableGrid portableGrid, ServerPlayerEntity player) {
this.portableGrid = portableGrid; this.portableGrid = portableGrid;
this.player = player; this.player = player;
} }

View File

@@ -8,6 +8,7 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerCon
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskListener; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskListener;
import com.raoulvdberge.refinedstorage.api.util.Action; import com.raoulvdberge.refinedstorage.api.util.Action;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.factory.FluidStorageDiskFactory;
import com.raoulvdberge.refinedstorage.util.StackUtils; import com.raoulvdberge.refinedstorage.util.StackUtils;
import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluid;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
@@ -20,11 +21,11 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Collection; import java.util.Collection;
public class StorageDiskFluid implements IStorageDisk<FluidStack> { public class FluidStorageDisk implements IStorageDisk<FluidStack> {
static final String NBT_VERSION = "Version"; public static final String NBT_VERSION = "Version";
static final String NBT_CAPACITY = "Capacity"; public static final String NBT_CAPACITY = "Capacity";
static final String NBT_FLUIDS = "Fluids"; public static final String NBT_FLUIDS = "Fluids";
static final int VERSION = 1; public static final int VERSION = 1;
private ServerWorld world; private ServerWorld world;
private int capacity; private int capacity;
@@ -34,7 +35,7 @@ public class StorageDiskFluid implements IStorageDisk<FluidStack> {
private IStorageDiskListener listener; private IStorageDiskListener listener;
private IStorageDiskContainerContext context; private IStorageDiskContainerContext context;
public StorageDiskFluid(ServerWorld world, int capacity) { public FluidStorageDisk(ServerWorld world, int capacity) {
if (world == null) { if (world == null) {
throw new IllegalArgumentException("World cannot be null"); throw new IllegalArgumentException("World cannot be null");
} }
@@ -184,10 +185,10 @@ public class StorageDiskFluid implements IStorageDisk<FluidStack> {
@Override @Override
public ResourceLocation getFactoryId() { public ResourceLocation getFactoryId() {
return StorageDiskFactoryFluid.ID; return FluidStorageDiskFactory.ID;
} }
Multimap<Fluid, FluidStack> getRawStacks() { public Multimap<Fluid, FluidStack> getRawStacks() {
return stacks; return stacks;
} }

View File

@@ -8,6 +8,7 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerCon
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskListener; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskListener;
import com.raoulvdberge.refinedstorage.api.util.Action; import com.raoulvdberge.refinedstorage.api.util.Action;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.factory.ItemStorageDiskFactory;
import com.raoulvdberge.refinedstorage.util.StackUtils; import com.raoulvdberge.refinedstorage.util.StackUtils;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -21,11 +22,11 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Collection; import java.util.Collection;
public class StorageDiskItem implements IStorageDisk<ItemStack> { public class ItemStorageDisk implements IStorageDisk<ItemStack> {
static final String NBT_VERSION = "Version"; public static final String NBT_VERSION = "Version";
static final String NBT_CAPACITY = "Capacity"; public static final String NBT_CAPACITY = "Capacity";
static final String NBT_ITEMS = "Items"; public static final String NBT_ITEMS = "Items";
static final int VERSION = 1; public static final int VERSION = 1;
private ServerWorld world; private ServerWorld world;
private int capacity; private int capacity;
@@ -35,7 +36,7 @@ public class StorageDiskItem implements IStorageDisk<ItemStack> {
private IStorageDiskListener listener; private IStorageDiskListener listener;
private IStorageDiskContainerContext context; private IStorageDiskContainerContext context;
public StorageDiskItem(ServerWorld world, int capacity) { public ItemStorageDisk(ServerWorld world, int capacity) {
if (world == null) { if (world == null) {
throw new IllegalArgumentException("World cannot be null"); throw new IllegalArgumentException("World cannot be null");
} }
@@ -63,7 +64,7 @@ public class StorageDiskItem implements IStorageDisk<ItemStack> {
@Override @Override
public ResourceLocation getFactoryId() { public ResourceLocation getFactoryId() {
return StorageDiskFactoryItem.ID; return ItemStorageDiskFactory.ID;
} }
@Override @Override
@@ -188,7 +189,7 @@ public class StorageDiskItem implements IStorageDisk<ItemStack> {
return remainder == null ? size : (size - remainder.getCount()); return remainder == null ? size : (size - remainder.getCount());
} }
Multimap<Item, ItemStack> getRawStacks() { public Multimap<Item, ItemStack> getRawStacks() {
return stacks; return stacks;
} }

View File

@@ -14,11 +14,11 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Collection; import java.util.Collection;
public class StorageDiskFluidPortable implements IStorageDisk<FluidStack> { public class PortableFluidStorageDisk implements IStorageDisk<FluidStack> {
private IStorageDisk<FluidStack> parent; private IStorageDisk<FluidStack> parent;
private IPortableGrid portableGrid; private IPortableGrid portableGrid;
public StorageDiskFluidPortable(IStorageDisk<FluidStack> parent, IPortableGrid portableGrid) { public PortableFluidStorageDisk(IStorageDisk<FluidStack> parent, IPortableGrid portableGrid) {
this.parent = parent; this.parent = parent;
this.portableGrid = portableGrid; this.portableGrid = portableGrid;
} }

View File

@@ -14,11 +14,11 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Collection; import java.util.Collection;
public class StorageDiskItemPortable implements IStorageDisk<ItemStack> { public class PortableItemStorageDisk implements IStorageDisk<ItemStack> {
private IStorageDisk<ItemStack> parent; private IStorageDisk<ItemStack> parent;
private IPortableGrid portableGrid; private IPortableGrid portableGrid;
public StorageDiskItemPortable(IStorageDisk<ItemStack> parent, IPortableGrid portableGrid) { public PortableItemStorageDisk(IStorageDisk<ItemStack> parent, IPortableGrid portableGrid) {
this.parent = parent; this.parent = parent;
this.portableGrid = portableGrid; this.portableGrid = portableGrid;
} }

View File

@@ -2,7 +2,7 @@ package com.raoulvdberge.refinedstorage.apiimpl.storage.disk;
import com.raoulvdberge.refinedstorage.RS; import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSync; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSync;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSyncData; import com.raoulvdberge.refinedstorage.api.storage.disk.StorageDiskSyncData;
import com.raoulvdberge.refinedstorage.network.disk.StorageDiskSizeRequestMessage; import com.raoulvdberge.refinedstorage.network.disk.StorageDiskSizeRequestMessage;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -13,16 +13,16 @@ import java.util.UUID;
public class StorageDiskSync implements IStorageDiskSync { public class StorageDiskSync implements IStorageDiskSync {
private static final int THROTTLE_MS = 500; private static final int THROTTLE_MS = 500;
private Map<UUID, IStorageDiskSyncData> data = new HashMap<>(); private Map<UUID, StorageDiskSyncData> data = new HashMap<>();
private Map<UUID, Long> syncTime = new HashMap<>(); private Map<UUID, Long> syncTime = new HashMap<>();
@Nullable @Nullable
@Override @Override
public IStorageDiskSyncData getData(UUID id) { public StorageDiskSyncData getData(UUID id) {
return data.get(id); return data.get(id);
} }
public void setData(UUID id, IStorageDiskSyncData data) { public void setData(UUID id, StorageDiskSyncData data) {
this.data.put(id, data); this.data.put(id, data);
} }

View File

@@ -1,8 +1,9 @@
package com.raoulvdberge.refinedstorage.apiimpl.storage.disk; package com.raoulvdberge.refinedstorage.apiimpl.storage.disk.factory;
import com.raoulvdberge.refinedstorage.RS; import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskFactory; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskFactory;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.FluidStorageDisk;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListNBT;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@@ -10,14 +11,14 @@ import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
public class StorageDiskFactoryFluid implements IStorageDiskFactory<FluidStack> { public class FluidStorageDiskFactory implements IStorageDiskFactory<FluidStack> {
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "fluid"); public static final ResourceLocation ID = new ResourceLocation(RS.ID, "fluid");
@Override @Override
public IStorageDisk<FluidStack> createFromNbt(ServerWorld world, CompoundNBT tag) { public IStorageDisk<FluidStack> createFromNbt(ServerWorld world, CompoundNBT tag) {
StorageDiskFluid disk = new StorageDiskFluid(world, tag.getInt(StorageDiskFluid.NBT_CAPACITY)); FluidStorageDisk disk = new FluidStorageDisk(world, tag.getInt(FluidStorageDisk.NBT_CAPACITY));
ListNBT list = tag.getList(StorageDiskFluid.NBT_FLUIDS, Constants.NBT.TAG_COMPOUND); ListNBT list = tag.getList(FluidStorageDisk.NBT_FLUIDS, Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < list.size(); ++i) { for (int i = 0; i < list.size(); ++i) {
FluidStack stack = FluidStack.loadFluidStackFromNBT(list.getCompound(i)); FluidStack stack = FluidStack.loadFluidStackFromNBT(list.getCompound(i));
@@ -32,6 +33,6 @@ public class StorageDiskFactoryFluid implements IStorageDiskFactory<FluidStack>
@Override @Override
public IStorageDisk<FluidStack> create(ServerWorld world, int capacity) { public IStorageDisk<FluidStack> create(ServerWorld world, int capacity) {
return new StorageDiskFluid(world, capacity); return new FluidStorageDisk(world, capacity);
} }
} }

View File

@@ -1,8 +1,9 @@
package com.raoulvdberge.refinedstorage.apiimpl.storage.disk; package com.raoulvdberge.refinedstorage.apiimpl.storage.disk.factory;
import com.raoulvdberge.refinedstorage.RS; import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskFactory; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskFactory;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.ItemStorageDisk;
import com.raoulvdberge.refinedstorage.util.StackUtils; import com.raoulvdberge.refinedstorage.util.StackUtils;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
@@ -11,14 +12,14 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.world.server.ServerWorld; import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.Constants;
public class StorageDiskFactoryItem implements IStorageDiskFactory<ItemStack> { public class ItemStorageDiskFactory implements IStorageDiskFactory<ItemStack> {
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "item"); public static final ResourceLocation ID = new ResourceLocation(RS.ID, "item");
@Override @Override
public IStorageDisk<ItemStack> createFromNbt(ServerWorld world, CompoundNBT tag) { public IStorageDisk<ItemStack> createFromNbt(ServerWorld world, CompoundNBT tag) {
StorageDiskItem disk = new StorageDiskItem(world, tag.getInt(StorageDiskItem.NBT_CAPACITY)); ItemStorageDisk disk = new ItemStorageDisk(world, tag.getInt(ItemStorageDisk.NBT_CAPACITY));
ListNBT list = tag.getList(StorageDiskItem.NBT_ITEMS, Constants.NBT.TAG_COMPOUND); ListNBT list = tag.getList(ItemStorageDisk.NBT_ITEMS, Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < list.size(); ++i) { for (int i = 0; i < list.size(); ++i) {
ItemStack stack = StackUtils.deserializeStackFromNbt(list.getCompound(i)); ItemStack stack = StackUtils.deserializeStackFromNbt(list.getCompound(i));
@@ -33,6 +34,6 @@ public class StorageDiskFactoryItem implements IStorageDiskFactory<ItemStack> {
@Override @Override
public IStorageDisk<ItemStack> create(ServerWorld world, int capacity) { public IStorageDisk<ItemStack> create(ServerWorld world, int capacity) {
return new StorageDiskItem(world, capacity); return new ItemStorageDisk(world, capacity);
} }
} }

View File

@@ -0,0 +1,84 @@
package com.raoulvdberge.refinedstorage.apiimpl.storage.tracker;
import com.raoulvdberge.refinedstorage.api.storage.tracker.IStorageTracker;
import com.raoulvdberge.refinedstorage.api.storage.tracker.StorageTrackerEntry;
import com.raoulvdberge.refinedstorage.api.util.IComparer;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraftforge.fluids.FluidStack;
import java.util.HashMap;
import java.util.Map;
public class FluidStorageTracker implements IStorageTracker<FluidStack> {
private static final String NBT_STACK = "Stack";
private static final String NBT_NAME = "Name";
private static final String NBT_TIME = "Time";
private final Map<Key, StorageTrackerEntry> changes = new HashMap<>();
private final Runnable listener;
public FluidStorageTracker(Runnable listener) {
this.listener = listener;
}
@Override
public void changed(PlayerEntity player, FluidStack stack) {
changes.put(new Key(stack), new StorageTrackerEntry(System.currentTimeMillis(), player.getName().getString()));
listener.run();
}
@Override
public StorageTrackerEntry get(FluidStack stack) {
return changes.get(stack);
}
public void readFromNbt(ListNBT list) {
for (int i = 0; i < list.size(); ++i) {
CompoundNBT tag = list.getCompound(i);
FluidStack stack = FluidStack.loadFluidStackFromNBT(tag.getCompound(NBT_STACK));
if (stack != null) {
changes.put(new Key(stack), new StorageTrackerEntry(tag.getLong(NBT_TIME), tag.getString(NBT_NAME)));
}
}
}
public ListNBT serializeNbt() {
ListNBT list = new ListNBT();
for (Map.Entry<Key, StorageTrackerEntry> entry : changes.entrySet()) {
CompoundNBT tag = new CompoundNBT();
tag.putLong(NBT_TIME, entry.getValue().getTime());
tag.putString(NBT_NAME, entry.getValue().getName());
tag.put(NBT_STACK, entry.getKey().stack.writeToNBT(new CompoundNBT()));
list.add(tag);
}
return list;
}
private class Key {
private final FluidStack stack;
public Key(FluidStack stack) {
this.stack = stack;
}
@Override
public boolean equals(Object other) {
return other instanceof Key && API.instance().getComparer().isEqual(stack, ((Key) other).stack, IComparer.COMPARE_NBT);
}
@Override
public int hashCode() {
return API.instance().getFluidStackHashCode(stack);
}
}
}

View File

@@ -1,6 +1,8 @@
package com.raoulvdberge.refinedstorage.apiimpl.storage; package com.raoulvdberge.refinedstorage.apiimpl.storage.tracker;
import com.raoulvdberge.refinedstorage.api.storage.IStorageTracker; import com.raoulvdberge.refinedstorage.api.storage.tracker.IStorageTracker;
import com.raoulvdberge.refinedstorage.api.storage.tracker.StorageTrackerEntry;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.util.StackUtils; import com.raoulvdberge.refinedstorage.util.StackUtils;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -10,40 +12,28 @@ import net.minecraft.nbt.ListNBT;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class StorageTrackerItem implements IStorageTracker<ItemStack> { public class ItemStorageTracker implements IStorageTracker<ItemStack> {
private static final String NBT_STACK = "Stack"; private static final String NBT_STACK = "Stack";
private static final String NBT_NAME = "Name"; private static final String NBT_NAME = "Name";
private static final String NBT_TIME = "Time"; private static final String NBT_TIME = "Time";
private final Map<Key, StorageTrackerEntry> changes = new HashMap<>();
private final Runnable listener;
private Map<ItemStack, IStorageTrackerEntry> changes = new HashMap<>(); /* TODO BROKEN new TCustomHashMap<>(new HashingStrategy<ItemStack>() { public ItemStorageTracker(Runnable listener) {
@Override
public int computeHashCode(ItemStack stack) {
return API.instance().getItemStackHashCode(stack);
}
@Override
public boolean equals(ItemStack left, ItemStack right) {
return API.instance().getComparer().isEqualNoQuantity(left, right);
}
});*/
private Runnable listener;
public StorageTrackerItem(Runnable listener) {
this.listener = listener; this.listener = listener;
} }
@Override @Override
public void changed(PlayerEntity player, ItemStack stack) { public void changed(PlayerEntity player, ItemStack stack) {
changes.put(stack, new StorageTrackerEntry(System.currentTimeMillis(), player.getName().getString())); // TODO correct? changes.put(new Key(stack), new StorageTrackerEntry(System.currentTimeMillis(), player.getName().getFormattedText()));
listener.run(); listener.run();
} }
@Override @Override
public IStorageTrackerEntry get(ItemStack stack) { public StorageTrackerEntry get(ItemStack stack) {
return changes.get(stack); return changes.get(new Key(stack));
} }
public void readFromNbt(ListNBT list) { public void readFromNbt(ListNBT list) {
@@ -53,10 +43,7 @@ public class StorageTrackerItem implements IStorageTracker<ItemStack> {
ItemStack stack = StackUtils.deserializeStackFromNbt(tag.getCompound(NBT_STACK)); ItemStack stack = StackUtils.deserializeStackFromNbt(tag.getCompound(NBT_STACK));
if (!stack.isEmpty()) { if (!stack.isEmpty()) {
changes.put( changes.put(new Key(stack), new StorageTrackerEntry(tag.getLong(NBT_TIME), tag.getString(NBT_NAME)));
stack,
new StorageTrackerEntry(tag.getLong(NBT_TIME), tag.getString(NBT_NAME))
);
} }
} }
} }
@@ -64,16 +51,34 @@ public class StorageTrackerItem implements IStorageTracker<ItemStack> {
public ListNBT serializeNbt() { public ListNBT serializeNbt() {
ListNBT list = new ListNBT(); ListNBT list = new ListNBT();
for (Map.Entry<ItemStack, IStorageTrackerEntry> entry : changes.entrySet()) { for (Map.Entry<Key, StorageTrackerEntry> entry : changes.entrySet()) {
CompoundNBT tag = new CompoundNBT(); CompoundNBT tag = new CompoundNBT();
tag.putLong(NBT_TIME, entry.getValue().getTime()); tag.putLong(NBT_TIME, entry.getValue().getTime());
tag.putString(NBT_NAME, entry.getValue().getName()); tag.putString(NBT_NAME, entry.getValue().getName());
tag.put(NBT_STACK, StackUtils.serializeStackToNbt(entry.getKey())); tag.put(NBT_STACK, StackUtils.serializeStackToNbt(entry.getKey().stack));
list.add(tag); list.add(tag);
} }
return list; return list;
} }
private class Key {
private final ItemStack stack;
public Key(ItemStack stack) {
this.stack = stack;
}
@Override
public boolean equals(Object other) {
return other instanceof Key && API.instance().getComparer().isEqualNoQuantity(stack, ((Key) other).stack);
}
@Override
public int hashCode() {
return API.instance().getItemStackHashCode(stack);
}
}
} }

View File

@@ -3,13 +3,13 @@ package com.raoulvdberge.refinedstorage.apiimpl.util;
import com.raoulvdberge.refinedstorage.api.util.IFilter; import com.raoulvdberge.refinedstorage.api.util.IFilter;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
public class FilterFluid implements IFilter<FluidStack> { public class FluidFilter implements IFilter<FluidStack> {
private FluidStack stack; private FluidStack stack;
private int compare; private int compare;
private int mode; private int mode;
private boolean modFilter; private boolean modFilter;
public FilterFluid(FluidStack stack, int compare, int mode, boolean modFilter) { public FluidFilter(FluidStack stack, int compare, int mode, boolean modFilter) {
this.stack = stack; this.stack = stack;
this.compare = compare; this.compare = compare;
this.mode = mode; this.mode = mode;

View File

@@ -3,13 +3,13 @@ package com.raoulvdberge.refinedstorage.apiimpl.util;
import com.raoulvdberge.refinedstorage.api.util.IFilter; import com.raoulvdberge.refinedstorage.api.util.IFilter;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class FilterItem implements IFilter<ItemStack> { public class ItemFilter implements IFilter<ItemStack> {
private ItemStack stack; private ItemStack stack;
private int compare; private int compare;
private int mode; private int mode;
private boolean modFilter; private boolean modFilter;
public FilterItem(ItemStack stack, int compare, int mode, boolean modFilter) { public ItemFilter(ItemStack stack, int compare, int mode, boolean modFilter) {
this.stack = stack; this.stack = stack;
this.compare = compare; this.compare = compare;
this.mode = mode; this.mode = mode;

View File

@@ -6,8 +6,8 @@ import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
import com.raoulvdberge.refinedstorage.api.network.grid.IGridCraftingListener; import com.raoulvdberge.refinedstorage.api.network.grid.IGridCraftingListener;
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler; import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler; import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCacheListener; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.GridNetworkNode; import com.raoulvdberge.refinedstorage.apiimpl.network.node.GridNetworkNode;
import com.raoulvdberge.refinedstorage.container.slot.filter.FilterSlot; import com.raoulvdberge.refinedstorage.container.slot.filter.FilterSlot;
import com.raoulvdberge.refinedstorage.container.slot.filter.FluidFilterSlot; import com.raoulvdberge.refinedstorage.container.slot.filter.FluidFilterSlot;

View File

@@ -4,7 +4,8 @@ import com.raoulvdberge.refinedstorage.RSItems;
import com.raoulvdberge.refinedstorage.api.network.grid.IGridTab; import com.raoulvdberge.refinedstorage.api.network.grid.IGridTab;
import com.raoulvdberge.refinedstorage.api.util.IFilter; import com.raoulvdberge.refinedstorage.api.util.IFilter;
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.GridTab; import com.raoulvdberge.refinedstorage.apiimpl.network.grid.GridTab;
import com.raoulvdberge.refinedstorage.apiimpl.util.FilterFluid; import com.raoulvdberge.refinedstorage.apiimpl.util.FluidFilter;
import com.raoulvdberge.refinedstorage.apiimpl.util.ItemFilter;
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventoryFilter; import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventoryFilter;
import com.raoulvdberge.refinedstorage.inventory.item.validator.ItemValidatorBasic; import com.raoulvdberge.refinedstorage.inventory.item.validator.ItemValidatorBasic;
import com.raoulvdberge.refinedstorage.item.FilterItem; import com.raoulvdberge.refinedstorage.item.FilterItem;
@@ -64,14 +65,14 @@ public class ItemHandlerFilter extends ItemHandlerBase {
if (stack.getItem() == RSItems.FILTER) { if (stack.getItem() == RSItems.FILTER) {
addFilter(stack); addFilter(stack);
} else if (!stack.isEmpty()) { } else if (!stack.isEmpty()) {
filters.add(new com.raoulvdberge.refinedstorage.apiimpl.util.FilterItem(stack, compare, mode, modFilter)); filters.add(new ItemFilter(stack, compare, mode, modFilter));
} }
} }
FluidInventoryFilter fluids = new FluidInventoryFilter(filter); FluidInventoryFilter fluids = new FluidInventoryFilter(filter);
for (FluidStack stack : fluids.getFilteredFluids()) { for (FluidStack stack : fluids.getFilteredFluids()) {
filters.add(new FilterFluid(stack, compare, mode, modFilter)); filters.add(new FluidFilter(stack, compare, mode, modFilter));
} }
ItemStack icon = FilterItem.getIcon(filter); ItemStack icon = FilterItem.getIcon(filter);

View File

@@ -5,7 +5,7 @@ import com.raoulvdberge.refinedstorage.RSItems;
import com.raoulvdberge.refinedstorage.api.storage.StorageType; import com.raoulvdberge.refinedstorage.api.storage.StorageType;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSyncData; import com.raoulvdberge.refinedstorage.api.storage.disk.StorageDiskSyncData;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.storage.FluidStorageType; import com.raoulvdberge.refinedstorage.apiimpl.storage.FluidStorageType;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
@@ -62,7 +62,7 @@ public class FluidStorageDiskItem extends Item implements IStorageDiskProvider {
API.instance().getStorageDiskSync().sendRequest(id); API.instance().getStorageDiskSync().sendRequest(id);
IStorageDiskSyncData data = API.instance().getStorageDiskSync().getData(id); StorageDiskSyncData data = API.instance().getStorageDiskSync().getData(id);
if (data != null) { if (data != null) {
if (data.getCapacity() == -1) { if (data.getCapacity() == -1) {
tooltip.add(new TranslationTextComponent("misc.refinedstorage.storage.stored", API.instance().getQuantityFormatter().format(data.getStored())).setStyle(new Style().setColor(TextFormatting.GRAY))); tooltip.add(new TranslationTextComponent("misc.refinedstorage.storage.stored", API.instance().getQuantityFormatter().format(data.getStored())).setStyle(new Style().setColor(TextFormatting.GRAY)));

View File

@@ -5,7 +5,7 @@ import com.raoulvdberge.refinedstorage.RSItems;
import com.raoulvdberge.refinedstorage.api.storage.StorageType; import com.raoulvdberge.refinedstorage.api.storage.StorageType;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSyncData; import com.raoulvdberge.refinedstorage.api.storage.disk.StorageDiskSyncData;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.storage.ItemStorageType; import com.raoulvdberge.refinedstorage.apiimpl.storage.ItemStorageType;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
@@ -62,7 +62,7 @@ public class StorageDiskItem extends Item implements IStorageDiskProvider {
API.instance().getStorageDiskSync().sendRequest(id); API.instance().getStorageDiskSync().sendRequest(id);
IStorageDiskSyncData data = API.instance().getStorageDiskSync().getData(id); StorageDiskSyncData data = API.instance().getStorageDiskSync().getData(id);
if (data != null) { if (data != null) {
if (data.getCapacity() == -1) { if (data.getCapacity() == -1) {
tooltip.add(new TranslationTextComponent("misc.refinedstorage.storage.stored", API.instance().getQuantityFormatter().format(data.getStored())).setStyle(new Style().setColor(TextFormatting.GRAY))); tooltip.add(new TranslationTextComponent("misc.refinedstorage.storage.stored", API.instance().getQuantityFormatter().format(data.getStored())).setStyle(new Style().setColor(TextFormatting.GRAY)));

View File

@@ -1,8 +1,8 @@
package com.raoulvdberge.refinedstorage.network.disk; package com.raoulvdberge.refinedstorage.network.disk;
import com.raoulvdberge.refinedstorage.api.storage.disk.StorageDiskSyncData;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskSync; import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskSync;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskSyncData;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.fml.network.NetworkEvent;

View File

@@ -1,6 +1,6 @@
package com.raoulvdberge.refinedstorage.screen.grid.stack; package com.raoulvdberge.refinedstorage.screen.grid.stack;
import com.raoulvdberge.refinedstorage.api.storage.IStorageTracker; import com.raoulvdberge.refinedstorage.api.storage.tracker.StorageTrackerEntry;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.render.FluidRenderer; import com.raoulvdberge.refinedstorage.render.FluidRenderer;
import com.raoulvdberge.refinedstorage.screen.BaseScreen; import com.raoulvdberge.refinedstorage.screen.BaseScreen;
@@ -14,13 +14,13 @@ public class FluidGridStack implements IGridStack {
private UUID id; private UUID id;
private FluidStack stack; private FluidStack stack;
@Nullable @Nullable
private IStorageTracker.IStorageTrackerEntry entry; private StorageTrackerEntry entry;
private boolean craftable; private boolean craftable;
private boolean displayCraftText; private boolean displayCraftText;
private String modId; private String modId;
private String modName; private String modName;
public FluidGridStack(UUID id, FluidStack stack, @Nullable IStorageTracker.IStorageTrackerEntry entry, boolean craftable, boolean displayCraftText) { public FluidGridStack(UUID id, FluidStack stack, @Nullable StorageTrackerEntry entry, boolean craftable, boolean displayCraftText) {
this.id = id; this.id = id;
this.stack = stack; this.stack = stack;
this.entry = entry; this.entry = entry;
@@ -127,12 +127,12 @@ public class FluidGridStack implements IGridStack {
@Nullable @Nullable
@Override @Override
public IStorageTracker.IStorageTrackerEntry getTrackerEntry() { public StorageTrackerEntry getTrackerEntry() {
return entry; return entry;
} }
@Override @Override
public void setTrackerEntry(@Nullable IStorageTracker.IStorageTrackerEntry entry) { public void setTrackerEntry(@Nullable StorageTrackerEntry entry) {
this.entry = entry; this.entry = entry;
} }
} }

View File

@@ -1,6 +1,6 @@
package com.raoulvdberge.refinedstorage.screen.grid.stack; package com.raoulvdberge.refinedstorage.screen.grid.stack;
import com.raoulvdberge.refinedstorage.api.storage.IStorageTracker; import com.raoulvdberge.refinedstorage.api.storage.tracker.StorageTrackerEntry;
import com.raoulvdberge.refinedstorage.screen.BaseScreen; import com.raoulvdberge.refinedstorage.screen.BaseScreen;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -28,9 +28,9 @@ public interface IGridStack {
Object getIngredient(); Object getIngredient();
@Nullable @Nullable
IStorageTracker.IStorageTrackerEntry getTrackerEntry(); StorageTrackerEntry getTrackerEntry();
void setTrackerEntry(@Nullable IStorageTracker.IStorageTrackerEntry entry); void setTrackerEntry(@Nullable StorageTrackerEntry entry);
boolean isCraftable(); boolean isCraftable();

View File

@@ -1,6 +1,6 @@
package com.raoulvdberge.refinedstorage.screen.grid.stack; package com.raoulvdberge.refinedstorage.screen.grid.stack;
import com.raoulvdberge.refinedstorage.api.storage.IStorageTracker; import com.raoulvdberge.refinedstorage.api.storage.tracker.StorageTrackerEntry;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.screen.BaseScreen; import com.raoulvdberge.refinedstorage.screen.BaseScreen;
import com.raoulvdberge.refinedstorage.util.RenderUtils; import com.raoulvdberge.refinedstorage.util.RenderUtils;
@@ -19,7 +19,7 @@ public class ItemGridStack implements IGridStack {
private boolean displayCraftText; private boolean displayCraftText;
private String[] oreIds = null; private String[] oreIds = null;
@Nullable @Nullable
private IStorageTracker.IStorageTrackerEntry entry; private StorageTrackerEntry entry;
private String modId; private String modId;
private String modName; private String modName;
private String tooltip; private String tooltip;
@@ -28,7 +28,7 @@ public class ItemGridStack implements IGridStack {
this.stack = stack; this.stack = stack;
} }
public ItemGridStack(UUID id, ItemStack stack, boolean craftable, boolean displayCraftText, IStorageTracker.IStorageTrackerEntry entry) { public ItemGridStack(UUID id, ItemStack stack, boolean craftable, boolean displayCraftText, StorageTrackerEntry entry) {
this.id = id; this.id = id;
this.stack = stack; this.stack = stack;
this.craftable = craftable; this.craftable = craftable;
@@ -171,12 +171,12 @@ public class ItemGridStack implements IGridStack {
@Nullable @Nullable
@Override @Override
public IStorageTracker.IStorageTrackerEntry getTrackerEntry() { public StorageTrackerEntry getTrackerEntry() {
return entry; return entry;
} }
@Override @Override
public void setTrackerEntry(@Nullable IStorageTracker.IStorageTrackerEntry entry) { public void setTrackerEntry(@Nullable StorageTrackerEntry entry) {
this.entry = entry; this.entry = entry;
} }
} }

View File

@@ -18,9 +18,9 @@ import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterMan
import com.raoulvdberge.refinedstorage.api.network.security.ISecurityManager; import com.raoulvdberge.refinedstorage.api.network.security.ISecurityManager;
import com.raoulvdberge.refinedstorage.api.storage.AccessType; import com.raoulvdberge.refinedstorage.api.storage.AccessType;
import com.raoulvdberge.refinedstorage.api.storage.IStorage; import com.raoulvdberge.refinedstorage.api.storage.IStorage;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
import com.raoulvdberge.refinedstorage.api.storage.IStorageTracker;
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExternal; import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExternal;
import com.raoulvdberge.refinedstorage.api.storage.tracker.IStorageTracker;
import com.raoulvdberge.refinedstorage.api.util.Action; import com.raoulvdberge.refinedstorage.api.util.Action;
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.CraftingManager; import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.CraftingManager;
import com.raoulvdberge.refinedstorage.apiimpl.energy.Energy; import com.raoulvdberge.refinedstorage.apiimpl.energy.Energy;
@@ -31,10 +31,10 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.item.NetworkItemHandler;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.ICoverable; import com.raoulvdberge.refinedstorage.apiimpl.network.node.ICoverable;
import com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter.ReaderWriterManager; import com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter.ReaderWriterManager;
import com.raoulvdberge.refinedstorage.apiimpl.network.security.SecurityManager; import com.raoulvdberge.refinedstorage.apiimpl.network.security.SecurityManager;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheFluid; import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.FluidStorageCache;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheItem; import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.ItemStorageCache;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageTrackerFluid; import com.raoulvdberge.refinedstorage.apiimpl.storage.tracker.FluidStorageTracker;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageTrackerItem; import com.raoulvdberge.refinedstorage.apiimpl.storage.tracker.ItemStorageTracker;
import com.raoulvdberge.refinedstorage.block.ControllerBlock; import com.raoulvdberge.refinedstorage.block.ControllerBlock;
import com.raoulvdberge.refinedstorage.integration.forgeenergy.EnergyProxy; import com.raoulvdberge.refinedstorage.integration.forgeenergy.EnergyProxy;
import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable; import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable;
@@ -132,11 +132,11 @@ public class ControllerTile extends BaseTile implements ITickableTileEntity, INe
private ISecurityManager securityManager = new SecurityManager(this); private ISecurityManager securityManager = new SecurityManager(this);
private IStorageCache<ItemStack> itemStorage = new StorageCacheItem(this); private IStorageCache<ItemStack> itemStorage = new ItemStorageCache(this);
private StorageTrackerItem itemStorageTracker = new StorageTrackerItem(this::markDirty); private ItemStorageTracker itemStorageTracker = new ItemStorageTracker(this::markDirty);
private IStorageCache<FluidStack> fluidStorage = new StorageCacheFluid(this); private IStorageCache<FluidStack> fluidStorage = new FluidStorageCache(this);
private StorageTrackerFluid fluidStorageTracker = new StorageTrackerFluid(this::markDirty); private FluidStorageTracker fluidStorageTracker = new FluidStorageTracker(this::markDirty);
private IReaderWriterManager readerWriterManager = new ReaderWriterManager(this); private IReaderWriterManager readerWriterManager = new ReaderWriterManager(this);

View File

@@ -4,10 +4,10 @@ import com.raoulvdberge.refinedstorage.api.network.INetwork;
import com.raoulvdberge.refinedstorage.api.network.grid.*; import com.raoulvdberge.refinedstorage.api.network.grid.*;
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler; import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler; import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCacheListener; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
import com.raoulvdberge.refinedstorage.api.util.IFilter; import com.raoulvdberge.refinedstorage.api.util.IFilter;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheListenerGridFluid; import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.listener.FluidGridStorageCacheListener;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerFilter; import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerFilter;
import com.raoulvdberge.refinedstorage.screen.BaseScreen; import com.raoulvdberge.refinedstorage.screen.BaseScreen;
import com.raoulvdberge.refinedstorage.screen.grid.GridScreen; import com.raoulvdberge.refinedstorage.screen.grid.GridScreen;
@@ -104,7 +104,7 @@ public class WirelessFluidGrid implements IGridNetworkAware {
@Override @Override
public IStorageCacheListener createListener(ServerPlayerEntity player) { public IStorageCacheListener createListener(ServerPlayerEntity player) {
return new StorageCacheListenerGridFluid(player, getNetwork()); return new FluidGridStorageCacheListener(player, getNetwork());
} }
@Nullable @Nullable

View File

@@ -4,10 +4,10 @@ import com.raoulvdberge.refinedstorage.api.network.INetwork;
import com.raoulvdberge.refinedstorage.api.network.grid.*; import com.raoulvdberge.refinedstorage.api.network.grid.*;
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler; import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler; import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCacheListener; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
import com.raoulvdberge.refinedstorage.api.util.IFilter; import com.raoulvdberge.refinedstorage.api.util.IFilter;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheListenerGridItem; import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.listener.ItemGridStorageCacheListener;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerFilter; import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerFilter;
import com.raoulvdberge.refinedstorage.screen.BaseScreen; import com.raoulvdberge.refinedstorage.screen.BaseScreen;
import com.raoulvdberge.refinedstorage.screen.grid.GridScreen; import com.raoulvdberge.refinedstorage.screen.grid.GridScreen;
@@ -105,7 +105,7 @@ public class WirelessGrid implements IGridNetworkAware {
@Override @Override
public IStorageCacheListener createListener(ServerPlayerEntity player) { public IStorageCacheListener createListener(ServerPlayerEntity player) {
return new StorageCacheListenerGridItem(player, getNetwork()); return new ItemGridStorageCacheListener(player, getNetwork());
} }
@Nullable @Nullable

View File

@@ -1,8 +1,8 @@
package com.raoulvdberge.refinedstorage.tile.grid.portable; package com.raoulvdberge.refinedstorage.tile.grid.portable;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache; import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
import com.raoulvdberge.refinedstorage.api.storage.IStorageTracker;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
import com.raoulvdberge.refinedstorage.api.storage.tracker.IStorageTracker;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase; import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;

View File

@@ -8,9 +8,9 @@ import com.raoulvdberge.refinedstorage.api.network.grid.IGridTab;
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler; import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler; import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler;
import com.raoulvdberge.refinedstorage.api.storage.AccessType; import com.raoulvdberge.refinedstorage.api.storage.AccessType;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCacheListener;
import com.raoulvdberge.refinedstorage.api.storage.StorageType; import com.raoulvdberge.refinedstorage.api.storage.StorageType;
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerContext; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerContext;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider;
@@ -19,9 +19,14 @@ import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.handler.FluidGridHandlerPortable; import com.raoulvdberge.refinedstorage.apiimpl.network.grid.handler.FluidGridHandlerPortable;
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.handler.ItemGridHandlerPortable; import com.raoulvdberge.refinedstorage.apiimpl.network.grid.handler.ItemGridHandlerPortable;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskdrive.DiskDriveNetworkNode; import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskdrive.DiskDriveNetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.storage.*; import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.PortableFluidStorageCache;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFluidPortable; import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.PortableItemStorageCache;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskItemPortable; import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.listener.PortableFluidGridStorageCacheListener;
import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.listener.PortableItemGridStorageCacheListener;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.PortableFluidStorageDisk;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.PortableItemStorageDisk;
import com.raoulvdberge.refinedstorage.apiimpl.storage.tracker.FluidStorageTracker;
import com.raoulvdberge.refinedstorage.apiimpl.storage.tracker.ItemStorageTracker;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase; import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerFilter; import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerFilter;
import com.raoulvdberge.refinedstorage.screen.BaseScreen; import com.raoulvdberge.refinedstorage.screen.BaseScreen;
@@ -69,8 +74,8 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
private int tabPage; private int tabPage;
private int size; private int size;
private StorageTrackerItem storageTracker = new StorageTrackerItem(() -> stack.getTag().put(NBT_STORAGE_TRACKER, getItemStorageTracker().serializeNbt())); private ItemStorageTracker storageTracker = new ItemStorageTracker(() -> stack.getTag().put(NBT_STORAGE_TRACKER, getItemStorageTracker().serializeNbt()));
private StorageTrackerFluid fluidStorageTracker = new StorageTrackerFluid(() -> stack.getTag().put(NBT_FLUID_STORAGE_TRACKER, getFluidStorageTracker().serializeNbt())); private FluidStorageTracker fluidStorageTracker = new FluidStorageTracker(() -> stack.getTag().put(NBT_FLUID_STORAGE_TRACKER, getFluidStorageTracker().serializeNbt()));
private List<IFilter> filters = new ArrayList<>(); private List<IFilter> filters = new ArrayList<>();
private List<IGridTab> tabs = new ArrayList<>(); private List<IGridTab> tabs = new ArrayList<>();
@@ -105,12 +110,12 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
switch (type) { switch (type) {
case ITEM: case ITEM:
storage = new StorageDiskItemPortable(disk, PortableGrid.this); storage = new PortableItemStorageDisk(disk, PortableGrid.this);
cache = new StorageCacheItemPortable(PortableGrid.this); cache = new PortableItemStorageCache(PortableGrid.this);
break; break;
case FLUID: case FLUID:
storage = new StorageDiskFluidPortable(disk, PortableGrid.this); storage = new PortableFluidStorageDisk(disk, PortableGrid.this);
cache = new StorageCacheFluidPortable(PortableGrid.this); cache = new PortableFluidStorageCache(PortableGrid.this);
break; break;
} }
@@ -219,7 +224,7 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
@Override @Override
public IStorageCacheListener createListener(ServerPlayerEntity player) { public IStorageCacheListener createListener(ServerPlayerEntity player) {
return getGridType() == GridType.FLUID ? new StorageCacheListenerGridPortableFluid(this, player) : new StorageCacheListenerGridPortable(this, player); return getGridType() == GridType.FLUID ? new PortableFluidGridStorageCacheListener(this, player) : new PortableItemGridStorageCacheListener(this, player);
} }
@Nullable @Nullable
@@ -364,12 +369,12 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
} }
@Override @Override
public StorageTrackerItem getItemStorageTracker() { public ItemStorageTracker getItemStorageTracker() {
return storageTracker; return storageTracker;
} }
@Override @Override
public StorageTrackerFluid getFluidStorageTracker() { public FluidStorageTracker getFluidStorageTracker() {
return fluidStorageTracker; return fluidStorageTracker;
} }

View File

@@ -9,19 +9,28 @@ import com.raoulvdberge.refinedstorage.api.network.grid.IGridCraftingListener;
import com.raoulvdberge.refinedstorage.api.network.grid.IGridTab; import com.raoulvdberge.refinedstorage.api.network.grid.IGridTab;
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler; import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler; import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler;
import com.raoulvdberge.refinedstorage.api.storage.*; import com.raoulvdberge.refinedstorage.api.storage.AccessType;
import com.raoulvdberge.refinedstorage.api.storage.StorageType;
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerContext; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerContext;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider;
import com.raoulvdberge.refinedstorage.api.storage.tracker.IStorageTracker;
import com.raoulvdberge.refinedstorage.api.util.IFilter; import com.raoulvdberge.refinedstorage.api.util.IFilter;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.handler.FluidGridHandlerPortable; import com.raoulvdberge.refinedstorage.apiimpl.network.grid.handler.FluidGridHandlerPortable;
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.handler.ItemGridHandlerPortable; import com.raoulvdberge.refinedstorage.apiimpl.network.grid.handler.ItemGridHandlerPortable;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.GridNetworkNode; import com.raoulvdberge.refinedstorage.apiimpl.network.node.GridNetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskdrive.DiskDriveNetworkNode; import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskdrive.DiskDriveNetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.storage.*; import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.PortableFluidStorageCache;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFluidPortable; import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.PortableItemStorageCache;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskItemPortable; import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.listener.PortableFluidGridStorageCacheListener;
import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.listener.PortableItemGridStorageCacheListener;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.PortableFluidStorageDisk;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.PortableItemStorageDisk;
import com.raoulvdberge.refinedstorage.apiimpl.storage.tracker.FluidStorageTracker;
import com.raoulvdberge.refinedstorage.apiimpl.storage.tracker.ItemStorageTracker;
import com.raoulvdberge.refinedstorage.block.BlockPortableGrid; import com.raoulvdberge.refinedstorage.block.BlockPortableGrid;
import com.raoulvdberge.refinedstorage.block.enums.PortableGridDiskState; import com.raoulvdberge.refinedstorage.block.enums.PortableGridDiskState;
import com.raoulvdberge.refinedstorage.block.enums.PortableGridType; import com.raoulvdberge.refinedstorage.block.enums.PortableGridType;
@@ -151,8 +160,8 @@ public class TilePortableGrid extends BaseTile implements IGrid, IPortableGrid,
private PortableGridDiskState diskState = PortableGridDiskState.NONE; private PortableGridDiskState diskState = PortableGridDiskState.NONE;
private boolean connected; private boolean connected;
private StorageTrackerItem storageTracker = new StorageTrackerItem(this::markDirty); private ItemStorageTracker storageTracker = new ItemStorageTracker(this::markDirty);
private StorageTrackerFluid fluidStorageTracker = new StorageTrackerFluid(this::markDirty); private FluidStorageTracker fluidStorageTracker = new FluidStorageTracker(this::markDirty);
private ListNBT enchants = null; private ListNBT enchants = null;
public TilePortableGrid() { public TilePortableGrid() {
@@ -182,12 +191,12 @@ public class TilePortableGrid extends BaseTile implements IGrid, IPortableGrid,
switch (type) { switch (type) {
case ITEM: case ITEM:
this.storage = new StorageDiskItemPortable(disk, this); this.storage = new PortableItemStorageDisk(disk, this);
this.cache = new StorageCacheItemPortable(this); this.cache = new PortableItemStorageCache(this);
break; break;
case FLUID: case FLUID:
this.storage = new StorageDiskFluidPortable(disk, this); this.storage = new PortableFluidStorageDisk(disk, this);
this.cache = new StorageCacheFluidPortable(this); this.cache = new PortableFluidStorageCache(this);
break; break;
} }
@@ -319,7 +328,7 @@ public class TilePortableGrid extends BaseTile implements IGrid, IPortableGrid,
@Override @Override
public IStorageCacheListener createListener(ServerPlayerEntity player) { public IStorageCacheListener createListener(ServerPlayerEntity player) {
return getServerGridType() == GridType.FLUID ? new StorageCacheListenerGridPortableFluid(this, player) : new StorageCacheListenerGridPortable(this, player); return getServerGridType() == GridType.FLUID ? new PortableFluidGridStorageCacheListener(this, player) : new PortableItemGridStorageCacheListener(this, player);
} }
@Nullable @Nullable

View File

@@ -1,11 +1,10 @@
package com.raoulvdberge.refinedstorage.util; package com.raoulvdberge.refinedstorage.util;
import com.raoulvdberge.refinedstorage.api.network.INetwork; import com.raoulvdberge.refinedstorage.api.network.INetwork;
import com.raoulvdberge.refinedstorage.api.storage.IStorageTracker;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider; import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider;
import com.raoulvdberge.refinedstorage.api.storage.tracker.StorageTrackerEntry;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageTrackerEntry;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase; import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.screen.grid.stack.FluidGridStack; import com.raoulvdberge.refinedstorage.screen.grid.stack.FluidGridStack;
import com.raoulvdberge.refinedstorage.screen.grid.stack.ItemGridStack; import com.raoulvdberge.refinedstorage.screen.grid.stack.ItemGridStack;
@@ -77,7 +76,7 @@ public final class StackUtils {
} }
} }
public static void writeItemGridStack(PacketBuffer buf, ItemStack stack, UUID id, @Nullable INetwork network, boolean displayCraftText, @Nullable IStorageTracker.IStorageTrackerEntry entry) { public static void writeItemGridStack(PacketBuffer buf, ItemStack stack, UUID id, @Nullable INetwork network, boolean displayCraftText, @Nullable StorageTrackerEntry entry) {
writeItemStack(buf, stack); writeItemStack(buf, stack);
buf.writeUniqueId(id); buf.writeUniqueId(id);
@@ -106,7 +105,7 @@ public final class StackUtils {
boolean craftable = buf.readBoolean(); boolean craftable = buf.readBoolean();
boolean displayCraftText = buf.readBoolean(); boolean displayCraftText = buf.readBoolean();
IStorageTracker.IStorageTrackerEntry entry = null; StorageTrackerEntry entry = null;
if (buf.readBoolean()) { if (buf.readBoolean()) {
entry = new StorageTrackerEntry(buf.readLong(), buf.readString()); entry = new StorageTrackerEntry(buf.readLong(), buf.readString());
} }
@@ -114,7 +113,7 @@ public final class StackUtils {
return new ItemGridStack(id, stack, craftable, displayCraftText, entry); return new ItemGridStack(id, stack, craftable, displayCraftText, entry);
} }
public static void writeFluidGridStack(PacketBuffer buf, FluidStack stack, UUID id, @Nullable INetwork network, boolean displayCraftText, @Nullable IStorageTracker.IStorageTrackerEntry entry) { public static void writeFluidGridStack(PacketBuffer buf, FluidStack stack, UUID id, @Nullable INetwork network, boolean displayCraftText, @Nullable StorageTrackerEntry entry) {
stack.writeToPacket(buf); stack.writeToPacket(buf);
buf.writeUniqueId(id); buf.writeUniqueId(id);
@@ -143,7 +142,7 @@ public final class StackUtils {
boolean craftable = buf.readBoolean(); boolean craftable = buf.readBoolean();
boolean displayCraftText = buf.readBoolean(); boolean displayCraftText = buf.readBoolean();
IStorageTracker.IStorageTrackerEntry entry = null; StorageTrackerEntry entry = null;
if (buf.readBoolean()) { if (buf.readBoolean()) {
entry = new StorageTrackerEntry(buf.readLong(), buf.readString()); entry = new StorageTrackerEntry(buf.readLong(), buf.readString());
} }