Refactor storage classes
This commit is contained in:
@@ -2,11 +2,18 @@ package com.raoulvdberge.refinedstorage;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFluidStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageFluidNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageItemNBT;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.VertexBuffer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -19,6 +26,7 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
@@ -89,7 +97,7 @@ public final class RSUtils {
|
||||
return Pair.of(buf.readInt(), new FluidStack(FluidRegistry.getFluid(ByteBufUtils.readUTF8String(buf)), buf.readInt(), ByteBufUtils.readTag(buf)));
|
||||
}
|
||||
|
||||
public static void createStorages(ItemStack disk, int slot, ItemStorageNBT[] itemStorages, FluidStorageNBT[] fluidStorages, Function<ItemStack, ItemStorageNBT> itemStorageSupplier, Function<ItemStack, FluidStorageNBT> fluidStorageNBTSupplier) {
|
||||
public static void createStorages(ItemStack disk, int slot, StorageItemNBT[] itemStorages, StorageFluidNBT[] fluidStorages, Function<ItemStack, StorageItemNBT> itemStorageSupplier, Function<ItemStack, StorageFluidNBT> fluidStorageNBTSupplier) {
|
||||
if (disk.isEmpty()) {
|
||||
itemStorages[slot] = null;
|
||||
fluidStorages[slot] = null;
|
||||
@@ -188,7 +196,7 @@ public final class RSUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static NBTTagList serializeFluidStackList(IFluidStackList list) {
|
||||
public static NBTTagList serializeFluidStackList(IStackList<FluidStack> list) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for (FluidStack stack : list.getStacks()) {
|
||||
@@ -198,14 +206,14 @@ public final class RSUtils {
|
||||
return tagList;
|
||||
}
|
||||
|
||||
public static IFluidStackList readFluidStackList(NBTTagList tagList) {
|
||||
IFluidStackList list = API.instance().createFluidStackList();
|
||||
public static IStackList<FluidStack> readFluidStackList(NBTTagList tagList) {
|
||||
IStackList<FluidStack> list = API.instance().createFluidStackList();
|
||||
|
||||
for (int i = 0; i < tagList.tagCount(); ++i) {
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(tagList.getCompoundTagAt(i));
|
||||
|
||||
if (stack != null) {
|
||||
list.add(stack);
|
||||
list.add(stack, stack.amount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,4 +369,125 @@ public final class RSUtils {
|
||||
|
||||
return new AdvancedRayTraceResult(result, bounds);
|
||||
}
|
||||
|
||||
public static class FluidRenderer {
|
||||
private static final int TEX_WIDTH = 16;
|
||||
private static final int TEX_HEIGHT = 16;
|
||||
private static final int MIN_FLUID_HEIGHT = 1;
|
||||
|
||||
private final int capacityMb;
|
||||
private final int width;
|
||||
private final int height;
|
||||
|
||||
public FluidRenderer(int capacityMb, int width, int height) {
|
||||
this.capacityMb = capacityMb;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void draw(Minecraft minecraft, int xPosition, int yPosition, FluidStack fluidStack) {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.enableAlpha();
|
||||
|
||||
drawFluid(minecraft, xPosition, yPosition, fluidStack);
|
||||
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
|
||||
private void drawFluid(Minecraft minecraft, int xPosition, int yPosition, FluidStack fluidStack) {
|
||||
if (fluidStack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
|
||||
if (fluid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
TextureMap textureMapBlocks = minecraft.getTextureMapBlocks();
|
||||
ResourceLocation fluidStill = fluid.getStill();
|
||||
TextureAtlasSprite fluidStillSprite = null;
|
||||
|
||||
if (fluidStill != null) {
|
||||
fluidStillSprite = textureMapBlocks.getTextureExtry(fluidStill.toString());
|
||||
}
|
||||
|
||||
if (fluidStillSprite == null) {
|
||||
fluidStillSprite = textureMapBlocks.getMissingSprite();
|
||||
}
|
||||
|
||||
int fluidColor = fluid.getColor(fluidStack);
|
||||
|
||||
int scaledAmount = height;
|
||||
|
||||
if (capacityMb != -1) {
|
||||
scaledAmount = (fluidStack.amount * height) / capacityMb;
|
||||
|
||||
if (fluidStack.amount > 0 && scaledAmount < MIN_FLUID_HEIGHT) {
|
||||
scaledAmount = MIN_FLUID_HEIGHT;
|
||||
}
|
||||
|
||||
if (scaledAmount > height) {
|
||||
scaledAmount = height;
|
||||
}
|
||||
}
|
||||
|
||||
minecraft.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
setGLColorFromInt(fluidColor);
|
||||
|
||||
int xTileCount = width / TEX_WIDTH;
|
||||
int xRemainder = width - (xTileCount * TEX_WIDTH);
|
||||
int yTileCount = scaledAmount / TEX_HEIGHT;
|
||||
int yRemainder = scaledAmount - (yTileCount * TEX_HEIGHT);
|
||||
|
||||
int yStart = yPosition + height;
|
||||
|
||||
for (int xTile = 0; xTile <= xTileCount; xTile++) {
|
||||
for (int yTile = 0; yTile <= yTileCount; yTile++) {
|
||||
int width = (xTile == xTileCount) ? xRemainder : TEX_WIDTH;
|
||||
int height = (yTile == yTileCount) ? yRemainder : TEX_HEIGHT;
|
||||
int x = xPosition + (xTile * TEX_WIDTH);
|
||||
int y = yStart - ((yTile + 1) * TEX_HEIGHT);
|
||||
|
||||
if (width > 0 && height > 0) {
|
||||
int maskTop = TEX_HEIGHT - height;
|
||||
int maskRight = TEX_WIDTH - width;
|
||||
|
||||
drawFluidTexture(x, y, fluidStillSprite, maskTop, maskRight, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setGLColorFromInt(int color) {
|
||||
float red = (color >> 16 & 0xFF) / 255.0F;
|
||||
float green = (color >> 8 & 0xFF) / 255.0F;
|
||||
float blue = (color & 0xFF) / 255.0F;
|
||||
|
||||
GlStateManager.color(red, green, blue, 1.0F);
|
||||
}
|
||||
|
||||
private static void drawFluidTexture(double xCoord, double yCoord, TextureAtlasSprite textureSprite, int maskTop, int maskRight, double zLevel) {
|
||||
double uMin = (double) textureSprite.getMinU();
|
||||
double uMax = (double) textureSprite.getMaxU();
|
||||
double vMin = (double) textureSprite.getMinV();
|
||||
double vMax = (double) textureSprite.getMaxV();
|
||||
uMax = uMax - (maskRight / 16.0 * (uMax - uMin));
|
||||
vMax = vMax - (maskTop / 16.0 * (vMax - vMin));
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
|
||||
VertexBuffer vertexBuffer = tessellator.getBuffer();
|
||||
vertexBuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
vertexBuffer.pos(xCoord, yCoord + 16, zLevel).tex(uMin, vMax).endVertex();
|
||||
vertexBuffer.pos(xCoord + 16 - maskRight, yCoord + 16, zLevel).tex(uMax, vMax).endVertex();
|
||||
vertexBuffer.pos(xCoord + 16 - maskRight, yCoord + maskTop, zLevel).tex(uMax, vMin).endVertex();
|
||||
vertexBuffer.pos(xCoord, yCoord + maskTop, zLevel).tex(uMin, vMin).endVertex();
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,7 @@ import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterCha
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterHandlerRegistry;
|
||||
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRegistry;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFluidStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IItemStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -70,13 +69,13 @@ public interface IRSAPI {
|
||||
* @return an empty item stack list
|
||||
*/
|
||||
@Nonnull
|
||||
IItemStackList createItemStackList();
|
||||
IStackList<ItemStack> createItemStackList();
|
||||
|
||||
/**
|
||||
* @return an empty fluid stack list
|
||||
*/
|
||||
@Nonnull
|
||||
IFluidStackList createFluidStackList();
|
||||
IStackList<FluidStack> createFluidStackList();
|
||||
|
||||
@Nonnull
|
||||
ICraftingMonitorElementList createCraftingMonitorElementList();
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.raoulvdberge.refinedstorage.api.autocrafting.task;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFluidStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IItemStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -31,7 +30,7 @@ public interface ICraftingStep {
|
||||
* @param fluids a list to compare the needed {@link FluidStack} inputs against (eg. a bucket, machine insert)
|
||||
* @return true if processing can start
|
||||
*/
|
||||
boolean canStartProcessing(IItemStackList items, IFluidStackList fluids);
|
||||
boolean canStartProcessing(IStackList<ItemStack> items, IStackList<FluidStack> fluids);
|
||||
|
||||
/**
|
||||
* Check if the processing can start.
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.preview.ICraftingPreviewElement;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IItemStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -114,7 +114,7 @@ public interface ICraftingTask {
|
||||
/**
|
||||
* @return the missing items
|
||||
*/
|
||||
IItemStackList getMissing();
|
||||
IStackList<ItemStack> getMissing();
|
||||
|
||||
/**
|
||||
* {@link ICraftingTask#calculate()} must be run before this!
|
||||
|
||||
@@ -6,8 +6,7 @@ import com.raoulvdberge.refinedstorage.api.network.grid.IFluidGridHandler;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IItemGridHandler;
|
||||
import com.raoulvdberge.refinedstorage.api.network.item.INetworkItemHandler;
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterChannel;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.fluid.IFluidStorageCache;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.item.IItemStorageCache;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -60,14 +59,14 @@ public interface INetworkMaster {
|
||||
INetworkItemHandler getNetworkItemHandler();
|
||||
|
||||
/**
|
||||
* @return the {@link IItemStorageCache} of this network
|
||||
* @return the {@link IStorageCache<ItemStack>} of this network
|
||||
*/
|
||||
IItemStorageCache getItemStorageCache();
|
||||
IStorageCache<ItemStack> getItemStorageCache();
|
||||
|
||||
/**
|
||||
* @return the {@link IFluidStorageCache} of this network
|
||||
* @return the {@link IStorageCache<FluidStack>} of this network
|
||||
*/
|
||||
IFluidStorageCache getFluidStorageCache();
|
||||
IStorageCache<FluidStack> getFluidStorageCache();
|
||||
|
||||
/**
|
||||
* @return the crafting tasks in this network, do NOT modify this list
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.raoulvdberge.refinedstorage.api.storage;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface IStorage<T> {
|
||||
@@ -10,6 +12,31 @@ public interface IStorage<T> {
|
||||
*/
|
||||
NonNullList<T> getStacks();
|
||||
|
||||
/**
|
||||
* Inserts a stack to this storage.
|
||||
*
|
||||
* @param stack the stack prototype to insert, do NOT modify
|
||||
* @param size the amount of that prototype that has to be inserted
|
||||
* @param simulate true if we are simulating, false otherwise
|
||||
* @return null if the insert was successful, or a stack with the remainder
|
||||
*/
|
||||
@Nullable
|
||||
T insert(@Nonnull T stack, int size, boolean simulate);
|
||||
|
||||
/**
|
||||
* Extracts a stack from this storage.
|
||||
* <p>
|
||||
* If the stack we found in the system is smaller than the requested size, return that stack anyway.
|
||||
*
|
||||
* @param stack a prototype of the stack to extract, do NOT modify
|
||||
* @param size the amount of that prototype that has to be extracted
|
||||
* @param flags the flags to compare on, see {@link IComparer}
|
||||
* @param simulate true if we are simulating, false otherwise
|
||||
* @return null if we didn't extract anything, or a stack with the result
|
||||
*/
|
||||
@Nullable
|
||||
T extract(@Nonnull T stack, int size, int flags, boolean simulate);
|
||||
|
||||
/**
|
||||
* @return the amount of fluids stored in this storage
|
||||
*/
|
||||
|
||||
57
src/main/java/com/raoulvdberge/refinedstorage/api/storage/IStorageCache.java
Executable file
57
src/main/java/com/raoulvdberge/refinedstorage/api/storage/IStorageCache.java
Executable file
@@ -0,0 +1,57 @@
|
||||
package com.raoulvdberge.refinedstorage.api.storage;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This holds all stacks from all the connected storages from a {@link INetworkMaster}.
|
||||
* <p>
|
||||
* Refined Storage uses this class mainly for use in Grids and Detectors to avoid querying
|
||||
* individual {@link IStorage}s constantly (performance impact) and to send and detect storage changes
|
||||
* more efficiently.
|
||||
*/
|
||||
public interface IStorageCache<T> {
|
||||
/**
|
||||
* Invalidates the cache.
|
||||
* Typically called when a {@link IStorageProvider} is added or removed from the network.
|
||||
*/
|
||||
void invalidate();
|
||||
|
||||
/**
|
||||
* Adds a stack to the cache.
|
||||
* <p>
|
||||
* Note that this doesn't modify any of the connected storages, but just modifies the cache.
|
||||
* Use {@link IStorage#insert(T, int, boolean)} to add a stack to an actual storage.
|
||||
* <p>
|
||||
* Will merge it with another stack if it already exists.
|
||||
*
|
||||
* @param stack the stack to add, do NOT modify
|
||||
* @param size the size to add
|
||||
* @param rebuilding true if this method is called while rebuilding, false otherwise
|
||||
*/
|
||||
void add(@Nonnull T stack, int size, boolean rebuilding);
|
||||
|
||||
/**
|
||||
* Removes a stack from the cache.
|
||||
* <p>
|
||||
* Note that this doesn't modify any of the connected storages, but just modifies the cache.
|
||||
* Use {@link IStorage#extract(T, int, int, boolean)} to remove a stack from an actual storage.
|
||||
*
|
||||
* @param stack the stack to remove, do NOT modify
|
||||
* @param size the size to remove
|
||||
*/
|
||||
void remove(@Nonnull T stack, int size);
|
||||
|
||||
/**
|
||||
* @return the list behind this cache
|
||||
*/
|
||||
IStackList<T> getList();
|
||||
|
||||
/**
|
||||
* @return the storages connected to this network
|
||||
*/
|
||||
List<IStorage<T>> getStorages();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.raoulvdberge.refinedstorage.api.storage;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IStorageProvider {
|
||||
void addItemStorages(List<IStorage<ItemStack>> storages);
|
||||
|
||||
void addFluidStorages(List<IStorage<FluidStack>> storages);
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.api.storage.fluid;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a fluid storage sink for the storage network.
|
||||
* Provide this through an {@link IFluidStorageProvider}.
|
||||
*/
|
||||
public interface IFluidStorage extends IStorage<FluidStack> {
|
||||
/**
|
||||
* Inserts a fluid in this storage.
|
||||
*
|
||||
* @param stack the fluid prototype to insert, do NOT modify
|
||||
* @param size the amount of that prototype that has to be inserted
|
||||
* @param simulate true if we are simulating, false otherwise
|
||||
* @return null if the insert was successful, or a stack with the remainder
|
||||
*/
|
||||
@Nullable
|
||||
FluidStack insertFluid(@Nonnull FluidStack stack, int size, boolean simulate);
|
||||
|
||||
/**
|
||||
* Extracts a fluid from this storage.
|
||||
* <p>
|
||||
* If the fluid we found in the system is smaller than the requested size, return that fluid anyway.
|
||||
*
|
||||
* @param stack a prototype of the fluid to extract, do NOT modify
|
||||
* @param size the amount of that fluid that has to be extracted
|
||||
* @param flags the flags to compare on, see {@link IComparer}
|
||||
* @param simulate true if we are simulating, false otherwise
|
||||
* @return null if we didn't extract anything, or a stack with the result
|
||||
*/
|
||||
@Nullable
|
||||
FluidStack extractFluid(@Nonnull FluidStack stack, int size, int flags, boolean simulate);
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.api.storage.fluid;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFluidStackList;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This holds all fluids from all the connected storages from a {@link INetworkMaster}.
|
||||
* <p>
|
||||
* Refined Storage uses this class mainly for use in Grids and Detectors to avoid querying
|
||||
* individual {@link IFluidStorage}s constantly (performance impact) and to send and detect storage changes
|
||||
* more efficiently.
|
||||
*/
|
||||
public interface IFluidStorageCache {
|
||||
/**
|
||||
* Invalidates the cache.
|
||||
* Typically called when a {@link IFluidStorageProvider} is added or removed from the network.
|
||||
*/
|
||||
void invalidate();
|
||||
|
||||
/**
|
||||
* Adds an item to the cache.
|
||||
* <p>
|
||||
* Note that this doesn't modify any of the connected storages, but just modifies the cache.
|
||||
* Use {@link INetworkMaster#insertFluid(FluidStack, int, boolean)} to add a fluid to an actual storage.
|
||||
* <p>
|
||||
* Will merge it with another fluid if it already exists.
|
||||
*
|
||||
* @param stack the stack to add, do NOT modify
|
||||
* @param rebuilding true if this method is called while rebuilding, false otherwise
|
||||
*/
|
||||
void add(@Nonnull FluidStack stack, boolean rebuilding);
|
||||
|
||||
/**
|
||||
* Removes a fluid from the cache.
|
||||
* <p>
|
||||
* Note that this doesn't modify any of the connected storages, but just modifies the cache.
|
||||
* Use {@link INetworkMaster#extractFluid(FluidStack, int, int, boolean)} to remove an fluid from an actual storage.
|
||||
*
|
||||
* @param stack the fluid to remove, do NOT modify
|
||||
*/
|
||||
void remove(@Nonnull FluidStack stack);
|
||||
|
||||
/**
|
||||
* @return the list behind this cache
|
||||
*/
|
||||
IFluidStackList getList();
|
||||
|
||||
/**
|
||||
* @return the fluid storages connected to this network
|
||||
*/
|
||||
List<IFluidStorage> getStorages();
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.api.storage.fluid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a node that provides fluid storage to the network.
|
||||
*/
|
||||
public interface IFluidStorageProvider {
|
||||
/**
|
||||
* Adds the fluid storages that this storage provider provides.
|
||||
*
|
||||
* @param storages the list to insert new storages to
|
||||
*/
|
||||
void addFluidStorages(List<IFluidStorage> storages);
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.api.storage.item;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Represents an item storage sink for the storage network.
|
||||
* Provide this through an {@link IItemStorageProvider}.
|
||||
*/
|
||||
public interface IItemStorage extends IStorage<ItemStack> {
|
||||
/**
|
||||
* Inserts an item to this storage.
|
||||
*
|
||||
* @param stack the stack prototype to insert, do NOT modify
|
||||
* @param size the amount of that prototype that has to be inserted
|
||||
* @param simulate true if we are simulating, false otherwise
|
||||
* @return null if the insert was successful, or a stack with the remainder
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack insertItem(@Nonnull ItemStack stack, int size, boolean simulate);
|
||||
|
||||
/**
|
||||
* Extracts an item from this storage.
|
||||
* <p>
|
||||
* If the stack we found in the system is smaller than the requested size, return that stack anyway.
|
||||
*
|
||||
* @param stack a prototype of the stack to extract, do NOT modify
|
||||
* @param size the amount of that prototype that has to be extracted
|
||||
* @param flags the flags to compare on, see {@link IComparer}
|
||||
* @param simulate true if we are simulating, false otherwise
|
||||
* @return null if we didn't extract anything, or a stack with the result
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags, boolean simulate);
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.api.storage.item;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IItemStackList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This holds all items from all the connected storages from a {@link INetworkMaster}.
|
||||
* <p>
|
||||
* Refined Storage uses this class mainly for use in Grids and Detectors to avoid querying
|
||||
* individual {@link IItemStorage}s constantly (performance impact) and to send and detect storage changes
|
||||
* more efficiently.
|
||||
*/
|
||||
public interface IItemStorageCache {
|
||||
/**
|
||||
* Invalidates the cache.
|
||||
* Typically called when a {@link IItemStorageProvider} is added or removed from the network.
|
||||
*/
|
||||
void invalidate();
|
||||
|
||||
/**
|
||||
* Adds an item to the cache.
|
||||
* <p>
|
||||
* Note that this doesn't modify any of the connected storages, but just modifies the cache.
|
||||
* Use {@link INetworkMaster#insertItem(ItemStack, int, boolean)} to add an item to an actual storage.
|
||||
* <p>
|
||||
* Will merge it with another item if it already exists.
|
||||
*
|
||||
* @param stack the stack to add, do NOT modify
|
||||
* @param size the size to add
|
||||
* @param rebuilding true if this method is called while rebuilding, false otherwise
|
||||
*/
|
||||
void add(@Nonnull ItemStack stack, int size, boolean rebuilding);
|
||||
|
||||
/**
|
||||
* Removes an item from the cache.
|
||||
* <p>
|
||||
* Note that this doesn't modify any of the connected storages, but just modifies the cache.
|
||||
* Use {@link INetworkMaster#extractItem(ItemStack, int, int, boolean)} to remove an item from an actual storage.
|
||||
*
|
||||
* @param stack the item to remove, do NOT modify
|
||||
* @param size the size to remove
|
||||
*/
|
||||
void remove(@Nonnull ItemStack stack, int size);
|
||||
|
||||
/**
|
||||
* @return the list behind this cache
|
||||
*/
|
||||
IItemStackList getList();
|
||||
|
||||
/**
|
||||
* @return the item storages connected to this network
|
||||
*/
|
||||
List<IItemStorage> getStorages();
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.api.storage.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a node that provides item storage to the network.
|
||||
*/
|
||||
public interface IItemStorageProvider {
|
||||
/**
|
||||
* Adds the item storages that this storage provider provides.
|
||||
*
|
||||
* @param storages the list to insert new storages to
|
||||
*/
|
||||
void addItemStorages(List<IItemStorage> storages);
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.api.util;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.IRSAPI;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* A fluid stack list.
|
||||
*/
|
||||
public interface IFluidStackList {
|
||||
/**
|
||||
* Adds a stack to the list, will merge it with another stack if it already exists in the list.
|
||||
*
|
||||
* @param stack the stack
|
||||
*/
|
||||
void add(FluidStack stack);
|
||||
|
||||
/**
|
||||
* Decrements the count of that stack in the list.
|
||||
*
|
||||
* @param stack the stack
|
||||
* @param size the size to remove
|
||||
* @param removeIfReachedZero true to remove the stack if the count reaches 0, false otherwise
|
||||
* @return whether the remove was successful for the full amount
|
||||
*/
|
||||
boolean remove(@Nonnull FluidStack stack, int size, boolean removeIfReachedZero);
|
||||
|
||||
/**
|
||||
* Decrements the count of that stack in the list.
|
||||
*
|
||||
* @param stack the stack
|
||||
* @param removeIfReachedZero true to remove the stack if the count reaches 0, false otherwise
|
||||
* @return whether the remove was successful for the full amount
|
||||
*/
|
||||
default boolean remove(@Nonnull FluidStack stack, boolean removeIfReachedZero) {
|
||||
return remove(stack, stack.amount, removeIfReachedZero);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrements the count of that stack in the list.
|
||||
* Keeps track of remove items and can be undone by calling {@link #undo()}
|
||||
*
|
||||
* @param stack the stack
|
||||
* @param size the size to remove
|
||||
* @param removeIfReachedZero true to remove the stack if the count reaches 0, false otherwise
|
||||
* @return whether the remove was successful for the full amount
|
||||
*/
|
||||
boolean trackedRemove(@Nonnull FluidStack stack, int size, boolean removeIfReachedZero);
|
||||
|
||||
/**
|
||||
* Decrements the count of that stack in the list.
|
||||
* Keeps track of remove items and can be undone by calling {@link #undo()}
|
||||
*
|
||||
* @param stack the stack
|
||||
* @param removeIfReachedZero true to remove the stack if the count reaches 0, false otherwise
|
||||
* @return whether the remove was successful for the full amount
|
||||
*/
|
||||
default boolean trackedRemove(@Nonnull FluidStack stack, boolean removeIfReachedZero) {
|
||||
return trackedRemove(stack, stack.amount, removeIfReachedZero);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore all tracked removes
|
||||
*/
|
||||
void undo();
|
||||
|
||||
/**
|
||||
* Returns a stack.
|
||||
*
|
||||
* @param stack the stack to search for
|
||||
* @return the stack, or null if no stack was found
|
||||
*/
|
||||
@Nullable
|
||||
default FluidStack get(@Nonnull FluidStack stack) {
|
||||
return get(stack, IComparer.COMPARE_NBT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stack.
|
||||
*
|
||||
* @param stack the stack to search for
|
||||
* @param flags the flags to compare on, see {@link IComparer}
|
||||
* @return the stack, or null if no stack was found
|
||||
*/
|
||||
@Nullable
|
||||
FluidStack get(@Nonnull FluidStack stack, int flags);
|
||||
|
||||
/**
|
||||
* Returns a stack.
|
||||
*
|
||||
* @param hash the hash of the stack to search for, see {@link IRSAPI#getFluidStackHashCode(FluidStack)}
|
||||
* @return the stack, or null if no stack was found
|
||||
*/
|
||||
@Nullable
|
||||
FluidStack get(int hash);
|
||||
|
||||
/**
|
||||
* Clears the list.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Removes all stacks with size zero.
|
||||
*/
|
||||
void clean();
|
||||
|
||||
/**
|
||||
* @return true if the list is empty, false otherwise
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
/**
|
||||
* @return a collection of stacks in this list
|
||||
*/
|
||||
@Nonnull
|
||||
Collection<FluidStack> getStacks();
|
||||
|
||||
/**
|
||||
* @return a new copy of this list, with the stacks in it copied as well
|
||||
*/
|
||||
@Nonnull
|
||||
IFluidStackList copy();
|
||||
}
|
||||
@@ -1,72 +1,69 @@
|
||||
package com.raoulvdberge.refinedstorage.api.util;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.IRSAPI;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An item stack list.
|
||||
* A stack list.
|
||||
*/
|
||||
public interface IItemStackList {
|
||||
public interface IStackList<T> {
|
||||
/**
|
||||
* Adds a stack to the list, will merge it with another stack if it already exists in the list.
|
||||
*
|
||||
* @param stack the stack
|
||||
* @param size the size to add
|
||||
*/
|
||||
void add(@Nonnull ItemStack stack, int size);
|
||||
void add(@Nonnull T stack, int size);
|
||||
|
||||
/**
|
||||
* Adds a stack to the list, will merge it with another stack if it already exists in the list.
|
||||
*
|
||||
* @param stack the stack
|
||||
*/
|
||||
default void add(@Nonnull ItemStack stack) {
|
||||
add(stack, stack.getCount());
|
||||
default void add(@Nonnull T stack) {
|
||||
add(stack, getSizeFromStack(stack));
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrements the count of that stack in the list.
|
||||
*
|
||||
* @param stack the stack
|
||||
* @param size the size to remove
|
||||
* @param stack the stack
|
||||
* @param size the size to remove
|
||||
* @return whether the remove was successful for the full amount
|
||||
*/
|
||||
boolean remove(@Nonnull ItemStack stack, int size);
|
||||
boolean remove(@Nonnull T stack, int size);
|
||||
|
||||
/**
|
||||
* Decrements the count of that stack in the list.
|
||||
*
|
||||
* @param stack the stack
|
||||
* @param stack the stack
|
||||
* @return whether the remove was successful for the full amount
|
||||
*/
|
||||
default boolean remove(@Nonnull ItemStack stack) {
|
||||
return remove(stack, stack.getCount());
|
||||
default void remove(@Nonnull T stack) {
|
||||
remove(stack, getSizeFromStack(stack));
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrements the count of that stack in the list.
|
||||
* Keeps track of remove items and can be undone by calling {@link #undo()}
|
||||
* Keeps track of removed stacks and can be undone by calling {@link #undo()}
|
||||
*
|
||||
* @param stack the stack
|
||||
* @param size the size to remove
|
||||
* @param stack the stack
|
||||
* @param size the size to remove
|
||||
* @return whether the remove was successful for the full amount
|
||||
*/
|
||||
boolean trackedRemove(@Nonnull ItemStack stack, int size);
|
||||
boolean trackedRemove(@Nonnull T stack, int size);
|
||||
|
||||
/**
|
||||
* Decrements the count of that stack in the list.
|
||||
* Keeps track of remove items and can be undone by calling {@link #undo()}
|
||||
* Keeps track of removed stacks and can be undone by calling {@link #undo()}
|
||||
*
|
||||
* @param stack the stack
|
||||
* @param stack the stack
|
||||
* @return whether the remove was successful for the full amount
|
||||
*/
|
||||
default boolean trackedRemove(@Nonnull ItemStack stack) {
|
||||
return trackedRemove(stack, stack.getCount());
|
||||
default boolean trackedRemove(@Nonnull T stack) {
|
||||
return trackedRemove(stack, getSizeFromStack(stack));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +74,7 @@ public interface IItemStackList {
|
||||
/**
|
||||
* @return the remove tracker
|
||||
*/
|
||||
List<ItemStack> getRemoveTracker();
|
||||
List<T> getRemoveTracker();
|
||||
|
||||
/**
|
||||
* Returns a stack.
|
||||
@@ -86,7 +83,7 @@ public interface IItemStackList {
|
||||
* @return the stack, or null if no stack was found
|
||||
*/
|
||||
@Nullable
|
||||
default ItemStack get(@Nonnull ItemStack stack) {
|
||||
default T get(@Nonnull T stack) {
|
||||
return get(stack, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT);
|
||||
}
|
||||
|
||||
@@ -98,16 +95,16 @@ public interface IItemStackList {
|
||||
* @return the stack, or null if no stack was found
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack get(@Nonnull ItemStack stack, int flags);
|
||||
T get(@Nonnull T stack, int flags);
|
||||
|
||||
/**
|
||||
* Returns a stack.
|
||||
*
|
||||
* @param hash the hash of the stack to search for, see {@link IRSAPI#getItemStackHashCode(ItemStack)}
|
||||
* @param hash the hash of the stack to search for
|
||||
* @return the stack, or null if no stack was found
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack get(int hash);
|
||||
T get(int hash);
|
||||
|
||||
/**
|
||||
* Clears the list.
|
||||
@@ -115,7 +112,7 @@ public interface IItemStackList {
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Removes all stacks with size zero
|
||||
* Removes all stacks with size zero.
|
||||
*/
|
||||
void clean();
|
||||
|
||||
@@ -124,21 +121,26 @@ public interface IItemStackList {
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
/**
|
||||
* @param stack the stack
|
||||
* @return the size of the stack
|
||||
*/
|
||||
int getSizeFromStack(T stack);
|
||||
|
||||
/**
|
||||
* @return a collection of stacks in this list
|
||||
*/
|
||||
@Nonnull
|
||||
Collection<ItemStack> getStacks();
|
||||
Collection<T> getStacks();
|
||||
|
||||
/**
|
||||
* @return a new copy of this list, with the stacks in it copied as well
|
||||
*/
|
||||
@Nonnull
|
||||
IItemStackList copy();
|
||||
IStackList<T> copy();
|
||||
|
||||
/**
|
||||
* @return the list wrapped in an ore dictionary optimized {@link IItemStackList}
|
||||
* @return an oredict stack list
|
||||
*/
|
||||
@Nonnull
|
||||
IItemStackList getOredicted();
|
||||
IStackList<T> getOredicted();
|
||||
}
|
||||
@@ -11,8 +11,7 @@ import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterCha
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterHandlerRegistry;
|
||||
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRegistry;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFluidStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IItemStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementRegistry;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewElementRegistry;
|
||||
@@ -21,8 +20,8 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter.ReaderWriter
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter.ReaderWriterHandlerRegistry;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.solderer.SoldererRegistry;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.Comparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.FluidStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.ItemStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.StackListFluid;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.StackListItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -89,14 +88,14 @@ public class API implements IRSAPI {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IItemStackList createItemStackList() {
|
||||
return new ItemStackList();
|
||||
public IStackList<ItemStack> createItemStackList() {
|
||||
return new StackListItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IFluidStackList createFluidStackList() {
|
||||
return new FluidStackList();
|
||||
public IStackList<FluidStack> createFluidStackList() {
|
||||
return new StackListFluid();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.registry.ICraftingTaskFa
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingStep;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFluidStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task.CraftingStep;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task.CraftingStepCraft;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task.CraftingStepProcess;
|
||||
@@ -68,7 +68,7 @@ public class CraftingTaskFactory implements ICraftingTaskFactory {
|
||||
}
|
||||
}
|
||||
|
||||
IFluidStackList toTakeFluids = RSUtils.readFluidStackList(tag.getTagList(CraftingTask.NBT_TO_TAKE_FLUIDS, Constants.NBT.TAG_COMPOUND));
|
||||
IStackList<FluidStack> toTakeFluids = RSUtils.readFluidStackList(tag.getTagList(CraftingTask.NBT_TO_TAKE_FLUIDS, Constants.NBT.TAG_COMPOUND));
|
||||
|
||||
NBTTagList toInsertFluidsList = tag.getTagList(CraftingTask.NBT_TO_INSERT_FLUIDS, Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
|
||||
@@ -7,8 +7,7 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternProvider
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingStep;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFluidStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IItemStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -162,14 +161,14 @@ public abstract class CraftingStep implements ICraftingStep {
|
||||
ITEM, FLUID
|
||||
}
|
||||
|
||||
protected AvailableType isItemAvailable(IItemStackList items, IFluidStackList fluids, ItemStack stack, ItemStack actualStack, int compare) {
|
||||
protected AvailableType isItemAvailable(IStackList<ItemStack> items, IStackList<FluidStack> fluids, ItemStack stack, ItemStack actualStack, int compare) {
|
||||
if (actualStack == null || actualStack.getCount() == 0 || !items.trackedRemove(actualStack, stack.getCount())) {
|
||||
FluidStack fluidInItem = RSUtils.getFluidFromStack(stack, true).getValue();
|
||||
|
||||
if (fluidInItem != null && RSUtils.hasFluidBucket(fluidInItem)) {
|
||||
FluidStack fluidStack = fluids.get(fluidInItem, compare);
|
||||
ItemStack bucket = items.get(RSUtils.EMPTY_BUCKET, compare);
|
||||
if (bucket != null && fluidStack != null && fluids.trackedRemove(fluidStack, fluidInItem.amount, true) && items.trackedRemove(bucket, 1)) {
|
||||
if (bucket != null && fluidStack != null && fluids.trackedRemove(fluidStack, fluidInItem.amount) && items.trackedRemove(bucket, 1)) {
|
||||
return AvailableType.FLUID;
|
||||
}
|
||||
}
|
||||
@@ -178,7 +177,7 @@ public abstract class CraftingStep implements ICraftingStep {
|
||||
return AvailableType.ITEM;
|
||||
}
|
||||
|
||||
protected boolean extractItems(IItemStackList actualInputs, int compare, Deque<ItemStack> toInsertItems) {
|
||||
protected boolean extractItems(IStackList<ItemStack> actualInputs, int compare, Deque<ItemStack> toInsertItems) {
|
||||
for (ItemStack insertStack : getToInsert()) {
|
||||
// This will be a tool, like a hammer
|
||||
if (insertStack.isItemStackDamageable()) {
|
||||
|
||||
@@ -3,10 +3,9 @@ package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFluidStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IItemStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.ItemStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.StackListItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -38,7 +37,7 @@ public class CraftingStepCraft extends CraftingStep {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStartProcessing(IItemStackList items, IFluidStackList fluids) {
|
||||
public boolean canStartProcessing(IStackList<ItemStack> items, IStackList<FluidStack> fluids) {
|
||||
int compare = CraftingTask.DEFAULT_COMPARE | (pattern.isOredict() ? IComparer.COMPARE_OREDICT : 0);
|
||||
for (ItemStack stack : getToInsert()) {
|
||||
// This will be a tool, like a hammer
|
||||
@@ -62,11 +61,11 @@ public class CraftingStepCraft extends CraftingStep {
|
||||
|
||||
@Override
|
||||
public void execute(Deque<ItemStack> toInsertItems, Deque<FluidStack> toInsertFluids) {
|
||||
IItemStackList actualInputs = API.instance().createItemStackList();
|
||||
IStackList<ItemStack> actualInputs = API.instance().createItemStackList();
|
||||
int compare = CraftingTask.DEFAULT_COMPARE | (getPattern().isOredict() ? IComparer.COMPARE_OREDICT : 0);
|
||||
if (extractItems(actualInputs, compare, toInsertItems)) {
|
||||
|
||||
ItemStack[] took = ItemStackList.toCraftingGrid(actualInputs, toInsert, compare);
|
||||
ItemStack[] took = StackListItem.toCraftingGrid(actualInputs, toInsert, compare);
|
||||
|
||||
for (ItemStack byproduct : (pattern.isOredict() ? pattern.getByproducts(took) : pattern.getByproducts())) {
|
||||
if (byproduct != null) {
|
||||
|
||||
@@ -3,8 +3,7 @@ package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFluidStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IItemStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -31,7 +30,7 @@ public class CraftingStepProcess extends CraftingStep {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStartProcessing(IItemStackList items, IFluidStackList fluids) {
|
||||
public boolean canStartProcessing(IStackList<ItemStack> items, IStackList<FluidStack> fluids) {
|
||||
IItemHandler inventory = getPattern().getContainer().getFacingInventory();
|
||||
int compare = CraftingTask.DEFAULT_COMPARE | (pattern.isOredict() ? IComparer.COMPARE_OREDICT : 0);
|
||||
if (inventory != null) {
|
||||
@@ -73,7 +72,7 @@ public class CraftingStepProcess extends CraftingStep {
|
||||
|
||||
@Override
|
||||
public void execute(Deque<ItemStack> toInsertItems, Deque<FluidStack> toInsertFluids) {
|
||||
IItemStackList actualInputs = API.instance().createItemStackList();
|
||||
IStackList<ItemStack> actualInputs = API.instance().createItemStackList();
|
||||
int compare = CraftingTask.DEFAULT_COMPARE | (getPattern().isOredict() ? IComparer.COMPARE_OREDICT : 0);
|
||||
if (extractItems(actualInputs, compare, toInsertItems)) {
|
||||
IItemHandler inventory = getPattern().getContainer().getFacingInventory();
|
||||
|
||||
@@ -10,8 +10,7 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingStep;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFluidStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IItemStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementError;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementInfo;
|
||||
@@ -19,7 +18,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor.Craf
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementText;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewElementFluidStack;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewElementItemStack;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.ItemStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.StackListItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -44,14 +43,14 @@ public class CraftingTask implements ICraftingTask {
|
||||
private ICraftingPattern pattern;
|
||||
private int quantity;
|
||||
private List<ICraftingStep> steps = new ArrayList<>();
|
||||
private IItemStackList toTake = API.instance().createItemStackList();
|
||||
private IItemStackList toCraft = API.instance().createItemStackList();
|
||||
private IItemStackList missing = API.instance().createItemStackList();
|
||||
private IStackList<ItemStack> toTake = API.instance().createItemStackList();
|
||||
private IStackList<ItemStack> toCraft = API.instance().createItemStackList();
|
||||
private IStackList<ItemStack> missing = API.instance().createItemStackList();
|
||||
private Set<ICraftingPattern> usedPatterns = new HashSet<>();
|
||||
private boolean recurseFound = false;
|
||||
private Deque<ItemStack> toInsertItems = new ArrayDeque<>();
|
||||
private Deque<FluidStack> toInsertFluids = new ArrayDeque<>();
|
||||
private IFluidStackList toTakeFluids = API.instance().createFluidStackList();
|
||||
private IStackList<FluidStack> toTakeFluids = API.instance().createFluidStackList();
|
||||
|
||||
public CraftingTask(INetworkMaster network, @Nullable ItemStack requested, ICraftingPattern pattern, int quantity) {
|
||||
this.network = network;
|
||||
@@ -60,7 +59,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public CraftingTask(INetworkMaster network, @Nullable ItemStack requested, ICraftingPattern pattern, int quantity, List<ICraftingStep> steps, Deque<ItemStack> toInsertItems, IFluidStackList toTakeFluids, Deque<FluidStack> toInsertFluids) {
|
||||
public CraftingTask(INetworkMaster network, @Nullable ItemStack requested, ICraftingPattern pattern, int quantity, List<ICraftingStep> steps, Deque<ItemStack> toInsertItems, IStackList<FluidStack> toTakeFluids, Deque<FluidStack> toInsertFluids) {
|
||||
this(network, requested, pattern, quantity);
|
||||
this.steps = steps;
|
||||
this.toInsertItems = toInsertItems;
|
||||
@@ -71,11 +70,11 @@ public class CraftingTask implements ICraftingTask {
|
||||
@Override
|
||||
public void calculate() {
|
||||
// Copy here might be expensive but since it is only executed once it isn't a big impact
|
||||
IItemStackList networkList = network.getItemStorageCache().getList().copy();
|
||||
IStackList<ItemStack> networkList = network.getItemStorageCache().getList().copy();
|
||||
networkList.clean(); // Remove the zero stacks
|
||||
networkList = networkList.getOredicted();
|
||||
IFluidStackList networkFluidList = network.getFluidStorageCache().getList().copy();
|
||||
IItemStackList toInsert = API.instance().createItemStackList();
|
||||
IStackList<FluidStack> networkFluidList = network.getFluidStorageCache().getList().copy();
|
||||
IStackList<ItemStack> toInsert = API.instance().createItemStackList();
|
||||
|
||||
ItemStack requested = this.requested != null ? this.requested : pattern.getOutputs().get(0);
|
||||
toCraft.add(ItemHandlerHelper.copyStackWithSize(requested, quantity));
|
||||
@@ -90,7 +89,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
usedPatterns.clear();
|
||||
}
|
||||
|
||||
private void calculate(IItemStackList networkList, IFluidStackList networkFluidList, ICraftingPattern pattern, IItemStackList toInsert) {
|
||||
private void calculate(IStackList<ItemStack> networkList, IStackList<FluidStack> networkFluidList, ICraftingPattern pattern, IStackList<ItemStack> toInsert) {
|
||||
recurseFound |= !usedPatterns.add(pattern);
|
||||
if (recurseFound) {
|
||||
return;
|
||||
@@ -98,8 +97,8 @@ public class CraftingTask implements ICraftingTask {
|
||||
|
||||
int compare = DEFAULT_COMPARE | (pattern.isOredict() ? IComparer.COMPARE_OREDICT : 0);
|
||||
|
||||
IItemStackList inputs = API.instance().createItemStackList();
|
||||
IItemStackList actualInputs = API.instance().createItemStackList();
|
||||
IStackList<ItemStack> inputs = API.instance().createItemStackList();
|
||||
IStackList<ItemStack> actualInputs = API.instance().createItemStackList();
|
||||
List<ItemStack> usedStacks = new LinkedList<>();
|
||||
|
||||
for (List<ItemStack> oreInputs : pattern.getOreInputs()) {
|
||||
@@ -223,7 +222,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
ItemStack[] took = null;
|
||||
if (missing.isEmpty()) {
|
||||
if (!pattern.isProcessing()) {
|
||||
took = ItemStackList.toCraftingGrid(actualInputs, usedStacks, compare);
|
||||
took = StackListItem.toCraftingGrid(actualInputs, usedStacks, compare);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +237,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
usedPatterns.remove(pattern);
|
||||
}
|
||||
|
||||
private boolean doFluidCalculation(IItemStackList networkList, IFluidStackList networkFluidList, ItemStack input, IItemStackList toInsert) {
|
||||
private boolean doFluidCalculation(IStackList<ItemStack> networkList, IStackList<FluidStack> networkFluidList, ItemStack input, IStackList<ItemStack> toInsert) {
|
||||
FluidStack fluidInItem = RSUtils.getFluidFromStack(input, true).getValue();
|
||||
|
||||
if (fluidInItem != null && RSUtils.hasFluidBucket(fluidInItem)) {
|
||||
@@ -273,7 +272,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
|
||||
if (hasBucket || bucketPattern != null) {
|
||||
toTakeFluids.add(fluidInItem.copy());
|
||||
networkFluidList.remove(fluidInItem, false);
|
||||
networkFluidList.remove(fluidInItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,8 +305,8 @@ public class CraftingTask implements ICraftingTask {
|
||||
|
||||
@Override
|
||||
public boolean update(Map<ICraftingPatternContainer, Integer> usedContainers) {
|
||||
IItemStackList oreDictPrepped = network.getItemStorageCache().getList().getOredicted();
|
||||
IFluidStackList networkFluids = network.getFluidStorageCache().getList();
|
||||
IStackList<ItemStack> oreDictPrepped = network.getItemStorageCache().getList().getOredicted();
|
||||
IStackList<FluidStack> networkFluids = network.getFluidStorageCache().getList();
|
||||
|
||||
if (!missing.isEmpty()) {
|
||||
for (ItemStack missing : this.missing.getStacks()) {
|
||||
@@ -471,8 +470,8 @@ public class CraftingTask implements ICraftingTask {
|
||||
if (steps.stream().filter(s -> !s.getPattern().isProcessing()).count() > 0) {
|
||||
elements.directAdd(new CraftingMonitorElementText("gui.refinedstorage:crafting_monitor.items_crafting", 16));
|
||||
|
||||
IItemStackList oreDictPrepped = network.getItemStorageCache().getList().getOredicted();
|
||||
IFluidStackList networkFluids = network.getFluidStorageCache().getList();
|
||||
IStackList<ItemStack> oreDictPrepped = network.getItemStorageCache().getList().getOredicted();
|
||||
IStackList<FluidStack> networkFluids = network.getFluidStorageCache().getList();
|
||||
|
||||
for (ICraftingStep step : steps.stream().filter(s -> !s.getPattern().isProcessing()).collect(Collectors.toList())) {
|
||||
for (int i = 0; i < step.getPattern().getOutputs().size(); ++i) {
|
||||
@@ -538,7 +537,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStackList getMissing() {
|
||||
public IStackList<ItemStack> getMissing() {
|
||||
return missing;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@ import com.raoulvdberge.refinedstorage.RSBlocks;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkNodeGraph;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.fluid.IFluidStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.item.IItemStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemBlockController;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileController;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileNetworkTransmitter;
|
||||
@@ -171,11 +170,8 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
controller.rebuildPatterns();
|
||||
}
|
||||
|
||||
if (node instanceof IItemStorageProvider) {
|
||||
if (node instanceof IStorageProvider) {
|
||||
controller.getItemStorageCache().invalidate();
|
||||
}
|
||||
|
||||
if (node instanceof IFluidStorageProvider) {
|
||||
controller.getFluidStorageCache().invalidate();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.storage;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class StorageCacheFluid implements IStorageCache<FluidStack> {
|
||||
private INetworkMaster network;
|
||||
private List<IStorage<FluidStack>> storages = new ArrayList<>();
|
||||
private IStackList<FluidStack> list = API.instance().createFluidStackList();
|
||||
|
||||
public StorageCacheFluid(INetworkMaster network) {
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void invalidate() {
|
||||
storages.clear();
|
||||
|
||||
network.getNodeGraph().all().stream()
|
||||
.filter(node -> node.canUpdate() && node instanceof IStorageProvider)
|
||||
.forEach(node -> ((IStorageProvider) node).addFluidStorages(storages));
|
||||
|
||||
list.clear();
|
||||
|
||||
for (IStorage<FluidStack> storage : storages) {
|
||||
if (storage.getAccessType() == AccessType.INSERT) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (FluidStack stack : storage.getStacks()) {
|
||||
add(stack, stack.amount, true);
|
||||
}
|
||||
}
|
||||
|
||||
network.sendFluidStorageToClient();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void add(@Nonnull FluidStack stack, int size, boolean rebuilding) {
|
||||
list.add(stack, size);
|
||||
|
||||
if (!rebuilding) {
|
||||
network.sendFluidStorageDeltaToClient(stack, size);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void remove(@Nonnull FluidStack stack, int size) {
|
||||
if (list.remove(stack, size)) {
|
||||
network.sendFluidStorageDeltaToClient(stack, -size);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStackList<FluidStack> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IStorage<FluidStack>> getStorages() {
|
||||
return storages;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.storage.item;
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.storage;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.item.IItemStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.item.IItemStorageCache;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.item.IItemStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IItemStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -13,12 +13,12 @@ import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemStorageCache implements IItemStorageCache {
|
||||
public class StorageCacheItem implements IStorageCache<ItemStack> {
|
||||
private INetworkMaster network;
|
||||
private List<IItemStorage> storages = new ArrayList<>();
|
||||
private IItemStackList list = API.instance().createItemStackList();
|
||||
private List<IStorage<ItemStack>> storages = new ArrayList<>();
|
||||
private IStackList<ItemStack> list = API.instance().createItemStackList();
|
||||
|
||||
public ItemStorageCache(INetworkMaster network) {
|
||||
public StorageCacheItem(INetworkMaster network) {
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ public class ItemStorageCache implements IItemStorageCache {
|
||||
storages.clear();
|
||||
|
||||
network.getNodeGraph().all().stream()
|
||||
.filter(node -> node.canUpdate() && node instanceof IItemStorageProvider)
|
||||
.forEach(node -> ((IItemStorageProvider) node).addItemStorages(storages));
|
||||
.filter(node -> node.canUpdate() && node instanceof IStorageProvider)
|
||||
.forEach(node -> ((IStorageProvider) node).addItemStorages(storages));
|
||||
|
||||
list.clear();
|
||||
|
||||
for (IItemStorage storage : storages) {
|
||||
for (IStorage<ItemStack> storage : storages) {
|
||||
if (storage.getAccessType() == AccessType.INSERT) {
|
||||
continue;
|
||||
}
|
||||
@@ -64,12 +64,12 @@ public class ItemStorageCache implements IItemStorageCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStackList getList() {
|
||||
public IStackList<ItemStack> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IItemStorage> getStorages() {
|
||||
public List<IStorage<ItemStack>> getStorages() {
|
||||
return storages;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.storage;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A implementation of {@link IStorage<FluidStack>} that stores storage fluids in NBT.
|
||||
*/
|
||||
public abstract class StorageFluidNBT implements IStorage<FluidStack> {
|
||||
/**
|
||||
* The current save protocol that is used. It's set to every {@link StorageFluidNBT} to allow for
|
||||
* safe backwards compatibility breaks.
|
||||
*/
|
||||
private static final int PROTOCOL = 1;
|
||||
|
||||
private static final String NBT_PROTOCOL = "Protocol";
|
||||
|
||||
private static final String NBT_FLUIDS = "Fluids";
|
||||
private static final String NBT_STORED = "Stored";
|
||||
|
||||
private NBTTagCompound tag;
|
||||
private int capacity;
|
||||
private TileEntity tile;
|
||||
|
||||
private NonNullList<FluidStack> stacks = NonNullList.create();
|
||||
|
||||
/**
|
||||
* @param tag The NBT tag we are reading from and writing the amount stored to, has to be initialized with {@link StorageFluidNBT#createNBT()} if it doesn't exist yet
|
||||
* @param capacity The capacity of this storage, -1 for infinite capacity
|
||||
* @param tile A {@link TileEntity} that the NBT storage is in, will be marked dirty when the storage changes
|
||||
*/
|
||||
public StorageFluidNBT(NBTTagCompound tag, int capacity, @Nullable TileEntity tile) {
|
||||
this.tag = tag;
|
||||
this.capacity = capacity;
|
||||
this.tile = tile;
|
||||
|
||||
readFromNBT();
|
||||
}
|
||||
|
||||
private void readFromNBT() {
|
||||
NBTTagList list = (NBTTagList) tag.getTag(NBT_FLUIDS);
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(list.getCompoundTagAt(i));
|
||||
|
||||
if (stack != null) {
|
||||
stacks.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the items to the NBT tag.
|
||||
*/
|
||||
public void writeToNBT() {
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
for (FluidStack stack : stacks) {
|
||||
list.appendTag(stack.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
tag.setTag(NBT_FLUIDS, list);
|
||||
tag.setInteger(NBT_PROTOCOL, PROTOCOL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonNullList<FluidStack> getStacks() {
|
||||
return stacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized FluidStack insert(@Nonnull FluidStack stack, int size, boolean simulate) {
|
||||
for (FluidStack otherStack : stacks) {
|
||||
if (otherStack.isFluidEqual(stack)) {
|
||||
if (getCapacity() != -1 && getStored() + size > getCapacity()) {
|
||||
int remainingSpace = getCapacity() - getStored();
|
||||
|
||||
if (remainingSpace <= 0) {
|
||||
if (isVoiding()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return RSUtils.copyStackWithSize(stack, size);
|
||||
}
|
||||
|
||||
if (!simulate) {
|
||||
tag.setInteger(NBT_STORED, getStored() + remainingSpace);
|
||||
|
||||
otherStack.amount += remainingSpace;
|
||||
|
||||
onStorageChanged();
|
||||
}
|
||||
|
||||
return isVoiding() ? null : RSUtils.copyStackWithSize(otherStack, size - remainingSpace);
|
||||
} else {
|
||||
if (!simulate) {
|
||||
tag.setInteger(NBT_STORED, getStored() + size);
|
||||
|
||||
otherStack.amount += size;
|
||||
|
||||
onStorageChanged();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getCapacity() != -1 && getStored() + size > getCapacity()) {
|
||||
int remainingSpace = getCapacity() - getStored();
|
||||
|
||||
if (remainingSpace <= 0) {
|
||||
if (isVoiding()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return RSUtils.copyStackWithSize(stack, size);
|
||||
}
|
||||
|
||||
if (!simulate) {
|
||||
tag.setInteger(NBT_STORED, getStored() + remainingSpace);
|
||||
|
||||
stacks.add(RSUtils.copyStackWithSize(stack, remainingSpace));
|
||||
|
||||
onStorageChanged();
|
||||
}
|
||||
|
||||
return isVoiding() ? null : RSUtils.copyStackWithSize(stack, size - remainingSpace);
|
||||
} else {
|
||||
if (!simulate) {
|
||||
tag.setInteger(NBT_STORED, getStored() + size);
|
||||
|
||||
stacks.add(RSUtils.copyStackWithSize(stack, size));
|
||||
|
||||
onStorageChanged();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized FluidStack extract(@Nonnull FluidStack stack, int size, int flags, boolean simulate) {
|
||||
for (FluidStack otherStack : stacks) {
|
||||
if (API.instance().getComparer().isEqual(otherStack, stack, flags)) {
|
||||
if (size > otherStack.amount) {
|
||||
size = otherStack.amount;
|
||||
}
|
||||
|
||||
if (!simulate) {
|
||||
if (otherStack.amount - size == 0) {
|
||||
stacks.remove(otherStack);
|
||||
} else {
|
||||
otherStack.amount -= size;
|
||||
}
|
||||
|
||||
tag.setInteger(NBT_STORED, getStored() - size);
|
||||
|
||||
onStorageChanged();
|
||||
}
|
||||
|
||||
return RSUtils.copyStackWithSize(otherStack, size);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onStorageChanged() {
|
||||
if (tile != null) {
|
||||
tile.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStored() {
|
||||
return getStoredFromNBT(tag);
|
||||
}
|
||||
|
||||
public int getCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
protected boolean isVoiding() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCacheDelta(int storedPreInsertion, int size, @Nullable FluidStack remainder) {
|
||||
if (getAccessType() == AccessType.INSERT) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int inserted = remainder == null ? size : (size - remainder.amount);
|
||||
|
||||
if (isVoiding() && storedPreInsertion + inserted > getCapacity()) {
|
||||
inserted = getCapacity() - storedPreInsertion;
|
||||
}
|
||||
|
||||
return inserted;
|
||||
}
|
||||
|
||||
public NBTTagCompound getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static int getStoredFromNBT(NBTTagCompound tag) {
|
||||
return tag.getInteger(NBT_STORED);
|
||||
}
|
||||
|
||||
public static NBTTagCompound getNBTShareTag(NBTTagCompound tag) {
|
||||
NBTTagCompound otherTag = new NBTTagCompound();
|
||||
|
||||
otherTag.setInteger(NBT_STORED, getStoredFromNBT(tag));
|
||||
otherTag.setTag(NBT_FLUIDS, new NBTTagList()); // To circumvent not being able to insert disks in Disk Drives (see FluidStorageNBT#isValid(ItemStack)).
|
||||
|
||||
return otherTag;
|
||||
}
|
||||
|
||||
/*
|
||||
* @return A NBT tag initialized with the fields that {@link NBTStorage} uses
|
||||
*/
|
||||
public static NBTTagCompound createNBT() {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
|
||||
tag.setTag(NBT_FLUIDS, new NBTTagList());
|
||||
tag.setInteger(NBT_STORED, 0);
|
||||
tag.setInteger(NBT_PROTOCOL, PROTOCOL);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static boolean isValid(ItemStack stack) {
|
||||
return stack.hasTagCompound() && stack.getTagCompound().hasKey(NBT_FLUIDS) && stack.getTagCompound().hasKey(NBT_STORED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stack The {@link ItemStack} to populate with the NBT tags from {@link StorageFluidNBT#createNBT()}
|
||||
* @return The provided {@link ItemStack} with NBT tags from {@link StorageFluidNBT#createNBT()}
|
||||
*/
|
||||
public static ItemStack createStackWithNBT(ItemStack stack) {
|
||||
stack.setTagCompound(createNBT());
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.storage.item;
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.storage;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.item.IItemStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -15,11 +15,11 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A implementation of {@link IItemStorage} that stores storage items in NBT.
|
||||
* A implementation of {@link IStorage<ItemStack>} that stores storage items in NBT.
|
||||
*/
|
||||
public abstract class ItemStorageNBT implements IItemStorage {
|
||||
public abstract class StorageItemNBT implements IStorage<ItemStack> {
|
||||
/**
|
||||
* The current save protocol that is used. It's set to every {@link ItemStorageNBT} to allow for
|
||||
* The current save protocol that is used. It's set to every {@link StorageItemNBT} to allow for
|
||||
* safe backwards compatibility breaks.
|
||||
*/
|
||||
private static final int PROTOCOL = 1;
|
||||
@@ -42,11 +42,11 @@ public abstract class ItemStorageNBT implements IItemStorage {
|
||||
private NonNullList<ItemStack> stacks = NonNullList.create();
|
||||
|
||||
/**
|
||||
* @param tag The NBT tag we are reading from and writing the amount stored to, has to be initialized with {@link ItemStorageNBT#createNBT()} if it doesn't exist yet
|
||||
* @param tag The NBT tag we are reading from and writing the amount stored to, has to be initialized with {@link StorageItemNBT#createNBT()} if it doesn't exist yet
|
||||
* @param capacity The capacity of this storage, -1 for infinite capacity
|
||||
* @param tile A {@link TileEntity} that the NBT storage is in, will be marked dirty when the storage changes
|
||||
*/
|
||||
public ItemStorageNBT(NBTTagCompound tag, int capacity, @Nullable TileEntity tile) {
|
||||
public StorageItemNBT(NBTTagCompound tag, int capacity, @Nullable TileEntity tile) {
|
||||
this.tag = tag;
|
||||
this.capacity = capacity;
|
||||
this.tile = tile;
|
||||
@@ -116,7 +116,7 @@ public abstract class ItemStorageNBT implements IItemStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ItemStack insertItem(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
public synchronized ItemStack insert(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
for (ItemStack otherStack : stacks) {
|
||||
if (API.instance().getComparer().isEqualNoQuantity(otherStack, stack)) {
|
||||
if (getCapacity() != -1 && getStored() + size > getCapacity()) {
|
||||
@@ -187,7 +187,7 @@ public abstract class ItemStorageNBT implements IItemStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags, boolean simulate) {
|
||||
public synchronized ItemStack extract(@Nonnull ItemStack stack, int size, int flags, boolean simulate) {
|
||||
for (ItemStack otherStack : stacks) {
|
||||
if (API.instance().getComparer().isEqual(otherStack, stack, flags)) {
|
||||
if (size > otherStack.getCount()) {
|
||||
@@ -282,8 +282,8 @@ public abstract class ItemStorageNBT implements IItemStorage {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stack The {@link ItemStack} to populate with the NBT tags from {@link ItemStorageNBT#createNBT()}
|
||||
* @return The provided {@link ItemStack} with NBT tags from {@link ItemStorageNBT#createNBT()}
|
||||
* @param stack The {@link ItemStack} to populate with the NBT tags from {@link StorageItemNBT#createNBT()}
|
||||
* @return The provided {@link ItemStack} with NBT tags from {@link StorageItemNBT#createNBT()}
|
||||
*/
|
||||
public static ItemStack createStackWithNBT(ItemStack stack) {
|
||||
stack.setTagCompound(createNBT());
|
||||
@@ -1,138 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.storage.fluid;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.VertexBuffer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
/**
|
||||
* This fluid renderer is copied over from JEI because Forge lacks a utility method for rendering fluids.
|
||||
*
|
||||
* @link https://github.com/mezz/JustEnoughItems/blob/1.10/src/main/java/mezz/jei/gui/ingredients/FluidStackRenderer.java
|
||||
*/
|
||||
public class FluidRenderer {
|
||||
private static final int TEX_WIDTH = 16;
|
||||
private static final int TEX_HEIGHT = 16;
|
||||
private static final int MIN_FLUID_HEIGHT = 1;
|
||||
|
||||
private final int capacityMb;
|
||||
private final int width;
|
||||
private final int height;
|
||||
|
||||
public FluidRenderer(int capacityMb, int width, int height) {
|
||||
this.capacityMb = capacityMb;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void draw(Minecraft minecraft, int xPosition, int yPosition, FluidStack fluidStack) {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.enableAlpha();
|
||||
|
||||
drawFluid(minecraft, xPosition, yPosition, fluidStack);
|
||||
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
|
||||
private void drawFluid(Minecraft minecraft, int xPosition, int yPosition, FluidStack fluidStack) {
|
||||
if (fluidStack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
|
||||
if (fluid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
TextureMap textureMapBlocks = minecraft.getTextureMapBlocks();
|
||||
ResourceLocation fluidStill = fluid.getStill();
|
||||
TextureAtlasSprite fluidStillSprite = null;
|
||||
|
||||
if (fluidStill != null) {
|
||||
fluidStillSprite = textureMapBlocks.getTextureExtry(fluidStill.toString());
|
||||
}
|
||||
|
||||
if (fluidStillSprite == null) {
|
||||
fluidStillSprite = textureMapBlocks.getMissingSprite();
|
||||
}
|
||||
|
||||
int fluidColor = fluid.getColor(fluidStack);
|
||||
|
||||
int scaledAmount = height;
|
||||
|
||||
if (capacityMb != -1) {
|
||||
scaledAmount = (fluidStack.amount * height) / capacityMb;
|
||||
|
||||
if (fluidStack.amount > 0 && scaledAmount < MIN_FLUID_HEIGHT) {
|
||||
scaledAmount = MIN_FLUID_HEIGHT;
|
||||
}
|
||||
|
||||
if (scaledAmount > height) {
|
||||
scaledAmount = height;
|
||||
}
|
||||
}
|
||||
|
||||
minecraft.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
setGLColorFromInt(fluidColor);
|
||||
|
||||
int xTileCount = width / TEX_WIDTH;
|
||||
int xRemainder = width - (xTileCount * TEX_WIDTH);
|
||||
int yTileCount = scaledAmount / TEX_HEIGHT;
|
||||
int yRemainder = scaledAmount - (yTileCount * TEX_HEIGHT);
|
||||
|
||||
int yStart = yPosition + height;
|
||||
|
||||
for (int xTile = 0; xTile <= xTileCount; xTile++) {
|
||||
for (int yTile = 0; yTile <= yTileCount; yTile++) {
|
||||
int width = (xTile == xTileCount) ? xRemainder : TEX_WIDTH;
|
||||
int height = (yTile == yTileCount) ? yRemainder : TEX_HEIGHT;
|
||||
int x = xPosition + (xTile * TEX_WIDTH);
|
||||
int y = yStart - ((yTile + 1) * TEX_HEIGHT);
|
||||
|
||||
if (width > 0 && height > 0) {
|
||||
int maskTop = TEX_HEIGHT - height;
|
||||
int maskRight = TEX_WIDTH - width;
|
||||
|
||||
drawFluidTexture(x, y, fluidStillSprite, maskTop, maskRight, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setGLColorFromInt(int color) {
|
||||
float red = (color >> 16 & 0xFF) / 255.0F;
|
||||
float green = (color >> 8 & 0xFF) / 255.0F;
|
||||
float blue = (color & 0xFF) / 255.0F;
|
||||
|
||||
GlStateManager.color(red, green, blue, 1.0F);
|
||||
}
|
||||
|
||||
private static void drawFluidTexture(double xCoord, double yCoord, TextureAtlasSprite textureSprite, int maskTop, int maskRight, double zLevel) {
|
||||
double uMin = (double) textureSprite.getMinU();
|
||||
double uMax = (double) textureSprite.getMaxU();
|
||||
double vMin = (double) textureSprite.getMinV();
|
||||
double vMax = (double) textureSprite.getMaxV();
|
||||
uMax = uMax - (maskRight / 16.0 * (uMax - uMin));
|
||||
vMax = vMax - (maskTop / 16.0 * (vMax - vMin));
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
|
||||
VertexBuffer vertexBuffer = tessellator.getBuffer();
|
||||
vertexBuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
vertexBuffer.pos(xCoord, yCoord + 16, zLevel).tex(uMin, vMax).endVertex();
|
||||
vertexBuffer.pos(xCoord + 16 - maskRight, yCoord + 16, zLevel).tex(uMax, vMax).endVertex();
|
||||
vertexBuffer.pos(xCoord + 16 - maskRight, yCoord + maskTop, zLevel).tex(uMax, vMin).endVertex();
|
||||
vertexBuffer.pos(xCoord, yCoord + maskTop, zLevel).tex(uMin, vMin).endVertex();
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.storage.fluid;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.fluid.IFluidStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.fluid.IFluidStorageCache;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.fluid.IFluidStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFluidStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FluidStorageCache implements IFluidStorageCache {
|
||||
private INetworkMaster network;
|
||||
private List<IFluidStorage> storages = new ArrayList<>();
|
||||
private IFluidStackList list = API.instance().createFluidStackList();
|
||||
|
||||
public FluidStorageCache(INetworkMaster network) {
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void invalidate() {
|
||||
storages.clear();
|
||||
|
||||
network.getNodeGraph().all().stream()
|
||||
.filter(node -> node.canUpdate() && node instanceof IFluidStorageProvider)
|
||||
.forEach(node -> ((IFluidStorageProvider) node).addFluidStorages(storages));
|
||||
|
||||
list.clear();
|
||||
|
||||
for (IFluidStorage storage : storages) {
|
||||
if (storage.getAccessType() == AccessType.INSERT) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (FluidStack stack : storage.getStacks()) {
|
||||
add(stack, true);
|
||||
}
|
||||
}
|
||||
|
||||
network.sendFluidStorageToClient();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void add(@Nonnull FluidStack stack, boolean rebuilding) {
|
||||
list.add(stack);
|
||||
|
||||
if (!rebuilding) {
|
||||
network.sendFluidStorageDeltaToClient(stack, stack.amount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void remove(@Nonnull FluidStack stack) {
|
||||
if (list.remove(stack, true)) {
|
||||
network.sendFluidStorageDeltaToClient(stack, -stack.amount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidStackList getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IFluidStorage> getStorages() {
|
||||
return storages;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.util;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFluidStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -13,15 +13,15 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class FluidStackList implements IFluidStackList {
|
||||
public class StackListFluid implements IStackList<FluidStack> {
|
||||
private ArrayListMultimap<Fluid, FluidStack> stacks = ArrayListMultimap.create();
|
||||
private List<FluidStack> removeTracker = new LinkedList<>();
|
||||
|
||||
@Override
|
||||
public void add(FluidStack stack) {
|
||||
public void add(FluidStack stack, int size) {
|
||||
for (FluidStack otherStack : stacks.get(stack.getFluid())) {
|
||||
if (stack.isFluidEqual(otherStack)) {
|
||||
otherStack.amount += stack.amount;
|
||||
otherStack.amount += size;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -31,13 +31,14 @@ public class FluidStackList implements IFluidStackList {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(@Nonnull FluidStack stack, int size, boolean removeIfReachedZero) {
|
||||
public boolean remove(@Nonnull FluidStack stack, int size) {
|
||||
for (FluidStack otherStack : stacks.get(stack.getFluid())) {
|
||||
if (stack.isFluidEqual(otherStack)) {
|
||||
otherStack.amount -= size;
|
||||
|
||||
boolean success = otherStack.amount >= 0;
|
||||
|
||||
if (otherStack.amount <= 0 && removeIfReachedZero) {
|
||||
if (otherStack.amount <= 0) {
|
||||
stacks.remove(otherStack.getFluid(), otherStack);
|
||||
}
|
||||
|
||||
@@ -49,7 +50,7 @@ public class FluidStackList implements IFluidStackList {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trackedRemove(@Nonnull FluidStack stack, int size, boolean removeIfReachedZero) {
|
||||
public boolean trackedRemove(@Nonnull FluidStack stack, int size) {
|
||||
for (FluidStack otherStack : stacks.get(stack.getFluid())) {
|
||||
if (stack.isFluidEqual(otherStack)) {
|
||||
FluidStack removed = new FluidStack(otherStack.getFluid(), Math.min(size, otherStack.amount));
|
||||
@@ -57,7 +58,7 @@ public class FluidStackList implements IFluidStackList {
|
||||
otherStack.amount -= size;
|
||||
boolean success = otherStack.amount >= 0;
|
||||
|
||||
if (otherStack.amount <= 0 && removeIfReachedZero) {
|
||||
if (otherStack.amount <= 0) {
|
||||
stacks.remove(otherStack.getFluid(), otherStack);
|
||||
}
|
||||
|
||||
@@ -70,10 +71,15 @@ public class FluidStackList implements IFluidStackList {
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
removeTracker.forEach(this::add);
|
||||
removeTracker.forEach(s -> add(s, s.amount));
|
||||
removeTracker.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getRemoveTracker() {
|
||||
return removeTracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public FluidStack get(@Nonnull FluidStack stack, int flags) {
|
||||
@@ -117,6 +123,11 @@ public class FluidStackList implements IFluidStackList {
|
||||
return stacks.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeFromStack(FluidStack stack) {
|
||||
return stack.amount;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Collection<FluidStack> getStacks() {
|
||||
@@ -125,8 +136,8 @@ public class FluidStackList implements IFluidStackList {
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IFluidStackList copy() {
|
||||
FluidStackList list = new FluidStackList();
|
||||
public IStackList<FluidStack> copy() {
|
||||
StackListFluid list = new StackListFluid();
|
||||
|
||||
for (FluidStack stack : stacks.values()) {
|
||||
list.stacks.put(stack.getFluid(), stack.copy());
|
||||
@@ -135,6 +146,11 @@ public class FluidStackList implements IFluidStackList {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStackList<FluidStack> getOredicted() {
|
||||
throw new IllegalAccessError("Fluid lists have no oredicted version!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return stacks.toString();
|
||||
@@ -2,7 +2,7 @@ package com.raoulvdberge.refinedstorage.apiimpl.util;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IItemStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -16,7 +16,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemStackList implements IItemStackList {
|
||||
public class StackListItem implements IStackList<ItemStack> {
|
||||
private ArrayListMultimap<Item, ItemStack> stacks = ArrayListMultimap.create();
|
||||
private List<ItemStack> removeTracker = new LinkedList<>();
|
||||
protected boolean needsCleanup = false;
|
||||
@@ -85,7 +85,7 @@ public class ItemStackList implements IItemStackList {
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
removeTracker.forEach(this::add);
|
||||
removeTracker.forEach(s -> add(s, s.getCount()));
|
||||
removeTracker.clear();
|
||||
}
|
||||
|
||||
@@ -140,6 +140,11 @@ public class ItemStackList implements IItemStackList {
|
||||
return stacks.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeFromStack(ItemStack stack) {
|
||||
return stack.getCount();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Collection<ItemStack> getStacks() {
|
||||
@@ -151,8 +156,8 @@ public class ItemStackList implements IItemStackList {
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IItemStackList copy() {
|
||||
ItemStackList list = new ItemStackList();
|
||||
public IStackList<ItemStack> copy() {
|
||||
StackListItem list = new StackListItem();
|
||||
|
||||
if (needsCleanup) {
|
||||
clean();
|
||||
@@ -166,12 +171,12 @@ public class ItemStackList implements IItemStackList {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IItemStackList getOredicted() {
|
||||
public StackListItemOredicted getOredicted() {
|
||||
if (needsCleanup) {
|
||||
clean();
|
||||
}
|
||||
return new ItemStackListOredicted(this);
|
||||
|
||||
return new StackListItemOredicted(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -179,7 +184,7 @@ public class ItemStackList implements IItemStackList {
|
||||
return stacks.toString();
|
||||
}
|
||||
|
||||
public static ItemStack[] toCraftingGrid(IItemStackList list, List<ItemStack> grid, int compare) {
|
||||
public static ItemStack[] toCraftingGrid(IStackList<ItemStack> list, List<ItemStack> grid, int compare) {
|
||||
ItemStack[] took = new ItemStack[9];
|
||||
for (int i = 0; i < grid.size(); i++) {
|
||||
ItemStack input = grid.get(i);
|
||||
@@ -193,7 +198,7 @@ public class ItemStackList implements IItemStackList {
|
||||
ItemStack actualInput = list.get(input, compare);
|
||||
ItemStack taken = ItemHandlerHelper.copyStackWithSize(actualInput, input.getCount());
|
||||
took[i] = taken;
|
||||
list.remove(taken);
|
||||
list.remove(taken, taken.getCount());
|
||||
}
|
||||
}
|
||||
return took;
|
||||
@@ -2,7 +2,7 @@ package com.raoulvdberge.refinedstorage.apiimpl.util;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IItemStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
@@ -13,14 +13,14 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemStackListOredicted implements IItemStackList {
|
||||
private ItemStackList underlyingList;
|
||||
public class StackListItemOredicted implements IStackList<ItemStack> {
|
||||
private StackListItem underlyingList;
|
||||
private ArrayListMultimap<Integer, ItemStack> stacks = ArrayListMultimap.create();
|
||||
|
||||
private ItemStackListOredicted() {
|
||||
private StackListItemOredicted() {
|
||||
}
|
||||
|
||||
public ItemStackListOredicted(ItemStackList list) {
|
||||
public StackListItemOredicted(StackListItem list) {
|
||||
this.underlyingList = list;
|
||||
initOreDict();
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public class ItemStackListOredicted implements IItemStackList {
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
underlyingList.getRemoveTracker().forEach(this::add);
|
||||
underlyingList.getRemoveTracker().forEach(s -> add(s, s.getCount()));
|
||||
underlyingList.getRemoveTracker().clear();
|
||||
}
|
||||
|
||||
@@ -133,6 +133,11 @@ public class ItemStackListOredicted implements IItemStackList {
|
||||
return underlyingList.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeFromStack(ItemStack stack) {
|
||||
return underlyingList.getSizeFromStack(stack);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Collection<ItemStack> getStacks() {
|
||||
@@ -141,18 +146,17 @@ public class ItemStackListOredicted implements IItemStackList {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IItemStackList copy() {
|
||||
ItemStackListOredicted newList = new ItemStackListOredicted();
|
||||
newList.underlyingList = (ItemStackList) this.underlyingList.copy();
|
||||
public IStackList<ItemStack> copy() {
|
||||
StackListItemOredicted newList = new StackListItemOredicted();
|
||||
newList.underlyingList = (StackListItem) this.underlyingList.copy();
|
||||
for (Map.Entry<Integer, ItemStack> entry : this.stacks.entries()) {
|
||||
newList.stacks.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return newList;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IItemStackList getOredicted() {
|
||||
public IStackList<ItemStack> getOredicted() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawer;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawers;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.fluid.FluidRenderer;
|
||||
import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButton;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
@@ -28,7 +28,7 @@ import java.util.Map;
|
||||
public abstract class GuiBase extends GuiContainer {
|
||||
private static final Map<String, ResourceLocation> TEXTURE_CACHE = new HashMap<>();
|
||||
|
||||
public static final FluidRenderer FLUID_RENDERER = new FluidRenderer(-1, 16, 16);
|
||||
public static final RSUtils.FluidRenderer FLUID_RENDERER = new RSUtils.FluidRenderer(-1, 16, 16);
|
||||
|
||||
public class ElementDrawers implements IElementDrawers {
|
||||
private IElementDrawer<FluidStack> fluidDrawer = (x, y, element) -> FLUID_RENDERER.draw(GuiBase.this.mc, x, y, element);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.fluid.FluidRenderer;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerFluidInterface;
|
||||
import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonCompare;
|
||||
import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
|
||||
|
||||
public class GuiFluidInterface extends GuiBase {
|
||||
private static final FluidRenderer TANK_RENDERER = new FluidRenderer(TileFluidInterface.TANK_CAPACITY, 12, 47);
|
||||
private static final RSUtils.FluidRenderer TANK_RENDERER = new RSUtils.FluidRenderer(TileFluidInterface.TANK_CAPACITY, 12, 47);
|
||||
|
||||
public GuiFluidInterface(ContainerFluidInterface container) {
|
||||
super(container, 211, 204);
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
package com.raoulvdberge.refinedstorage.inventory;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSItems;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageFluidNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageItemNBT;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IItemValidator {
|
||||
IItemValidator ITEM_STORAGE_DISK = new ItemValidatorBasic(RSItems.STORAGE_DISK) {
|
||||
@Override
|
||||
public boolean isValid(ItemStack disk) {
|
||||
return super.isValid(disk) && ItemStorageNBT.isValid(disk);
|
||||
return super.isValid(disk) && StorageItemNBT.isValid(disk);
|
||||
}
|
||||
};
|
||||
IItemValidator FLUID_STORAGE_DISK = new ItemValidatorBasic(RSItems.FLUID_STORAGE_DISK) {
|
||||
@Override
|
||||
public boolean isValid(ItemStack disk) {
|
||||
return super.isValid(disk) && FluidStorageNBT.isValid(disk);
|
||||
return super.isValid(disk) && StorageFluidNBT.isValid(disk);
|
||||
}
|
||||
};
|
||||
IItemValidator STORAGE_DISK = new IItemValidator() {
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.raoulvdberge.refinedstorage.item;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSBlocks;
|
||||
import com.raoulvdberge.refinedstorage.RSItems;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageFluidNBT;
|
||||
import com.raoulvdberge.refinedstorage.block.EnumFluidStorageType;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileFluidStorage;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -31,9 +31,9 @@ public class ItemBlockFluidStorage extends ItemBlockBase {
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(TileFluidStorage.NBT_STORAGE);
|
||||
|
||||
if (type == EnumFluidStorageType.TYPE_CREATIVE) {
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored", FluidStorageNBT.getStoredFromNBT(tag)));
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored", StorageFluidNBT.getStoredFromNBT(tag)));
|
||||
} else {
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored_capacity", FluidStorageNBT.getStoredFromNBT(tag), type.getCapacity()));
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored_capacity", StorageFluidNBT.getStoredFromNBT(tag), type.getCapacity()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public class ItemBlockFluidStorage extends ItemBlockBase {
|
||||
|
||||
EnumFluidStorageType type = EnumFluidStorageType.getById(stack.getMetadata());
|
||||
|
||||
if (type != null && stack.getCount() == 1 && isValid(stack) && FluidStorageNBT.getStoredFromNBT(stack.getTagCompound().getCompoundTag(TileFluidStorage.NBT_STORAGE)) <= 0 && stack.getMetadata() != ItemFluidStorageDisk.TYPE_CREATIVE && !world.isRemote && player.isSneaking()) {
|
||||
if (type != null && stack.getCount() == 1 && isValid(stack) && StorageFluidNBT.getStoredFromNBT(stack.getTagCompound().getCompoundTag(TileFluidStorage.NBT_STORAGE)) <= 0 && stack.getMetadata() != ItemFluidStorageDisk.TYPE_CREATIVE && !world.isRemote && player.isSneaking()) {
|
||||
ItemStack storagePart = new ItemStack(RSItems.FLUID_STORAGE_PART, 1, stack.getMetadata());
|
||||
|
||||
if (!player.inventory.addItemStackToInventory(storagePart.copy())) {
|
||||
@@ -90,12 +90,12 @@ public class ItemBlockFluidStorage extends ItemBlockBase {
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTShareTag(ItemStack stack) {
|
||||
return !isValid(stack) ? super.getNBTShareTag(stack) : FluidStorageNBT.getNBTShareTag(stack.getTagCompound().getCompoundTag(TileFluidStorage.NBT_STORAGE));
|
||||
return !isValid(stack) ? super.getNBTShareTag(stack) : StorageFluidNBT.getNBTShareTag(stack.getTagCompound().getCompoundTag(TileFluidStorage.NBT_STORAGE));
|
||||
}
|
||||
|
||||
public static ItemStack initNBT(ItemStack stack) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setTag(TileFluidStorage.NBT_STORAGE, FluidStorageNBT.createNBT());
|
||||
tag.setTag(TileFluidStorage.NBT_STORAGE, StorageFluidNBT.createNBT());
|
||||
stack.setTagCompound(tag);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.raoulvdberge.refinedstorage.item;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSBlocks;
|
||||
import com.raoulvdberge.refinedstorage.RSItems;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageItemNBT;
|
||||
import com.raoulvdberge.refinedstorage.block.EnumItemStorageType;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileStorage;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -31,9 +31,9 @@ public class ItemBlockStorage extends ItemBlockBase {
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(TileStorage.NBT_STORAGE);
|
||||
|
||||
if (type == EnumItemStorageType.TYPE_CREATIVE) {
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored", ItemStorageNBT.getStoredFromNBT(tag)));
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored", StorageItemNBT.getStoredFromNBT(tag)));
|
||||
} else {
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored_capacity", ItemStorageNBT.getStoredFromNBT(tag), type.getCapacity()));
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored_capacity", StorageItemNBT.getStoredFromNBT(tag), type.getCapacity()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public class ItemBlockStorage extends ItemBlockBase {
|
||||
|
||||
EnumItemStorageType type = EnumItemStorageType.getById(stack.getMetadata());
|
||||
|
||||
if (type != null && stack.getCount() == 1 && isValid(stack) && ItemStorageNBT.getStoredFromNBT(stack.getTagCompound().getCompoundTag(TileStorage.NBT_STORAGE)) <= 0 && stack.getMetadata() != ItemStorageDisk.TYPE_CREATIVE && !world.isRemote && player.isSneaking()) {
|
||||
if (type != null && stack.getCount() == 1 && isValid(stack) && StorageItemNBT.getStoredFromNBT(stack.getTagCompound().getCompoundTag(TileStorage.NBT_STORAGE)) <= 0 && stack.getMetadata() != ItemStorageDisk.TYPE_CREATIVE && !world.isRemote && player.isSneaking()) {
|
||||
ItemStack storagePart = new ItemStack(RSItems.STORAGE_PART, 1, stack.getMetadata());
|
||||
|
||||
if (!player.inventory.addItemStackToInventory(storagePart.copy())) {
|
||||
@@ -90,12 +90,12 @@ public class ItemBlockStorage extends ItemBlockBase {
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTShareTag(ItemStack stack) {
|
||||
return !isValid(stack) ? super.getNBTShareTag(stack) : ItemStorageNBT.getNBTShareTag(stack.getTagCompound().getCompoundTag(TileStorage.NBT_STORAGE));
|
||||
return !isValid(stack) ? super.getNBTShareTag(stack) : StorageItemNBT.getNBTShareTag(stack.getTagCompound().getCompoundTag(TileStorage.NBT_STORAGE));
|
||||
}
|
||||
|
||||
public static ItemStack initNBT(ItemStack stack) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setTag(TileStorage.NBT_STORAGE, ItemStorageNBT.createNBT());
|
||||
tag.setTag(TileStorage.NBT_STORAGE, StorageItemNBT.createNBT());
|
||||
stack.setTagCompound(tag);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.raoulvdberge.refinedstorage.item;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSItems;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageFluidNBT;
|
||||
import com.raoulvdberge.refinedstorage.block.EnumFluidStorageType;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -43,15 +43,15 @@ public class ItemFluidStorageDisk extends ItemBase {
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs tab, NonNullList<ItemStack> subItems) {
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
subItems.add(FluidStorageNBT.createStackWithNBT(new ItemStack(item, 1, i)));
|
||||
subItems.add(StorageFluidNBT.createStackWithNBT(new ItemStack(item, 1, i)));
|
||||
}
|
||||
}
|
||||
|
||||
private void applyDebugDiskData(ItemStack stack) {
|
||||
if (debugDiskTag == null) {
|
||||
debugDiskTag = FluidStorageNBT.createNBT();
|
||||
debugDiskTag = StorageFluidNBT.createNBT();
|
||||
|
||||
FluidStorageNBT storage = new FluidStorageNBT(debugDiskTag, -1, null) {
|
||||
StorageFluidNBT storage = new StorageFluidNBT(debugDiskTag, -1, null) {
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 0;
|
||||
@@ -64,7 +64,7 @@ public class ItemFluidStorageDisk extends ItemBase {
|
||||
};
|
||||
|
||||
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) {
|
||||
storage.insertFluid(new FluidStack(fluid, 0), Fluid.BUCKET_VOLUME * 1000, false);
|
||||
storage.insert(new FluidStack(fluid, 0), Fluid.BUCKET_VOLUME * 1000, false);
|
||||
}
|
||||
|
||||
storage.writeToNBT();
|
||||
@@ -81,7 +81,7 @@ public class ItemFluidStorageDisk extends ItemBase {
|
||||
if (stack.getMetadata() == TYPE_DEBUG) {
|
||||
applyDebugDiskData(stack);
|
||||
} else {
|
||||
FluidStorageNBT.createStackWithNBT(stack);
|
||||
StorageFluidNBT.createStackWithNBT(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public class ItemFluidStorageDisk extends ItemBase {
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack disk = player.getHeldItem(hand);
|
||||
|
||||
if (!world.isRemote && player.isSneaking() && FluidStorageNBT.isValid(disk) && FluidStorageNBT.getStoredFromNBT(disk.getTagCompound()) <= 0 && disk.getMetadata() != TYPE_CREATIVE) {
|
||||
if (!world.isRemote && player.isSneaking() && StorageFluidNBT.isValid(disk) && StorageFluidNBT.getStoredFromNBT(disk.getTagCompound()) <= 0 && disk.getMetadata() != TYPE_CREATIVE) {
|
||||
ItemStack storagePart = new ItemStack(RSItems.FLUID_STORAGE_PART, 1, disk.getMetadata());
|
||||
|
||||
if (!player.inventory.addItemStackToInventory(storagePart.copy())) {
|
||||
@@ -105,13 +105,13 @@ public class ItemFluidStorageDisk extends ItemBase {
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack disk, EntityPlayer player, List<String> tooltip, boolean advanced) {
|
||||
if (FluidStorageNBT.isValid(disk)) {
|
||||
if (StorageFluidNBT.isValid(disk)) {
|
||||
int capacity = EnumFluidStorageType.getById(disk.getItemDamage()).getCapacity();
|
||||
|
||||
if (capacity == -1) {
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored", FluidStorageNBT.getStoredFromNBT(disk.getTagCompound())));
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored", StorageFluidNBT.getStoredFromNBT(disk.getTagCompound())));
|
||||
} else {
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored_capacity", FluidStorageNBT.getStoredFromNBT(disk.getTagCompound()), capacity));
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored_capacity", StorageFluidNBT.getStoredFromNBT(disk.getTagCompound()), capacity));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public class ItemFluidStorageDisk extends ItemBase {
|
||||
public void onCreated(ItemStack stack, World world, EntityPlayer player) {
|
||||
super.onCreated(stack, world, player);
|
||||
|
||||
FluidStorageNBT.createStackWithNBT(stack);
|
||||
StorageFluidNBT.createStackWithNBT(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -130,6 +130,6 @@ public class ItemFluidStorageDisk extends ItemBase {
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTShareTag(ItemStack stack) {
|
||||
return FluidStorageNBT.getNBTShareTag(stack.getTagCompound());
|
||||
return StorageFluidNBT.getNBTShareTag(stack.getTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IItemStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@@ -136,7 +136,7 @@ public class ItemPattern extends ItemBase implements ICraftingPatternProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
IItemStackList outputs = API.instance().createItemStackList();
|
||||
IStackList<ItemStack> outputs = API.instance().createItemStackList();
|
||||
|
||||
NBTTagList outputsTag = pattern.getTagCompound().getTagList(NBT_OUTPUTS, Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.raoulvdberge.refinedstorage.item;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSItems;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageItemNBT;
|
||||
import com.raoulvdberge.refinedstorage.block.EnumItemStorageType;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -41,7 +41,7 @@ public class ItemStorageDisk extends ItemBase {
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs tab, NonNullList<ItemStack> subItems) {
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
subItems.add(ItemStorageNBT.createStackWithNBT(new ItemStack(item, 1, i)));
|
||||
subItems.add(StorageItemNBT.createStackWithNBT(new ItemStack(item, 1, i)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,16 +53,16 @@ public class ItemStorageDisk extends ItemBase {
|
||||
if (stack.getItemDamage() == TYPE_DEBUG) {
|
||||
applyDebugDiskData(stack);
|
||||
} else {
|
||||
ItemStorageNBT.createStackWithNBT(stack);
|
||||
StorageItemNBT.createStackWithNBT(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void applyDebugDiskData(ItemStack stack) {
|
||||
if (debugDiskTag == null) {
|
||||
debugDiskTag = ItemStorageNBT.createNBT();
|
||||
debugDiskTag = StorageItemNBT.createNBT();
|
||||
|
||||
ItemStorageNBT storage = new ItemStorageNBT(debugDiskTag, -1, null) {
|
||||
StorageItemNBT storage = new StorageItemNBT(debugDiskTag, -1, null) {
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 0;
|
||||
@@ -85,7 +85,7 @@ public class ItemStorageDisk extends ItemBase {
|
||||
item.getSubItems(item, CreativeTabs.INVENTORY, stacks);
|
||||
|
||||
for (ItemStack itemStack : stacks) {
|
||||
storage.insertItem(itemStack, 1000, false);
|
||||
storage.insert(itemStack, 1000, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,13 +98,13 @@ public class ItemStorageDisk extends ItemBase {
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack disk, EntityPlayer player, List<String> tooltip, boolean advanced) {
|
||||
if (ItemStorageNBT.isValid(disk)) {
|
||||
if (StorageItemNBT.isValid(disk)) {
|
||||
int capacity = EnumItemStorageType.getById(disk.getItemDamage()).getCapacity();
|
||||
|
||||
if (capacity == -1) {
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored", ItemStorageNBT.getStoredFromNBT(disk.getTagCompound())));
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored", StorageItemNBT.getStoredFromNBT(disk.getTagCompound())));
|
||||
} else {
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored_capacity", ItemStorageNBT.getStoredFromNBT(disk.getTagCompound()), capacity));
|
||||
tooltip.add(I18n.format("misc.refinedstorage:storage.stored_capacity", StorageItemNBT.getStoredFromNBT(disk.getTagCompound()), capacity));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class ItemStorageDisk extends ItemBase {
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack disk = player.getHeldItem(hand);
|
||||
|
||||
if (!world.isRemote && player.isSneaking() && ItemStorageNBT.isValid(disk) && ItemStorageNBT.getStoredFromNBT(disk.getTagCompound()) <= 0 && disk.getMetadata() != TYPE_CREATIVE) {
|
||||
if (!world.isRemote && player.isSneaking() && StorageItemNBT.isValid(disk) && StorageItemNBT.getStoredFromNBT(disk.getTagCompound()) <= 0 && disk.getMetadata() != TYPE_CREATIVE) {
|
||||
ItemStack storagePart = new ItemStack(RSItems.STORAGE_PART, 1, disk.getMetadata());
|
||||
|
||||
if (!player.inventory.addItemStackToInventory(storagePart.copy())) {
|
||||
@@ -130,7 +130,7 @@ public class ItemStorageDisk extends ItemBase {
|
||||
public void onCreated(ItemStack stack, World world, EntityPlayer player) {
|
||||
super.onCreated(stack, world, player);
|
||||
|
||||
ItemStorageNBT.createStackWithNBT(stack);
|
||||
StorageItemNBT.createStackWithNBT(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,6 +140,6 @@ public class ItemStorageDisk extends ItemBase {
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTShareTag(ItemStack stack) {
|
||||
return ItemStorageNBT.getNBTShareTag(stack.getTagCompound());
|
||||
return StorageItemNBT.getNBTShareTag(stack.getTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter.ReaderWriter
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter.ReaderWriterHandlerItems;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter.ReaderWriterHandlerRedstone;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.solderer.*;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageFluidNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageItemNBT;
|
||||
import com.raoulvdberge.refinedstorage.block.*;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiHandler;
|
||||
import com.raoulvdberge.refinedstorage.integration.craftingtweaks.IntegrationCraftingTweaks;
|
||||
@@ -548,7 +548,7 @@ public class ProxyCommon {
|
||||
|
||||
// Storage Disks
|
||||
for (int type = 0; type <= 3; ++type) {
|
||||
ItemStack disk = ItemStorageNBT.createStackWithNBT(new ItemStack(RSItems.STORAGE_DISK, 1, type));
|
||||
ItemStack disk = StorageItemNBT.createStackWithNBT(new ItemStack(RSItems.STORAGE_DISK, 1, type));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(disk,
|
||||
"GRG",
|
||||
@@ -568,7 +568,7 @@ public class ProxyCommon {
|
||||
|
||||
// Fluid Storage Disks
|
||||
for (int type = 0; type <= 3; ++type) {
|
||||
ItemStack disk = FluidStorageNBT.createStackWithNBT(new ItemStack(RSItems.FLUID_STORAGE_DISK, 1, type));
|
||||
ItemStack disk = StorageFluidNBT.createStackWithNBT(new ItemStack(RSItems.FLUID_STORAGE_DISK, 1, type));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(disk,
|
||||
"GRG",
|
||||
|
||||
@@ -20,19 +20,16 @@ import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterCha
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterHandler;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.fluid.IFluidStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.fluid.IFluidStorageCache;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.item.IItemStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.item.IItemStorageCache;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IItemStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkNodeGraph;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.FluidGridHandler;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.ItemGridHandler;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.item.NetworkItemHandler;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.fluid.FluidStorageCache;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.item.ItemStorageCache;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheFluid;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheItem;
|
||||
import com.raoulvdberge.refinedstorage.block.BlockController;
|
||||
import com.raoulvdberge.refinedstorage.block.EnumControllerType;
|
||||
import com.raoulvdberge.refinedstorage.block.EnumGridType;
|
||||
@@ -162,8 +159,8 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
|
||||
|
||||
private INetworkNodeGraph nodeGraph = new NetworkNodeGraph(this);
|
||||
|
||||
private IItemStorageCache itemStorage = new ItemStorageCache(this);
|
||||
private IFluidStorageCache fluidStorage = new FluidStorageCache(this);
|
||||
private IStorageCache<ItemStack> itemStorage = new StorageCacheItem(this);
|
||||
private IStorageCache<FluidStack> fluidStorage = new StorageCacheFluid(this);
|
||||
|
||||
private Map<String, IReaderWriterChannel> readerWriterChannels = new HashMap<>();
|
||||
|
||||
@@ -334,12 +331,13 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
|
||||
nodeGraph.disconnectAll();
|
||||
}
|
||||
|
||||
public IItemStorageCache getItemStorageCache() {
|
||||
@Override
|
||||
public IStorageCache<ItemStack> getItemStorageCache() {
|
||||
return itemStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidStorageCache getFluidStorageCache() {
|
||||
public IStorageCache<FluidStack> getFluidStorageCache() {
|
||||
return fluidStorage;
|
||||
}
|
||||
|
||||
@@ -395,7 +393,7 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
|
||||
int highestScore = 0;
|
||||
int highestPattern = 0;
|
||||
|
||||
IItemStackList itemList = itemStorage.getList().getOredicted();
|
||||
IStackList<ItemStack> itemList = itemStorage.getList().getOredicted();
|
||||
|
||||
for (int i = 0; i < patterns.size(); ++i) {
|
||||
int score = 0;
|
||||
@@ -585,10 +583,10 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
|
||||
int inserted = 0;
|
||||
int insertedExternally = 0;
|
||||
|
||||
for (IItemStorage storage : this.itemStorage.getStorages()) {
|
||||
for (IStorage<ItemStack> storage : this.itemStorage.getStorages()) {
|
||||
int storedPre = storage.getStored();
|
||||
|
||||
remainder = storage.insertItem(remainder, size, simulate);
|
||||
remainder = storage.insert(remainder, size, simulate);
|
||||
|
||||
if (!simulate) {
|
||||
inserted += storage.getCacheDelta(storedPre, size, remainder);
|
||||
@@ -645,11 +643,11 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
|
||||
|
||||
ItemStack newStack = null;
|
||||
|
||||
for (IItemStorage storage : this.itemStorage.getStorages()) {
|
||||
for (IStorage<ItemStack> storage : this.itemStorage.getStorages()) {
|
||||
ItemStack took = null;
|
||||
|
||||
if (storage.getAccessType() != AccessType.INSERT) {
|
||||
took = storage.extractItem(stack, requested - received, flags, simulate);
|
||||
took = storage.extract(stack, requested - received, flags, simulate);
|
||||
}
|
||||
|
||||
if (took != null) {
|
||||
@@ -692,10 +690,10 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
|
||||
|
||||
int inserted = 0;
|
||||
|
||||
for (IFluidStorage storage : this.fluidStorage.getStorages()) {
|
||||
for (IStorage<FluidStack> storage : this.fluidStorage.getStorages()) {
|
||||
int storedPre = storage.getStored();
|
||||
|
||||
remainder = storage.insertFluid(remainder, size, simulate);
|
||||
remainder = storage.insert(remainder, size, simulate);
|
||||
|
||||
if (!simulate) {
|
||||
inserted += storage.getCacheDelta(storedPre, size, remainder);
|
||||
@@ -713,7 +711,7 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
|
||||
}
|
||||
|
||||
if (inserted > 0) {
|
||||
fluidStorage.add(RSUtils.copyStackWithSize(stack, inserted), false);
|
||||
fluidStorage.add(stack, inserted, false);
|
||||
}
|
||||
|
||||
return remainder;
|
||||
@@ -727,11 +725,11 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
|
||||
|
||||
FluidStack newStack = null;
|
||||
|
||||
for (IFluidStorage storage : this.fluidStorage.getStorages()) {
|
||||
for (IStorage<FluidStack> storage : this.fluidStorage.getStorages()) {
|
||||
FluidStack took = null;
|
||||
|
||||
if (storage.getAccessType() != AccessType.INSERT) {
|
||||
took = storage.extractFluid(stack, requested - received, flags, simulate);
|
||||
took = storage.extract(stack, requested - received, flags, simulate);
|
||||
}
|
||||
|
||||
if (took != null) {
|
||||
@@ -754,7 +752,7 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
|
||||
}
|
||||
|
||||
if (newStack != null && !simulate) {
|
||||
fluidStorage.remove(newStack);
|
||||
fluidStorage.remove(newStack, newStack.amount);
|
||||
}
|
||||
|
||||
return newStack;
|
||||
|
||||
@@ -5,13 +5,11 @@ import com.raoulvdberge.refinedstorage.RSItems;
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.fluid.IFluidStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.fluid.IFluidStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.item.IItemStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.item.IItemStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageFluidNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageItemNBT;
|
||||
import com.raoulvdberge.refinedstorage.block.EnumFluidStorageType;
|
||||
import com.raoulvdberge.refinedstorage.block.EnumItemStorageType;
|
||||
import com.raoulvdberge.refinedstorage.inventory.IItemValidator;
|
||||
@@ -34,7 +32,7 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFluidStorageProvider, IStorageGui, IComparable, IFilterable, IPrioritizable, IType, IExcessVoidable, IAccessType {
|
||||
public class TileDiskDrive extends TileNode implements IStorageProvider, IStorageGui, IComparable, IFilterable, IPrioritizable, IType, IExcessVoidable, IAccessType {
|
||||
public static final TileDataParameter<Integer> PRIORITY = IPrioritizable.createParameter();
|
||||
public static final TileDataParameter<Integer> COMPARE = IComparable.createParameter();
|
||||
public static final TileDataParameter<Integer> MODE = IFilterable.createParameter();
|
||||
@@ -42,7 +40,7 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
public static final TileDataParameter<Boolean> VOID_EXCESS = IExcessVoidable.createParameter();
|
||||
public static final TileDataParameter<AccessType> ACCESS_TYPE = IAccessType.createParameter();
|
||||
|
||||
public class ItemStorage extends ItemStorageNBT {
|
||||
public class ItemStorage extends StorageItemNBT {
|
||||
private int lastState;
|
||||
|
||||
public ItemStorage(ItemStack disk) {
|
||||
@@ -57,12 +55,12 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack insertItem(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
public ItemStack insert(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
if (!IFilterable.canTake(itemFilters, mode, getCompare(), stack)) {
|
||||
return ItemHandlerHelper.copyStackWithSize(stack, size);
|
||||
}
|
||||
|
||||
return super.insertItem(stack, size, simulate);
|
||||
return super.insert(stack, size, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +87,7 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
}
|
||||
}
|
||||
|
||||
public class FluidStorage extends FluidStorageNBT {
|
||||
public class FluidStorage extends StorageFluidNBT {
|
||||
private int lastState;
|
||||
|
||||
public FluidStorage(ItemStack disk) {
|
||||
@@ -104,12 +102,12 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack insertFluid(FluidStack stack, int size, boolean simulate) {
|
||||
public FluidStack insert(FluidStack stack, int size, boolean simulate) {
|
||||
if (!IFilterable.canTakeFluids(fluidFilters, mode, getCompare(), stack)) {
|
||||
return RSUtils.copyStackWithSize(stack, size);
|
||||
}
|
||||
|
||||
return super.insertFluid(stack, size, simulate);
|
||||
return super.insert(stack, size, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -248,8 +246,8 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItemStorages(List<IItemStorage> storages) {
|
||||
for (IItemStorage storage : this.itemStorages) {
|
||||
public void addItemStorages(List<IStorage<ItemStack>> storages) {
|
||||
for (IStorage<ItemStack> storage : this.itemStorages) {
|
||||
if (storage != null) {
|
||||
storages.add(storage);
|
||||
}
|
||||
@@ -257,8 +255,8 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFluidStorages(List<IFluidStorage> storages) {
|
||||
for (IFluidStorage storage : this.fluidStorages) {
|
||||
public void addFluidStorages(List<IStorage<FluidStack>> storages) {
|
||||
for (IStorage<FluidStack> storage : this.fluidStorages) {
|
||||
if (storage != null) {
|
||||
storages.add(storage);
|
||||
}
|
||||
@@ -359,7 +357,7 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
return diskState;
|
||||
}
|
||||
|
||||
public static void writeDiskState(NBTTagCompound tag, int disks, boolean connected, ItemStorageNBT[] itemStorages, FluidStorageNBT[] fluidStorages) {
|
||||
public static void writeDiskState(NBTTagCompound tag, int disks, boolean connected, StorageItemNBT[] itemStorages, StorageFluidNBT[] fluidStorages) {
|
||||
for (int i = 0; i < disks; ++i) {
|
||||
int state = DISK_STATE_NONE;
|
||||
|
||||
@@ -506,7 +504,7 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
ItemStack disk = disks.getStackInSlot(i);
|
||||
|
||||
if (!disk.isEmpty()) {
|
||||
stored += disk.getItem() == RSItems.STORAGE_DISK ? ItemStorageNBT.getStoredFromNBT(disk.getTagCompound()) : FluidStorageNBT.getStoredFromNBT(disk.getTagCompound());
|
||||
stored += disk.getItem() == RSItems.STORAGE_DISK ? StorageItemNBT.getStoredFromNBT(disk.getTagCompound()) : StorageFluidNBT.getStoredFromNBT(disk.getTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.raoulvdberge.refinedstorage.tile;
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageFluidNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageItemNBT;
|
||||
import com.raoulvdberge.refinedstorage.block.EnumFluidStorageType;
|
||||
import com.raoulvdberge.refinedstorage.block.EnumItemStorageType;
|
||||
import com.raoulvdberge.refinedstorage.inventory.IItemValidator;
|
||||
@@ -113,7 +113,7 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
||||
}
|
||||
};
|
||||
|
||||
public class ItemStorage extends ItemStorageNBT {
|
||||
public class ItemStorage extends StorageItemNBT {
|
||||
private int lastState;
|
||||
|
||||
public ItemStorage(ItemStack disk) {
|
||||
@@ -133,21 +133,21 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack insertItem(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
public ItemStack insert(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
if (!IFilterable.canTake(itemFilters, mode, getCompare(), stack)) {
|
||||
return ItemHandlerHelper.copyStackWithSize(stack, size);
|
||||
}
|
||||
|
||||
return super.insertItem(stack, size, simulate);
|
||||
return super.insert(stack, size, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags, boolean simulate) {
|
||||
public ItemStack extract(@Nonnull ItemStack stack, int size, int flags, boolean simulate) {
|
||||
if (!IFilterable.canTake(itemFilters, mode, getCompare(), stack)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return super.extractItem(stack, size, flags, simulate);
|
||||
return super.extract(stack, size, flags, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -164,7 +164,7 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
||||
}
|
||||
}
|
||||
|
||||
public class FluidStorage extends FluidStorageNBT {
|
||||
public class FluidStorage extends StorageFluidNBT {
|
||||
private int lastState;
|
||||
|
||||
public FluidStorage(ItemStack disk) {
|
||||
@@ -184,21 +184,21 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack insertFluid(FluidStack stack, int size, boolean simulate) {
|
||||
public FluidStack insert(FluidStack stack, int size, boolean simulate) {
|
||||
if (!IFilterable.canTakeFluids(fluidFilters, mode, getCompare(), stack)) {
|
||||
return RSUtils.copyStackWithSize(stack, size);
|
||||
}
|
||||
|
||||
return super.insertFluid(stack, size, simulate);
|
||||
return super.insert(stack, size, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack extractFluid(FluidStack stack, int size, int flags, boolean simulate) {
|
||||
public FluidStack extract(FluidStack stack, int size, int flags, boolean simulate) {
|
||||
if (!IFilterable.canTakeFluids(fluidFilters, mode, getCompare(), stack)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return super.extractFluid(stack, size, flags, simulate);
|
||||
return super.extract(stack, size, flags, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -290,7 +290,7 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack extracted = storage.extractItem(stack, upgrades.getItemInteractCount(), compare, false);
|
||||
ItemStack extracted = storage.extract(stack, upgrades.getItemInteractCount(), compare, false);
|
||||
if (extracted == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -301,7 +301,7 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
||||
}
|
||||
|
||||
// We need to check if the stack was inserted
|
||||
storage.insertItem(((extracted == remainder) ? remainder.copy() : remainder), remainder.getCount(), false);
|
||||
storage.insert(((extracted == remainder) ? remainder.copy() : remainder), remainder.getCount(), false);
|
||||
}
|
||||
|
||||
if (storage.getStacks().size() == 0) {
|
||||
@@ -350,7 +350,7 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack remainder = storage.insertItem(extracted, extracted.getCount(), false);
|
||||
ItemStack remainder = storage.insert(extracted, extracted.getCount(), false);
|
||||
|
||||
if (remainder != null) {
|
||||
network.insertItem(remainder, remainder.getCount(), false);
|
||||
@@ -374,7 +374,7 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
||||
}
|
||||
|
||||
if (stack != null) {
|
||||
extracted = storage.extractFluid(stack, upgrades.getItemInteractCount(), compare, false);
|
||||
extracted = storage.extract(stack, upgrades.getItemInteractCount(), compare, false);
|
||||
}
|
||||
} while (extracted == null && storage.getStacks().size() > i);
|
||||
|
||||
@@ -386,7 +386,7 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
||||
FluidStack remainder = network.insertFluid(extracted, extracted.amount, false);
|
||||
|
||||
if (remainder != null) {
|
||||
storage.insertFluid(remainder, remainder.amount, false);
|
||||
storage.insert(remainder, remainder.amount, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
||||
return;
|
||||
}
|
||||
|
||||
FluidStack remainder = storage.insertFluid(extracted, extracted.amount, false);
|
||||
FluidStack remainder = storage.insert(extracted, extracted.amount, false);
|
||||
|
||||
if (remainder != null) {
|
||||
network.insertFluid(remainder, remainder.amount, false);
|
||||
|
||||
@@ -5,23 +5,24 @@ import com.raoulvdberge.refinedstorage.RSBlocks;
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.fluid.IFluidStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.fluid.IFluidStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageFluidNBT;
|
||||
import com.raoulvdberge.refinedstorage.block.BlockFluidStorage;
|
||||
import com.raoulvdberge.refinedstorage.block.EnumFluidStorageType;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.*;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TileFluidStorage extends TileNode implements IFluidStorageProvider, IStorageGui, IComparable, IFilterable, IPrioritizable, IExcessVoidable, IAccessType {
|
||||
public class TileFluidStorage extends TileNode implements IStorageProvider, IStorageGui, IComparable, IFilterable, IPrioritizable, IExcessVoidable, IAccessType {
|
||||
public static final TileDataParameter<Integer> PRIORITY = IPrioritizable.createParameter();
|
||||
public static final TileDataParameter<Integer> COMPARE = IComparable.createParameter();
|
||||
public static final TileDataParameter<Boolean> VOID_EXCESS = IExcessVoidable.createParameter();
|
||||
@@ -30,11 +31,11 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider,
|
||||
public static final TileDataParameter<Integer> STORED = new TileDataParameter<>(DataSerializers.VARINT, 0, new ITileDataProducer<Integer, TileFluidStorage>() {
|
||||
@Override
|
||||
public Integer getValue(TileFluidStorage tile) {
|
||||
return FluidStorageNBT.getStoredFromNBT(tile.storageTag);
|
||||
return StorageFluidNBT.getStoredFromNBT(tile.storageTag);
|
||||
}
|
||||
});
|
||||
|
||||
class FluidStorage extends FluidStorageNBT {
|
||||
class FluidStorage extends StorageFluidNBT {
|
||||
public FluidStorage() {
|
||||
super(TileFluidStorage.this.getStorageTag(), TileFluidStorage.this.getCapacity(), TileFluidStorage.this);
|
||||
}
|
||||
@@ -45,12 +46,12 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider,
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack insertFluid(FluidStack stack, int size, boolean simulate) {
|
||||
public FluidStack insert(FluidStack stack, int size, boolean simulate) {
|
||||
if (!IFilterable.canTakeFluids(filters, mode, compare, stack)) {
|
||||
return RSUtils.copyStackWithSize(stack, size);
|
||||
}
|
||||
|
||||
return super.insertFluid(stack, size, simulate);
|
||||
return super.insert(stack, size, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,7 +74,7 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider,
|
||||
|
||||
private ItemHandlerFluid filters = new ItemHandlerFluid(9, this);
|
||||
|
||||
private NBTTagCompound storageTag = FluidStorageNBT.createNBT();
|
||||
private NBTTagCompound storageTag = StorageFluidNBT.createNBT();
|
||||
|
||||
private FluidStorage storage;
|
||||
|
||||
@@ -130,7 +131,12 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFluidStorages(List<IFluidStorage> storages) {
|
||||
public void addItemStorages(List<IStorage<ItemStack>> storages) {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFluidStorages(List<IStorage<FluidStack>> storages) {
|
||||
if (storage != null) {
|
||||
storages.add(storage);
|
||||
}
|
||||
@@ -284,7 +290,7 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider,
|
||||
this.storageTag = storageTag;
|
||||
}
|
||||
|
||||
public FluidStorageNBT getStorage() {
|
||||
public StorageFluidNBT getStorage() {
|
||||
return storage;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ import com.raoulvdberge.refinedstorage.RSBlocks;
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.item.IItemStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.item.IItemStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageItemNBT;
|
||||
import com.raoulvdberge.refinedstorage.block.BlockStorage;
|
||||
import com.raoulvdberge.refinedstorage.block.EnumItemStorageType;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
|
||||
@@ -18,12 +18,13 @@ import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class TileStorage extends TileNode implements IItemStorageProvider, IStorageGui, IComparable, IFilterable, IPrioritizable, IExcessVoidable, IAccessType {
|
||||
public class TileStorage extends TileNode implements IStorageProvider, IStorageGui, IComparable, IFilterable, IPrioritizable, IExcessVoidable, IAccessType {
|
||||
public static final TileDataParameter<Integer> PRIORITY = IPrioritizable.createParameter();
|
||||
public static final TileDataParameter<Integer> COMPARE = IComparable.createParameter();
|
||||
public static final TileDataParameter<Integer> MODE = IFilterable.createParameter();
|
||||
@@ -31,12 +32,12 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
|
||||
public static final TileDataParameter<Integer> STORED = new TileDataParameter<>(DataSerializers.VARINT, 0, new ITileDataProducer<Integer, TileStorage>() {
|
||||
@Override
|
||||
public Integer getValue(TileStorage tile) {
|
||||
return ItemStorageNBT.getStoredFromNBT(tile.storageTag);
|
||||
return StorageItemNBT.getStoredFromNBT(tile.storageTag);
|
||||
}
|
||||
});
|
||||
public static final TileDataParameter<Boolean> VOID_EXCESS = IExcessVoidable.createParameter();
|
||||
|
||||
class ItemStorage extends ItemStorageNBT {
|
||||
class ItemStorage extends StorageItemNBT {
|
||||
public ItemStorage() {
|
||||
super(TileStorage.this.getStorageTag(), TileStorage.this.getCapacity(), TileStorage.this);
|
||||
}
|
||||
@@ -47,12 +48,12 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack insertItem(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
public ItemStack insert(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
if (!IFilterable.canTake(filters, mode, compare, stack)) {
|
||||
return ItemHandlerHelper.copyStackWithSize(stack, size);
|
||||
}
|
||||
|
||||
return super.insertItem(stack, size, simulate);
|
||||
return super.insert(stack, size, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,7 +76,7 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
|
||||
|
||||
private ItemHandlerBasic filters = new ItemHandlerBasic(9, this);
|
||||
|
||||
private NBTTagCompound storageTag = ItemStorageNBT.createNBT();
|
||||
private NBTTagCompound storageTag = StorageItemNBT.createNBT();
|
||||
|
||||
private ItemStorage storage;
|
||||
|
||||
@@ -132,12 +133,17 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItemStorages(List<IItemStorage> storages) {
|
||||
public void addItemStorages(List<IStorage<ItemStack>> storages) {
|
||||
if (storage != null) {
|
||||
storages.add(storage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFluidStorages(List<IStorage<FluidStack>> storages) {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
super.read(tag);
|
||||
@@ -298,7 +304,7 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
|
||||
this.storageTag = storageTag;
|
||||
}
|
||||
|
||||
public ItemStorageNBT getStorage() {
|
||||
public StorageItemNBT getStorage() {
|
||||
return storage;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.raoulvdberge.refinedstorage.tile.externalstorage;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.fluid.IFluidStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||
@@ -14,7 +14,7 @@ import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class FluidStorageExternal implements IFluidStorage {
|
||||
public class FluidStorageExternal implements IStorage<FluidStack> {
|
||||
private FluidStack cache;
|
||||
|
||||
private TileExternalStorage externalStorage;
|
||||
@@ -40,7 +40,7 @@ public class FluidStorageExternal implements IFluidStorage {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FluidStack insertFluid(@Nonnull FluidStack stack, int size, boolean simulate) {
|
||||
public FluidStack insert(@Nonnull FluidStack stack, int size, boolean simulate) {
|
||||
if (getProperties() != null && IFilterable.canTakeFluids(externalStorage.getFluidFilters(), externalStorage.getMode(), externalStorage.getCompare(), stack) && getProperties().canFillFluidType(stack)) {
|
||||
int filled = handler.fill(RSUtils.copyStackWithSize(stack, size), !simulate);
|
||||
|
||||
@@ -56,7 +56,7 @@ public class FluidStorageExternal implements IFluidStorage {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FluidStack extractFluid(@Nonnull FluidStack stack, int size, int flags, boolean simulate) {
|
||||
public FluidStack extract(@Nonnull FluidStack stack, int size, int flags, boolean simulate) {
|
||||
FluidStack toDrain = RSUtils.copyStackWithSize(stack, size);
|
||||
|
||||
if (API.instance().getComparer().isEqual(getContents(), toDrain, flags)) {
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ItemStorageDSU extends ItemStorageExternal {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack insertItem(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
public ItemStack insert(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
if (IFilterable.canTake(externalStorage.getItemFilters(), externalStorage.getMode(), externalStorage.getCompare(), stack)) {
|
||||
if (unit.getStoredItemType() != null) {
|
||||
if (API.instance().getComparer().isEqualNoQuantity(unit.getStoredItemType(), stack)) {
|
||||
@@ -86,7 +86,7 @@ public class ItemStorageDSU extends ItemStorageExternal {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags, boolean simulate) {
|
||||
public ItemStack extract(@Nonnull ItemStack stack, int size, int flags, boolean simulate) {
|
||||
if (API.instance().getComparer().isEqual(stack, unit.getStoredItemType(), flags)) {
|
||||
if (size > unit.getStoredItemType().getCount()) {
|
||||
size = unit.getStoredItemType().getCount();
|
||||
|
||||
@@ -32,13 +32,13 @@ public class ItemStorageDrawer extends ItemStorageExternal {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack insertItem(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
return insertItem(externalStorage, drawer, stack, size, simulate);
|
||||
public ItemStack insert(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
return insert(externalStorage, drawer, stack, size, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags, boolean simulate) {
|
||||
return extractItem(drawer, stack, size, flags, simulate);
|
||||
public ItemStack extract(@Nonnull ItemStack stack, int size, int flags, boolean simulate) {
|
||||
return extract(drawer, stack, size, flags, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,7 +64,7 @@ public class ItemStorageDrawer extends ItemStorageExternal {
|
||||
return RSUtils.emptyNonNullList();
|
||||
}
|
||||
|
||||
public static ItemStack insertItem(TileExternalStorage externalStorage, IDrawer drawer, @Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
public static ItemStack insert(TileExternalStorage externalStorage, IDrawer drawer, @Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
if (IFilterable.canTake(externalStorage.getItemFilters(), externalStorage.getMode(), externalStorage.getCompare(), stack) && drawer.canItemBeStored(stack)) {
|
||||
int stored = drawer.getStoredItemCount();
|
||||
int remainingSpace = drawer.getMaxCapacity(stack) - stored;
|
||||
@@ -95,7 +95,7 @@ public class ItemStorageDrawer extends ItemStorageExternal {
|
||||
return ItemHandlerHelper.copyStackWithSize(stack, size);
|
||||
}
|
||||
|
||||
public static ItemStack extractItem(IDrawer drawer, @Nonnull ItemStack stack, int size, int flags, boolean simulate) {
|
||||
public static ItemStack extract(IDrawer drawer, @Nonnull ItemStack stack, int size, int flags, boolean simulate) {
|
||||
if (API.instance().getComparer().isEqual(stack, drawer.getStoredItemPrototype(), flags) && drawer.canItemBeExtracted(stack)) {
|
||||
if (size > drawer.getStoredItemCount()) {
|
||||
size = drawer.getStoredItemCount();
|
||||
|
||||
@@ -62,12 +62,12 @@ public class ItemStorageDrawerGroup extends ItemStorageExternal {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack insertItem(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
public ItemStack insert(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
ItemStack remainder = stack;
|
||||
|
||||
for (int i = 0; i < drawers.getDrawerCount(); ++i) {
|
||||
if (drawers.isDrawerEnabled(i)) {
|
||||
remainder = ItemStorageDrawer.insertItem(externalStorage, drawers.getDrawer(i), stack, size, simulate);
|
||||
remainder = ItemStorageDrawer.insert(externalStorage, drawers.getDrawer(i), stack, size, simulate);
|
||||
|
||||
if (remainder == null || remainder.getCount() <= 0) {
|
||||
break;
|
||||
@@ -82,14 +82,14 @@ public class ItemStorageDrawerGroup extends ItemStorageExternal {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags, boolean simulate) {
|
||||
public ItemStack extract(@Nonnull ItemStack stack, int size, int flags, boolean simulate) {
|
||||
int toExtract = size;
|
||||
|
||||
ItemStack result = null;
|
||||
|
||||
for (int i = 0; i < drawers.getDrawerCount(); ++i) {
|
||||
if (drawers.isDrawerEnabled(i)) {
|
||||
ItemStack extracted = ItemStorageDrawer.extractItem(drawers.getDrawer(i), stack, toExtract, flags, simulate);
|
||||
ItemStack extracted = ItemStorageDrawer.extract(drawers.getDrawer(i), stack, toExtract, flags, simulate);
|
||||
|
||||
if (extracted != null) {
|
||||
if (result == null) {
|
||||
|
||||
@@ -2,14 +2,14 @@ package com.raoulvdberge.refinedstorage.tile.externalstorage;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.item.IItemStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ItemStorageExternal implements IItemStorage {
|
||||
public abstract class ItemStorageExternal implements IStorage<ItemStack> {
|
||||
private List<ItemStack> cache;
|
||||
|
||||
public abstract int getCapacity();
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ItemStorageItemHandler extends ItemStorageExternal {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack insertItem(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
public ItemStack insert(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
if (IFilterable.canTake(externalStorage.getItemFilters(), externalStorage.getMode(), externalStorage.getCompare(), stack)) {
|
||||
return ItemHandlerHelper.insertItem(handler, ItemHandlerHelper.copyStackWithSize(stack, size), simulate);
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class ItemStorageItemHandler extends ItemStorageExternal {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags, boolean simulate) {
|
||||
public ItemStack extract(@Nonnull ItemStack stack, int size, int flags, boolean simulate) {
|
||||
int remaining = size;
|
||||
|
||||
ItemStack received = null;
|
||||
|
||||
@@ -6,10 +6,8 @@ import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.fluid.IFluidStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.fluid.IFluidStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.item.IItemStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.item.IItemStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
|
||||
@@ -18,9 +16,11 @@ import com.raoulvdberge.refinedstorage.tile.TileNode;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.*;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -29,7 +29,7 @@ import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TileExternalStorage extends TileNode implements IItemStorageProvider, IFluidStorageProvider, IStorageGui, IComparable, IFilterable, IPrioritizable, IType, IAccessType {
|
||||
public class TileExternalStorage extends TileNode implements IStorageProvider, IStorageGui, IComparable, IFilterable, IPrioritizable, IType, IAccessType {
|
||||
public static final TileDataParameter<Integer> PRIORITY = IPrioritizable.createParameter();
|
||||
public static final TileDataParameter<Integer> COMPARE = IComparable.createParameter();
|
||||
public static final TileDataParameter<Integer> MODE = IFilterable.createParameter();
|
||||
@@ -261,12 +261,12 @@ public class TileExternalStorage extends TileNode implements IItemStorageProvide
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItemStorages(List<IItemStorage> storages) {
|
||||
public void addItemStorages(List<IStorage<ItemStack>> storages) {
|
||||
storages.addAll(this.itemStorages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFluidStorages(List<IFluidStorage> storages) {
|
||||
public void addFluidStorages(List<IStorage<FluidStack>> storages) {
|
||||
storages.addAll(this.fluidStorages);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user