Refactor of network nodes. TODO: generics and proper node saving / loading
This commit is contained in:
		@@ -34,6 +34,7 @@ import net.minecraft.util.math.Vec3d;
 | 
				
			|||||||
import net.minecraft.util.text.Style;
 | 
					import net.minecraft.util.text.Style;
 | 
				
			||||||
import net.minecraft.util.text.TextComponentTranslation;
 | 
					import net.minecraft.util.text.TextComponentTranslation;
 | 
				
			||||||
import net.minecraft.util.text.TextFormatting;
 | 
					import net.minecraft.util.text.TextFormatting;
 | 
				
			||||||
 | 
					import net.minecraft.world.World;
 | 
				
			||||||
import net.minecraftforge.common.util.Constants;
 | 
					import net.minecraftforge.common.util.Constants;
 | 
				
			||||||
import net.minecraftforge.fluids.Fluid;
 | 
					import net.minecraftforge.fluids.Fluid;
 | 
				
			||||||
import net.minecraftforge.fluids.FluidRegistry;
 | 
					import net.minecraftforge.fluids.FluidRegistry;
 | 
				
			||||||
@@ -254,6 +255,12 @@ public final class RSUtils {
 | 
				
			|||||||
        return AccessType.INSERT_EXTRACT;
 | 
					        return AccessType.INSERT_EXTRACT;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static void updateBlock(World world, BlockPos pos) {
 | 
				
			||||||
 | 
					        if (world != null) {
 | 
				
			||||||
 | 
					            world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 1 | 2);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static IItemHandler getItemHandler(TileEntity tile, EnumFacing side) {
 | 
					    public static IItemHandler getItemHandler(TileEntity tile, EnumFacing side) {
 | 
				
			||||||
        if (tile == null) {
 | 
					        if (tile == null) {
 | 
				
			||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,8 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.api.network;
 | 
					package com.raoulvdberge.refinedstorage.api.network;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import net.minecraft.item.ItemStack;
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraft.util.math.BlockPos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.annotation.Nonnull;
 | 
					import javax.annotation.Nonnull;
 | 
				
			||||||
import javax.annotation.Nullable;
 | 
					import javax.annotation.Nullable;
 | 
				
			||||||
@@ -44,4 +46,14 @@ public interface INetworkNode {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @Nullable
 | 
					    @Nullable
 | 
				
			||||||
    INetworkMaster getNetwork();
 | 
					    INetworkMaster getNetwork();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void update();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NBTTagCompound write(NBTTagCompound tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void read(NBTTagCompound tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    BlockPos getPos();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void markDirty();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.api.network;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public interface INetworkNodeProxy {
 | 
				
			||||||
 | 
					    INetworkNode getNode();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    INetworkNode createNode();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -8,6 +8,7 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.preview.ICraftingPreview
 | 
				
			|||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.registry.ICraftingTaskRegistry;
 | 
					import com.raoulvdberge.refinedstorage.api.autocrafting.registry.ICraftingTaskRegistry;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkNodeProxy;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterChannel;
 | 
					import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterChannel;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterHandlerRegistry;
 | 
					import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterHandlerRegistry;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRegistry;
 | 
					import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRegistry;
 | 
				
			||||||
@@ -23,7 +24,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.solderer.SoldererRegistry;
 | 
				
			|||||||
import com.raoulvdberge.refinedstorage.apiimpl.util.Comparer;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.util.Comparer;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.apiimpl.util.StackListFluid;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.util.StackListFluid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.apiimpl.util.StackListItem;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.util.StackListItem;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.proxy.CapabilityNetworkNode;
 | 
					import com.raoulvdberge.refinedstorage.proxy.CapabilityNetworkNodeProxy;
 | 
				
			||||||
import net.minecraft.item.ItemStack;
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
import net.minecraft.tileentity.TileEntity;
 | 
					import net.minecraft.tileentity.TileEntity;
 | 
				
			||||||
import net.minecraft.util.EnumFacing;
 | 
					import net.minecraft.util.EnumFacing;
 | 
				
			||||||
@@ -137,8 +138,9 @@ public class API implements IRSAPI {
 | 
				
			|||||||
        for (EnumFacing facing : EnumFacing.VALUES) {
 | 
					        for (EnumFacing facing : EnumFacing.VALUES) {
 | 
				
			||||||
            TileEntity tile = world.getTileEntity(pos.offset(facing));
 | 
					            TileEntity tile = world.getTileEntity(pos.offset(facing));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (tile != null && tile.hasCapability(CapabilityNetworkNode.NETWORK_NODE_CAPABILITY, facing.getOpposite())) {
 | 
					            if (tile != null && tile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite())) {
 | 
				
			||||||
                INetworkNode node = tile.getCapability(CapabilityNetworkNode.NETWORK_NODE_CAPABILITY, facing.getOpposite());
 | 
					                INetworkNodeProxy nodeProxy = tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite());
 | 
				
			||||||
 | 
					                INetworkNode node = nodeProxy.getNode();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (node.getNetwork() != null) {
 | 
					                if (node.getNetwork() != null) {
 | 
				
			||||||
                    node.getNetwork().getNodeGraph().rebuild();
 | 
					                    node.getNetwork().getNodeGraph().rebuild();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,8 +2,9 @@ package com.raoulvdberge.refinedstorage.apiimpl.network;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSUtils;
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkNodeProxy;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
 | 
					import com.raoulvdberge.refinedstorage.api.network.security.Permission;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.proxy.CapabilityNetworkNode;
 | 
					import com.raoulvdberge.refinedstorage.proxy.CapabilityNetworkNodeProxy;
 | 
				
			||||||
import net.minecraft.tileentity.TileEntity;
 | 
					import net.minecraft.tileentity.TileEntity;
 | 
				
			||||||
import net.minecraft.util.EnumFacing;
 | 
					import net.minecraft.util.EnumFacing;
 | 
				
			||||||
import net.minecraftforge.event.world.BlockEvent;
 | 
					import net.minecraftforge.event.world.BlockEvent;
 | 
				
			||||||
@@ -16,8 +17,9 @@ public class NetworkListener {
 | 
				
			|||||||
            for (EnumFacing facing : EnumFacing.VALUES) {
 | 
					            for (EnumFacing facing : EnumFacing.VALUES) {
 | 
				
			||||||
                TileEntity tile = e.getWorld().getTileEntity(e.getBlockSnapshot().getPos().offset(facing));
 | 
					                TileEntity tile = e.getWorld().getTileEntity(e.getBlockSnapshot().getPos().offset(facing));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (tile != null && tile.hasCapability(CapabilityNetworkNode.NETWORK_NODE_CAPABILITY, facing.getOpposite())) {
 | 
					                if (tile != null && tile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite())) {
 | 
				
			||||||
                    INetworkNode node = tile.getCapability(CapabilityNetworkNode.NETWORK_NODE_CAPABILITY, facing.getOpposite());
 | 
					                    INetworkNodeProxy nodeProxy = tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite());
 | 
				
			||||||
 | 
					                    INetworkNode node = nodeProxy.getNode();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, e.getPlayer())) {
 | 
					                    if (node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, e.getPlayer())) {
 | 
				
			||||||
                        RSUtils.sendNoPermissionMessage(e.getPlayer());
 | 
					                        RSUtils.sendNoPermissionMessage(e.getPlayer());
 | 
				
			||||||
@@ -36,9 +38,9 @@ public class NetworkListener {
 | 
				
			|||||||
        if (!e.getWorld().isRemote) {
 | 
					        if (!e.getWorld().isRemote) {
 | 
				
			||||||
            TileEntity tile = e.getWorld().getTileEntity(e.getPos());
 | 
					            TileEntity tile = e.getWorld().getTileEntity(e.getPos());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (tile != null && tile.hasCapability(CapabilityNetworkNode.NETWORK_NODE_CAPABILITY, null)) {
 | 
					            if (tile != null && tile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, null)) {
 | 
				
			||||||
 | 
					                INetworkNodeProxy nodeProxy = tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, null);
 | 
				
			||||||
                INetworkNode node = tile.getCapability(CapabilityNetworkNode.NETWORK_NODE_CAPABILITY, null);
 | 
					                INetworkNode node = nodeProxy.getNode();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, e.getPlayer())) {
 | 
					                if (node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, e.getPlayer())) {
 | 
				
			||||||
                    RSUtils.sendNoPermissionMessage(e.getPlayer());
 | 
					                    RSUtils.sendNoPermissionMessage(e.getPlayer());
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,6 +4,7 @@ import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
				
			|||||||
import com.raoulvdberge.refinedstorage.api.network.INetworkNeighborhoodAware;
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkNeighborhoodAware;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.INetworkNodeGraph;
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkNodeGraph;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkNodeProxy;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.item.ItemBlockController;
 | 
					import com.raoulvdberge.refinedstorage.item.ItemBlockController;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileController;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileController;
 | 
				
			||||||
import net.minecraft.block.state.IBlockState;
 | 
					import net.minecraft.block.state.IBlockState;
 | 
				
			||||||
@@ -16,7 +17,7 @@ import net.minecraft.world.World;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import java.util.*;
 | 
					import java.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import static com.raoulvdberge.refinedstorage.proxy.CapabilityNetworkNode.NETWORK_NODE_CAPABILITY;
 | 
					import static com.raoulvdberge.refinedstorage.proxy.CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class NetworkNodeGraph implements INetworkNodeGraph {
 | 
					public class NetworkNodeGraph implements INetworkNodeGraph {
 | 
				
			||||||
    private TileController controller;
 | 
					    private TileController controller;
 | 
				
			||||||
@@ -42,11 +43,14 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        INetworkNeighborhoodAware.Operator operator = (world, pos, side) -> {
 | 
					        INetworkNeighborhoodAware.Operator operator = (world, pos, side) -> {
 | 
				
			||||||
            TileEntity tile = world.getTileEntity(pos);
 | 
					            TileEntity tile = world.getTileEntity(pos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (tile != null && !tile.isInvalid()) {
 | 
					            if (tile != null && !tile.isInvalid()) {
 | 
				
			||||||
                if (tile instanceof TileController) {
 | 
					                if (tile instanceof TileController) {
 | 
				
			||||||
                    removeOtherControler(world, pos);
 | 
					                    removeOtherController(world, pos);
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    INetworkNode otherNode = NETWORK_NODE_CAPABILITY.cast(tile.getCapability(NETWORK_NODE_CAPABILITY, side));
 | 
					                    INetworkNodeProxy otherNodeProxy = NETWORK_NODE_PROXY_CAPABILITY.cast(tile.getCapability(NETWORK_NODE_PROXY_CAPABILITY, side));
 | 
				
			||||||
 | 
					                    INetworkNode otherNode = otherNodeProxy.getNode();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (otherNode != null && newNodes.add(otherNode)) {
 | 
					                    if (otherNode != null && newNodes.add(otherNode)) {
 | 
				
			||||||
                        toCheck.add(new NodeToCheck(otherNode, world, pos, side, tile));
 | 
					                        toCheck.add(new NodeToCheck(otherNode, world, pos, side, tile));
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
@@ -117,7 +121,7 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
 | 
				
			|||||||
        return controller.getWorld();
 | 
					        return controller.getWorld();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void removeOtherControler(World world, BlockPos otherControllerPos) {
 | 
					    private void removeOtherController(World world, BlockPos otherControllerPos) {
 | 
				
			||||||
        if (!controller.getPos().equals(otherControllerPos)) {
 | 
					        if (!controller.getPos().equals(otherControllerPos)) {
 | 
				
			||||||
            IBlockState state = world.getBlockState(otherControllerPos);
 | 
					            IBlockState state = world.getBlockState(otherControllerPos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -157,7 +161,7 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
 | 
				
			|||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                for (EnumFacing checkSide : EnumFacing.VALUES) {
 | 
					                for (EnumFacing checkSide : EnumFacing.VALUES) {
 | 
				
			||||||
                    if (checkSide != side) { // Avoid going backward
 | 
					                    if (checkSide != side) { // Avoid going backward
 | 
				
			||||||
                        INetworkNode nodeOnSide = NETWORK_NODE_CAPABILITY.cast(tile.getCapability(NETWORK_NODE_CAPABILITY, checkSide));
 | 
					                        INetworkNode nodeOnSide = NETWORK_NODE_PROXY_CAPABILITY.cast(tile.getCapability(NETWORK_NODE_PROXY_CAPABILITY, checkSide));
 | 
				
			||||||
                        if (nodeOnSide == node) {
 | 
					                        if (nodeOnSide == node) {
 | 
				
			||||||
                            operator.apply(world, pos.offset(checkSide), checkSide.getOpposite());
 | 
					                            operator.apply(world, pos.offset(checkSide), checkSide.getOpposite());
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,151 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkNeighborhoodAware;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.util.IWrenchable;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
 | 
				
			||||||
 | 
					import net.minecraft.block.state.IBlockState;
 | 
				
			||||||
 | 
					import net.minecraft.item.Item;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraft.util.EnumFacing;
 | 
				
			||||||
 | 
					import net.minecraft.util.math.BlockPos;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.IItemHandler;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nonnull;
 | 
				
			||||||
 | 
					import javax.annotation.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public abstract class NetworkNode implements INetworkNode, INetworkNeighborhoodAware, IWrenchable {
 | 
				
			||||||
 | 
					    protected boolean rebuildOnUpdateChange;
 | 
				
			||||||
 | 
					    private RedstoneMode redstoneMode = RedstoneMode.IGNORE;
 | 
				
			||||||
 | 
					    @Nullable
 | 
				
			||||||
 | 
					    protected INetworkMaster network;
 | 
				
			||||||
 | 
					    private boolean couldUpdate;
 | 
				
			||||||
 | 
					    protected int ticks;
 | 
				
			||||||
 | 
					    protected INetworkNodeHolder holder;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNode(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        this.holder = holder;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public RedstoneMode getRedstoneMode() {
 | 
				
			||||||
 | 
					        return redstoneMode;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setRedstoneMode(RedstoneMode redstoneMode) {
 | 
				
			||||||
 | 
					        this.redstoneMode = redstoneMode;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public ItemStack getItemStack() {
 | 
				
			||||||
 | 
					        IBlockState state = holder.world().getBlockState(holder.pos());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Item item = Item.getItemFromBlock(state.getBlock());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return new ItemStack(item, 1, state.getBlock().getMetaFromState(state));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onConnected(INetworkMaster network) {
 | 
				
			||||||
 | 
					        onConnectedStateChange(network, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.network = network;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onDisconnected(INetworkMaster network) {
 | 
				
			||||||
 | 
					        this.network = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        onConnectedStateChange(network, false);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected void onConnectedStateChange(INetworkMaster network, boolean state) {
 | 
				
			||||||
 | 
					        if (hasConnectivityState()) {
 | 
				
			||||||
 | 
					            RSUtils.updateBlock(holder.world(), holder.pos());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void markDirty() {
 | 
				
			||||||
 | 
					        // @todo
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean canUpdate() {
 | 
				
			||||||
 | 
					        return redstoneMode.isEnabled(holder.world(), holder.pos());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void update() {
 | 
				
			||||||
 | 
					        ++ticks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (couldUpdate != canUpdate()) {
 | 
				
			||||||
 | 
					            couldUpdate = canUpdate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (network != null) {
 | 
				
			||||||
 | 
					                onConnectedStateChange(network, couldUpdate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (rebuildOnUpdateChange) {
 | 
				
			||||||
 | 
					                    network.getNodeGraph().rebuild();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        writeConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void read(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        readConfiguration(tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void readConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nullable
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public INetworkMaster getNetwork() {
 | 
				
			||||||
 | 
					        return network;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public BlockPos getPos() {
 | 
				
			||||||
 | 
					        return holder.pos();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean canConduct(@Nullable EnumFacing direction) {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void walkNeighborhood(Operator operator) {
 | 
				
			||||||
 | 
					        for (EnumFacing facing : EnumFacing.VALUES) {
 | 
				
			||||||
 | 
					            if (canConduct(facing)) {
 | 
				
			||||||
 | 
					                operator.apply(holder.world(), holder.pos().offset(facing), facing.getOpposite());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getDrops() {
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean hasConnectivityState() {
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeBasic extends NetworkNode {
 | 
				
			||||||
 | 
					    private int energyUsage;
 | 
				
			||||||
 | 
					    private boolean connectivityState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeBasic(INetworkNodeHolder holder, int energyUsage, boolean connectivityState) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.energyUsage = energyUsage;
 | 
				
			||||||
 | 
					        this.connectivityState = connectivityState;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        return energyUsage;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean hasConnectivityState() {
 | 
				
			||||||
 | 
					        return connectivityState;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,320 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.mojang.authlib.GameProfile;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.util.IComparer;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.container.slot.SlotFilter;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerChangeListenerNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.TileConstructor;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IComparable;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IType;
 | 
				
			||||||
 | 
					import net.minecraft.block.Block;
 | 
				
			||||||
 | 
					import net.minecraft.block.BlockSkull;
 | 
				
			||||||
 | 
					import net.minecraft.block.SoundType;
 | 
				
			||||||
 | 
					import net.minecraft.block.state.IBlockState;
 | 
				
			||||||
 | 
					import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
 | 
				
			||||||
 | 
					import net.minecraft.dispenser.PositionImpl;
 | 
				
			||||||
 | 
					import net.minecraft.entity.item.EntityFireworkRocket;
 | 
				
			||||||
 | 
					import net.minecraft.init.Blocks;
 | 
				
			||||||
 | 
					import net.minecraft.init.Items;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTUtil;
 | 
				
			||||||
 | 
					import net.minecraft.tileentity.TileEntity;
 | 
				
			||||||
 | 
					import net.minecraft.tileentity.TileEntitySkull;
 | 
				
			||||||
 | 
					import net.minecraft.util.EnumFacing;
 | 
				
			||||||
 | 
					import net.minecraft.util.SoundCategory;
 | 
				
			||||||
 | 
					import net.minecraft.util.math.BlockPos;
 | 
				
			||||||
 | 
					import net.minecraft.world.WorldServer;
 | 
				
			||||||
 | 
					import net.minecraftforge.common.MinecraftForge;
 | 
				
			||||||
 | 
					import net.minecraftforge.common.util.BlockSnapshot;
 | 
				
			||||||
 | 
					import net.minecraftforge.common.util.FakePlayerFactory;
 | 
				
			||||||
 | 
					import net.minecraftforge.event.world.BlockEvent;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.Fluid;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.FluidStack;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.IItemHandler;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeConstructor extends NetworkNode implements IComparable, IType {
 | 
				
			||||||
 | 
					    private static final String NBT_COMPARE = "Compare";
 | 
				
			||||||
 | 
					    private static final String NBT_TYPE = "Type";
 | 
				
			||||||
 | 
					    private static final String NBT_DROP = "Drop";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static final int BASE_SPEED = 20;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic itemFilters = new ItemHandlerBasic(1, new ItemHandlerChangeListenerNode(this)) {
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        protected void onContentsChanged(int slot) {
 | 
				
			||||||
 | 
					            super.onContentsChanged(slot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            item = getStackInSlot(slot).isEmpty() ? null : getStackInSlot(slot).copy();
 | 
				
			||||||
 | 
					            block = SlotFilter.getBlockState(holder.world(), holder.pos().offset(holder.getDirection()), getStackInSlot(slot));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(1, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerChangeListenerNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_CRAFTING);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
 | 
				
			||||||
 | 
					    private int type = IType.ITEMS;
 | 
				
			||||||
 | 
					    private boolean drop = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private IBlockState block;
 | 
				
			||||||
 | 
					    private ItemStack item;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeConstructor(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        return RS.INSTANCE.config.constructorUsage + upgrades.getEnergyUsage();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void update() {
 | 
				
			||||||
 | 
					        super.update();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (network != null && ticks % upgrades.getSpeed(BASE_SPEED, 4) == 0) {
 | 
				
			||||||
 | 
					            if (type == IType.ITEMS) {
 | 
				
			||||||
 | 
					                if (block != null) {
 | 
				
			||||||
 | 
					                    if (drop && item != null) {
 | 
				
			||||||
 | 
					                        dropItem();
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        placeBlock();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                } else if (item != null) {
 | 
				
			||||||
 | 
					                    if (item.getItem() == Items.FIREWORKS && !drop) {
 | 
				
			||||||
 | 
					                        ItemStack took = network.extractItem(item, 1, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (took != null) {
 | 
				
			||||||
 | 
					                            holder.world().spawnEntity(new EntityFireworkRocket(holder.world(), getDispensePositionX(), getDispensePositionY(), getDispensePositionZ(), took));
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        dropItem();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } else if (type == IType.FLUIDS) {
 | 
				
			||||||
 | 
					                FluidStack stack = fluidFilters.getFluidStackInSlot(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (stack != null && stack.getFluid().canBePlacedInWorld() && stack.amount >= Fluid.BUCKET_VOLUME) {
 | 
				
			||||||
 | 
					                    BlockPos front = holder.pos().offset(holder.getDirection());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    Block block = stack.getFluid().getBlock();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (holder.world().isAirBlock(front) && block.canPlaceBlockAt(holder.world(), front)) {
 | 
				
			||||||
 | 
					                        FluidStack took = network.extractFluid(stack, Fluid.BUCKET_VOLUME, compare, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (took != null) {
 | 
				
			||||||
 | 
					                            IBlockState state = block.getDefaultState();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (state.getBlock() == Blocks.WATER) {
 | 
				
			||||||
 | 
					                                state = Blocks.FLOWING_WATER.getDefaultState();
 | 
				
			||||||
 | 
					                            } else if (state.getBlock() == Blocks.LAVA) {
 | 
				
			||||||
 | 
					                                state = Blocks.FLOWING_LAVA.getDefaultState();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            holder.world().setBlockState(front, state, 1 | 2);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void placeBlock() {
 | 
				
			||||||
 | 
					        BlockPos front = holder.pos().offset(holder.getDirection());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (holder.world().isAirBlock(front) && block.getBlock().canPlaceBlockAt(holder.world(), front)) {
 | 
				
			||||||
 | 
					            ItemStack took = network.extractItem(itemFilters.getStackInSlot(0), 1, compare, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (took != null) {
 | 
				
			||||||
 | 
					                @SuppressWarnings("deprecation")
 | 
				
			||||||
 | 
					                IBlockState state = block.getBlock().getStateFromMeta(took.getMetadata());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                BlockEvent.PlaceEvent e = new BlockEvent.PlaceEvent(new BlockSnapshot(holder.world(), front, state), holder.world().getBlockState(holder.pos()), FakePlayerFactory.getMinecraft((WorldServer) holder.world()), null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (MinecraftForge.EVENT_BUS.post(e)) {
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                network.extractItem(itemFilters.getStackInSlot(0), 1, compare, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                holder.world().setBlockState(front, state, 1 | 2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // From ItemBlock#onItemUse
 | 
				
			||||||
 | 
					                SoundType blockSound = block.getBlock().getSoundType(state, holder.world(), holder.pos(), null);
 | 
				
			||||||
 | 
					                holder.world().playSound(null, front, blockSound.getPlaceSound(), SoundCategory.BLOCKS, (blockSound.getVolume() + 1.0F) / 2.0F, blockSound.getPitch() * 0.8F);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (block.getBlock() == Blocks.SKULL) {
 | 
				
			||||||
 | 
					                    holder.world().setBlockState(front, holder.world().getBlockState(front).withProperty(BlockSkull.FACING, holder.getDirection()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    TileEntity tile = holder.world().getTileEntity(front);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (tile instanceof TileEntitySkull) {
 | 
				
			||||||
 | 
					                        TileEntitySkull skullTile = (TileEntitySkull) tile;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (item.getItemDamage() == 3) {
 | 
				
			||||||
 | 
					                            GameProfile playerInfo = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (item.hasTagCompound()) {
 | 
				
			||||||
 | 
					                                NBTTagCompound tag = item.getTagCompound();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                if (tag.hasKey("SkullOwner", 10)) {
 | 
				
			||||||
 | 
					                                    playerInfo = NBTUtil.readGameProfileFromNBT(tag.getCompoundTag("SkullOwner"));
 | 
				
			||||||
 | 
					                                } else if (tag.hasKey("SkullOwner", 8) && !tag.getString("SkullOwner").isEmpty()) {
 | 
				
			||||||
 | 
					                                    playerInfo = new GameProfile(null, tag.getString("SkullOwner"));
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            skullTile.setPlayerProfile(playerInfo);
 | 
				
			||||||
 | 
					                        } else {
 | 
				
			||||||
 | 
					                            skullTile.setType(item.getMetadata());
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        Blocks.SKULL.checkWitherSpawn(holder.world(), front, skullTile);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } else if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
 | 
				
			||||||
 | 
					                ItemStack craft = itemFilters.getStackInSlot(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                network.scheduleCraftingTask(craft, 1, compare);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void dropItem() {
 | 
				
			||||||
 | 
					        ItemStack took = network.extractItem(item, 1, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (took != null) {
 | 
				
			||||||
 | 
					            BehaviorDefaultDispenseItem.doDispense(holder.world(), took, 6, holder.getDirection(), new PositionImpl(getDispensePositionX(), getDispensePositionY(), getDispensePositionZ()));
 | 
				
			||||||
 | 
					        } else if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
 | 
				
			||||||
 | 
					            ItemStack craft = itemFilters.getStackInSlot(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            network.scheduleCraftingTask(craft, 1, compare);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // From BlockDispenser#getDispensePosition
 | 
				
			||||||
 | 
					    private double getDispensePositionX() {
 | 
				
			||||||
 | 
					        return (double) holder.pos().getX() + 0.5D + 0.8D * (double) holder.getDirection().getFrontOffsetX();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // From BlockDispenser#getDispensePosition
 | 
				
			||||||
 | 
					    private double getDispensePositionY() {
 | 
				
			||||||
 | 
					        return (double) holder.pos().getY() + (holder.getDirection() == EnumFacing.DOWN ? 0.45D : 0.5D) + 0.8D * (double) holder.getDirection().getFrontOffsetY();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // From BlockDispenser#getDispensePosition
 | 
				
			||||||
 | 
					    private double getDispensePositionZ() {
 | 
				
			||||||
 | 
					        return (double) holder.pos().getZ() + 0.5D + 0.8D * (double) holder.getDirection().getFrontOffsetZ();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getCompare() {
 | 
				
			||||||
 | 
					        return compare;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setCompare(int compare) {
 | 
				
			||||||
 | 
					        this.compare = compare;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void read(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.read(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(upgrades, 1, tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.write(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(upgrades, 1, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.writeConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_COMPARE, compare);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_TYPE, type);
 | 
				
			||||||
 | 
					        tag.setBoolean(NBT_DROP, drop);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(itemFilters, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(fluidFilters, 2, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void readConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.readConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_COMPARE)) {
 | 
				
			||||||
 | 
					            compare = tag.getInteger(NBT_COMPARE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_TYPE)) {
 | 
				
			||||||
 | 
					            type = tag.getInteger(NBT_TYPE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_DROP)) {
 | 
				
			||||||
 | 
					            drop = tag.getBoolean(NBT_DROP);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(itemFilters, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(fluidFilters, 2, tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean isDrop() {
 | 
				
			||||||
 | 
					        return drop;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setDrop(boolean drop) {
 | 
				
			||||||
 | 
					        this.drop = drop;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getUpgrades() {
 | 
				
			||||||
 | 
					        return upgrades;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getDrops() {
 | 
				
			||||||
 | 
					        return upgrades;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean hasConnectivityState() {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getType() {
 | 
				
			||||||
 | 
					        return holder.world().isRemote ? TileConstructor.TYPE.getValue() : type;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setType(int type) {
 | 
				
			||||||
 | 
					        this.type = type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getFilterInventory() {
 | 
				
			||||||
 | 
					        return getType() == IType.ITEMS ? itemFilters : fluidFilters;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,206 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					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.network.INetworkMaster;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.util.IComparer;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerChangeListenerNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraft.tileentity.TileEntity;
 | 
				
			||||||
 | 
					import net.minecraft.util.math.BlockPos;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.IItemHandler;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.wrapper.CombinedInvWrapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternContainer {
 | 
				
			||||||
 | 
					    private static final String NBT_TRIGGERED_AUTOCRAFTING = "TriggeredAutocrafting";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic patterns = new ItemHandlerBasic(9, new ItemHandlerChangeListenerNode(this), s -> {
 | 
				
			||||||
 | 
					        // We can only validate the crafting pattern if the world exists.
 | 
				
			||||||
 | 
					        // If the world doesn't exist, this is probably called while reading and in that case it doesn't matter.
 | 
				
			||||||
 | 
					        if (holder.world() != null) {
 | 
				
			||||||
 | 
					            return s.getItem() instanceof ICraftingPatternProvider && ((ICraftingPatternProvider) s.getItem()).create(holder.world(), s, this).isValid();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }) {
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        protected void onContentsChanged(int slot) {
 | 
				
			||||||
 | 
					            super.onContentsChanged(slot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (network != null && !holder.world().isRemote) {
 | 
				
			||||||
 | 
					                rebuildPatterns();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (network != null) {
 | 
				
			||||||
 | 
					                network.rebuildPatterns();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private List<ICraftingPattern> actualPatterns = new ArrayList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerChangeListenerNode(this), ItemUpgrade.TYPE_SPEED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private boolean triggeredAutocrafting = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeCrafter(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void rebuildPatterns() {
 | 
				
			||||||
 | 
					        actualPatterns.clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i = 0; i < patterns.getSlots(); ++i) {
 | 
				
			||||||
 | 
					            ItemStack patternStack = patterns.getStackInSlot(i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!patternStack.isEmpty()) {
 | 
				
			||||||
 | 
					                ICraftingPattern pattern = ((ICraftingPatternProvider) patternStack.getItem()).create(holder.world(), patternStack, this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (pattern.isValid()) {
 | 
				
			||||||
 | 
					                    actualPatterns.add(pattern);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        int usage = RS.INSTANCE.config.crafterUsage + upgrades.getEnergyUsage();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i = 0; i < patterns.getSlots(); ++i) {
 | 
				
			||||||
 | 
					            if (!patterns.getStackInSlot(i).isEmpty()) {
 | 
				
			||||||
 | 
					                usage += RS.INSTANCE.config.crafterPerPatternUsage;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return usage;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void update() {
 | 
				
			||||||
 | 
					        super.update();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (ticks == 1) {
 | 
				
			||||||
 | 
					            rebuildPatterns();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (network != null && triggeredAutocrafting && holder.world().isBlockPowered(holder.pos())) {
 | 
				
			||||||
 | 
					            for (ICraftingPattern pattern : actualPatterns) {
 | 
				
			||||||
 | 
					                for (ItemStack output : pattern.getOutputs()) {
 | 
				
			||||||
 | 
					                    network.scheduleCraftingTask(output, 1, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onConnectedStateChange(INetworkMaster network, boolean state) {
 | 
				
			||||||
 | 
					        super.onConnectedStateChange(network, state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!state) {
 | 
				
			||||||
 | 
					            network.getCraftingTasks().stream()
 | 
				
			||||||
 | 
					                    .filter(task -> task.getPattern().getContainer().getPosition().equals(holder.pos()))
 | 
				
			||||||
 | 
					                    .forEach(network::cancelCraftingTask);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        network.rebuildPatterns();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void read(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.read(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(patterns, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(upgrades, 1, tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.write(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(patterns, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(upgrades, 1, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.writeConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setBoolean(NBT_TRIGGERED_AUTOCRAFTING, triggeredAutocrafting);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void readConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.readConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_TRIGGERED_AUTOCRAFTING)) {
 | 
				
			||||||
 | 
					            triggeredAutocrafting = tag.getBoolean(NBT_TRIGGERED_AUTOCRAFTING);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getSpeedUpdateCount() {
 | 
				
			||||||
 | 
					        return upgrades.getUpgradeCount(ItemUpgrade.TYPE_SPEED);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getFacingInventory() {
 | 
				
			||||||
 | 
					        return RSUtils.getItemHandler(getFacingTile(), holder.getDirection().getOpposite());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileEntity getFacingTile() {
 | 
				
			||||||
 | 
					        return holder.world().getTileEntity(holder.pos().offset(holder.getDirection()));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<ICraftingPattern> getPatterns() {
 | 
				
			||||||
 | 
					        return actualPatterns;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public BlockPos getPosition() {
 | 
				
			||||||
 | 
					        return holder.pos();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getPatternItems() {
 | 
				
			||||||
 | 
					        return patterns;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getUpgrades() {
 | 
				
			||||||
 | 
					        return upgrades;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean isTriggeredAutocrafting() {
 | 
				
			||||||
 | 
					        return triggeredAutocrafting;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setTriggeredAutocrafting(boolean triggeredAutocrafting) {
 | 
				
			||||||
 | 
					        this.triggeredAutocrafting = triggeredAutocrafting;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getDrops() {
 | 
				
			||||||
 | 
					        return new CombinedInvWrapper(patterns, upgrades);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean hasConnectivityState() {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,62 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.craftingmonitor.ICraftingMonitor;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.craftingmonitor.TileCraftingMonitor;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
 | 
				
			||||||
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
 | 
					import net.minecraft.entity.player.EntityPlayerMP;
 | 
				
			||||||
 | 
					import net.minecraft.util.math.BlockPos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeCraftingMonitor extends NetworkNode implements ICraftingMonitor {
 | 
				
			||||||
 | 
					    public NetworkNodeCraftingMonitor(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        return RS.INSTANCE.config.craftingMonitorUsage;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean hasConnectivityState() {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getGuiTitle() {
 | 
				
			||||||
 | 
					        return "gui.refinedstorage:crafting_monitor";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onCancelled(EntityPlayerMP player, int id) {
 | 
				
			||||||
 | 
					        if (network != null) {
 | 
				
			||||||
 | 
					            network.getItemGridHandler().onCraftingCancelRequested(player, id);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Integer> getRedstoneModeParameter() {
 | 
				
			||||||
 | 
					        return TileCraftingMonitor.REDSTONE_MODE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nullable
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public BlockPos getNetworkPosition() {
 | 
				
			||||||
 | 
					        return network != null ? network.getPosition() : null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean isActive() {
 | 
				
			||||||
 | 
					        return ((TileCraftingMonitor) holder.world().getTileEntity(holder.pos())).isActive();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void onOpened(EntityPlayer player) {
 | 
				
			||||||
 | 
					        if (network != null) {
 | 
				
			||||||
 | 
					            network.sendCraftingMonitorUpdate((EntityPlayerMP) player);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,279 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.util.IComparer;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerChangeListenerNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.TileDestructor;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IComparable;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IType;
 | 
				
			||||||
 | 
					import net.minecraft.block.Block;
 | 
				
			||||||
 | 
					import net.minecraft.block.BlockLiquid;
 | 
				
			||||||
 | 
					import net.minecraft.block.state.IBlockState;
 | 
				
			||||||
 | 
					import net.minecraft.entity.Entity;
 | 
				
			||||||
 | 
					import net.minecraft.entity.item.EntityItem;
 | 
				
			||||||
 | 
					import net.minecraft.inventory.InventoryHelper;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraft.util.math.AxisAlignedBB;
 | 
				
			||||||
 | 
					import net.minecraft.util.math.BlockPos;
 | 
				
			||||||
 | 
					import net.minecraft.world.WorldServer;
 | 
				
			||||||
 | 
					import net.minecraft.world.chunk.Chunk;
 | 
				
			||||||
 | 
					import net.minecraftforge.common.MinecraftForge;
 | 
				
			||||||
 | 
					import net.minecraftforge.common.util.FakePlayerFactory;
 | 
				
			||||||
 | 
					import net.minecraftforge.event.world.BlockEvent;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.Fluid;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.FluidStack;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.IFluidBlock;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.capability.IFluidHandler;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.capability.wrappers.BlockLiquidWrapper;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.capability.wrappers.FluidBlockWrapper;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.IItemHandler;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.Collections;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeDestructor extends NetworkNode implements IComparable, IFilterable, IType {
 | 
				
			||||||
 | 
					    private static final String NBT_COMPARE = "Compare";
 | 
				
			||||||
 | 
					    private static final String NBT_MODE = "Mode";
 | 
				
			||||||
 | 
					    private static final String NBT_TYPE = "Type";
 | 
				
			||||||
 | 
					    private static final String NBT_PICKUP = "Pickup";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static final int BASE_SPEED = 20;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic itemFilters = new ItemHandlerBasic(9, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					    private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerChangeListenerNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_SILK_TOUCH, ItemUpgrade.TYPE_FORTUNE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
 | 
				
			||||||
 | 
					    private int mode = IFilterable.WHITELIST;
 | 
				
			||||||
 | 
					    private int type = IType.ITEMS;
 | 
				
			||||||
 | 
					    private boolean pickupItem = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeDestructor(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        return RS.INSTANCE.config.destructorUsage + upgrades.getEnergyUsage();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void update() {
 | 
				
			||||||
 | 
					        if (network != null && ticks % upgrades.getSpeed(BASE_SPEED, 4) == 0) {
 | 
				
			||||||
 | 
					            BlockPos front = holder.pos().offset(holder.getDirection());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (pickupItem && type == IType.ITEMS) {
 | 
				
			||||||
 | 
					                List<Entity> droppedItems = new ArrayList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                Chunk chunk = holder.world().getChunkFromBlockCoords(front);
 | 
				
			||||||
 | 
					                chunk.getEntitiesWithinAABBForEntity(null, new AxisAlignedBB(front), droppedItems, null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                for (Entity entity : droppedItems) {
 | 
				
			||||||
 | 
					                    if (entity instanceof EntityItem) {
 | 
				
			||||||
 | 
					                        ItemStack droppedItem = ((EntityItem) entity).getEntityItem();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (IFilterable.canTake(itemFilters, mode, compare, droppedItem) && network.insertItem(droppedItem, droppedItem.getCount(), true) == null) {
 | 
				
			||||||
 | 
					                            network.insertItem(droppedItem.copy(), droppedItem.getCount(), false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            holder.world().removeEntity(entity);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } else if (type == IType.ITEMS) {
 | 
				
			||||||
 | 
					                IBlockState frontBlockState = holder.world().getBlockState(front);
 | 
				
			||||||
 | 
					                Block frontBlock = frontBlockState.getBlock();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                @SuppressWarnings("deprecation")
 | 
				
			||||||
 | 
					                ItemStack frontStack = frontBlock.getItem(holder.world(), front, frontBlockState);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (!frontStack.isEmpty()) {
 | 
				
			||||||
 | 
					                    if (IFilterable.canTake(itemFilters, mode, compare, frontStack) && frontBlockState.getBlockHardness(holder.world(), front) != -1.0) {
 | 
				
			||||||
 | 
					                        List<ItemStack> drops;
 | 
				
			||||||
 | 
					                        if (upgrades.hasUpgrade(ItemUpgrade.TYPE_SILK_TOUCH) && frontBlock.canSilkHarvest(holder.world(), front, frontBlockState, null)) {
 | 
				
			||||||
 | 
					                            drops = Collections.singletonList(frontStack);
 | 
				
			||||||
 | 
					                        } else {
 | 
				
			||||||
 | 
					                            drops = frontBlock.getDrops(holder.world(), front, frontBlockState, upgrades.getFortuneLevel());
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        for (ItemStack drop : drops) {
 | 
				
			||||||
 | 
					                            if (network.insertItem(drop, drop.getCount(), true) != null) {
 | 
				
			||||||
 | 
					                                return;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        BlockEvent.BreakEvent e = new BlockEvent.BreakEvent(holder.world(), front, frontBlockState, FakePlayerFactory.getMinecraft((WorldServer) holder.world()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (!MinecraftForge.EVENT_BUS.post(e)) {
 | 
				
			||||||
 | 
					                            holder.world().playEvent(null, 2001, front, Block.getStateId(frontBlockState));
 | 
				
			||||||
 | 
					                            holder.world().setBlockToAir(front);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            for (ItemStack drop : drops) {
 | 
				
			||||||
 | 
					                                // We check if the controller isn't null here because when a destructor faces a node and removes it
 | 
				
			||||||
 | 
					                                // it will essentially remove this block itself from the network without knowing
 | 
				
			||||||
 | 
					                                if (network == null) {
 | 
				
			||||||
 | 
					                                    InventoryHelper.spawnItemStack(holder.world(), front.getX(), front.getY(), front.getZ(), drop);
 | 
				
			||||||
 | 
					                                } else {
 | 
				
			||||||
 | 
					                                    network.insertItem(drop, drop.getCount(), false);
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } else if (type == IType.FLUIDS) {
 | 
				
			||||||
 | 
					                Block frontBlock = holder.world().getBlockState(front).getBlock();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                IFluidHandler handler = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (frontBlock instanceof BlockLiquid) {
 | 
				
			||||||
 | 
					                    handler = new BlockLiquidWrapper((BlockLiquid) frontBlock, holder.world(), front);
 | 
				
			||||||
 | 
					                } else if (frontBlock instanceof IFluidBlock) {
 | 
				
			||||||
 | 
					                    handler = new FluidBlockWrapper((IFluidBlock) frontBlock, holder.world(), front);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (handler != null) {
 | 
				
			||||||
 | 
					                    FluidStack stack = handler.drain(Fluid.BUCKET_VOLUME, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (stack != null && IFilterable.canTakeFluids(fluidFilters, mode, compare, stack) && network.insertFluid(stack, stack.amount, true) == null) {
 | 
				
			||||||
 | 
					                        FluidStack drained = handler.drain(Fluid.BUCKET_VOLUME, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        network.insertFluid(drained, drained.amount, false);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getCompare() {
 | 
				
			||||||
 | 
					        return compare;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setCompare(int compare) {
 | 
				
			||||||
 | 
					        this.compare = compare;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getMode() {
 | 
				
			||||||
 | 
					        return mode;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setMode(int mode) {
 | 
				
			||||||
 | 
					        this.mode = mode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void read(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.read(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(upgrades, 1, tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.write(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(upgrades, 1, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.writeConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_COMPARE, compare);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_MODE, mode);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_TYPE, type);
 | 
				
			||||||
 | 
					        tag.setBoolean(NBT_PICKUP, pickupItem);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(itemFilters, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(fluidFilters, 2, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void readConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.readConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_COMPARE)) {
 | 
				
			||||||
 | 
					            compare = tag.getInteger(NBT_COMPARE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_MODE)) {
 | 
				
			||||||
 | 
					            mode = tag.getInteger(NBT_MODE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_TYPE)) {
 | 
				
			||||||
 | 
					            type = tag.getInteger(NBT_TYPE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_PICKUP)) {
 | 
				
			||||||
 | 
					            pickupItem = tag.getBoolean(NBT_PICKUP);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(itemFilters, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(fluidFilters, 2, tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getUpgrades() {
 | 
				
			||||||
 | 
					        return upgrades;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getInventory() {
 | 
				
			||||||
 | 
					        return itemFilters;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean hasConnectivityState() {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getDrops() {
 | 
				
			||||||
 | 
					        return upgrades;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getType() {
 | 
				
			||||||
 | 
					        return holder.world().isRemote ? TileDestructor.TYPE.getValue() : type;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setType(int type) {
 | 
				
			||||||
 | 
					        this.type = type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getFilterInventory() {
 | 
				
			||||||
 | 
					        return getType() == IType.ITEMS ? itemFilters : fluidFilters;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean isPickupItem() {
 | 
				
			||||||
 | 
					        return pickupItem;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setPickupItem(boolean pickupItem) {
 | 
				
			||||||
 | 
					        this.pickupItem = pickupItem;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,239 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
 | 
					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.apiimpl.API;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerChangeListenerNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.TileDetector;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IComparable;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IType;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.FluidStack;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.IItemHandler;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeDetector extends NetworkNode implements IComparable, IType {
 | 
				
			||||||
 | 
					    private static final int SPEED = 5;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static final int MODE_UNDER = 0;
 | 
				
			||||||
 | 
					    public static final int MODE_EQUAL = 1;
 | 
				
			||||||
 | 
					    public static final int MODE_ABOVE = 2;
 | 
				
			||||||
 | 
					    public static final int MODE_AUTOCRAFTING = 3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static final String NBT_COMPARE = "Compare";
 | 
				
			||||||
 | 
					    private static final String NBT_MODE = "Mode";
 | 
				
			||||||
 | 
					    private static final String NBT_AMOUNT = "Amount";
 | 
				
			||||||
 | 
					    private static final String NBT_TYPE = "Type";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic itemFilters = new ItemHandlerBasic(1, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					    private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(1, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
 | 
				
			||||||
 | 
					    private int type = IType.ITEMS;
 | 
				
			||||||
 | 
					    private int mode = MODE_EQUAL;
 | 
				
			||||||
 | 
					    private int amount = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private boolean powered = false;
 | 
				
			||||||
 | 
					    private boolean wasPowered;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeDetector(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        return RS.INSTANCE.config.detectorUsage;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void update() {
 | 
				
			||||||
 | 
					        if (powered != wasPowered) {
 | 
				
			||||||
 | 
					            wasPowered = powered;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            holder.world().notifyNeighborsOfStateChange(holder.pos(), RSBlocks.DETECTOR, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            RSUtils.updateBlock(holder.world(), holder.pos());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (network != null && ticks % SPEED == 0) {
 | 
				
			||||||
 | 
					            if (type == IType.ITEMS) {
 | 
				
			||||||
 | 
					                ItemStack slot = itemFilters.getStackInSlot(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (!slot.isEmpty()) {
 | 
				
			||||||
 | 
					                    if (mode == MODE_AUTOCRAFTING) {
 | 
				
			||||||
 | 
					                        boolean found = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        for (ICraftingTask task : network.getCraftingTasks()) {
 | 
				
			||||||
 | 
					                            for (ItemStack output : task.getPattern().getOutputs()) {
 | 
				
			||||||
 | 
					                                if (API.instance().getComparer().isEqualNoQuantity(slot, output)) {
 | 
				
			||||||
 | 
					                                    found = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    break;
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (found) {
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        powered = found;
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        ItemStack stack = network.getItemStorageCache().getList().get(slot, compare);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        powered = isPowered(stack == null ? null : stack.getCount());
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    powered = mode == MODE_AUTOCRAFTING ? !network.getCraftingTasks().isEmpty() : isPowered(network.getItemStorageCache().getList().getStacks().stream().map(s -> s.getCount()).mapToInt(Number::intValue).sum());
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } else if (type == IType.FLUIDS) {
 | 
				
			||||||
 | 
					                FluidStack slot = fluidFilters.getFluidStackInSlot(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (slot != null) {
 | 
				
			||||||
 | 
					                    FluidStack stack = network.getFluidStorageCache().getList().get(slot, compare);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    powered = isPowered(stack == null ? null : stack.amount);
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    powered = isPowered(network.getFluidStorageCache().getList().getStacks().stream().map(s -> s.amount).mapToInt(Number::intValue).sum());
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onConnectedStateChange(INetworkMaster network, boolean state) {
 | 
				
			||||||
 | 
					        super.onConnectedStateChange(network, state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!state) {
 | 
				
			||||||
 | 
					            powered = false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean isPowered() {
 | 
				
			||||||
 | 
					        return powered;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private boolean isPowered(Integer size) {
 | 
				
			||||||
 | 
					        if (size != null) {
 | 
				
			||||||
 | 
					            switch (mode) {
 | 
				
			||||||
 | 
					                case MODE_UNDER:
 | 
				
			||||||
 | 
					                    return size < amount;
 | 
				
			||||||
 | 
					                case MODE_EQUAL:
 | 
				
			||||||
 | 
					                    return size == amount;
 | 
				
			||||||
 | 
					                case MODE_ABOVE:
 | 
				
			||||||
 | 
					                    return size > amount;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            if (mode == MODE_UNDER && amount != 0) {
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            } else if (mode == MODE_EQUAL && amount == 0) {
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getCompare() {
 | 
				
			||||||
 | 
					        return compare;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setCompare(int compare) {
 | 
				
			||||||
 | 
					        this.compare = compare;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getMode() {
 | 
				
			||||||
 | 
					        return mode;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setMode(int mode) {
 | 
				
			||||||
 | 
					        this.mode = mode;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getAmount() {
 | 
				
			||||||
 | 
					        return amount;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setAmount(int amount) {
 | 
				
			||||||
 | 
					        this.amount = amount;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.writeConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_COMPARE, compare);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_MODE, mode);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_AMOUNT, amount);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_TYPE, type);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(itemFilters, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(fluidFilters, 1, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void readConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.readConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_COMPARE)) {
 | 
				
			||||||
 | 
					            compare = tag.getInteger(NBT_COMPARE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_MODE)) {
 | 
				
			||||||
 | 
					            mode = tag.getInteger(NBT_MODE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_AMOUNT)) {
 | 
				
			||||||
 | 
					            amount = tag.getInteger(NBT_AMOUNT);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_TYPE)) {
 | 
				
			||||||
 | 
					            type = tag.getInteger(NBT_TYPE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(itemFilters, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(fluidFilters, 1, tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getInventory() {
 | 
				
			||||||
 | 
					        return itemFilters;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setRedstoneMode(RedstoneMode mode) {
 | 
				
			||||||
 | 
					        // NO OP
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getType() {
 | 
				
			||||||
 | 
					        return holder.world().isRemote ? TileDetector.TYPE.getValue() : type;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setType(int type) {
 | 
				
			||||||
 | 
					        this.type = type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getFilterInventory() {
 | 
				
			||||||
 | 
					        return getType() == IType.ITEMS ? itemFilters : fluidFilters;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,492 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					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.IStorage;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.util.IComparer;
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerChangeListenerNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.IStorageGui;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.TileDiskDrive;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.*;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.FluidStack;
 | 
				
			||||||
 | 
					import net.minecraftforge.fml.common.FMLCommonHandler;
 | 
				
			||||||
 | 
					import net.minecraftforge.fml.relauncher.Side;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.IItemHandler;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.ItemHandlerHelper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nonnull;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeDiskDrive extends NetworkNode implements IStorageGui, IStorageProvider, IComparable, IFilterable, IPrioritizable, IType, IExcessVoidable, IAccessType {
 | 
				
			||||||
 | 
					    public class StorageItem extends StorageItemNBT {
 | 
				
			||||||
 | 
					        private int lastState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public StorageItem(ItemStack disk) {
 | 
				
			||||||
 | 
					            super(disk.getTagCompound(), EnumItemStorageType.getById(disk.getItemDamage()).getCapacity(), NetworkNodeDiskDrive.this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            lastState = TileDiskDrive.getDiskState(getStored(), getCapacity());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public int getPriority() {
 | 
				
			||||||
 | 
					            return priority;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public ItemStack insert(@Nonnull ItemStack stack, int size, boolean simulate) {
 | 
				
			||||||
 | 
					            if (!IFilterable.canTake(itemFilters, mode, getCompare(), stack)) {
 | 
				
			||||||
 | 
					                return ItemHandlerHelper.copyStackWithSize(stack, size);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return super.insert(stack, size, simulate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public AccessType getAccessType() {
 | 
				
			||||||
 | 
					            return accessType;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public boolean isVoiding() {
 | 
				
			||||||
 | 
					            return voidExcess;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public void onStorageChanged() {
 | 
				
			||||||
 | 
					            super.onStorageChanged();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int currentState = TileDiskDrive.getDiskState(getStored(), getCapacity());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (lastState != currentState) {
 | 
				
			||||||
 | 
					                lastState = currentState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                RSUtils.updateBlock(holder.world(), holder.pos());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public class StorageFluid extends StorageFluidNBT {
 | 
				
			||||||
 | 
					        private int lastState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public StorageFluid(ItemStack disk) {
 | 
				
			||||||
 | 
					            super(disk.getTagCompound(), EnumFluidStorageType.getById(disk.getItemDamage()).getCapacity(), NetworkNodeDiskDrive.this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            lastState = TileDiskDrive.getDiskState(getStored(), getCapacity());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public int getPriority() {
 | 
				
			||||||
 | 
					            return priority;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public FluidStack insert(FluidStack stack, int size, boolean simulate) {
 | 
				
			||||||
 | 
					            if (!IFilterable.canTakeFluids(fluidFilters, mode, getCompare(), stack)) {
 | 
				
			||||||
 | 
					                return RSUtils.copyStackWithSize(stack, size);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return super.insert(stack, size, simulate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public AccessType getAccessType() {
 | 
				
			||||||
 | 
					            return accessType;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public boolean isVoiding() {
 | 
				
			||||||
 | 
					            return voidExcess;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public void onStorageChanged() {
 | 
				
			||||||
 | 
					            super.onStorageChanged();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int currentState = TileDiskDrive.getDiskState(getStored(), getCapacity());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (lastState != currentState) {
 | 
				
			||||||
 | 
					                lastState = currentState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                RSUtils.updateBlock(holder.world(), holder.pos());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static final String NBT_PRIORITY = "Priority";
 | 
				
			||||||
 | 
					    private static final String NBT_COMPARE = "Compare";
 | 
				
			||||||
 | 
					    private static final String NBT_MODE = "Mode";
 | 
				
			||||||
 | 
					    private static final String NBT_TYPE = "Type";
 | 
				
			||||||
 | 
					    private static final String NBT_VOID_EXCESS = "VoidExcess";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic disks = new ItemHandlerBasic(8, new ItemHandlerChangeListenerNode(this), IItemValidator.STORAGE_DISK) {
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        protected void onContentsChanged(int slot) {
 | 
				
			||||||
 | 
					            super.onContentsChanged(slot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
 | 
				
			||||||
 | 
					                RSUtils.createStorages(getStackInSlot(slot), slot, itemStorages, fluidStorages, s -> new StorageItem(s), s -> new StorageFluid(s));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (network != null) {
 | 
				
			||||||
 | 
					                    network.getItemStorageCache().invalidate();
 | 
				
			||||||
 | 
					                    network.getFluidStorageCache().invalidate();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                RSUtils.updateBlock(holder.world(), holder.pos());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public ItemStack extractItem(int slot, int amount, boolean simulate) {
 | 
				
			||||||
 | 
					            if (itemStorages[slot] != null) {
 | 
				
			||||||
 | 
					                itemStorages[slot].writeToNBT();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (fluidStorages[slot] != null) {
 | 
				
			||||||
 | 
					                fluidStorages[slot].writeToNBT();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return super.extractItem(slot, amount, simulate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic itemFilters = new ItemHandlerBasic(9, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					    private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private StorageItem itemStorages[] = new StorageItem[8];
 | 
				
			||||||
 | 
					    private StorageFluid fluidStorages[] = new StorageFluid[8];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private AccessType accessType = AccessType.INSERT_EXTRACT;
 | 
				
			||||||
 | 
					    private int priority = 0;
 | 
				
			||||||
 | 
					    private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
 | 
				
			||||||
 | 
					    private int mode = IFilterable.WHITELIST;
 | 
				
			||||||
 | 
					    private int type = IType.ITEMS;
 | 
				
			||||||
 | 
					    private boolean voidExcess = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeDiskDrive(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public StorageItem[] getItemStorages() {
 | 
				
			||||||
 | 
					        return itemStorages;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public StorageFluid[] getFluidStorages() {
 | 
				
			||||||
 | 
					        return fluidStorages;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        int usage = RS.INSTANCE.config.diskDriveUsage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i = 0; i < disks.getSlots(); ++i) {
 | 
				
			||||||
 | 
					            if (!disks.getStackInSlot(i).isEmpty()) {
 | 
				
			||||||
 | 
					                usage += RS.INSTANCE.config.diskDrivePerDiskUsage;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return usage;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void onBreak() {
 | 
				
			||||||
 | 
					        for (StorageItem storage : this.itemStorages) {
 | 
				
			||||||
 | 
					            if (storage != null) {
 | 
				
			||||||
 | 
					                storage.writeToNBT();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (StorageFluid storage : this.fluidStorages) {
 | 
				
			||||||
 | 
					            if (storage != null) {
 | 
				
			||||||
 | 
					                storage.writeToNBT();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onConnectedStateChange(INetworkMaster network, boolean state) {
 | 
				
			||||||
 | 
					        super.onConnectedStateChange(network, state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        network.getItemStorageCache().invalidate();
 | 
				
			||||||
 | 
					        network.getFluidStorageCache().invalidate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.updateBlock(holder.world(), holder.pos());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void addItemStorages(List<IStorage<ItemStack>> storages) {
 | 
				
			||||||
 | 
					        for (IStorage<ItemStack> storage : this.itemStorages) {
 | 
				
			||||||
 | 
					            if (storage != null) {
 | 
				
			||||||
 | 
					                storages.add(storage);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void addFluidStorages(List<IStorage<FluidStack>> storages) {
 | 
				
			||||||
 | 
					        for (IStorage<FluidStack> storage : this.fluidStorages) {
 | 
				
			||||||
 | 
					            if (storage != null) {
 | 
				
			||||||
 | 
					                storages.add(storage);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void read(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.read(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(disks, 0, tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.write(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i = 0; i < disks.getSlots(); ++i) {
 | 
				
			||||||
 | 
					            if (itemStorages[i] != null) {
 | 
				
			||||||
 | 
					                itemStorages[i].writeToNBT();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (fluidStorages[i] != null) {
 | 
				
			||||||
 | 
					                fluidStorages[i].writeToNBT();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(disks, 0, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.writeConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(itemFilters, 1, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(fluidFilters, 2, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_PRIORITY, priority);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_COMPARE, compare);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_MODE, mode);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_TYPE, type);
 | 
				
			||||||
 | 
					        tag.setBoolean(NBT_VOID_EXCESS, voidExcess);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeAccessType(tag, accessType);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void readConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.readConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(itemFilters, 1, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(fluidFilters, 2, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_PRIORITY)) {
 | 
				
			||||||
 | 
					            priority = tag.getInteger(NBT_PRIORITY);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_COMPARE)) {
 | 
				
			||||||
 | 
					            compare = tag.getInteger(NBT_COMPARE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_MODE)) {
 | 
				
			||||||
 | 
					            mode = tag.getInteger(NBT_MODE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_TYPE)) {
 | 
				
			||||||
 | 
					            type = tag.getInteger(NBT_TYPE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_VOID_EXCESS)) {
 | 
				
			||||||
 | 
					            voidExcess = tag.getBoolean(NBT_VOID_EXCESS);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        accessType = RSUtils.readAccessType(tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getCompare() {
 | 
				
			||||||
 | 
					        return compare;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setCompare(int compare) {
 | 
				
			||||||
 | 
					        this.compare = compare;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getMode() {
 | 
				
			||||||
 | 
					        return mode;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setMode(int mode) {
 | 
				
			||||||
 | 
					        this.mode = mode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getGuiTitle() {
 | 
				
			||||||
 | 
					        return "block.refinedstorage:disk_drive.name";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Integer> getTypeParameter() {
 | 
				
			||||||
 | 
					        return TileDiskDrive.TYPE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Integer> getRedstoneModeParameter() {
 | 
				
			||||||
 | 
					        return TileDiskDrive.REDSTONE_MODE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Integer> getCompareParameter() {
 | 
				
			||||||
 | 
					        return TileDiskDrive.COMPARE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Integer> getFilterParameter() {
 | 
				
			||||||
 | 
					        return TileDiskDrive.MODE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Integer> getPriorityParameter() {
 | 
				
			||||||
 | 
					        return TileDiskDrive.PRIORITY;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Boolean> getVoidExcessParameter() {
 | 
				
			||||||
 | 
					        return TileDiskDrive.VOID_EXCESS;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<AccessType> getAccessTypeParameter() {
 | 
				
			||||||
 | 
					        return TileDiskDrive.ACCESS_TYPE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getVoidExcessType() {
 | 
				
			||||||
 | 
					        return "items_fluids";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getStored() {
 | 
				
			||||||
 | 
					        int stored = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i = 0; i < disks.getSlots(); ++i) {
 | 
				
			||||||
 | 
					            ItemStack disk = disks.getStackInSlot(i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!disk.isEmpty()) {
 | 
				
			||||||
 | 
					                stored += disk.getItem() == RSItems.STORAGE_DISK ? StorageItemNBT.getStoredFromNBT(disk.getTagCompound()) : StorageFluidNBT.getStoredFromNBT(disk.getTagCompound());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return stored;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getCapacity() {
 | 
				
			||||||
 | 
					        int capacity = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i = 0; i < disks.getSlots(); ++i) {
 | 
				
			||||||
 | 
					            ItemStack disk = disks.getStackInSlot(i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!disk.isEmpty()) {
 | 
				
			||||||
 | 
					                int diskCapacity = disk.getItem() == RSItems.STORAGE_DISK ? EnumItemStorageType.getById(disk.getItemDamage()).getCapacity() : EnumFluidStorageType.getById(disk.getItemDamage()).getCapacity();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (diskCapacity == -1) {
 | 
				
			||||||
 | 
					                    return -1;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                capacity += diskCapacity;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return capacity;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public AccessType getAccessType() {
 | 
				
			||||||
 | 
					        return accessType;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setAccessType(AccessType value) {
 | 
				
			||||||
 | 
					        this.accessType = value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (network != null) {
 | 
				
			||||||
 | 
					            network.getFluidStorageCache().invalidate();
 | 
				
			||||||
 | 
					            network.getItemStorageCache().invalidate();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getPriority() {
 | 
				
			||||||
 | 
					        return priority;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setPriority(int priority) {
 | 
				
			||||||
 | 
					        this.priority = priority;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getDisks() {
 | 
				
			||||||
 | 
					        return disks;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean getVoidExcess() {
 | 
				
			||||||
 | 
					        return voidExcess;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setVoidExcess(boolean voidExcess) {
 | 
				
			||||||
 | 
					        this.voidExcess = voidExcess;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getType() {
 | 
				
			||||||
 | 
					        return holder.world().isRemote ? TileDiskDrive.TYPE.getValue() : type;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setType(int type) {
 | 
				
			||||||
 | 
					        this.type = type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getFilterInventory() {
 | 
				
			||||||
 | 
					        return getType() == IType.ITEMS ? itemFilters : fluidFilters;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getDrops() {
 | 
				
			||||||
 | 
					        return disks;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,580 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.util.IComparer;
 | 
				
			||||||
 | 
					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.*;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.TileDiskDrive;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IComparable;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IType;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.FluidStack;
 | 
				
			||||||
 | 
					import net.minecraftforge.fml.common.FMLCommonHandler;
 | 
				
			||||||
 | 
					import net.minecraftforge.fml.relauncher.Side;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.IItemHandler;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.ItemHandlerHelper;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.wrapper.CombinedInvWrapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nonnull;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeDiskManipulator extends NetworkNode implements IComparable, IFilterable, IType {
 | 
				
			||||||
 | 
					    public static final int IO_MODE_INSERT = 0;
 | 
				
			||||||
 | 
					    public static final int IO_MODE_EXTRACT = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static final String NBT_COMPARE = "Compare";
 | 
				
			||||||
 | 
					    private static final String NBT_MODE = "Mode";
 | 
				
			||||||
 | 
					    private static final String NBT_TYPE = "Type";
 | 
				
			||||||
 | 
					    private static final String NBT_IO_MODE = "IOMode";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
 | 
				
			||||||
 | 
					    private int mode = IFilterable.WHITELIST;
 | 
				
			||||||
 | 
					    private int type = IType.ITEMS;
 | 
				
			||||||
 | 
					    private int ioMode = IO_MODE_INSERT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private StorageItem[] itemStorages = new StorageItem[6];
 | 
				
			||||||
 | 
					    private StorageFluid[] fluidStorages = new StorageFluid[6];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerChangeListenerNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_STACK);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic inputDisks = new ItemHandlerBasic(3, new ItemHandlerChangeListenerNode(this), IItemValidator.STORAGE_DISK) {
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        protected void onContentsChanged(int slot) {
 | 
				
			||||||
 | 
					            super.onContentsChanged(slot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
 | 
				
			||||||
 | 
					                RSUtils.createStorages(getStackInSlot(slot), slot, itemStorages, fluidStorages, s -> new StorageItem(s), s -> new StorageFluid(s));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                RSUtils.updateBlock(holder.world(), holder.pos());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        @Nonnull
 | 
				
			||||||
 | 
					        public ItemStack extractItem(int slot, int amount, boolean simulate) {
 | 
				
			||||||
 | 
					            if (itemStorages[slot] != null) {
 | 
				
			||||||
 | 
					                itemStorages[slot].writeToNBT();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (fluidStorages[slot] != null) {
 | 
				
			||||||
 | 
					                fluidStorages[slot].writeToNBT();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return super.extractItem(slot, amount, simulate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic outputDisks = new ItemHandlerBasic(3, new ItemHandlerChangeListenerNode(this), IItemValidator.STORAGE_DISK) {
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        protected void onContentsChanged(int slot) {
 | 
				
			||||||
 | 
					            super.onContentsChanged(slot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
 | 
				
			||||||
 | 
					                RSUtils.createStorages(getStackInSlot(slot), 3 + slot, itemStorages, fluidStorages, s -> new StorageItem(s), s -> new StorageFluid(s));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                RSUtils.updateBlock(holder.world(), holder.pos());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeDiskManipulator(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public class StorageItem extends StorageItemNBT {
 | 
				
			||||||
 | 
					        private int lastState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public StorageItem(ItemStack disk) {
 | 
				
			||||||
 | 
					            super(disk.getTagCompound(), EnumItemStorageType.getById(disk.getItemDamage()).getCapacity(), NetworkNodeDiskManipulator.this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            lastState = TileDiskDrive.getDiskState(getStored(), getCapacity());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public int getPriority() {
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public boolean isVoiding() {
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public ItemStack insert(@Nonnull ItemStack stack, int size, boolean simulate) {
 | 
				
			||||||
 | 
					            if (!IFilterable.canTake(itemFilters, mode, getCompare(), stack)) {
 | 
				
			||||||
 | 
					                return ItemHandlerHelper.copyStackWithSize(stack, size);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return super.insert(stack, size, simulate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public ItemStack extract(@Nonnull ItemStack stack, int size, int flags, boolean simulate) {
 | 
				
			||||||
 | 
					            if (!IFilterable.canTake(itemFilters, mode, getCompare(), stack)) {
 | 
				
			||||||
 | 
					                return null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return super.extract(stack, size, flags, simulate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public void onStorageChanged() {
 | 
				
			||||||
 | 
					            super.onStorageChanged();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int currentState = TileDiskDrive.getDiskState(getStored(), getCapacity());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (lastState != currentState) {
 | 
				
			||||||
 | 
					                lastState = currentState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                RSUtils.updateBlock(holder.world(), holder.pos());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public class StorageFluid extends StorageFluidNBT {
 | 
				
			||||||
 | 
					        private int lastState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public StorageFluid(ItemStack disk) {
 | 
				
			||||||
 | 
					            super(disk.getTagCompound(), EnumFluidStorageType.getById(disk.getItemDamage()).getCapacity(), NetworkNodeDiskManipulator.this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            lastState = TileDiskDrive.getDiskState(getStored(), getCapacity());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public int getPriority() {
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public boolean isVoiding() {
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public FluidStack insert(FluidStack stack, int size, boolean simulate) {
 | 
				
			||||||
 | 
					            if (!IFilterable.canTakeFluids(fluidFilters, mode, getCompare(), stack)) {
 | 
				
			||||||
 | 
					                return RSUtils.copyStackWithSize(stack, size);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return super.insert(stack, size, simulate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public FluidStack extract(FluidStack stack, int size, int flags, boolean simulate) {
 | 
				
			||||||
 | 
					            if (!IFilterable.canTakeFluids(fluidFilters, mode, getCompare(), stack)) {
 | 
				
			||||||
 | 
					                return null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return super.extract(stack, size, flags, simulate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public void onStorageChanged() {
 | 
				
			||||||
 | 
					            super.onStorageChanged();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int currentState = TileDiskDrive.getDiskState(getStored(), getCapacity());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (lastState != currentState) {
 | 
				
			||||||
 | 
					                lastState = currentState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                RSUtils.updateBlock(holder.world(), holder.pos());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic itemFilters = new ItemHandlerBasic(9, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					    private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        return RS.INSTANCE.config.diskManipulatorUsage + upgrades.getEnergyUsage();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean hasConnectivityState() {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void update() {
 | 
				
			||||||
 | 
					        if (network == null || ticks % upgrades.getSpeed() != 0) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        int slot = 0;
 | 
				
			||||||
 | 
					        if (type == IType.ITEMS) {
 | 
				
			||||||
 | 
					            while (slot < 3 && itemStorages[slot] == null) {
 | 
				
			||||||
 | 
					                slot++;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (slot == 3) {
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            StorageItem storage = itemStorages[slot];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (ioMode == IO_MODE_INSERT) {
 | 
				
			||||||
 | 
					                insertIntoNetwork(storage, slot);
 | 
				
			||||||
 | 
					            } else if (ioMode == IO_MODE_EXTRACT) {
 | 
				
			||||||
 | 
					                extractFromNetwork(storage, slot);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else if (type == IType.FLUIDS) {
 | 
				
			||||||
 | 
					            while (slot < 3 && fluidStorages[slot] == null) {
 | 
				
			||||||
 | 
					                slot++;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (slot == 3) {
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            StorageFluid storage = fluidStorages[slot];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (ioMode == IO_MODE_INSERT) {
 | 
				
			||||||
 | 
					                insertIntoNetwork(storage, slot);
 | 
				
			||||||
 | 
					            } else if (ioMode == IO_MODE_EXTRACT) {
 | 
				
			||||||
 | 
					                extractFromNetwork(storage, slot);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void insertIntoNetwork(StorageItem storage, int slot) {
 | 
				
			||||||
 | 
					        if (storage.getStored() == 0) {
 | 
				
			||||||
 | 
					            moveDriveToOutput(slot);
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i = 0; i < storage.getStacks().size(); i++) {
 | 
				
			||||||
 | 
					            ItemStack stack = storage.getStacks().get(i);
 | 
				
			||||||
 | 
					            if (stack == null) {
 | 
				
			||||||
 | 
					                continue;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ItemStack extracted = storage.extract(stack, upgrades.getItemInteractCount(), compare, false);
 | 
				
			||||||
 | 
					            if (extracted == null) {
 | 
				
			||||||
 | 
					                continue;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ItemStack remainder = network.insertItem(extracted, extracted.getCount(), false);
 | 
				
			||||||
 | 
					            if (remainder == null) {
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // We need to check if the stack was inserted
 | 
				
			||||||
 | 
					            storage.insert(((extracted == remainder) ? remainder.copy() : remainder), remainder.getCount(), false);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (storage.getStacks().size() == 0) {
 | 
				
			||||||
 | 
					            moveDriveToOutput(slot);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void extractFromNetwork(StorageItem storage, int slot) {
 | 
				
			||||||
 | 
					        if (storage.getStored() == storage.getCapacity()) {
 | 
				
			||||||
 | 
					            moveDriveToOutput(slot);
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ItemStack extracted = null;
 | 
				
			||||||
 | 
					        int i = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (IFilterable.isEmpty(itemFilters)) {
 | 
				
			||||||
 | 
					            ItemStack toExtract = null;
 | 
				
			||||||
 | 
					            ArrayList<ItemStack> networkItems = new ArrayList<>(network.getItemStorageCache().getList().getStacks());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int j = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            while ((toExtract == null || toExtract.getCount() == 0) && j < networkItems.size()) {
 | 
				
			||||||
 | 
					                toExtract = networkItems.get(j++);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (toExtract != null) {
 | 
				
			||||||
 | 
					                extracted = network.extractItem(toExtract, upgrades.getItemInteractCount(), compare, false);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            while (itemFilters.getSlots() > i && extracted == null) {
 | 
				
			||||||
 | 
					                ItemStack stack = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                while (itemFilters.getSlots() > i && stack == null) {
 | 
				
			||||||
 | 
					                    stack = itemFilters.getStackInSlot(i++);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (stack != null) {
 | 
				
			||||||
 | 
					                    extracted = network.extractItem(stack, upgrades.getItemInteractCount(), compare, false);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (extracted == null) {
 | 
				
			||||||
 | 
					            moveDriveToOutput(slot);
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ItemStack remainder = storage.insert(extracted, extracted.getCount(), false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (remainder != null) {
 | 
				
			||||||
 | 
					            network.insertItem(remainder, remainder.getCount(), false);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void insertIntoNetwork(StorageFluid storage, int slot) {
 | 
				
			||||||
 | 
					        if (storage.getStored() == 0) {
 | 
				
			||||||
 | 
					            moveDriveToOutput(slot);
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        FluidStack extracted = null;
 | 
				
			||||||
 | 
					        int i = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        while (extracted == null && storage.getStacks().size() > i) {
 | 
				
			||||||
 | 
					            FluidStack stack = storage.getStacks().get(i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            while (stack == null && storage.getStacks().size() > i) {
 | 
				
			||||||
 | 
					                i++;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (stack != null) {
 | 
				
			||||||
 | 
					                extracted = storage.extract(stack, upgrades.getItemInteractCount(), compare, false);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (extracted == null) {
 | 
				
			||||||
 | 
					            moveDriveToOutput(slot);
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        FluidStack remainder = network.insertFluid(extracted, extracted.amount, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (remainder != null) {
 | 
				
			||||||
 | 
					            storage.insert(remainder, remainder.amount, false);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void extractFromNetwork(StorageFluid storage, int slot) {
 | 
				
			||||||
 | 
					        if (storage.getStored() == storage.getCapacity()) {
 | 
				
			||||||
 | 
					            moveDriveToOutput(slot);
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        FluidStack extracted = null;
 | 
				
			||||||
 | 
					        int i = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (IFilterable.isEmpty(itemFilters)) {
 | 
				
			||||||
 | 
					            FluidStack toExtract = null;
 | 
				
			||||||
 | 
					            ArrayList<FluidStack> networkFluids = new ArrayList<>(network.getFluidStorageCache().getList().getStacks());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int j = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            while ((toExtract == null || toExtract.amount == 0) && j < networkFluids.size()) {
 | 
				
			||||||
 | 
					                toExtract = networkFluids.get(j++);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (toExtract != null) {
 | 
				
			||||||
 | 
					                extracted = network.extractFluid(toExtract, upgrades.getItemInteractCount(), compare, false);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            while (fluidFilters.getSlots() > i && extracted == null) {
 | 
				
			||||||
 | 
					                FluidStack stack = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                while (fluidFilters.getSlots() > i && stack == null) {
 | 
				
			||||||
 | 
					                    stack = fluidFilters.getFluidStackInSlot(i++);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (stack != null) {
 | 
				
			||||||
 | 
					                    extracted = network.extractFluid(stack, upgrades.getItemInteractCount(), compare, false);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (extracted == null) {
 | 
				
			||||||
 | 
					            moveDriveToOutput(slot);
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        FluidStack remainder = storage.insert(extracted, extracted.amount, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (remainder != null) {
 | 
				
			||||||
 | 
					            network.insertFluid(remainder, remainder.amount, false);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void moveDriveToOutput(int slot) {
 | 
				
			||||||
 | 
					        ItemStack disk = inputDisks.getStackInSlot(slot);
 | 
				
			||||||
 | 
					        if (!disk.isEmpty()) {
 | 
				
			||||||
 | 
					            int i = 0;
 | 
				
			||||||
 | 
					            while (i < 3 && !outputDisks.getStackInSlot(i).isEmpty()) {
 | 
				
			||||||
 | 
					                i++;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (i == 3) {
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (slot < 3) {
 | 
				
			||||||
 | 
					                if (itemStorages[slot] != null) {
 | 
				
			||||||
 | 
					                    itemStorages[slot].writeToNBT();
 | 
				
			||||||
 | 
					                    itemStorages[slot] = null;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (fluidStorages[slot] != null) {
 | 
				
			||||||
 | 
					                    fluidStorages[slot].writeToNBT();
 | 
				
			||||||
 | 
					                    fluidStorages[slot] = null;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            inputDisks.extractItem(slot, 1, false);
 | 
				
			||||||
 | 
					            outputDisks.insertItem(i, disk, false);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getCompare() {
 | 
				
			||||||
 | 
					        return compare;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setCompare(int compare) {
 | 
				
			||||||
 | 
					        this.compare = compare;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getType() {
 | 
				
			||||||
 | 
					        return this.type;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setType(int type) {
 | 
				
			||||||
 | 
					        this.type = type;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getFilterInventory() {
 | 
				
			||||||
 | 
					        return getType() == IType.ITEMS ? itemFilters : fluidFilters;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setMode(int mode) {
 | 
				
			||||||
 | 
					        this.mode = mode;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getMode() {
 | 
				
			||||||
 | 
					        return this.mode;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getIoMode() {
 | 
				
			||||||
 | 
					        return ioMode;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setIoMode(int ioMode) {
 | 
				
			||||||
 | 
					        this.ioMode = ioMode;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getInputDisks() {
 | 
				
			||||||
 | 
					        return inputDisks;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getOutputDisks() {
 | 
				
			||||||
 | 
					        return outputDisks;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getUpgrades() {
 | 
				
			||||||
 | 
					        return upgrades;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public StorageItem[] getItemStorages() {
 | 
				
			||||||
 | 
					        return itemStorages;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public StorageFluid[] getFluidStorages() {
 | 
				
			||||||
 | 
					        return fluidStorages;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void read(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.read(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(upgrades, 3, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(inputDisks, 4, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(outputDisks, 5, tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.write(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        onBreak();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(upgrades, 3, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(inputDisks, 4, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(outputDisks, 5, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.writeConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(itemFilters, 1, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(fluidFilters, 2, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_COMPARE, compare);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_MODE, mode);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_TYPE, type);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_IO_MODE, ioMode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void readConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.readConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(itemFilters, 1, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(fluidFilters, 2, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_COMPARE)) {
 | 
				
			||||||
 | 
					            compare = tag.getInteger(NBT_COMPARE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_MODE)) {
 | 
				
			||||||
 | 
					            mode = tag.getInteger(NBT_MODE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_TYPE)) {
 | 
				
			||||||
 | 
					            type = tag.getInteger(NBT_TYPE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_IO_MODE)) {
 | 
				
			||||||
 | 
					            ioMode = tag.getInteger(NBT_IO_MODE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void onBreak() {
 | 
				
			||||||
 | 
					        for (StorageItem storage : itemStorages) {
 | 
				
			||||||
 | 
					            if (storage != null) {
 | 
				
			||||||
 | 
					                storage.writeToNBT();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (StorageFluid storage : fluidStorages) {
 | 
				
			||||||
 | 
					            if (storage != null) {
 | 
				
			||||||
 | 
					                storage.writeToNBT();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getDrops() {
 | 
				
			||||||
 | 
					        return new CombinedInvWrapper(inputDisks, outputDisks, upgrades);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,253 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.util.IComparer;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.API;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerChangeListenerNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.TileExporter;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IComparable;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IType;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.Fluid;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.FluidStack;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.capability.IFluidHandler;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.capability.IFluidTankProperties;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.IItemHandler;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.ItemHandlerHelper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeExporter extends NetworkNode implements IComparable, IType {
 | 
				
			||||||
 | 
					    private static final String NBT_COMPARE = "Compare";
 | 
				
			||||||
 | 
					    private static final String NBT_TYPE = "Type";
 | 
				
			||||||
 | 
					    private static final String NBT_REGULATOR = "Regulator";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic itemFilters = new ItemHandlerBasic(9, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					    private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerChangeListenerNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_CRAFTING, ItemUpgrade.TYPE_STACK);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
 | 
				
			||||||
 | 
					    private int type = IType.ITEMS;
 | 
				
			||||||
 | 
					    private boolean regulator = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeExporter(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        return RS.INSTANCE.config.exporterUsage + upgrades.getEnergyUsage();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void update() {
 | 
				
			||||||
 | 
					        if (network != null && ticks % upgrades.getSpeed() == 0) {
 | 
				
			||||||
 | 
					            if (type == IType.ITEMS) {
 | 
				
			||||||
 | 
					                IItemHandler handler = RSUtils.getItemHandler(holder.world().getTileEntity(holder.pos().offset(holder.getDirection())), holder.getDirection().getOpposite());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (handler != null) {
 | 
				
			||||||
 | 
					                    for (int i = 0; i < itemFilters.getSlots(); ++i) {
 | 
				
			||||||
 | 
					                        ItemStack slot = itemFilters.getStackInSlot(i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (!slot.isEmpty()) {
 | 
				
			||||||
 | 
					                            int stackSize = upgrades.getItemInteractCount();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            boolean skipSlot = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (regulator) {
 | 
				
			||||||
 | 
					                                for (int index = 0; i < handler.getSlots() && !skipSlot; i++) {
 | 
				
			||||||
 | 
					                                    ItemStack exporterStack = handler.getStackInSlot(index);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    if (API.instance().getComparer().isEqual(slot, exporterStack, compare)) {
 | 
				
			||||||
 | 
					                                        if (exporterStack.getCount() >= slot.getCount()) {
 | 
				
			||||||
 | 
					                                            skipSlot = true;
 | 
				
			||||||
 | 
					                                        } else {
 | 
				
			||||||
 | 
					                                            stackSize = upgrades.hasUpgrade(ItemUpgrade.TYPE_STACK) ? slot.getCount() - exporterStack.getCount() : 1;
 | 
				
			||||||
 | 
					                                        }
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (skipSlot) {
 | 
				
			||||||
 | 
					                                continue;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            ItemStack took = network.extractItem(slot, stackSize, compare, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (took == null) {
 | 
				
			||||||
 | 
					                                if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
 | 
				
			||||||
 | 
					                                    network.scheduleCraftingTask(slot, 1, compare);
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            } else if (ItemHandlerHelper.insertItem(handler, took, true).isEmpty()) {
 | 
				
			||||||
 | 
					                                took = network.extractItem(slot, upgrades.getItemInteractCount(), compare, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                ItemHandlerHelper.insertItem(handler, took, false);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } else if (type == IType.FLUIDS) {
 | 
				
			||||||
 | 
					                IFluidHandler handler = RSUtils.getFluidHandler(holder.world().getTileEntity(holder.pos().offset(holder.getDirection())), holder.getDirection().getOpposite());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (handler != null) {
 | 
				
			||||||
 | 
					                    for (FluidStack stack : fluidFilters.getFluids()) {
 | 
				
			||||||
 | 
					                        if (stack != null) {
 | 
				
			||||||
 | 
					                            FluidStack stackInStorage = network.getFluidStorageCache().getList().get(stack, compare);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (stackInStorage != null) {
 | 
				
			||||||
 | 
					                                int toExtract = Math.min(Fluid.BUCKET_VOLUME * upgrades.getItemInteractCount(), stackInStorage.amount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                boolean skipSlot = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                if (regulator) {
 | 
				
			||||||
 | 
					                                    for (IFluidTankProperties tankProperty : handler.getTankProperties()) {
 | 
				
			||||||
 | 
					                                        FluidStack exporterStack = tankProperty.getContents();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                        if (API.instance().getComparer().isEqual(stackInStorage, exporterStack, compare)) {
 | 
				
			||||||
 | 
					                                            if (exporterStack.amount >= stack.amount * Fluid.BUCKET_VOLUME) {
 | 
				
			||||||
 | 
					                                                skipSlot = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                                break;
 | 
				
			||||||
 | 
					                                            } else {
 | 
				
			||||||
 | 
					                                                toExtract = upgrades.hasUpgrade(ItemUpgrade.TYPE_STACK) ? stack.amount * Fluid.BUCKET_VOLUME - exporterStack.amount : Fluid.BUCKET_VOLUME;
 | 
				
			||||||
 | 
					                                                toExtract = Math.min(toExtract, stackInStorage.amount);
 | 
				
			||||||
 | 
					                                            }
 | 
				
			||||||
 | 
					                                        }
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                if (skipSlot) {
 | 
				
			||||||
 | 
					                                    continue;
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                FluidStack took = network.extractFluid(stack, toExtract, compare, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                if (took != null) {
 | 
				
			||||||
 | 
					                                    int filled = handler.fill(took, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    if (filled > 0) {
 | 
				
			||||||
 | 
					                                        took = network.extractFluid(stack, filled, compare, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                        handler.fill(took, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                        break;
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getCompare() {
 | 
				
			||||||
 | 
					        return compare;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setCompare(int compare) {
 | 
				
			||||||
 | 
					        this.compare = compare;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void read(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.read(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(upgrades, 1, tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.write(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(upgrades, 1, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.writeConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_COMPARE, compare);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_TYPE, type);
 | 
				
			||||||
 | 
					        tag.setBoolean(NBT_REGULATOR, regulator);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(itemFilters, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(fluidFilters, 2, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void readConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.readConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_COMPARE)) {
 | 
				
			||||||
 | 
					            compare = tag.getInteger(NBT_COMPARE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_TYPE)) {
 | 
				
			||||||
 | 
					            type = tag.getInteger(NBT_TYPE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_REGULATOR)) {
 | 
				
			||||||
 | 
					            regulator = tag.getBoolean(NBT_REGULATOR);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(itemFilters, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(fluidFilters, 2, tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getUpgrades() {
 | 
				
			||||||
 | 
					        return upgrades;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getDrops() {
 | 
				
			||||||
 | 
					        return upgrades;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getType() {
 | 
				
			||||||
 | 
					        return holder.world().isRemote ? TileExporter.TYPE.getValue() : type;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setType(int type) {
 | 
				
			||||||
 | 
					        this.type = type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setRegulator(boolean regulator) {
 | 
				
			||||||
 | 
					        this.regulator = regulator;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean isRegulator() {
 | 
				
			||||||
 | 
					        return holder.world().isRemote ? TileExporter.REGULATOR.getValue() : regulator;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ItemHandlerBasic getItemFilters() {
 | 
				
			||||||
 | 
					        return itemFilters;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ItemHandlerFluid getFluidFilters() {
 | 
				
			||||||
 | 
					        return fluidFilters;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getFilterInventory() {
 | 
				
			||||||
 | 
					        return getType() == IType.ITEMS ? itemFilters : fluidFilters;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,219 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.util.IComparer;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerChangeListenerNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IComparable;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.Fluid;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.FluidStack;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.FluidTank;
 | 
				
			||||||
 | 
					import org.apache.commons.lang3.tuple.Pair;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeFluidInterface extends NetworkNode implements IComparable {
 | 
				
			||||||
 | 
					    public static final int TANK_CAPACITY = 16000;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static final String NBT_COMPARE = "Compare";
 | 
				
			||||||
 | 
					    private static final String NBT_TANK_IN = "TankIn";
 | 
				
			||||||
 | 
					    private static final String NBT_TANK_OUT = "TankOut";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int compare = IComparer.COMPARE_NBT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private FluidTank tankIn = new FluidTank(TANK_CAPACITY) {
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        protected void onContentsChanged() {
 | 
				
			||||||
 | 
					            super.onContentsChanged();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!holder.world().isRemote) {
 | 
				
			||||||
 | 
					                ((TileFluidInterface) holder.world().getTileEntity(holder.pos())).getDataManager().sendParameterToWatchers(TileFluidInterface.TANK_IN);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            markDirty();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private FluidTank tankOut = new FluidTank(TANK_CAPACITY) {
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        protected void onContentsChanged() {
 | 
				
			||||||
 | 
					            super.onContentsChanged();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!holder.world().isRemote) {
 | 
				
			||||||
 | 
					                ((TileFluidInterface) holder.world().getTileEntity(holder.pos())).getDataManager().sendParameterToWatchers(TileFluidInterface.TANK_OUT);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            markDirty();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic in = new ItemHandlerBasic(1, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					    private ItemHandlerFluid out = new ItemHandlerFluid(1, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerChangeListenerNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_STACK);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeFluidInterface(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tankIn.setCanDrain(false);
 | 
				
			||||||
 | 
					        tankIn.setCanFill(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tankOut.setCanDrain(true);
 | 
				
			||||||
 | 
					        tankOut.setCanFill(false);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void update() {
 | 
				
			||||||
 | 
					        ItemStack container = in.getStackInSlot(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!container.isEmpty()) {
 | 
				
			||||||
 | 
					            Pair<ItemStack, FluidStack> result = RSUtils.getFluidFromStack(container, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (result.getValue() != null && tankIn.fillInternal(result.getValue(), false) == result.getValue().amount) {
 | 
				
			||||||
 | 
					                result = RSUtils.getFluidFromStack(container, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                tankIn.fillInternal(result.getValue(), true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                in.setStackInSlot(0, result.getLeft());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (network != null && ticks % upgrades.getSpeed() == 0) {
 | 
				
			||||||
 | 
					            FluidStack drained = tankIn.drainInternal(Fluid.BUCKET_VOLUME * upgrades.getItemInteractCount(), true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Drain in tank
 | 
				
			||||||
 | 
					            if (drained != null) {
 | 
				
			||||||
 | 
					                FluidStack remainder = network.insertFluid(drained, drained.amount, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (remainder != null) {
 | 
				
			||||||
 | 
					                    tankIn.fillInternal(remainder, true);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            FluidStack stack = out.getFluidStackInSlot(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Fill out tank
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // If our out fluid doesn't match the new fluid, empty it first
 | 
				
			||||||
 | 
					            if (tankOut.getFluid() != null && (stack == null || (tankOut.getFluid().getFluid() != stack.getFluid()))) {
 | 
				
			||||||
 | 
					                FluidStack remainder = tankOut.drainInternal(Fluid.BUCKET_VOLUME * upgrades.getItemInteractCount(), true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (remainder != null) {
 | 
				
			||||||
 | 
					                    network.insertFluid(remainder, remainder.amount, false);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } else if (stack != null) {
 | 
				
			||||||
 | 
					                // Fill the out fluid
 | 
				
			||||||
 | 
					                FluidStack stackInStorage = network.getFluidStorageCache().getList().get(stack, compare);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (stackInStorage != null) {
 | 
				
			||||||
 | 
					                    int toExtract = Math.min(Fluid.BUCKET_VOLUME * upgrades.getItemInteractCount(), stackInStorage.amount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    FluidStack took = network.extractFluid(stack, toExtract, compare, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (took != null && (toExtract - tankOut.fillInternal(took, false)) == 0) {
 | 
				
			||||||
 | 
					                        took = network.extractFluid(stack, toExtract, compare, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        tankOut.fillInternal(took, true);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        return RS.INSTANCE.config.fluidInterfaceUsage;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getCompare() {
 | 
				
			||||||
 | 
					        return compare;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setCompare(int compare) {
 | 
				
			||||||
 | 
					        this.compare = compare;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.write(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(upgrades, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(in, 1, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setTag(NBT_TANK_IN, tankIn.writeToNBT(new NBTTagCompound()));
 | 
				
			||||||
 | 
					        tag.setTag(NBT_TANK_OUT, tankOut.writeToNBT(new NBTTagCompound()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void read(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.read(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(upgrades, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(in, 1, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_TANK_IN)) {
 | 
				
			||||||
 | 
					            tankIn.readFromNBT(tag.getCompoundTag(NBT_TANK_IN));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_TANK_OUT)) {
 | 
				
			||||||
 | 
					            tankOut.readFromNBT(tag.getCompoundTag(NBT_TANK_OUT));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.writeConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(out, 2, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_COMPARE, compare);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void readConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.readConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(out, 2, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_COMPARE)) {
 | 
				
			||||||
 | 
					            compare = tag.getInteger(NBT_COMPARE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ItemHandlerUpgrade getUpgrades() {
 | 
				
			||||||
 | 
					        return upgrades;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ItemHandlerBasic getIn() {
 | 
				
			||||||
 | 
					        return in;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ItemHandlerFluid getOut() {
 | 
				
			||||||
 | 
					        return out;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public FluidTank getTankIn() {
 | 
				
			||||||
 | 
					        return tankIn;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public FluidTank getTankOut() {
 | 
				
			||||||
 | 
					        return tankOut;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean hasConnectivityState() {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,331 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					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.IStorage;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.util.IComparer;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageFluidNBT;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.block.BlockFluidStorage;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.block.EnumFluidStorageType;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerChangeListenerNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.IStorageGui;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.TileFluidStorage;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.*;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.FluidStack;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeFluidStorage extends NetworkNode implements IStorageGui, IStorageProvider, IComparable, IFilterable, IPrioritizable, IExcessVoidable, IAccessType {
 | 
				
			||||||
 | 
					    class StorageFluid extends StorageFluidNBT {
 | 
				
			||||||
 | 
					        public StorageFluid() {
 | 
				
			||||||
 | 
					            super(NetworkNodeFluidStorage.this.getStorageTag(), NetworkNodeFluidStorage.this.getCapacity(), NetworkNodeFluidStorage.this);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public int getPriority() {
 | 
				
			||||||
 | 
					            return priority;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public FluidStack insert(FluidStack stack, int size, boolean simulate) {
 | 
				
			||||||
 | 
					            if (!IFilterable.canTakeFluids(filters, mode, compare, stack)) {
 | 
				
			||||||
 | 
					                return RSUtils.copyStackWithSize(stack, size);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return super.insert(stack, size, simulate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public AccessType getAccessType() {
 | 
				
			||||||
 | 
					            return accessType;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public boolean isVoiding() {
 | 
				
			||||||
 | 
					            return voidExcess;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static final String NBT_STORAGE = "Storage";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static final String NBT_PRIORITY = "Priority";
 | 
				
			||||||
 | 
					    private static final String NBT_COMPARE = "Compare";
 | 
				
			||||||
 | 
					    private static final String NBT_MODE = "Mode";
 | 
				
			||||||
 | 
					    private static final String NBT_VOID_EXCESS = "VoidExcess";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerFluid filters = new ItemHandlerFluid(9, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private NBTTagCompound storageTag = StorageFluidNBT.createNBT();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private StorageFluid storage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private EnumFluidStorageType type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private AccessType accessType = AccessType.INSERT_EXTRACT;
 | 
				
			||||||
 | 
					    private int priority = 0;
 | 
				
			||||||
 | 
					    private int compare = IComparer.COMPARE_NBT;
 | 
				
			||||||
 | 
					    private int mode = IFilterable.WHITELIST;
 | 
				
			||||||
 | 
					    private boolean voidExcess = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeFluidStorage(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        return RS.INSTANCE.config.fluidStorageUsage;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void update() {
 | 
				
			||||||
 | 
					        super.update();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (storage == null && storageTag != null) {
 | 
				
			||||||
 | 
					            storage = new StorageFluid();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (network != null) {
 | 
				
			||||||
 | 
					                network.getFluidStorageCache().invalidate();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void onBreak() {
 | 
				
			||||||
 | 
					        if (storage != null) {
 | 
				
			||||||
 | 
					            storage.writeToNBT();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onConnectedStateChange(INetworkMaster network, boolean state) {
 | 
				
			||||||
 | 
					        super.onConnectedStateChange(network, state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        network.getFluidStorageCache().invalidate();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void addItemStorages(List<IStorage<ItemStack>> storages) {
 | 
				
			||||||
 | 
					        // NO OP
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void addFluidStorages(List<IStorage<FluidStack>> storages) {
 | 
				
			||||||
 | 
					        if (storage != null) {
 | 
				
			||||||
 | 
					            storages.add(storage);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void read(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.read(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_STORAGE)) {
 | 
				
			||||||
 | 
					            storageTag = tag.getCompoundTag(NBT_STORAGE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.write(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (storage != null) {
 | 
				
			||||||
 | 
					            storage.writeToNBT();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setTag(NBT_STORAGE, storageTag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.writeConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(filters, 0, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_PRIORITY, priority);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_COMPARE, compare);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_MODE, mode);
 | 
				
			||||||
 | 
					        tag.setBoolean(NBT_VOID_EXCESS, voidExcess);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeAccessType(tag, accessType);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void readConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.readConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(filters, 0, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_PRIORITY)) {
 | 
				
			||||||
 | 
					            priority = tag.getInteger(NBT_PRIORITY);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_COMPARE)) {
 | 
				
			||||||
 | 
					            compare = tag.getInteger(NBT_COMPARE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_MODE)) {
 | 
				
			||||||
 | 
					            mode = tag.getInteger(NBT_MODE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_VOID_EXCESS)) {
 | 
				
			||||||
 | 
					            voidExcess = tag.getBoolean(NBT_VOID_EXCESS);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        accessType = RSUtils.readAccessType(tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public EnumFluidStorageType getType() {
 | 
				
			||||||
 | 
					        if (type == null && holder.world().getBlockState(holder.pos()).getBlock() == RSBlocks.FLUID_STORAGE) {
 | 
				
			||||||
 | 
					            type = ((EnumFluidStorageType) holder.world().getBlockState(holder.pos()).getValue(BlockFluidStorage.TYPE));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return type == null ? EnumFluidStorageType.TYPE_64K : type;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getCompare() {
 | 
				
			||||||
 | 
					        return compare;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setCompare(int compare) {
 | 
				
			||||||
 | 
					        this.compare = compare;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getMode() {
 | 
				
			||||||
 | 
					        return mode;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setMode(int mode) {
 | 
				
			||||||
 | 
					        this.mode = mode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NBTTagCompound getStorageTag() {
 | 
				
			||||||
 | 
					        return storageTag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setStorageTag(NBTTagCompound storageTag) {
 | 
				
			||||||
 | 
					        this.storageTag = storageTag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public StorageFluidNBT getStorage() {
 | 
				
			||||||
 | 
					        return storage;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ItemHandlerFluid getFilters() {
 | 
				
			||||||
 | 
					        return filters;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getGuiTitle() {
 | 
				
			||||||
 | 
					        return "block.refinedstorage:fluid_storage." + getType().getId() + ".name";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Integer> getTypeParameter() {
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Integer> getRedstoneModeParameter() {
 | 
				
			||||||
 | 
					        return TileFluidStorage.REDSTONE_MODE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Integer> getCompareParameter() {
 | 
				
			||||||
 | 
					        return TileFluidStorage.COMPARE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Integer> getFilterParameter() {
 | 
				
			||||||
 | 
					        return TileFluidStorage.MODE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Integer> getPriorityParameter() {
 | 
				
			||||||
 | 
					        return TileFluidStorage.PRIORITY;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Boolean> getVoidExcessParameter() {
 | 
				
			||||||
 | 
					        return TileFluidStorage.VOID_EXCESS;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<AccessType> getAccessTypeParameter() {
 | 
				
			||||||
 | 
					        return TileFluidStorage.ACCESS_TYPE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getVoidExcessType() {
 | 
				
			||||||
 | 
					        return "fluids";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getStored() {
 | 
				
			||||||
 | 
					        return TileFluidStorage.STORED.getValue();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getCapacity() {
 | 
				
			||||||
 | 
					        return getType().getCapacity();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public AccessType getAccessType() {
 | 
				
			||||||
 | 
					        return accessType;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setAccessType(AccessType value) {
 | 
				
			||||||
 | 
					        this.accessType = value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (network != null) {
 | 
				
			||||||
 | 
					            network.getFluidStorageCache().invalidate();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getPriority() {
 | 
				
			||||||
 | 
					        return priority;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setPriority(int priority) {
 | 
				
			||||||
 | 
					        this.priority = priority;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean getVoidExcess() {
 | 
				
			||||||
 | 
					        return voidExcess;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setVoidExcess(boolean value) {
 | 
				
			||||||
 | 
					        this.voidExcess = value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,552 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSItems;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.grid.IFluidGridHandler;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.grid.IItemGridHandler;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.security.Permission;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.API;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.block.BlockGrid;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.block.EnumGridType;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.container.ContainerGrid;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.gui.grid.GridFilter;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.gui.grid.GridTab;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerChangeListenerNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerGridFilterInGrid;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemValidatorBasic;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.item.ItemPattern;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
				
			||||||
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
 | 
					import net.minecraft.entity.player.EntityPlayerMP;
 | 
				
			||||||
 | 
					import net.minecraft.inventory.*;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.item.crafting.CraftingManager;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraft.util.NonNullList;
 | 
				
			||||||
 | 
					import net.minecraft.util.math.BlockPos;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.IItemHandler;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.ItemHandlerHelper;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.wrapper.CombinedInvWrapper;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.wrapper.InvWrapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nullable;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeGrid extends NetworkNode implements IGrid {
 | 
				
			||||||
 | 
					    public static final String NBT_VIEW_TYPE = "ViewType";
 | 
				
			||||||
 | 
					    public static final String NBT_SORTING_DIRECTION = "SortingDirection";
 | 
				
			||||||
 | 
					    public static final String NBT_SORTING_TYPE = "SortingType";
 | 
				
			||||||
 | 
					    public static final String NBT_SEARCH_BOX_MODE = "SearchBoxMode";
 | 
				
			||||||
 | 
					    public static final String NBT_OREDICT_PATTERN = "OredictPattern";
 | 
				
			||||||
 | 
					    public static final String NBT_TAB_SELECTED = "TabSelected";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static final int SORTING_DIRECTION_ASCENDING = 0;
 | 
				
			||||||
 | 
					    public static final int SORTING_DIRECTION_DESCENDING = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static final int SORTING_TYPE_QUANTITY = 0;
 | 
				
			||||||
 | 
					    public static final int SORTING_TYPE_NAME = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static final int SEARCH_BOX_MODE_NORMAL = 0;
 | 
				
			||||||
 | 
					    public static final int SEARCH_BOX_MODE_NORMAL_AUTOSELECTED = 1;
 | 
				
			||||||
 | 
					    public static final int SEARCH_BOX_MODE_JEI_SYNCHRONIZED = 2;
 | 
				
			||||||
 | 
					    public static final int SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED = 3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static final int VIEW_TYPE_NORMAL = 0;
 | 
				
			||||||
 | 
					    public static final int VIEW_TYPE_NON_CRAFTABLES = 1;
 | 
				
			||||||
 | 
					    public static final int VIEW_TYPE_CRAFTABLES = 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Container craftingContainer = new Container() {
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public boolean canInteractWith(EntityPlayer player) {
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public void onCraftMatrixChanged(IInventory inventory) {
 | 
				
			||||||
 | 
					            onCraftingMatrixChanged();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    private InventoryCrafting matrix = new InventoryCrafting(craftingContainer, 3, 3);
 | 
				
			||||||
 | 
					    private InventoryCraftResult result = new InventoryCraftResult();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic patterns = new ItemHandlerBasic(2, new ItemHandlerChangeListenerNode(this), new ItemValidatorBasic(RSItems.PATTERN));
 | 
				
			||||||
 | 
					    private List<GridFilter> filteredItems = new ArrayList<>();
 | 
				
			||||||
 | 
					    private List<GridTab> tabs = new ArrayList<>();
 | 
				
			||||||
 | 
					    private ItemHandlerGridFilterInGrid filter = new ItemHandlerGridFilterInGrid(filteredItems, tabs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private EnumGridType type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int viewType = VIEW_TYPE_NORMAL;
 | 
				
			||||||
 | 
					    private int sortingDirection = SORTING_DIRECTION_DESCENDING;
 | 
				
			||||||
 | 
					    private int sortingType = SORTING_TYPE_QUANTITY;
 | 
				
			||||||
 | 
					    private int searchBoxMode = SEARCH_BOX_MODE_NORMAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int tabSelected = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private boolean oredictPattern = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeGrid(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        switch (getType()) {
 | 
				
			||||||
 | 
					            case NORMAL:
 | 
				
			||||||
 | 
					                return RS.INSTANCE.config.gridUsage;
 | 
				
			||||||
 | 
					            case CRAFTING:
 | 
				
			||||||
 | 
					                return RS.INSTANCE.config.craftingGridUsage;
 | 
				
			||||||
 | 
					            case PATTERN:
 | 
				
			||||||
 | 
					                return RS.INSTANCE.config.patternGridUsage;
 | 
				
			||||||
 | 
					            case FLUID:
 | 
				
			||||||
 | 
					                return RS.INSTANCE.config.fluidGridUsage;
 | 
				
			||||||
 | 
					            default:
 | 
				
			||||||
 | 
					                return 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setViewType(int viewType) {
 | 
				
			||||||
 | 
					        this.viewType = viewType;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setSortingDirection(int sortingDirection) {
 | 
				
			||||||
 | 
					        this.sortingDirection = sortingDirection;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setSortingType(int sortingType) {
 | 
				
			||||||
 | 
					        this.sortingType = sortingType;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setSearchBoxMode(int searchBoxMode) {
 | 
				
			||||||
 | 
					        this.searchBoxMode = searchBoxMode;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setTabSelected(int tabSelected) {
 | 
				
			||||||
 | 
					        this.tabSelected = tabSelected;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean isOredictPattern() {
 | 
				
			||||||
 | 
					        return oredictPattern;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setOredictPattern(boolean oredictPattern) {
 | 
				
			||||||
 | 
					        this.oredictPattern = oredictPattern;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public EnumGridType getType() {
 | 
				
			||||||
 | 
					        if (type == null && holder.world().getBlockState(holder.pos()).getBlock() == RSBlocks.GRID) {
 | 
				
			||||||
 | 
					            type = (EnumGridType) holder.world().getBlockState(holder.pos()).getValue(BlockGrid.TYPE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return type == null ? EnumGridType.NORMAL : type;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nullable
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public BlockPos getNetworkPosition() {
 | 
				
			||||||
 | 
					        return network != null ? network.getPosition() : null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void onOpened(EntityPlayer player) {
 | 
				
			||||||
 | 
					        if (network != null) {
 | 
				
			||||||
 | 
					            if (getType() == EnumGridType.FLUID) {
 | 
				
			||||||
 | 
					                network.sendFluidStorageToClient((EntityPlayerMP) player);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                network.sendItemStorageToClient((EntityPlayerMP) player);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemGridHandler getItemHandler() {
 | 
				
			||||||
 | 
					        return network != null ? network.getItemGridHandler() : null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IFluidGridHandler getFluidHandler() {
 | 
				
			||||||
 | 
					        return network != null ? network.getFluidGridHandler() : null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getGuiTitle() {
 | 
				
			||||||
 | 
					        return getType() == EnumGridType.FLUID ? "gui.refinedstorage:fluid_grid" : "gui.refinedstorage:grid";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public InventoryCrafting getMatrix() {
 | 
				
			||||||
 | 
					        return matrix;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public InventoryCraftResult getResult() {
 | 
				
			||||||
 | 
					        return result;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getPatterns() {
 | 
				
			||||||
 | 
					        return patterns;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public ItemHandlerBasic getFilter() {
 | 
				
			||||||
 | 
					        return filter;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<GridFilter> getFilteredItems() {
 | 
				
			||||||
 | 
					        return filteredItems;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<GridTab> getTabs() {
 | 
				
			||||||
 | 
					        return tabs;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void onCraftingMatrixChanged() {
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        result.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(matrix, holder.world()));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void onCrafted(EntityPlayer player) {
 | 
				
			||||||
 | 
					        NonNullList<ItemStack> remainder = CraftingManager.getInstance().getRemainingItems(matrix, holder.world());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i = 0; i < matrix.getSizeInventory(); ++i) {
 | 
				
			||||||
 | 
					            ItemStack slot = matrix.getStackInSlot(i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (i < remainder.size() && !remainder.get(i).isEmpty()) {
 | 
				
			||||||
 | 
					                // If there is no space for the remainder, dump it in the player inventory
 | 
				
			||||||
 | 
					                if (!slot.isEmpty() && slot.getCount() > 1) {
 | 
				
			||||||
 | 
					                    if (!player.inventory.addItemStackToInventory(remainder.get(i).copy())) {
 | 
				
			||||||
 | 
					                        ItemStack remainderStack = network.insertItem(remainder.get(i).copy(), remainder.get(i).getCount(), false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (remainderStack != null) {
 | 
				
			||||||
 | 
					                            InventoryHelper.spawnItemStack(player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ(), remainderStack);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    matrix.decrStackSize(i, 1);
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    matrix.setInventorySlotContents(i, remainder.get(i).copy());
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } else if (!slot.isEmpty()) {
 | 
				
			||||||
 | 
					                if (slot.getCount() == 1 && network != null) {
 | 
				
			||||||
 | 
					                    matrix.setInventorySlotContents(i, RSUtils.getStack(network.extractItem(slot, 1, false)));
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    matrix.decrStackSize(i, 1);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        onCraftingMatrixChanged();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void onCraftedShift(ContainerGrid container, EntityPlayer player) {
 | 
				
			||||||
 | 
					        List<ItemStack> craftedItemsList = new ArrayList<>();
 | 
				
			||||||
 | 
					        int craftedItems = 0;
 | 
				
			||||||
 | 
					        ItemStack crafted = result.getStackInSlot(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        while (true) {
 | 
				
			||||||
 | 
					            onCrafted(player);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            craftedItemsList.add(crafted.copy());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            craftedItems += crafted.getCount();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!API.instance().getComparer().isEqual(crafted, result.getStackInSlot(0)) || craftedItems + crafted.getCount() > crafted.getMaxStackSize()) {
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (ItemStack craftedItem : craftedItemsList) {
 | 
				
			||||||
 | 
					            if (!player.inventory.addItemStackToInventory(craftedItem.copy())) {
 | 
				
			||||||
 | 
					                ItemStack remainder = network.insertItem(craftedItem, craftedItem.getCount(), false);
 | 
				
			||||||
 | 
					                if (remainder != null) {
 | 
				
			||||||
 | 
					                    InventoryHelper.spawnItemStack(player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ(), remainder);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        container.sendCraftingSlots();
 | 
				
			||||||
 | 
					        container.detectAndSendChanges();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void onCreatePattern() {
 | 
				
			||||||
 | 
					        if (canCreatePattern()) {
 | 
				
			||||||
 | 
					            patterns.extractItem(0, 1, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ItemStack pattern = new ItemStack(RSItems.PATTERN);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ItemPattern.setOredict(pattern, oredictPattern);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            for (int i = 0; i < 9; ++i) {
 | 
				
			||||||
 | 
					                ItemStack ingredient = matrix.getStackInSlot(i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (!ingredient.isEmpty()) {
 | 
				
			||||||
 | 
					                    ItemPattern.setSlot(pattern, i, ingredient);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            patterns.setStackInSlot(1, pattern);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean canCreatePattern() {
 | 
				
			||||||
 | 
					        return !result.getStackInSlot(0).isEmpty() && patterns.getStackInSlot(1).isEmpty() && !patterns.getStackInSlot(0).isEmpty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void onRecipeTransfer(EntityPlayer player, ItemStack[][] recipe) {
 | 
				
			||||||
 | 
					        if (network != null && getType() == EnumGridType.CRAFTING && !network.getSecurityManager().hasPermission(Permission.EXTRACT, player)) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // First try to empty the crafting matrix
 | 
				
			||||||
 | 
					        for (int i = 0; i < matrix.getSizeInventory(); ++i) {
 | 
				
			||||||
 | 
					            ItemStack slot = matrix.getStackInSlot(i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!slot.isEmpty()) {
 | 
				
			||||||
 | 
					                // Only if we are a crafting grid. Pattern grids can just be emptied.
 | 
				
			||||||
 | 
					                if (getType() == EnumGridType.CRAFTING) {
 | 
				
			||||||
 | 
					                    // If we are connected, try to insert into network. If it fails, stop.
 | 
				
			||||||
 | 
					                    if (network != null) {
 | 
				
			||||||
 | 
					                        if (network.insertItem(slot, slot.getCount(), true) != null) {
 | 
				
			||||||
 | 
					                            return;
 | 
				
			||||||
 | 
					                        } else {
 | 
				
			||||||
 | 
					                            network.insertItem(slot, slot.getCount(), false);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        // If we aren't connected, try to insert into player inventory. If it fails, stop.
 | 
				
			||||||
 | 
					                        if (!player.inventory.addItemStackToInventory(slot.copy())) {
 | 
				
			||||||
 | 
					                            return;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                matrix.setInventorySlotContents(i, ItemStack.EMPTY);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Now let's fill the matrix
 | 
				
			||||||
 | 
					        for (int i = 0; i < matrix.getSizeInventory(); ++i) {
 | 
				
			||||||
 | 
					            if (recipe[i] != null) {
 | 
				
			||||||
 | 
					                ItemStack[] possibilities = recipe[i];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // If we are a crafting grid
 | 
				
			||||||
 | 
					                if (getType() == EnumGridType.CRAFTING) {
 | 
				
			||||||
 | 
					                    boolean found = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    // If we are connected, first try to get the possibilities from the network
 | 
				
			||||||
 | 
					                    if (network != null) {
 | 
				
			||||||
 | 
					                        for (ItemStack possibility : possibilities) {
 | 
				
			||||||
 | 
					                            ItemStack took = network.extractItem(possibility, 1, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (took != null) {
 | 
				
			||||||
 | 
					                                matrix.setInventorySlotContents(i, RSUtils.getStack(took));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                found = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    // If we haven't found anything in the network (or we are disconnected), go look in the player inventory
 | 
				
			||||||
 | 
					                    if (!found) {
 | 
				
			||||||
 | 
					                        for (ItemStack possibility : possibilities) {
 | 
				
			||||||
 | 
					                            for (int j = 0; j < player.inventory.getSizeInventory(); ++j) {
 | 
				
			||||||
 | 
					                                if (API.instance().getComparer().isEqualNoQuantity(possibility, player.inventory.getStackInSlot(j))) {
 | 
				
			||||||
 | 
					                                    matrix.setInventorySlotContents(i, ItemHandlerHelper.copyStackWithSize(player.inventory.getStackInSlot(j), 1));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    player.inventory.decrStackSize(j, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    found = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    break;
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (found) {
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                } else if (getType() == EnumGridType.PATTERN) {
 | 
				
			||||||
 | 
					                    // If we are a pattern grid we can just set the slot
 | 
				
			||||||
 | 
					                    matrix.setInventorySlotContents(i, possibilities[0]);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getViewType() {
 | 
				
			||||||
 | 
					        return holder.world().isRemote ? TileGrid.VIEW_TYPE.getValue() : viewType;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getSortingDirection() {
 | 
				
			||||||
 | 
					        return holder.world().isRemote ? TileGrid.SORTING_DIRECTION.getValue() : sortingDirection;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getSortingType() {
 | 
				
			||||||
 | 
					        return holder.world().isRemote ? TileGrid.SORTING_TYPE.getValue() : sortingType;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getSearchBoxMode() {
 | 
				
			||||||
 | 
					        return holder.world().isRemote ? TileGrid.SEARCH_BOX_MODE.getValue() : searchBoxMode;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getTabSelected() {
 | 
				
			||||||
 | 
					        return holder.world().isRemote ? TileGrid.TAB_SELECTED.getValue() : tabSelected;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onViewTypeChanged(int type) {
 | 
				
			||||||
 | 
					        TileDataManager.setParameter(TileGrid.VIEW_TYPE, type);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onSortingTypeChanged(int type) {
 | 
				
			||||||
 | 
					        TileDataManager.setParameter(TileGrid.SORTING_TYPE, type);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onSortingDirectionChanged(int direction) {
 | 
				
			||||||
 | 
					        TileDataManager.setParameter(TileGrid.SORTING_DIRECTION, direction);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onSearchBoxModeChanged(int searchBoxMode) {
 | 
				
			||||||
 | 
					        TileDataManager.setParameter(TileGrid.SEARCH_BOX_MODE, searchBoxMode);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onTabSelectionChanged(int tab) {
 | 
				
			||||||
 | 
					        TileDataManager.setParameter(TileGrid.TAB_SELECTED, tab);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Integer> getRedstoneModeConfig() {
 | 
				
			||||||
 | 
					        return TileGrid.REDSTONE_MODE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean isActive() {
 | 
				
			||||||
 | 
					        return ((TileGrid) holder.world().getTileEntity(holder.pos())).isActive();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean hasConnectivityState() {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void read(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.read(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItemsLegacy(matrix, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(patterns, 1, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(filter, 2, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_TAB_SELECTED)) {
 | 
				
			||||||
 | 
					            tabSelected = tag.getInteger(NBT_TAB_SELECTED);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.write(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItemsLegacy(matrix, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(patterns, 1, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(filter, 2, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_TAB_SELECTED, tabSelected);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.writeConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_VIEW_TYPE, viewType);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_SORTING_DIRECTION, sortingDirection);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_SORTING_TYPE, sortingType);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_SEARCH_BOX_MODE, searchBoxMode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setBoolean(NBT_OREDICT_PATTERN, oredictPattern);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void readConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.readConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_VIEW_TYPE)) {
 | 
				
			||||||
 | 
					            viewType = tag.getInteger(NBT_VIEW_TYPE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_SORTING_DIRECTION)) {
 | 
				
			||||||
 | 
					            sortingDirection = tag.getInteger(NBT_SORTING_DIRECTION);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_SORTING_TYPE)) {
 | 
				
			||||||
 | 
					            sortingType = tag.getInteger(NBT_SORTING_TYPE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_SEARCH_BOX_MODE)) {
 | 
				
			||||||
 | 
					            searchBoxMode = tag.getInteger(NBT_SEARCH_BOX_MODE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_OREDICT_PATTERN)) {
 | 
				
			||||||
 | 
					            oredictPattern = tag.getBoolean(NBT_OREDICT_PATTERN);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getDrops() {
 | 
				
			||||||
 | 
					        switch (getType()) {
 | 
				
			||||||
 | 
					            case CRAFTING:
 | 
				
			||||||
 | 
					                return new CombinedInvWrapper(filter, new InvWrapper(matrix));
 | 
				
			||||||
 | 
					            case PATTERN:
 | 
				
			||||||
 | 
					                return new CombinedInvWrapper(filter, patterns);
 | 
				
			||||||
 | 
					            default:
 | 
				
			||||||
 | 
					                return new CombinedInvWrapper(filter);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static boolean isValidViewType(int type) {
 | 
				
			||||||
 | 
					        return type == VIEW_TYPE_NORMAL ||
 | 
				
			||||||
 | 
					                type == VIEW_TYPE_CRAFTABLES ||
 | 
				
			||||||
 | 
					                type == VIEW_TYPE_NON_CRAFTABLES;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static boolean isValidSearchBoxMode(int mode) {
 | 
				
			||||||
 | 
					        return mode == SEARCH_BOX_MODE_NORMAL ||
 | 
				
			||||||
 | 
					                mode == SEARCH_BOX_MODE_NORMAL_AUTOSELECTED ||
 | 
				
			||||||
 | 
					                mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED ||
 | 
				
			||||||
 | 
					                mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static boolean isSearchBoxModeWithAutoselection(int mode) {
 | 
				
			||||||
 | 
					        return mode == SEARCH_BOX_MODE_NORMAL_AUTOSELECTED || mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static boolean isValidSortingType(int type) {
 | 
				
			||||||
 | 
					        return type == SORTING_TYPE_QUANTITY || type == SORTING_TYPE_NAME;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static boolean isValidSortingDirection(int direction) {
 | 
				
			||||||
 | 
					        return direction == SORTING_DIRECTION_ASCENDING || direction == SORTING_DIRECTION_DESCENDING;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,202 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.util.IComparer;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerChangeListenerNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.TileDiskDrive;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.TileImporter;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IComparable;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IType;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraft.tileentity.TileEntity;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.Fluid;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.FluidStack;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.capability.IFluidHandler;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.IItemHandler;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeImporter extends NetworkNode implements IComparable, IFilterable, IType {
 | 
				
			||||||
 | 
					    private static final String NBT_COMPARE = "Compare";
 | 
				
			||||||
 | 
					    private static final String NBT_MODE = "Mode";
 | 
				
			||||||
 | 
					    private static final String NBT_TYPE = "Type";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic itemFilters = new ItemHandlerBasic(9, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					    private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerChangeListenerNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_STACK);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
 | 
				
			||||||
 | 
					    private int mode = IFilterable.WHITELIST;
 | 
				
			||||||
 | 
					    private int type = IType.ITEMS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int currentSlot;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeImporter(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        return RS.INSTANCE.config.importerUsage + upgrades.getEnergyUsage();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void update() {
 | 
				
			||||||
 | 
					        if (type == IType.ITEMS) {
 | 
				
			||||||
 | 
					            TileEntity tile = holder.world().getTileEntity(holder.pos().offset(holder.getDirection()));
 | 
				
			||||||
 | 
					            IItemHandler handler = RSUtils.getItemHandler(tile, holder.getDirection().getOpposite());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (handler == null || tile instanceof TileDiskDrive) {
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (currentSlot >= handler.getSlots()) {
 | 
				
			||||||
 | 
					                currentSlot = 0;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (handler.getSlots() > 0) {
 | 
				
			||||||
 | 
					                ItemStack stack = handler.getStackInSlot(currentSlot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (stack.isEmpty() || !IFilterable.canTake(itemFilters, mode, compare, stack)) {
 | 
				
			||||||
 | 
					                    currentSlot++;
 | 
				
			||||||
 | 
					                } else if (ticks % upgrades.getSpeed() == 0) {
 | 
				
			||||||
 | 
					                    ItemStack result = handler.extractItem(currentSlot, upgrades.getItemInteractCount(), true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (!result.isEmpty() && network.insertItem(result, result.getCount(), true) == null) {
 | 
				
			||||||
 | 
					                        network.insertItem(result, result.getCount(), false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        handler.extractItem(currentSlot, upgrades.getItemInteractCount(), false);
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        currentSlot++;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else if (type == IType.FLUIDS && ticks % upgrades.getSpeed() == 0) {
 | 
				
			||||||
 | 
					            IFluidHandler handler = RSUtils.getFluidHandler(holder.world().getTileEntity(holder.pos().offset(holder.getDirection())), holder.getDirection().getOpposite());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (handler != null) {
 | 
				
			||||||
 | 
					                FluidStack stack = handler.drain(Fluid.BUCKET_VOLUME, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (stack != null && IFilterable.canTakeFluids(fluidFilters, mode, compare, stack) && network.insertFluid(stack, stack.amount, true) == null) {
 | 
				
			||||||
 | 
					                    FluidStack toDrain = handler.drain(Fluid.BUCKET_VOLUME * upgrades.getItemInteractCount(), false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (toDrain != null) {
 | 
				
			||||||
 | 
					                        FluidStack remainder = network.insertFluid(toDrain, toDrain.amount, false);
 | 
				
			||||||
 | 
					                        if (remainder != null) {
 | 
				
			||||||
 | 
					                            toDrain.amount -= remainder.amount;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        handler.drain(toDrain, true);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getCompare() {
 | 
				
			||||||
 | 
					        return compare;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setCompare(int compare) {
 | 
				
			||||||
 | 
					        this.compare = compare;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getMode() {
 | 
				
			||||||
 | 
					        return mode;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setMode(int mode) {
 | 
				
			||||||
 | 
					        this.mode = mode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void read(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.read(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(upgrades, 1, tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.write(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(upgrades, 1, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.writeConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_COMPARE, compare);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_MODE, mode);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_TYPE, type);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(itemFilters, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(fluidFilters, 2, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void readConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.readConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_COMPARE)) {
 | 
				
			||||||
 | 
					            compare = tag.getInteger(NBT_COMPARE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_MODE)) {
 | 
				
			||||||
 | 
					            mode = tag.getInteger(NBT_MODE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_TYPE)) {
 | 
				
			||||||
 | 
					            type = tag.getInteger(NBT_TYPE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(itemFilters, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(fluidFilters, 2, tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getUpgrades() {
 | 
				
			||||||
 | 
					        return upgrades;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getDrops() {
 | 
				
			||||||
 | 
					        return upgrades;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getType() {
 | 
				
			||||||
 | 
					        return holder.world().isRemote ? TileImporter.TYPE.getValue() : type;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setType(int type) {
 | 
				
			||||||
 | 
					        this.type = type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getFilterInventory() {
 | 
				
			||||||
 | 
					        return getType() == IType.ITEMS ? itemFilters : fluidFilters;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,190 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.util.IComparer;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerChangeListenerNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerInterface;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IComparable;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.IItemHandler;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.wrapper.CombinedInvWrapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeInterface extends NetworkNode implements IComparable {
 | 
				
			||||||
 | 
					    private static final String NBT_COMPARE = "Compare";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic importItems = new ItemHandlerBasic(9, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic exportSpecimenItems = new ItemHandlerBasic(9, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					    private ItemHandlerBasic exportItems = new ItemHandlerBasic(9, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerInterface items = new ItemHandlerInterface(importItems, exportItems);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerChangeListenerNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_STACK, ItemUpgrade.TYPE_CRAFTING);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int currentSlot = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeInterface(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        return RS.INSTANCE.config.interfaceUsage + upgrades.getEnergyUsage();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void update() {
 | 
				
			||||||
 | 
					        if (network == null) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (currentSlot >= importItems.getSlots()) {
 | 
				
			||||||
 | 
					            currentSlot = 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ItemStack slot = importItems.getStackInSlot(currentSlot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (slot.isEmpty()) {
 | 
				
			||||||
 | 
					            currentSlot++;
 | 
				
			||||||
 | 
					        } else if (ticks % upgrades.getSpeed() == 0) {
 | 
				
			||||||
 | 
					            int size = Math.min(slot.getCount(), upgrades.getItemInteractCount());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ItemStack remainder = network.insertItem(slot, size, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (remainder == null) {
 | 
				
			||||||
 | 
					                importItems.extractItemInternal(currentSlot, size, false);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                importItems.extractItemInternal(currentSlot, size - remainder.getCount(), false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                currentSlot++;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i = 0; i < 9; ++i) {
 | 
				
			||||||
 | 
					            ItemStack wanted = exportSpecimenItems.getStackInSlot(i);
 | 
				
			||||||
 | 
					            ItemStack got = exportItems.getStackInSlot(i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (wanted.isEmpty()) {
 | 
				
			||||||
 | 
					                if (!got.isEmpty()) {
 | 
				
			||||||
 | 
					                    exportItems.setStackInSlot(i, RSUtils.getStack(network.insertItem(got, got.getCount(), false)));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                int delta = got.isEmpty() ? wanted.getCount() : (wanted.getCount() - got.getCount());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (delta > 0) {
 | 
				
			||||||
 | 
					                    ItemStack result = network.extractItem(wanted, delta, compare, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (result != null) {
 | 
				
			||||||
 | 
					                        if (exportItems.getStackInSlot(i).isEmpty()) {
 | 
				
			||||||
 | 
					                            exportItems.setStackInSlot(i, result);
 | 
				
			||||||
 | 
					                        } else {
 | 
				
			||||||
 | 
					                            exportItems.getStackInSlot(i).grow(result.getCount());
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    } else if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
 | 
				
			||||||
 | 
					                        network.scheduleCraftingTask(wanted, delta, compare);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                } else if (delta < 0) {
 | 
				
			||||||
 | 
					                    ItemStack remainder = network.insertItem(got, Math.abs(delta), false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (remainder == null) {
 | 
				
			||||||
 | 
					                        exportItems.extractItem(i, Math.abs(delta), false);
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        exportItems.extractItem(i, Math.abs(delta) - remainder.getCount(), false);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getCompare() {
 | 
				
			||||||
 | 
					        return compare;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setCompare(int compare) {
 | 
				
			||||||
 | 
					        this.compare = compare;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void read(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.read(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(importItems, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(exportItems, 2, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(upgrades, 3, tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.write(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(importItems, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(exportItems, 2, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(upgrades, 3, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.writeConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(exportSpecimenItems, 1, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_COMPARE, compare);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void readConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.readConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(exportSpecimenItems, 1, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_COMPARE)) {
 | 
				
			||||||
 | 
					            compare = tag.getInteger(NBT_COMPARE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getImportItems() {
 | 
				
			||||||
 | 
					        return importItems;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getExportSpecimenItems() {
 | 
				
			||||||
 | 
					        return exportSpecimenItems;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getExportItems() {
 | 
				
			||||||
 | 
					        return exportItems;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ItemHandlerInterface getItems() {
 | 
				
			||||||
 | 
					        return items;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getUpgrades() {
 | 
				
			||||||
 | 
					        return upgrades;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getDrops() {
 | 
				
			||||||
 | 
					        return new CombinedInvWrapper(importItems, exportItems, upgrades);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean hasConnectivityState() {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,152 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSItems;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerChangeListenerNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemValidatorBasic;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.item.ItemNetworkCard;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraft.util.math.BlockPos;
 | 
				
			||||||
 | 
					import net.minecraft.world.World;
 | 
				
			||||||
 | 
					import net.minecraftforge.common.DimensionManager;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.IItemHandler;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.wrapper.CombinedInvWrapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeNetworkTransmitter extends NetworkNode {
 | 
				
			||||||
 | 
					    private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(1, new ItemHandlerChangeListenerNode(this), ItemUpgrade.TYPE_INTERDIMENSIONAL) {
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        protected void onContentsChanged(int slot) {
 | 
				
			||||||
 | 
					            super.onContentsChanged(slot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (network != null) {
 | 
				
			||||||
 | 
					                network.getNodeGraph().rebuild();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic networkCard = new ItemHandlerBasic(1, new ItemHandlerChangeListenerNode(this), new ItemValidatorBasic(RSItems.NETWORK_CARD)) {
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        protected void onContentsChanged(int slot) {
 | 
				
			||||||
 | 
					            super.onContentsChanged(slot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ItemStack card = getStackInSlot(slot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (card.isEmpty()) {
 | 
				
			||||||
 | 
					                receiver = null;
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                receiver = ItemNetworkCard.getReceiver(card);
 | 
				
			||||||
 | 
					                receiverDimension = ItemNetworkCard.getDimension(card);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (network != null) {
 | 
				
			||||||
 | 
					                network.getNodeGraph().rebuild();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private BlockPos receiver;
 | 
				
			||||||
 | 
					    private int receiverDimension;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeNetworkTransmitter(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        rebuildOnUpdateChange = true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean canTransmit() {
 | 
				
			||||||
 | 
					        return canUpdate() && receiver != null && isDimensionSupported();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.write(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(networkCard, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(upgrades, 1, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void read(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.read(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(networkCard, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(upgrades, 1, tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        return Math.min(
 | 
				
			||||||
 | 
					                RS.INSTANCE.config.interdimensionalUpgradeUsage,
 | 
				
			||||||
 | 
					                RS.INSTANCE.config.networkTransmitterUsage + (isSameDimension() ? (int) Math.ceil(RS.INSTANCE.config.networkTransmitterPerBlockUsage * getDistance()) : 0) + upgrades.getEnergyUsage()
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ItemHandlerBasic getNetworkCard() {
 | 
				
			||||||
 | 
					        return networkCard;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ItemHandlerUpgrade getUpgrades() {
 | 
				
			||||||
 | 
					        return upgrades;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getDrops() {
 | 
				
			||||||
 | 
					        return new CombinedInvWrapper(networkCard, upgrades);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nullable
 | 
				
			||||||
 | 
					    public BlockPos getReceiver() {
 | 
				
			||||||
 | 
					        return receiver;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getReceiverDimension() {
 | 
				
			||||||
 | 
					        return receiverDimension;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getDistance() {
 | 
				
			||||||
 | 
					        if (receiver == null) {
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return (int) Math.sqrt(Math.pow(holder.pos().getX() - receiver.getX(), 2) + Math.pow(holder.pos().getY() - receiver.getY(), 2) + Math.pow(holder.pos().getZ() - receiver.getZ(), 2));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean isSameDimension() {
 | 
				
			||||||
 | 
					        return holder.world().provider.getDimension() == receiverDimension;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean isDimensionSupported() {
 | 
				
			||||||
 | 
					        return isSameDimension() || upgrades.hasUpgrade(ItemUpgrade.TYPE_INTERDIMENSIONAL);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean hasConnectivityState() {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void walkNeighborhood(Operator operator) {
 | 
				
			||||||
 | 
					        super.walkNeighborhood(operator);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (canTransmit()) {
 | 
				
			||||||
 | 
					            if (!isSameDimension()) {
 | 
				
			||||||
 | 
					                final World dimensionWorld = DimensionManager.getWorld(receiverDimension);
 | 
				
			||||||
 | 
					                if (dimensionWorld != null) {
 | 
				
			||||||
 | 
					                    operator.apply(dimensionWorld, receiver, null);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                operator.apply(holder.world(), receiver, null);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,79 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReader;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.TileReader;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
 | 
				
			||||||
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
 | 
					import net.minecraft.entity.player.EntityPlayerMP;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeReader extends NetworkNode implements IReader {
 | 
				
			||||||
 | 
					    private static final String NBT_CHANNEL = "Channel";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private String channel = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeReader(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        return RS.INSTANCE.config.readerUsage;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getRedstoneStrength() {
 | 
				
			||||||
 | 
					        return holder.world().getRedstonePower(holder.pos().offset(holder.getDirection()), holder.getDirection());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getTitle() {
 | 
				
			||||||
 | 
					        return "gui.refinedstorage:reader";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getChannel() {
 | 
				
			||||||
 | 
					        return channel;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setChannel(String channel) {
 | 
				
			||||||
 | 
					        this.channel = channel;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<String> getChannelParameter() {
 | 
				
			||||||
 | 
					        return TileReader.CHANNEL;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean hasConnectivityState() {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void read(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.read(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_CHANNEL)) {
 | 
				
			||||||
 | 
					            channel = tag.getString(NBT_CHANNEL);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.write(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setString(NBT_CHANNEL, channel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void onOpened(EntityPlayer entity) {
 | 
				
			||||||
 | 
					        if (network != null) {
 | 
				
			||||||
 | 
					            network.sendReaderWriterChannelUpdate((EntityPlayerMP) entity);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
 | 
				
			||||||
 | 
					import net.minecraft.util.EnumFacing;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeRelay extends NetworkNode {
 | 
				
			||||||
 | 
					    public NetworkNodeRelay(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        setRedstoneMode(RedstoneMode.LOW);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        rebuildOnUpdateChange = true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        return getRedstoneMode() == RedstoneMode.IGNORE ? 0 : RS.INSTANCE.config.relayUsage;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean canConduct(@Nullable EnumFacing direction) {
 | 
				
			||||||
 | 
					        return canUpdate();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean hasConnectivityState() {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,174 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSItems;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.security.ISecurityCard;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.security.ISecurityCardContainer;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.security.Permission;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.security.SecurityCard;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerChangeListenerNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemValidatorBasic;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.item.ItemSecurityCard;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.IItemHandler;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.wrapper.CombinedInvWrapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nullable;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.UUID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeSecurityManager extends NetworkNode implements ISecurityCardContainer {
 | 
				
			||||||
 | 
					    private static final String NBT_OWNER = "Owner";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private List<ISecurityCard> actualCards = new ArrayList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic cards = new ItemHandlerBasic(9 * 2, new ItemHandlerChangeListenerNode(this), new ItemValidatorBasic(RSItems.SECURITY_CARD)) {
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        protected void onContentsChanged(int slot) {
 | 
				
			||||||
 | 
					            super.onContentsChanged(slot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!holder.world().isRemote) {
 | 
				
			||||||
 | 
					                rebuildCards();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (network != null) {
 | 
				
			||||||
 | 
					                network.getSecurityManager().rebuild();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    private ItemHandlerBasic editCard = new ItemHandlerBasic(1, new ItemHandlerChangeListenerNode(this), new ItemValidatorBasic(RSItems.SECURITY_CARD));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nullable
 | 
				
			||||||
 | 
					    private UUID owner;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeSecurityManager(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        int usage = RS.INSTANCE.config.securityManagerUsage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i = 0; i < cards.getSlots(); ++i) {
 | 
				
			||||||
 | 
					            if (!cards.getStackInSlot(i).isEmpty()) {
 | 
				
			||||||
 | 
					                usage += RS.INSTANCE.config.securityManagerPerSecurityCardUsage;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return usage;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void update() {
 | 
				
			||||||
 | 
					        super.update();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (ticks == 1) {
 | 
				
			||||||
 | 
					            rebuildCards();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setOwner(@Nullable UUID owner) {
 | 
				
			||||||
 | 
					        this.owner = owner;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nullable
 | 
				
			||||||
 | 
					    public UUID getOwner() {
 | 
				
			||||||
 | 
					        return owner;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void rebuildCards() {
 | 
				
			||||||
 | 
					        actualCards.clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i = 0; i < cards.getSlots(); ++i) {
 | 
				
			||||||
 | 
					            ItemStack stack = cards.getStackInSlot(i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!stack.isEmpty()) {
 | 
				
			||||||
 | 
					                UUID uuid = ItemSecurityCard.getOwner(stack);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (uuid == null) {
 | 
				
			||||||
 | 
					                    continue;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                SecurityCard card = new SecurityCard(uuid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                for (Permission permission : Permission.values()) {
 | 
				
			||||||
 | 
					                    card.getPermissions().put(permission, ItemSecurityCard.hasPermission(stack, permission));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                actualCards.add(card);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void read(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.read(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_OWNER)) {
 | 
				
			||||||
 | 
					            owner = UUID.fromString(tag.getString(NBT_OWNER));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(cards, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(editCard, 1, tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.write(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (owner != null) {
 | 
				
			||||||
 | 
					            tag.setString(NBT_OWNER, owner.toString());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(cards, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(editCard, 1, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onConnectedStateChange(INetworkMaster network, boolean state) {
 | 
				
			||||||
 | 
					        super.onConnectedStateChange(network, state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        network.getSecurityManager().rebuild();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ItemHandlerBasic getCardsItems() {
 | 
				
			||||||
 | 
					        return cards;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ItemHandlerBasic getEditCard() {
 | 
				
			||||||
 | 
					        return editCard;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void updatePermission(Permission permission, boolean state) {
 | 
				
			||||||
 | 
					        ItemStack card = getEditCard().getStackInSlot(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!card.isEmpty()) {
 | 
				
			||||||
 | 
					            ItemSecurityCard.setPermission(card, permission, state);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<ISecurityCard> getCards() {
 | 
				
			||||||
 | 
					        return actualCards;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getDrops() {
 | 
				
			||||||
 | 
					        return new CombinedInvWrapper(cards, editCard);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean hasConnectivityState() {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,188 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRecipe;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.API;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerChangeListenerNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.IItemHandler;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.wrapper.CombinedInvWrapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nonnull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeSolderer extends NetworkNode {
 | 
				
			||||||
 | 
					    private static final String NBT_WORKING = "Working";
 | 
				
			||||||
 | 
					    private static final String NBT_PROGRESS = "Progress";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic items = new ItemHandlerBasic(3, new ItemHandlerChangeListenerNode(this)) {
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        @Nonnull
 | 
				
			||||||
 | 
					        public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
 | 
				
			||||||
 | 
					            for (ISoldererRecipe recipe : API.instance().getSoldererRegistry().getRecipes()) {
 | 
				
			||||||
 | 
					                if (API.instance().getComparer().isEqualNoQuantity(recipe.getRow(slot), stack) || API.instance().getComparer().isEqualOredict(recipe.getRow(slot), stack)) {
 | 
				
			||||||
 | 
					                    return super.insertItem(slot, stack, simulate);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return stack;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    private ItemHandlerBasic result = new ItemHandlerBasic(1, new ItemHandlerChangeListenerNode(this)) {
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        @Nonnull
 | 
				
			||||||
 | 
					        public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
 | 
				
			||||||
 | 
					            return stack;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerChangeListenerNode(this), ItemUpgrade.TYPE_SPEED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ISoldererRecipe recipe;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private boolean working = false;
 | 
				
			||||||
 | 
					    private int progress = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeSolderer(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        return RS.INSTANCE.config.soldererUsage + upgrades.getEnergyUsage();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void update() {
 | 
				
			||||||
 | 
					        if (network == null) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (items.getStackInSlot(1).isEmpty() && items.getStackInSlot(2).isEmpty() && result.getStackInSlot(0).isEmpty()) {
 | 
				
			||||||
 | 
					            stop();
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            ISoldererRecipe newRecipe = API.instance().getSoldererRegistry().getRecipe(items);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (newRecipe == null) {
 | 
				
			||||||
 | 
					                stop();
 | 
				
			||||||
 | 
					            } else if (newRecipe != recipe) {
 | 
				
			||||||
 | 
					                boolean sameItem = !result.getStackInSlot(0).isEmpty() && API.instance().getComparer().isEqualNoQuantity(result.getStackInSlot(0), newRecipe.getResult());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (result.getStackInSlot(0).isEmpty() || (sameItem && ((result.getStackInSlot(0).getCount() + newRecipe.getResult().getCount()) <= result.getStackInSlot(0).getMaxStackSize()))) {
 | 
				
			||||||
 | 
					                    recipe = newRecipe;
 | 
				
			||||||
 | 
					                    progress = 0;
 | 
				
			||||||
 | 
					                    working = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    markDirty();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } else if (working) {
 | 
				
			||||||
 | 
					                progress += 1 + upgrades.getUpgradeCount(ItemUpgrade.TYPE_SPEED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (progress >= recipe.getDuration()) {
 | 
				
			||||||
 | 
					                    if (!result.getStackInSlot(0).isEmpty()) {
 | 
				
			||||||
 | 
					                        result.getStackInSlot(0).grow(recipe.getResult().getCount());
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        result.setStackInSlot(0, recipe.getResult().copy());
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    for (int i = 0; i < 3; ++i) {
 | 
				
			||||||
 | 
					                        if (recipe.getRow(i) != null) {
 | 
				
			||||||
 | 
					                            items.extractItem(i, recipe.getRow(i).getCount(), false);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    recipe = null;
 | 
				
			||||||
 | 
					                    progress = 0;
 | 
				
			||||||
 | 
					                    // Don't set working to false yet, wait till the next update because we may have another stack waiting.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    markDirty();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onConnectedStateChange(INetworkMaster network, boolean state) {
 | 
				
			||||||
 | 
					        super.onConnectedStateChange(network, state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!state) {
 | 
				
			||||||
 | 
					            stop();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void stop() {
 | 
				
			||||||
 | 
					        progress = 0;
 | 
				
			||||||
 | 
					        working = false;
 | 
				
			||||||
 | 
					        recipe = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void read(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.read(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(items, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(upgrades, 1, tag);
 | 
				
			||||||
 | 
					        RSUtils.readItems(result, 2, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        recipe = API.instance().getSoldererRegistry().getRecipe(items);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_WORKING)) {
 | 
				
			||||||
 | 
					            working = tag.getBoolean(NBT_WORKING);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_PROGRESS)) {
 | 
				
			||||||
 | 
					            progress = tag.getInteger(NBT_PROGRESS);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.write(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(items, 0, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(upgrades, 1, tag);
 | 
				
			||||||
 | 
					        RSUtils.writeItems(result, 2, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setBoolean(NBT_WORKING, working);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_PROGRESS, progress);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ItemHandlerBasic getItems() {
 | 
				
			||||||
 | 
					        return items;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ItemHandlerBasic getResult() {
 | 
				
			||||||
 | 
					        return result;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IItemHandler getUpgrades() {
 | 
				
			||||||
 | 
					        return upgrades;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ISoldererRecipe getRecipe() {
 | 
				
			||||||
 | 
					        return recipe;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean isWorking() {
 | 
				
			||||||
 | 
					        return working;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getProgress() {
 | 
				
			||||||
 | 
					        return progress;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getDrops() {
 | 
				
			||||||
 | 
					        return new CombinedInvWrapper(items, result, upgrades);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,333 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					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.IStorage;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.util.IComparer;
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerChangeListenerNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.IStorageGui;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.TileStorage;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.config.*;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraftforge.fluids.FluidStack;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.ItemHandlerHelper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nonnull;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeStorage extends NetworkNode implements IStorageGui, IStorageProvider, IComparable, IFilterable, IPrioritizable, IExcessVoidable, IAccessType {
 | 
				
			||||||
 | 
					    class StorageItem extends StorageItemNBT {
 | 
				
			||||||
 | 
					        public StorageItem() {
 | 
				
			||||||
 | 
					            super(NetworkNodeStorage.this.getStorageTag(), NetworkNodeStorage.this.getCapacity(), NetworkNodeStorage.this);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public int getPriority() {
 | 
				
			||||||
 | 
					            return priority;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public ItemStack insert(@Nonnull ItemStack stack, int size, boolean simulate) {
 | 
				
			||||||
 | 
					            if (!IFilterable.canTake(filters, mode, compare, stack)) {
 | 
				
			||||||
 | 
					                return ItemHandlerHelper.copyStackWithSize(stack, size);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return super.insert(stack, size, simulate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public AccessType getAccessType() {
 | 
				
			||||||
 | 
					            return accessType;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public boolean isVoiding() {
 | 
				
			||||||
 | 
					            return voidExcess;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static final String NBT_STORAGE = "Storage";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static final String NBT_PRIORITY = "Priority";
 | 
				
			||||||
 | 
					    private static final String NBT_COMPARE = "Compare";
 | 
				
			||||||
 | 
					    private static final String NBT_MODE = "Mode";
 | 
				
			||||||
 | 
					    private static final String NBT_VOID_EXCESS = "VoidExcess";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ItemHandlerBasic filters = new ItemHandlerBasic(9, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private NBTTagCompound storageTag = StorageItemNBT.createNBT();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private StorageItem storage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private EnumItemStorageType type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private AccessType accessType = AccessType.INSERT_EXTRACT;
 | 
				
			||||||
 | 
					    private int priority = 0;
 | 
				
			||||||
 | 
					    private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
 | 
				
			||||||
 | 
					    private int mode = IFilterable.WHITELIST;
 | 
				
			||||||
 | 
					    private boolean voidExcess = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeStorage(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        return RS.INSTANCE.config.storageUsage;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void update() {
 | 
				
			||||||
 | 
					        super.update();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (storage == null && storageTag != null) {
 | 
				
			||||||
 | 
					            storage = new StorageItem();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (network != null) {
 | 
				
			||||||
 | 
					                network.getItemStorageCache().invalidate();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void onBreak() {
 | 
				
			||||||
 | 
					        if (storage != null) {
 | 
				
			||||||
 | 
					            storage.writeToNBT();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onConnectedStateChange(INetworkMaster network, boolean state) {
 | 
				
			||||||
 | 
					        super.onConnectedStateChange(network, state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        network.getItemStorageCache().invalidate();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_STORAGE)) {
 | 
				
			||||||
 | 
					            storageTag = tag.getCompoundTag(NBT_STORAGE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.write(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (storage != null) {
 | 
				
			||||||
 | 
					            storage.writeToNBT();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setTag(NBT_STORAGE, storageTag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.writeConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(filters, 0, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_PRIORITY, priority);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_COMPARE, compare);
 | 
				
			||||||
 | 
					        tag.setInteger(NBT_MODE, mode);
 | 
				
			||||||
 | 
					        tag.setBoolean(NBT_VOID_EXCESS, voidExcess);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeAccessType(tag, accessType);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void readConfiguration(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.readConfiguration(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(filters, 0, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_PRIORITY)) {
 | 
				
			||||||
 | 
					            priority = tag.getInteger(NBT_PRIORITY);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_COMPARE)) {
 | 
				
			||||||
 | 
					            compare = tag.getInteger(NBT_COMPARE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_MODE)) {
 | 
				
			||||||
 | 
					            mode = tag.getInteger(NBT_MODE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_VOID_EXCESS)) {
 | 
				
			||||||
 | 
					            voidExcess = tag.getBoolean(NBT_VOID_EXCESS);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        accessType = RSUtils.readAccessType(tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public EnumItemStorageType getType() {
 | 
				
			||||||
 | 
					        if (type == null && holder.world().getBlockState(holder.pos()).getBlock() == RSBlocks.STORAGE) {
 | 
				
			||||||
 | 
					            type = ((EnumItemStorageType) holder.world().getBlockState(holder.pos()).getValue(BlockStorage.TYPE));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return type == null ? EnumItemStorageType.TYPE_1K : type;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getCompare() {
 | 
				
			||||||
 | 
					        return compare;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setCompare(int compare) {
 | 
				
			||||||
 | 
					        this.compare = compare;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getMode() {
 | 
				
			||||||
 | 
					        return mode;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setMode(int mode) {
 | 
				
			||||||
 | 
					        this.mode = mode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean getVoidExcess() {
 | 
				
			||||||
 | 
					        return voidExcess;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setVoidExcess(boolean voidExcess) {
 | 
				
			||||||
 | 
					        this.voidExcess = voidExcess;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NBTTagCompound getStorageTag() {
 | 
				
			||||||
 | 
					        return storageTag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setStorageTag(NBTTagCompound storageTag) {
 | 
				
			||||||
 | 
					        this.storageTag = storageTag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public StorageItemNBT getStorage() {
 | 
				
			||||||
 | 
					        return storage;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ItemHandlerBasic getFilters() {
 | 
				
			||||||
 | 
					        return filters;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getGuiTitle() {
 | 
				
			||||||
 | 
					        return "block.refinedstorage:storage." + getType().getId() + ".name";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Integer> getTypeParameter() {
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Integer> getRedstoneModeParameter() {
 | 
				
			||||||
 | 
					        return TileStorage.REDSTONE_MODE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Integer> getCompareParameter() {
 | 
				
			||||||
 | 
					        return TileStorage.COMPARE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Integer> getFilterParameter() {
 | 
				
			||||||
 | 
					        return TileStorage.MODE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Integer> getPriorityParameter() {
 | 
				
			||||||
 | 
					        return TileStorage.PRIORITY;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<Boolean> getVoidExcessParameter() {
 | 
				
			||||||
 | 
					        return TileStorage.VOID_EXCESS;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<AccessType> getAccessTypeParameter() {
 | 
				
			||||||
 | 
					        return TileStorage.ACCESS_TYPE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getVoidExcessType() {
 | 
				
			||||||
 | 
					        return "items";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getStored() {
 | 
				
			||||||
 | 
					        return TileStorage.STORED.getValue();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getCapacity() {
 | 
				
			||||||
 | 
					        return getType().getCapacity();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public AccessType getAccessType() {
 | 
				
			||||||
 | 
					        return accessType;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setAccessType(AccessType value) {
 | 
				
			||||||
 | 
					        this.accessType = value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (network != null) {
 | 
				
			||||||
 | 
					            network.getItemStorageCache().invalidate();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getPriority() {
 | 
				
			||||||
 | 
					        return priority;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setPriority(int priority) {
 | 
				
			||||||
 | 
					        this.priority = priority;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,84 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.IWirelessTransmitter;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerChangeListenerNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraft.util.EnumFacing;
 | 
				
			||||||
 | 
					import net.minecraft.util.math.BlockPos;
 | 
				
			||||||
 | 
					import net.minecraftforge.items.IItemHandler;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeWirelessTransmitter extends NetworkNode implements IWirelessTransmitter {
 | 
				
			||||||
 | 
					    private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerChangeListenerNode(this), ItemUpgrade.TYPE_RANGE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeWirelessTransmitter(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        return RS.INSTANCE.config.wirelessTransmitterUsage + upgrades.getEnergyUsage();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void read(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.read(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.readItems(upgrades, 0, tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.write(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RSUtils.writeItems(upgrades, 0, tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getRange() {
 | 
				
			||||||
 | 
					        return RS.INSTANCE.config.wirelessTransmitterBaseRange + (upgrades.getUpgradeCount(ItemUpgrade.TYPE_RANGE) * RS.INSTANCE.config.wirelessTransmitterRangePerUpgrade);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public BlockPos getOrigin() {
 | 
				
			||||||
 | 
					        return holder.pos();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getDimension() {
 | 
				
			||||||
 | 
					        return holder.world().provider.getDimension();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ItemHandlerBasic getUpgrades() {
 | 
				
			||||||
 | 
					        return upgrades;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public IItemHandler getDrops() {
 | 
				
			||||||
 | 
					        return upgrades;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean canConduct(@Nullable EnumFacing direction) {
 | 
				
			||||||
 | 
					        return direction != null && EnumFacing.DOWN.equals(direction);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean hasConnectivityState() {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void walkNeighborhood(Operator operator) {
 | 
				
			||||||
 | 
					        operator.apply(holder.world(), holder.pos().offset(EnumFacing.DOWN), EnumFacing.UP);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,127 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterChannel;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterHandler;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.readerwriter.IWriter;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.TileWriter;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
 | 
				
			||||||
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
 | 
					import net.minecraft.entity.player.EntityPlayerMP;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraft.util.EnumFacing;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkNodeWriter extends NetworkNode implements IWriter {
 | 
				
			||||||
 | 
					    private static final String NBT_CHANNEL = "Channel";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private String channel = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int redstoneStrength;
 | 
				
			||||||
 | 
					    private int lastRedstoneStrength;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkNodeWriter(INetworkNodeHolder holder) {
 | 
				
			||||||
 | 
					        super(holder);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
 | 
					        return RS.INSTANCE.config.writerUsage;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void update() {
 | 
				
			||||||
 | 
					        super.update();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (getRedstoneStrength() != lastRedstoneStrength) {
 | 
				
			||||||
 | 
					            lastRedstoneStrength = getRedstoneStrength();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            holder.world().notifyNeighborsOfStateChange(holder.pos(), RSBlocks.WRITER, true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getRedstoneStrength() {
 | 
				
			||||||
 | 
					        return network != null ? redstoneStrength : 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setRedstoneStrength(int strength) {
 | 
				
			||||||
 | 
					        redstoneStrength = strength;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // @todo
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public EnumFacing getDirection() {
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getTitle() {
 | 
				
			||||||
 | 
					        return "gui.refinedstorage:writer";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getChannel() {
 | 
				
			||||||
 | 
					        return channel;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setChannel(String channel) {
 | 
				
			||||||
 | 
					        if (network != null && channel.equals("")) {
 | 
				
			||||||
 | 
					            IReaderWriterChannel networkChannel = network.getReaderWriterChannel(this.channel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (networkChannel != null) {
 | 
				
			||||||
 | 
					                for (IReaderWriterHandler handler : networkChannel.getHandlers()) {
 | 
				
			||||||
 | 
					                    handler.onWriterDisabled(this);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.channel = channel;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TileDataParameter<String> getChannelParameter() {
 | 
				
			||||||
 | 
					        return TileWriter.CHANNEL;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean hasConnectivityState() {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void read(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.read(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tag.hasKey(NBT_CHANNEL)) {
 | 
				
			||||||
 | 
					            channel = tag.getString(NBT_CHANNEL);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public NBTTagCompound write(NBTTagCompound tag) {
 | 
				
			||||||
 | 
					        super.write(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tag.setString(NBT_CHANNEL, channel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // @todo
 | 
				
			||||||
 | 
					    /*
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setDirection(EnumFacing direction) {
 | 
				
			||||||
 | 
					        super.setDirection(direction);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        world.notifyNeighborsOfStateChange(pos, RSBlocks.WRITER, true);
 | 
				
			||||||
 | 
					    }*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void onOpened(EntityPlayer entity) {
 | 
				
			||||||
 | 
					        if (network != null) {
 | 
				
			||||||
 | 
					            network.sendReaderWriterChannelUpdate((EntityPlayerMP) entity);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.tile.externalstorage;
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node.externalstorage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
 | 
					import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
 | 
				
			||||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
 | 
					import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
 | 
				
			||||||
@@ -9,16 +9,18 @@ import com.raoulvdberge.refinedstorage.api.storage.AccessType;
 | 
				
			|||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
 | 
					import com.raoulvdberge.refinedstorage.api.storage.IStorage;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
 | 
					import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
 | 
					import com.raoulvdberge.refinedstorage.api.util.IComparer;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerChangeListenerNode;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
 | 
					import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.INetworkNodeHolder;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.IStorageGui;
 | 
					import com.raoulvdberge.refinedstorage.tile.IStorageGui;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.TileExternalStorage;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileNode;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileNode;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.config.*;
 | 
					import com.raoulvdberge.refinedstorage.tile.config.*;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
 | 
					 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
 | 
					import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
 | 
				
			||||||
import net.minecraft.item.ItemStack;
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
import net.minecraft.nbt.NBTTagCompound;
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
import net.minecraft.network.datasync.DataSerializers;
 | 
					 | 
				
			||||||
import net.minecraft.tileentity.TileEntity;
 | 
					import net.minecraft.tileentity.TileEntity;
 | 
				
			||||||
import net.minecraftforge.fluids.FluidStack;
 | 
					import net.minecraftforge.fluids.FluidStack;
 | 
				
			||||||
import net.minecraftforge.fluids.capability.IFluidHandler;
 | 
					import net.minecraftforge.fluids.capability.IFluidHandler;
 | 
				
			||||||
@@ -29,72 +31,27 @@ import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
 | 
				
			|||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class TileExternalStorage extends TileNode implements IStorageProvider, IStorageGui, IComparable, IFilterable, IPrioritizable, IType, IAccessType {
 | 
					public class NetworkNodeExternalStorage extends NetworkNode 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();
 | 
					 | 
				
			||||||
    public static final TileDataParameter<Integer> TYPE = IType.createParameter();
 | 
					 | 
				
			||||||
    public static final TileDataParameter<AccessType> ACCESS_TYPE = IAccessType.createParameter();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public static final TileDataParameter<Integer> STORED = new TileDataParameter<>(DataSerializers.VARINT, 0, new ITileDataProducer<Integer, TileExternalStorage>() {
 | 
					 | 
				
			||||||
        @Override
 | 
					 | 
				
			||||||
        public Integer getValue(TileExternalStorage tile) {
 | 
					 | 
				
			||||||
            int stored = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            for (StorageItemExternal storage : tile.itemStorages) {
 | 
					 | 
				
			||||||
                stored += storage.getStored();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            for (StorageFluidExternal storage : tile.fluidStorages) {
 | 
					 | 
				
			||||||
                stored += storage.getStored();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            return stored;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public static final TileDataParameter<Integer> CAPACITY = new TileDataParameter<>(DataSerializers.VARINT, 0, new ITileDataProducer<Integer, TileExternalStorage>() {
 | 
					 | 
				
			||||||
        @Override
 | 
					 | 
				
			||||||
        public Integer getValue(TileExternalStorage tile) {
 | 
					 | 
				
			||||||
            int capacity = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            for (StorageItemExternal storage : tile.itemStorages) {
 | 
					 | 
				
			||||||
                capacity += storage.getCapacity();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            for (StorageFluidExternal storage : tile.fluidStorages) {
 | 
					 | 
				
			||||||
                capacity += storage.getCapacity();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            return capacity;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private static final String NBT_PRIORITY = "Priority";
 | 
					    private static final String NBT_PRIORITY = "Priority";
 | 
				
			||||||
    private static final String NBT_COMPARE = "Compare";
 | 
					    private static final String NBT_COMPARE = "Compare";
 | 
				
			||||||
    private static final String NBT_MODE = "Mode";
 | 
					    private static final String NBT_MODE = "Mode";
 | 
				
			||||||
    private static final String NBT_TYPE = "Type";
 | 
					    private static final String NBT_TYPE = "Type";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private ItemHandlerBasic itemFilters = new ItemHandlerBasic(9, this);
 | 
					    private ItemHandlerBasic itemFilters = new ItemHandlerBasic(9, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
    private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, this);
 | 
					    private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, new ItemHandlerChangeListenerNode(this));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private int priority = 0;
 | 
					    private int priority = 0;
 | 
				
			||||||
    private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
 | 
					    private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
 | 
				
			||||||
    private int mode = IFilterable.WHITELIST;
 | 
					    private int mode = IFilterable.WHITELIST;
 | 
				
			||||||
    private int type = IType.ITEMS;
 | 
					    private int type = IType.ITEMS;
 | 
				
			||||||
    private AccessType accessType = AccessType.INSERT_EXTRACT;
 | 
					    private AccessType accessType = AccessType.INSERT_EXTRACT;
 | 
				
			||||||
 | 
					    private int networkTicks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private List<StorageItemExternal> itemStorages = new ArrayList<>();
 | 
					    private List<StorageItemExternal> itemStorages = new ArrayList<>();
 | 
				
			||||||
    private List<StorageFluidExternal> fluidStorages = new ArrayList<>();
 | 
					    private List<StorageFluidExternal> fluidStorages = new ArrayList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public TileExternalStorage() {
 | 
					    public NetworkNodeExternalStorage(INetworkNodeHolder holder) {
 | 
				
			||||||
        dataManager.addWatchedParameter(PRIORITY);
 | 
					        super(holder);
 | 
				
			||||||
        dataManager.addWatchedParameter(COMPARE);
 | 
					 | 
				
			||||||
        dataManager.addWatchedParameter(MODE);
 | 
					 | 
				
			||||||
        dataManager.addWatchedParameter(STORED);
 | 
					 | 
				
			||||||
        dataManager.addWatchedParameter(CAPACITY);
 | 
					 | 
				
			||||||
        dataManager.addWatchedParameter(TYPE);
 | 
					 | 
				
			||||||
        dataManager.addWatchedParameter(ACCESS_TYPE);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -103,12 +60,8 @@ public class TileExternalStorage extends TileNode implements IStorageProvider, I
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void updateNode() {
 | 
					    public void onConnectedStateChange(INetworkMaster network, boolean state) {
 | 
				
			||||||
    }
 | 
					        super.onConnectedStateChange(network, state);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Override
 | 
					 | 
				
			||||||
    public void onConnectionChange(INetworkMaster network, boolean state) {
 | 
					 | 
				
			||||||
        super.onConnectionChange(network, state);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        updateStorage(network);
 | 
					        updateStorage(network);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -116,11 +69,11 @@ public class TileExternalStorage extends TileNode implements IStorageProvider, I
 | 
				
			|||||||
        network.getFluidStorageCache().invalidate();
 | 
					        network.getFluidStorageCache().invalidate();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private int networkTicks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void update() {
 | 
					    public void update() {
 | 
				
			||||||
        if (!getWorld().isRemote && network != null) {
 | 
					        super.update();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (network != null) {
 | 
				
			||||||
            if (networkTicks++ == 0) {
 | 
					            if (networkTicks++ == 0) {
 | 
				
			||||||
                updateStorage(network);
 | 
					                updateStorage(network);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -143,8 +96,6 @@ public class TileExternalStorage extends TileNode implements IStorageProvider, I
 | 
				
			|||||||
                network.getFluidStorageCache().invalidate();
 | 
					                network.getFluidStorageCache().invalidate();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        super.update();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -230,7 +181,7 @@ public class TileExternalStorage extends TileNode implements IStorageProvider, I
 | 
				
			|||||||
        itemStorages.clear();
 | 
					        itemStorages.clear();
 | 
				
			||||||
        fluidStorages.clear();
 | 
					        fluidStorages.clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        TileEntity facing = getFacingTile();
 | 
					        TileEntity facing = holder.world().getTileEntity(holder.pos().offset(holder.getDirection()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (type == IType.ITEMS) {
 | 
					        if (type == IType.ITEMS) {
 | 
				
			||||||
            if (facing instanceof IDrawerGroup) {
 | 
					            if (facing instanceof IDrawerGroup) {
 | 
				
			||||||
@@ -240,14 +191,14 @@ public class TileExternalStorage extends TileNode implements IStorageProvider, I
 | 
				
			|||||||
            } else if (facing instanceof IDeepStorageUnit) {
 | 
					            } else if (facing instanceof IDeepStorageUnit) {
 | 
				
			||||||
                itemStorages.add(new StorageItemDSU(this, (IDeepStorageUnit) facing));
 | 
					                itemStorages.add(new StorageItemDSU(this, (IDeepStorageUnit) facing));
 | 
				
			||||||
            } else if (!(facing instanceof TileNode)) {
 | 
					            } else if (!(facing instanceof TileNode)) {
 | 
				
			||||||
                IItemHandler itemHandler = RSUtils.getItemHandler(facing, getDirection().getOpposite());
 | 
					                IItemHandler itemHandler = RSUtils.getItemHandler(facing, holder.getDirection().getOpposite());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (itemHandler != null) {
 | 
					                if (itemHandler != null) {
 | 
				
			||||||
                    itemStorages.add(new StorageItemItemHandler(this, itemHandler));
 | 
					                    itemStorages.add(new StorageItemItemHandler(this, itemHandler));
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else if (type == IType.FLUIDS) {
 | 
					        } else if (type == IType.FLUIDS) {
 | 
				
			||||||
            IFluidHandler fluidHandler = RSUtils.getFluidHandler(facing, getDirection().getOpposite());
 | 
					            IFluidHandler fluidHandler = RSUtils.getFluidHandler(facing, holder.getDirection().getOpposite());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (fluidHandler != null) {
 | 
					            if (fluidHandler != null) {
 | 
				
			||||||
                for (IFluidTankProperties property : fluidHandler.getTankProperties()) {
 | 
					                for (IFluidTankProperties property : fluidHandler.getTankProperties()) {
 | 
				
			||||||
@@ -277,22 +228,22 @@ public class TileExternalStorage extends TileNode implements IStorageProvider, I
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public TileDataParameter<Integer> getRedstoneModeParameter() {
 | 
					    public TileDataParameter<Integer> getRedstoneModeParameter() {
 | 
				
			||||||
        return REDSTONE_MODE;
 | 
					        return TileExternalStorage.REDSTONE_MODE;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public TileDataParameter<Integer> getCompareParameter() {
 | 
					    public TileDataParameter<Integer> getCompareParameter() {
 | 
				
			||||||
        return COMPARE;
 | 
					        return TileExternalStorage.COMPARE;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public TileDataParameter<Integer> getFilterParameter() {
 | 
					    public TileDataParameter<Integer> getFilterParameter() {
 | 
				
			||||||
        return MODE;
 | 
					        return TileExternalStorage.MODE;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public TileDataParameter<Integer> getPriorityParameter() {
 | 
					    public TileDataParameter<Integer> getPriorityParameter() {
 | 
				
			||||||
        return PRIORITY;
 | 
					        return TileExternalStorage.PRIORITY;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -302,7 +253,7 @@ public class TileExternalStorage extends TileNode implements IStorageProvider, I
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public TileDataParameter<AccessType> getAccessTypeParameter() {
 | 
					    public TileDataParameter<AccessType> getAccessTypeParameter() {
 | 
				
			||||||
        return ACCESS_TYPE;
 | 
					        return TileExternalStorage.ACCESS_TYPE;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -312,12 +263,12 @@ public class TileExternalStorage extends TileNode implements IStorageProvider, I
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public int getStored() {
 | 
					    public int getStored() {
 | 
				
			||||||
        return STORED.getValue();
 | 
					        return TileExternalStorage.STORED.getValue();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public int getCapacity() {
 | 
					    public int getCapacity() {
 | 
				
			||||||
        return CAPACITY.getValue();
 | 
					        return TileExternalStorage.CAPACITY.getValue();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -339,12 +290,12 @@ public class TileExternalStorage extends TileNode implements IStorageProvider, I
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public TileDataParameter<Integer> getTypeParameter() {
 | 
					    public TileDataParameter<Integer> getTypeParameter() {
 | 
				
			||||||
        return TYPE;
 | 
					        return TileExternalStorage.TYPE;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public int getType() {
 | 
					    public int getType() {
 | 
				
			||||||
        return getWorld().isRemote ? TYPE.getValue() : type;
 | 
					        return holder.world().isRemote ? TileExternalStorage.TYPE.getValue() : type;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -370,4 +321,12 @@ public class TileExternalStorage extends TileNode implements IStorageProvider, I
 | 
				
			|||||||
    public ItemHandlerFluid getFluidFilters() {
 | 
					    public ItemHandlerFluid getFluidFilters() {
 | 
				
			||||||
        return fluidFilters;
 | 
					        return fluidFilters;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public List<StorageItemExternal> getItemStorages() {
 | 
				
			||||||
 | 
					        return itemStorages;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public List<StorageFluidExternal> getFluidStorages() {
 | 
				
			||||||
 | 
					        return fluidStorages;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.tile.externalstorage;
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node.externalstorage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSUtils;
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
 | 
					import com.raoulvdberge.refinedstorage.api.storage.AccessType;
 | 
				
			||||||
@@ -17,10 +17,10 @@ import javax.annotation.Nullable;
 | 
				
			|||||||
public class StorageFluidExternal implements IStorage<FluidStack> {
 | 
					public class StorageFluidExternal implements IStorage<FluidStack> {
 | 
				
			||||||
    private FluidStack cache;
 | 
					    private FluidStack cache;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private TileExternalStorage externalStorage;
 | 
					    private NetworkNodeExternalStorage externalStorage;
 | 
				
			||||||
    private IFluidHandler handler;
 | 
					    private IFluidHandler handler;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public StorageFluidExternal(TileExternalStorage externalStorage, IFluidHandler handler, IFluidTankProperties properties) {
 | 
					    public StorageFluidExternal(NetworkNodeExternalStorage externalStorage, IFluidHandler handler, IFluidTankProperties properties) {
 | 
				
			||||||
        this.externalStorage = externalStorage;
 | 
					        this.externalStorage = externalStorage;
 | 
				
			||||||
        this.handler = handler;
 | 
					        this.handler = handler;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.tile.externalstorage;
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node.externalstorage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSUtils;
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
 | 
					import com.raoulvdberge.refinedstorage.api.storage.AccessType;
 | 
				
			||||||
@@ -12,10 +12,10 @@ import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
 | 
				
			|||||||
import javax.annotation.Nonnull;
 | 
					import javax.annotation.Nonnull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class StorageItemDSU extends StorageItemExternal {
 | 
					public class StorageItemDSU extends StorageItemExternal {
 | 
				
			||||||
    private TileExternalStorage externalStorage;
 | 
					    private NetworkNodeExternalStorage externalStorage;
 | 
				
			||||||
    private IDeepStorageUnit unit;
 | 
					    private IDeepStorageUnit unit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public StorageItemDSU(TileExternalStorage externalStorage, IDeepStorageUnit unit) {
 | 
					    public StorageItemDSU(NetworkNodeExternalStorage externalStorage, IDeepStorageUnit unit) {
 | 
				
			||||||
        this.externalStorage = externalStorage;
 | 
					        this.externalStorage = externalStorage;
 | 
				
			||||||
        this.unit = unit;
 | 
					        this.unit = unit;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.tile.externalstorage;
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node.externalstorage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
 | 
					import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
 | 
				
			||||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable;
 | 
					import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable;
 | 
				
			||||||
@@ -13,10 +13,10 @@ import net.minecraftforge.items.ItemHandlerHelper;
 | 
				
			|||||||
import javax.annotation.Nonnull;
 | 
					import javax.annotation.Nonnull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class StorageItemDrawer extends StorageItemExternal {
 | 
					public class StorageItemDrawer extends StorageItemExternal {
 | 
				
			||||||
    private TileExternalStorage externalStorage;
 | 
					    private NetworkNodeExternalStorage externalStorage;
 | 
				
			||||||
    private IDrawer drawer;
 | 
					    private IDrawer drawer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public StorageItemDrawer(TileExternalStorage externalStorage, IDrawer drawer) {
 | 
					    public StorageItemDrawer(NetworkNodeExternalStorage externalStorage, IDrawer drawer) {
 | 
				
			||||||
        this.externalStorage = externalStorage;
 | 
					        this.externalStorage = externalStorage;
 | 
				
			||||||
        this.drawer = drawer;
 | 
					        this.drawer = drawer;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -64,7 +64,7 @@ public class StorageItemDrawer extends StorageItemExternal {
 | 
				
			|||||||
        return RSUtils.emptyNonNullList();
 | 
					        return RSUtils.emptyNonNullList();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static ItemStack insert(TileExternalStorage externalStorage, IDrawer drawer, @Nonnull ItemStack stack, int size, boolean simulate) {
 | 
					    public static ItemStack insert(NetworkNodeExternalStorage externalStorage, IDrawer drawer, @Nonnull ItemStack stack, int size, boolean simulate) {
 | 
				
			||||||
        if (IFilterable.canTake(externalStorage.getItemFilters(), externalStorage.getMode(), externalStorage.getCompare(), stack) && drawer.canItemBeStored(stack)) {
 | 
					        if (IFilterable.canTake(externalStorage.getItemFilters(), externalStorage.getMode(), externalStorage.getCompare(), stack) && drawer.canItemBeStored(stack)) {
 | 
				
			||||||
            int stored = drawer.getStoredItemCount();
 | 
					            int stored = drawer.getStoredItemCount();
 | 
				
			||||||
            int remainingSpace = drawer.getMaxCapacity(stack) - stored;
 | 
					            int remainingSpace = drawer.getMaxCapacity(stack) - stored;
 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.tile.externalstorage;
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node.externalstorage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
 | 
					import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
 | 
					import com.raoulvdberge.refinedstorage.api.storage.AccessType;
 | 
				
			||||||
@@ -9,10 +9,10 @@ import javax.annotation.Nonnull;
 | 
				
			|||||||
import javax.annotation.Nullable;
 | 
					import javax.annotation.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class StorageItemDrawerGroup extends StorageItemExternal {
 | 
					public class StorageItemDrawerGroup extends StorageItemExternal {
 | 
				
			||||||
    private TileExternalStorage externalStorage;
 | 
					    private NetworkNodeExternalStorage externalStorage;
 | 
				
			||||||
    private IDrawerGroup drawers;
 | 
					    private IDrawerGroup drawers;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public StorageItemDrawerGroup(TileExternalStorage externalStorage, IDrawerGroup drawers) {
 | 
					    public StorageItemDrawerGroup(NetworkNodeExternalStorage externalStorage, IDrawerGroup drawers) {
 | 
				
			||||||
        this.externalStorage = externalStorage;
 | 
					        this.externalStorage = externalStorage;
 | 
				
			||||||
        this.drawers = drawers;
 | 
					        this.drawers = drawers;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.tile.externalstorage;
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node.externalstorage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
 | 
					import com.raoulvdberge.refinedstorage.api.storage.AccessType;
 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.tile.externalstorage;
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.network.node.externalstorage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
 | 
					import com.raoulvdberge.refinedstorage.api.storage.AccessType;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.API;
 | 
				
			||||||
@@ -11,17 +11,19 @@ import net.minecraftforge.items.ItemHandlerHelper;
 | 
				
			|||||||
import javax.annotation.Nonnull;
 | 
					import javax.annotation.Nonnull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class StorageItemItemHandler extends StorageItemExternal {
 | 
					public class StorageItemItemHandler extends StorageItemExternal {
 | 
				
			||||||
    private TileExternalStorage externalStorage;
 | 
					    private NetworkNodeExternalStorage externalStorage;
 | 
				
			||||||
    private IItemHandler handler;
 | 
					    private IItemHandler handler;
 | 
				
			||||||
    private AccessType lockedAccessType = AccessType.INSERT_EXTRACT;
 | 
					    private AccessType lockedAccessType = AccessType.INSERT_EXTRACT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public StorageItemItemHandler(TileExternalStorage externalStorage, IItemHandler handler) {
 | 
					    public StorageItemItemHandler(NetworkNodeExternalStorage externalStorage, IItemHandler handler) {
 | 
				
			||||||
        this.externalStorage = externalStorage;
 | 
					        this.externalStorage = externalStorage;
 | 
				
			||||||
        this.handler = handler;
 | 
					        this.handler = handler;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // @todo
 | 
				
			||||||
 | 
					        /*
 | 
				
			||||||
        if (externalStorage.getFacingTile().getBlockType().getUnlocalizedName().equals("tile.ExtraUtils2:TrashCan")) {
 | 
					        if (externalStorage.getFacingTile().getBlockType().getUnlocalizedName().equals("tile.ExtraUtils2:TrashCan")) {
 | 
				
			||||||
            lockedAccessType = AccessType.INSERT;
 | 
					            lockedAccessType = AccessType.INSERT;
 | 
				
			||||||
        }
 | 
					        }*/
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -1,13 +1,13 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.apiimpl.storage;
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.storage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSUtils;
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
 | 
					import com.raoulvdberge.refinedstorage.api.storage.AccessType;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
 | 
					import com.raoulvdberge.refinedstorage.api.storage.IStorage;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.API;
 | 
				
			||||||
import net.minecraft.item.ItemStack;
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
import net.minecraft.nbt.NBTTagCompound;
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
import net.minecraft.nbt.NBTTagList;
 | 
					import net.minecraft.nbt.NBTTagList;
 | 
				
			||||||
import net.minecraft.tileentity.TileEntity;
 | 
					 | 
				
			||||||
import net.minecraft.util.NonNullList;
 | 
					import net.minecraft.util.NonNullList;
 | 
				
			||||||
import net.minecraftforge.fluids.FluidStack;
 | 
					import net.minecraftforge.fluids.FluidStack;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -31,19 +31,19 @@ public abstract class StorageFluidNBT implements IStorage<FluidStack> {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private NBTTagCompound tag;
 | 
					    private NBTTagCompound tag;
 | 
				
			||||||
    private int capacity;
 | 
					    private int capacity;
 | 
				
			||||||
    private TileEntity tile;
 | 
					    private INetworkNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private NonNullList<FluidStack> stacks = NonNullList.create();
 | 
					    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 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 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
 | 
					     * @param node     A {@link INetworkNode} that the NBT storage is in, will be marked dirty when the storage changes
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public StorageFluidNBT(NBTTagCompound tag, int capacity, @Nullable TileEntity tile) {
 | 
					    public StorageFluidNBT(NBTTagCompound tag, int capacity, @Nullable INetworkNode node) {
 | 
				
			||||||
        this.tag = tag;
 | 
					        this.tag = tag;
 | 
				
			||||||
        this.capacity = capacity;
 | 
					        this.capacity = capacity;
 | 
				
			||||||
        this.tile = tile;
 | 
					        this.node = node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        readFromNBT();
 | 
					        readFromNBT();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -178,8 +178,8 @@ public abstract class StorageFluidNBT implements IStorage<FluidStack> {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void onStorageChanged() {
 | 
					    public void onStorageChanged() {
 | 
				
			||||||
        if (tile != null) {
 | 
					        if (node != null) {
 | 
				
			||||||
            tile.markDirty();
 | 
					            node.markDirty();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.apiimpl.storage;
 | 
					package com.raoulvdberge.refinedstorage.apiimpl.storage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
 | 
					import com.raoulvdberge.refinedstorage.api.storage.AccessType;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
 | 
					import com.raoulvdberge.refinedstorage.api.storage.IStorage;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.API;
 | 
				
			||||||
@@ -7,7 +8,6 @@ import net.minecraft.item.Item;
 | 
				
			|||||||
import net.minecraft.item.ItemStack;
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
import net.minecraft.nbt.NBTTagCompound;
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
import net.minecraft.nbt.NBTTagList;
 | 
					import net.minecraft.nbt.NBTTagList;
 | 
				
			||||||
import net.minecraft.tileentity.TileEntity;
 | 
					 | 
				
			||||||
import net.minecraft.util.NonNullList;
 | 
					import net.minecraft.util.NonNullList;
 | 
				
			||||||
import net.minecraftforge.items.ItemHandlerHelper;
 | 
					import net.minecraftforge.items.ItemHandlerHelper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -37,19 +37,20 @@ public abstract class StorageItemNBT implements IStorage<ItemStack> {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private NBTTagCompound tag;
 | 
					    private NBTTagCompound tag;
 | 
				
			||||||
    private int capacity;
 | 
					    private int capacity;
 | 
				
			||||||
    private TileEntity tile;
 | 
					    @Nullable
 | 
				
			||||||
 | 
					    private INetworkNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private NonNullList<ItemStack> stacks = NonNullList.create();
 | 
					    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 StorageItemNBT#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 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
 | 
					     * @param node     A {@link INetworkNode} that the NBT storage is in, will be marked dirty when the storage changes
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public StorageItemNBT(NBTTagCompound tag, int capacity, @Nullable TileEntity tile) {
 | 
					    public StorageItemNBT(NBTTagCompound tag, int capacity, @Nullable INetworkNode node) {
 | 
				
			||||||
        this.tag = tag;
 | 
					        this.tag = tag;
 | 
				
			||||||
        this.capacity = capacity;
 | 
					        this.capacity = capacity;
 | 
				
			||||||
        this.tile = tile;
 | 
					        this.node = node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        readFromNBT();
 | 
					        readFromNBT();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -214,8 +215,8 @@ public abstract class StorageItemNBT implements IStorage<ItemStack> {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void onStorageChanged() {
 | 
					    public void onStorageChanged() {
 | 
				
			||||||
        if (tile != null) {
 | 
					        if (node != null) {
 | 
				
			||||||
            tile.markDirty();
 | 
					            node.markDirty();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,9 +3,10 @@ package com.raoulvdberge.refinedstorage.block;
 | 
				
			|||||||
import com.raoulvdberge.refinedstorage.RS;
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSUtils;
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkNodeProxy;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
 | 
					import com.raoulvdberge.refinedstorage.api.network.security.Permission;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.item.ItemBlockBase;
 | 
					import com.raoulvdberge.refinedstorage.item.ItemBlockBase;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.proxy.CapabilityNetworkNode;
 | 
					import com.raoulvdberge.refinedstorage.proxy.CapabilityNetworkNodeProxy;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileBase;
 | 
				
			||||||
import net.minecraft.block.Block;
 | 
					import net.minecraft.block.Block;
 | 
				
			||||||
import net.minecraft.block.material.Material;
 | 
					import net.minecraft.block.material.Material;
 | 
				
			||||||
@@ -96,7 +97,7 @@ public abstract class BlockBase extends Block {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            tile.setDirection(getPlacementType().cycle(tile.getDirection()));
 | 
					            tile.setDirection(getPlacementType().cycle(tile.getDirection()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            tile.updateBlock();
 | 
					            RSUtils.updateBlock(world, pos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -140,8 +141,9 @@ public abstract class BlockBase extends Block {
 | 
				
			|||||||
    protected boolean tryOpenNetworkGui(int guiId, EntityPlayer player, World world, BlockPos pos, EnumFacing facing, Permission... permissions) {
 | 
					    protected boolean tryOpenNetworkGui(int guiId, EntityPlayer player, World world, BlockPos pos, EnumFacing facing, Permission... permissions) {
 | 
				
			||||||
        TileEntity tile = world.getTileEntity(pos);
 | 
					        TileEntity tile = world.getTileEntity(pos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (tile != null && tile.hasCapability(CapabilityNetworkNode.NETWORK_NODE_CAPABILITY, facing)) {
 | 
					        if (tile != null && tile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing)) {
 | 
				
			||||||
            INetworkNode node = CapabilityNetworkNode.NETWORK_NODE_CAPABILITY.cast(tile.getCapability(CapabilityNetworkNode.NETWORK_NODE_CAPABILITY, facing));
 | 
					            INetworkNodeProxy nodeProxy = CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY.cast(tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing));
 | 
				
			||||||
 | 
					            INetworkNode node = nodeProxy.getNode();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (node.getNetwork() != null) {
 | 
					            if (node.getNetwork() != null) {
 | 
				
			||||||
                for (Permission permission : permissions) {
 | 
					                for (Permission permission : permissions) {
 | 
				
			||||||
@@ -163,8 +165,9 @@ public abstract class BlockBase extends Block {
 | 
				
			|||||||
    public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) {
 | 
					    public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) {
 | 
				
			||||||
        TileEntity tile = world.getTileEntity(pos);
 | 
					        TileEntity tile = world.getTileEntity(pos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (tile != null && tile.hasCapability(CapabilityNetworkNode.NETWORK_NODE_CAPABILITY, null)) {
 | 
					        if (tile != null && tile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, null)) {
 | 
				
			||||||
            INetworkNode node = tile.getCapability(CapabilityNetworkNode.NETWORK_NODE_CAPABILITY, null);
 | 
					            INetworkNodeProxy nodeProxy = tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, null);
 | 
				
			||||||
 | 
					            INetworkNode node = nodeProxy.getNode();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (node.getNetwork() != null) {
 | 
					            if (node.getNetwork() != null) {
 | 
				
			||||||
                if (!(entity instanceof EntityPlayer)) {
 | 
					                if (!(entity instanceof EntityPlayer)) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.block;
 | 
					package com.raoulvdberge.refinedstorage.block;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSUtils;
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.proxy.CapabilityNetworkNode;
 | 
					import com.raoulvdberge.refinedstorage.proxy.CapabilityNetworkNodeProxy;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileCable;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileCable;
 | 
				
			||||||
import net.minecraft.block.properties.PropertyBool;
 | 
					import net.minecraft.block.properties.PropertyBool;
 | 
				
			||||||
import net.minecraft.block.state.BlockStateContainer;
 | 
					import net.minecraft.block.state.BlockStateContainer;
 | 
				
			||||||
@@ -93,7 +93,7 @@ public class BlockCable extends BlockNode {
 | 
				
			|||||||
        TileEntity otherTile = world.getTileEntity(pos.offset(direction));
 | 
					        TileEntity otherTile = world.getTileEntity(pos.offset(direction));
 | 
				
			||||||
        EnumFacing otherTileSide = direction.getOpposite();
 | 
					        EnumFacing otherTileSide = direction.getOpposite();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return otherTile != null && otherTile.hasCapability(CapabilityNetworkNode.NETWORK_NODE_CAPABILITY, otherTileSide);
 | 
					        return otherTile != null && otherTile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, otherTileSide);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private boolean isInAABB(AxisAlignedBB aabb, float hitX, float hitY, float hitZ) {
 | 
					    private boolean isInAABB(AxisAlignedBB aabb, float hitX, float hitY, float hitZ) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.block;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSGui;
 | 
					import com.raoulvdberge.refinedstorage.RSGui;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
 | 
					import com.raoulvdberge.refinedstorage.api.network.security.Permission;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCraftingMonitor;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.craftingmonitor.TileCraftingMonitor;
 | 
					import com.raoulvdberge.refinedstorage.tile.craftingmonitor.TileCraftingMonitor;
 | 
				
			||||||
import net.minecraft.block.state.IBlockState;
 | 
					import net.minecraft.block.state.IBlockState;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
@@ -24,7 +25,7 @@ public class BlockCraftingMonitor extends BlockNode {
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
 | 
					    public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
 | 
				
			||||||
        if (!world.isRemote && tryOpenNetworkGui(RSGui.CRAFTING_MONITOR, player, world, pos, side, Permission.MODIFY, Permission.AUTOCRAFTING)) {
 | 
					        if (!world.isRemote && tryOpenNetworkGui(RSGui.CRAFTING_MONITOR, player, world, pos, side, Permission.MODIFY, Permission.AUTOCRAFTING)) {
 | 
				
			||||||
            ((TileCraftingMonitor) world.getTileEntity(pos)).onOpened(player);
 | 
					            ((NetworkNodeCraftingMonitor) ((TileCraftingMonitor) world.getTileEntity(pos)).getNode()).onOpened(player);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.block;
 | 
					package com.raoulvdberge.refinedstorage.block;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSGui;
 | 
					import com.raoulvdberge.refinedstorage.RSGui;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeDiskDrive;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.render.PropertyObject;
 | 
					import com.raoulvdberge.refinedstorage.render.PropertyObject;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileDiskDrive;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileDiskDrive;
 | 
				
			||||||
import net.minecraft.block.state.BlockStateContainer;
 | 
					import net.minecraft.block.state.BlockStateContainer;
 | 
				
			||||||
@@ -47,7 +48,7 @@ public class BlockDiskDrive extends BlockNode {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void breakBlock(World world, BlockPos pos, IBlockState state) {
 | 
					    public void breakBlock(World world, BlockPos pos, IBlockState state) {
 | 
				
			||||||
        ((TileDiskDrive) world.getTileEntity(pos)).onBreak();
 | 
					        ((NetworkNodeDiskDrive) ((TileDiskDrive) world.getTileEntity(pos)).getNode()).onBreak();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        super.breakBlock(world, pos, state);
 | 
					        super.breakBlock(world, pos, state);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.block;
 | 
					package com.raoulvdberge.refinedstorage.block;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSGui;
 | 
					import com.raoulvdberge.refinedstorage.RSGui;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeDiskManipulator;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.render.PropertyObject;
 | 
					import com.raoulvdberge.refinedstorage.render.PropertyObject;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileDiskManipulator;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileDiskManipulator;
 | 
				
			||||||
import net.minecraft.block.state.BlockStateContainer;
 | 
					import net.minecraft.block.state.BlockStateContainer;
 | 
				
			||||||
@@ -47,7 +48,7 @@ public class BlockDiskManipulator extends BlockNode {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void breakBlock(World world, BlockPos pos, IBlockState state) {
 | 
					    public void breakBlock(World world, BlockPos pos, IBlockState state) {
 | 
				
			||||||
        ((TileDiskManipulator) world.getTileEntity(pos)).onBreak();
 | 
					        ((NetworkNodeDiskManipulator) ((TileDiskManipulator) world.getTileEntity(pos)).getNode()).onBreak();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        super.breakBlock(world, pos, state);
 | 
					        super.breakBlock(world, pos, state);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,8 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.block;
 | 
					package com.raoulvdberge.refinedstorage.block;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSGui;
 | 
					import com.raoulvdberge.refinedstorage.RSGui;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.externalstorage.TileExternalStorage;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.externalstorage.NetworkNodeExternalStorage;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.tile.TileExternalStorage;
 | 
				
			||||||
import net.minecraft.block.Block;
 | 
					import net.minecraft.block.Block;
 | 
				
			||||||
import net.minecraft.block.state.IBlockState;
 | 
					import net.minecraft.block.state.IBlockState;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
@@ -85,9 +86,9 @@ public class BlockExternalStorage extends BlockCable {
 | 
				
			|||||||
        super.neighborChanged(state, world, pos, block, fromPos);
 | 
					        super.neighborChanged(state, world, pos, block, fromPos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!world.isRemote) {
 | 
					        if (!world.isRemote) {
 | 
				
			||||||
            TileExternalStorage externalStorage = (TileExternalStorage) world.getTileEntity(pos);
 | 
					            NetworkNodeExternalStorage externalStorage = (NetworkNodeExternalStorage) ((TileExternalStorage) world.getTileEntity(pos)).getNode();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (externalStorage.hasNetwork()) {
 | 
					            if (externalStorage.getNetwork() != null) {
 | 
				
			||||||
                externalStorage.updateStorage(externalStorage.getNetwork());
 | 
					                externalStorage.updateStorage(externalStorage.getNetwork());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.block;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
					import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSGui;
 | 
					import com.raoulvdberge.refinedstorage.RSGui;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeFluidStorage;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.item.ItemBlockFluidStorage;
 | 
					import com.raoulvdberge.refinedstorage.item.ItemBlockFluidStorage;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileFluidStorage;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileFluidStorage;
 | 
				
			||||||
import net.minecraft.block.properties.PropertyEnum;
 | 
					import net.minecraft.block.properties.PropertyEnum;
 | 
				
			||||||
@@ -75,14 +76,14 @@ public class BlockFluidStorage extends BlockNode {
 | 
				
			|||||||
    public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
 | 
					    public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
 | 
				
			||||||
        super.onBlockPlacedBy(world, pos, state, player, stack);
 | 
					        super.onBlockPlacedBy(world, pos, state, player, stack);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!world.isRemote && stack.hasTagCompound() && stack.getTagCompound().hasKey(TileFluidStorage.NBT_STORAGE)) {
 | 
					        if (!world.isRemote && stack.hasTagCompound() && stack.getTagCompound().hasKey(NetworkNodeFluidStorage.NBT_STORAGE)) {
 | 
				
			||||||
            ((TileFluidStorage) world.getTileEntity(pos)).setStorageTag(stack.getTagCompound().getCompoundTag(TileFluidStorage.NBT_STORAGE));
 | 
					            ((NetworkNodeFluidStorage) ((TileFluidStorage) world.getTileEntity(pos)).getNode()).setStorageTag(stack.getTagCompound().getCompoundTag(NetworkNodeFluidStorage.NBT_STORAGE));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void breakBlock(World world, BlockPos pos, IBlockState state) {
 | 
					    public void breakBlock(World world, BlockPos pos, IBlockState state) {
 | 
				
			||||||
        ((TileFluidStorage) world.getTileEntity(pos)).onBreak();
 | 
					        ((NetworkNodeFluidStorage) ((TileFluidStorage) world.getTileEntity(pos)).getNode()).onBreak();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        super.breakBlock(world, pos, state);
 | 
					        super.breakBlock(world, pos, state);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -95,7 +96,7 @@ public class BlockFluidStorage extends BlockNode {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        ItemStack stack = new ItemStack(RSBlocks.FLUID_STORAGE, 1, getMetaFromState(state));
 | 
					        ItemStack stack = new ItemStack(RSBlocks.FLUID_STORAGE, 1, getMetaFromState(state));
 | 
				
			||||||
        stack.setTagCompound(new NBTTagCompound());
 | 
					        stack.setTagCompound(new NBTTagCompound());
 | 
				
			||||||
        stack.getTagCompound().setTag(TileFluidStorage.NBT_STORAGE, storage.getStorageTag());
 | 
					        stack.getTagCompound().setTag(NetworkNodeFluidStorage.NBT_STORAGE, ((NetworkNodeFluidStorage) ((TileFluidStorage) world.getTileEntity(pos)).getNode()).getStorageTag());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        drops.add(stack);
 | 
					        drops.add(stack);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.block;
 | 
					package com.raoulvdberge.refinedstorage.block;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSGui;
 | 
					import com.raoulvdberge.refinedstorage.RSGui;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.item.ItemBlockBase;
 | 
					import com.raoulvdberge.refinedstorage.item.ItemBlockBase;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
					import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
				
			||||||
import net.minecraft.block.properties.PropertyEnum;
 | 
					import net.minecraft.block.properties.PropertyEnum;
 | 
				
			||||||
@@ -56,7 +57,7 @@ public class BlockGrid extends BlockNode {
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
 | 
					    public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
 | 
				
			||||||
        if (!world.isRemote && tryOpenNetworkGui(RSGui.GRID, player, world, pos, side)) {
 | 
					        if (!world.isRemote && tryOpenNetworkGui(RSGui.GRID, player, world, pos, side)) {
 | 
				
			||||||
            ((TileGrid) world.getTileEntity(pos)).onOpened(player);
 | 
					            ((NetworkNodeGrid) ((TileGrid) world.getTileEntity(pos)).getNode()).onOpened(player);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.block;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
					import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSGui;
 | 
					import com.raoulvdberge.refinedstorage.RSGui;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeReader;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileReader;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileReader;
 | 
				
			||||||
import net.minecraft.block.state.IBlockState;
 | 
					import net.minecraft.block.state.IBlockState;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
@@ -32,7 +33,7 @@ public class BlockReader extends BlockCable {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!world.isRemote && tryOpenNetworkGui(RSGui.READER_WRITER, player, world, pos, side)) {
 | 
					        if (!world.isRemote && tryOpenNetworkGui(RSGui.READER_WRITER, player, world, pos, side)) {
 | 
				
			||||||
            ((TileReader) world.getTileEntity(pos)).onOpened(player);
 | 
					            ((NetworkNodeReader) ((TileReader) world.getTileEntity(pos)).getNode()).onOpened(player);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.block;
 | 
				
			|||||||
import com.raoulvdberge.refinedstorage.RS;
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSGui;
 | 
					import com.raoulvdberge.refinedstorage.RSGui;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
 | 
					import com.raoulvdberge.refinedstorage.api.network.security.Permission;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeSecurityManager;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileSecurityManager;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileSecurityManager;
 | 
				
			||||||
import net.minecraft.block.state.IBlockState;
 | 
					import net.minecraft.block.state.IBlockState;
 | 
				
			||||||
import net.minecraft.entity.EntityLivingBase;
 | 
					import net.minecraft.entity.EntityLivingBase;
 | 
				
			||||||
@@ -29,14 +30,14 @@ public class BlockSecurityManager extends BlockNode {
 | 
				
			|||||||
        super.onBlockPlacedBy(world, pos, state, placer, stack);
 | 
					        super.onBlockPlacedBy(world, pos, state, placer, stack);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!world.isRemote && placer instanceof EntityPlayer) {
 | 
					        if (!world.isRemote && placer instanceof EntityPlayer) {
 | 
				
			||||||
            ((TileSecurityManager) world.getTileEntity(pos)).setOwner(((EntityPlayer) placer).getGameProfile().getId());
 | 
					            ((NetworkNodeSecurityManager) ((TileSecurityManager) world.getTileEntity(pos)).getNode()).setOwner(((EntityPlayer) placer).getGameProfile().getId());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
 | 
					    public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
 | 
				
			||||||
        if (!world.isRemote) {
 | 
					        if (!world.isRemote) {
 | 
				
			||||||
            if (player.getGameProfile().getId().equals(((TileSecurityManager) world.getTileEntity(pos)).getOwner())) {
 | 
					            if (player.getGameProfile().getId().equals(((NetworkNodeSecurityManager) ((TileSecurityManager) world.getTileEntity(pos)).getNode()).getOwner())) {
 | 
				
			||||||
                player.openGui(RS.INSTANCE, RSGui.SECURITY_MANAGER, world, pos.getX(), pos.getY(), pos.getZ());
 | 
					                player.openGui(RS.INSTANCE, RSGui.SECURITY_MANAGER, world, pos.getX(), pos.getY(), pos.getZ());
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                tryOpenNetworkGui(RSGui.SECURITY_MANAGER, player, world, pos, side, Permission.MODIFY, Permission.SECURITY);
 | 
					                tryOpenNetworkGui(RSGui.SECURITY_MANAGER, player, world, pos, side, Permission.MODIFY, Permission.SECURITY);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.block;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
					import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSGui;
 | 
					import com.raoulvdberge.refinedstorage.RSGui;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeStorage;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.item.ItemBlockStorage;
 | 
					import com.raoulvdberge.refinedstorage.item.ItemBlockStorage;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileStorage;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileStorage;
 | 
				
			||||||
import net.minecraft.block.properties.PropertyEnum;
 | 
					import net.minecraft.block.properties.PropertyEnum;
 | 
				
			||||||
@@ -75,14 +76,14 @@ public class BlockStorage extends BlockNode {
 | 
				
			|||||||
    public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
 | 
					    public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
 | 
				
			||||||
        super.onBlockPlacedBy(world, pos, state, player, stack);
 | 
					        super.onBlockPlacedBy(world, pos, state, player, stack);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!world.isRemote && stack.hasTagCompound() && stack.getTagCompound().hasKey(TileStorage.NBT_STORAGE)) {
 | 
					        if (!world.isRemote && stack.hasTagCompound() && stack.getTagCompound().hasKey(NetworkNodeStorage.NBT_STORAGE)) {
 | 
				
			||||||
            ((TileStorage) world.getTileEntity(pos)).setStorageTag(stack.getTagCompound().getCompoundTag(TileStorage.NBT_STORAGE));
 | 
					            ((NetworkNodeStorage) ((TileStorage) world.getTileEntity(pos)).getNode()).setStorageTag(stack.getTagCompound().getCompoundTag(NetworkNodeStorage.NBT_STORAGE));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void breakBlock(World world, BlockPos pos, IBlockState state) {
 | 
					    public void breakBlock(World world, BlockPos pos, IBlockState state) {
 | 
				
			||||||
        ((TileStorage) world.getTileEntity(pos)).onBreak();
 | 
					        ((NetworkNodeStorage) ((TileStorage) world.getTileEntity(pos)).getNode()).onBreak();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        super.breakBlock(world, pos, state);
 | 
					        super.breakBlock(world, pos, state);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -95,7 +96,7 @@ public class BlockStorage extends BlockNode {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        ItemStack stack = new ItemStack(RSBlocks.STORAGE, 1, getMetaFromState(state));
 | 
					        ItemStack stack = new ItemStack(RSBlocks.STORAGE, 1, getMetaFromState(state));
 | 
				
			||||||
        stack.setTagCompound(new NBTTagCompound());
 | 
					        stack.setTagCompound(new NBTTagCompound());
 | 
				
			||||||
        stack.getTagCompound().setTag(TileStorage.NBT_STORAGE, storage.getStorageTag());
 | 
					        stack.getTagCompound().setTag(NetworkNodeStorage.NBT_STORAGE, ((NetworkNodeStorage) ((TileStorage) world.getTileEntity(pos)).getNode()).getStorageTag());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        drops.add(stack);
 | 
					        drops.add(stack);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,8 @@ package com.raoulvdberge.refinedstorage.block;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
					import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSGui;
 | 
					import com.raoulvdberge.refinedstorage.RSGui;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.readerwriter.IWriter;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeWriter;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileWriter;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileWriter;
 | 
				
			||||||
import net.minecraft.block.state.IBlockState;
 | 
					import net.minecraft.block.state.IBlockState;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
@@ -32,7 +34,7 @@ public class BlockWriter extends BlockCable {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!world.isRemote && tryOpenNetworkGui(RSGui.READER_WRITER, player, world, pos, side)) {
 | 
					        if (!world.isRemote && tryOpenNetworkGui(RSGui.READER_WRITER, player, world, pos, side)) {
 | 
				
			||||||
            ((TileWriter) world.getTileEntity(pos)).onOpened(player);
 | 
					            ((NetworkNodeWriter) ((TileWriter) world.getTileEntity(pos)).getNode()).onOpened(player);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
@@ -46,7 +48,7 @@ public class BlockWriter extends BlockCable {
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    @SuppressWarnings("deprecation")
 | 
					    @SuppressWarnings("deprecation")
 | 
				
			||||||
    public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
 | 
					    public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
 | 
				
			||||||
        TileWriter writer = (TileWriter) world.getTileEntity(pos);
 | 
					        IWriter writer = (IWriter) ((TileWriter) world.getTileEntity(pos)).getNode();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return side == writer.getDirection().getOpposite() ? writer.getRedstoneStrength() : 0;
 | 
					        return side == writer.getDirection().getOpposite() ? writer.getRedstoneStrength() : 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container;
 | 
					package com.raoulvdberge.refinedstorage.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeConstructor;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
 | 
					import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileConstructor;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileConstructor;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
@@ -12,10 +13,10 @@ public class ContainerConstructor extends ContainerBase {
 | 
				
			|||||||
        super(constructor, player);
 | 
					        super(constructor, player);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 4; ++i) {
 | 
					        for (int i = 0; i < 4; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotItemHandler(constructor.getUpgrades(), i, 187, 6 + (i * 18)));
 | 
					            addSlotToContainer(new SlotItemHandler(((NetworkNodeConstructor) constructor.getNode()).getUpgrades(), i, 187, 6 + (i * 18)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addSlotToContainer(new SlotFilterType(constructor, 0, 80, 20));
 | 
					        addSlotToContainer(new SlotFilterType((NetworkNodeConstructor) constructor.getNode(), 0, 80, 20));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addPlayerInventory(8, 55);
 | 
					        addPlayerInventory(8, 55);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container;
 | 
					package com.raoulvdberge.refinedstorage.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCrafter;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileCrafter;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileCrafter;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
import net.minecraft.inventory.Slot;
 | 
					import net.minecraft.inventory.Slot;
 | 
				
			||||||
@@ -11,11 +12,11 @@ public class ContainerCrafter extends ContainerBase {
 | 
				
			|||||||
        super(crafter, player);
 | 
					        super(crafter, player);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 9; ++i) {
 | 
					        for (int i = 0; i < 9; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotItemHandler(crafter.getPatternItems(), i, 8 + (18 * i), 20));
 | 
					            addSlotToContainer(new SlotItemHandler(((NetworkNodeCrafter) crafter.getNode()).getPatternItems(), i, 8 + (18 * i), 20));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 4; ++i) {
 | 
					        for (int i = 0; i < 4; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotItemHandler(crafter.getUpgrades(), i, 187, 6 + (i * 18)));
 | 
					            addSlotToContainer(new SlotItemHandler(((NetworkNodeCrafter) crafter.getNode()).getUpgrades(), i, 187, 6 + (i * 18)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addPlayerInventory(8, 55);
 | 
					        addPlayerInventory(8, 55);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container;
 | 
					package com.raoulvdberge.refinedstorage.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeDestructor;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
 | 
					import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileDestructor;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileDestructor;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
@@ -12,11 +13,11 @@ public class ContainerDestructor extends ContainerBase {
 | 
				
			|||||||
        super(destructor, player);
 | 
					        super(destructor, player);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 4; ++i) {
 | 
					        for (int i = 0; i < 4; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotItemHandler(destructor.getUpgrades(), i, 187, 6 + (i * 18)));
 | 
					            addSlotToContainer(new SlotItemHandler(((NetworkNodeDestructor) destructor.getNode()).getUpgrades(), i, 187, 6 + (i * 18)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 9; ++i) {
 | 
					        for (int i = 0; i < 9; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotFilterType(destructor, i, 8 + (18 * i), 20));
 | 
					            addSlotToContainer(new SlotFilterType((NetworkNodeDestructor) destructor.getNode(), i, 8 + (18 * i), 20));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addPlayerInventory(8, 55);
 | 
					        addPlayerInventory(8, 55);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container;
 | 
					package com.raoulvdberge.refinedstorage.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeDetector;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
 | 
					import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileDetector;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileDetector;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
@@ -10,7 +11,7 @@ public class ContainerDetector extends ContainerBase {
 | 
				
			|||||||
    public ContainerDetector(TileDetector detector, EntityPlayer player) {
 | 
					    public ContainerDetector(TileDetector detector, EntityPlayer player) {
 | 
				
			||||||
        super(detector, player);
 | 
					        super(detector, player);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addSlotToContainer(new SlotFilterType(detector, 0, 107, 20));
 | 
					        addSlotToContainer(new SlotFilterType((NetworkNodeDetector) detector.getNode(), 0, 107, 20));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addPlayerInventory(8, 55);
 | 
					        addPlayerInventory(8, 55);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container;
 | 
					package com.raoulvdberge.refinedstorage.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeDiskDrive;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
 | 
					import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileDiskDrive;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileDiskDrive;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
@@ -15,11 +16,11 @@ public class ContainerDiskDrive extends ContainerBase {
 | 
				
			|||||||
        int y = 54;
 | 
					        int y = 54;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 8; ++i) {
 | 
					        for (int i = 0; i < 8; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotItemHandler(drive.getDisks(), i, x + ((i % 2) * 18), y + Math.floorDiv(i, 2) * 18));
 | 
					            addSlotToContainer(new SlotItemHandler(((NetworkNodeDiskDrive) drive.getNode()).getDisks(), i, x + ((i % 2) * 18), y + Math.floorDiv(i, 2) * 18));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 9; ++i) {
 | 
					        for (int i = 0; i < 9; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotFilterType(drive, i, 8 + (18 * i), 20));
 | 
					            addSlotToContainer(new SlotFilterType((NetworkNodeDiskDrive) drive.getNode(), i, 8 + (18 * i), 20));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addPlayerInventory(8, 141);
 | 
					        addPlayerInventory(8, 141);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container;
 | 
					package com.raoulvdberge.refinedstorage.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeDiskManipulator;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
 | 
					import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileDiskManipulator;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileDiskManipulator;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
@@ -12,19 +13,19 @@ public class ContainerDiskManipulator extends ContainerBase {
 | 
				
			|||||||
        super(manipulator, player);
 | 
					        super(manipulator, player);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 4; ++i) {
 | 
					        for (int i = 0; i < 4; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotItemHandler(manipulator.getUpgrades(), i, 187, 6 + (i * 18)));
 | 
					            addSlotToContainer(new SlotItemHandler(((NetworkNodeDiskManipulator) manipulator.getNode()).getUpgrades(), i, 187, 6 + (i * 18)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 3; ++i) {
 | 
					        for (int i = 0; i < 3; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotItemHandler(manipulator.getInputDisks(), i, 44, 57 + (i * 18)));
 | 
					            addSlotToContainer(new SlotItemHandler(((NetworkNodeDiskManipulator) manipulator.getNode()).getInputDisks(), i, 44, 57 + (i * 18)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 3; ++i) {
 | 
					        for (int i = 0; i < 3; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotItemHandler(manipulator.getOutputDisks(), i, 116, 57 + (i * 18)));
 | 
					            addSlotToContainer(new SlotItemHandler(((NetworkNodeDiskManipulator) manipulator.getNode()).getOutputDisks(), i, 116, 57 + (i * 18)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 9; ++i) {
 | 
					        for (int i = 0; i < 9; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotFilterType(manipulator, i, 8 + (18 * i), 20));
 | 
					            addSlotToContainer(new SlotFilterType((NetworkNodeDiskManipulator) manipulator.getNode(), i, 8 + (18 * i), 20));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addPlayerInventory(8, 129);
 | 
					        addPlayerInventory(8, 129);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container;
 | 
					package com.raoulvdberge.refinedstorage.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeExporter;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilter;
 | 
					import com.raoulvdberge.refinedstorage.container.slot.SlotFilter;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
 | 
					import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileExporter;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileExporter;
 | 
				
			||||||
@@ -24,11 +25,11 @@ public class ContainerExporter extends ContainerBase {
 | 
				
			|||||||
        this.inventoryItemStacks.clear();
 | 
					        this.inventoryItemStacks.clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 4; ++i) {
 | 
					        for (int i = 0; i < 4; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotItemHandler(exporter.getUpgrades(), i, 187, 6 + (i * 18)));
 | 
					            addSlotToContainer(new SlotItemHandler(((NetworkNodeExporter) exporter.getNode()).getUpgrades(), i, 187, 6 + (i * 18)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 9; ++i) {
 | 
					        for (int i = 0; i < 9; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotFilterType(exporter, i, 8 + (18 * i), 20, exporter.isRegulator() ? SlotFilter.FILTER_ALLOW_SIZE : 0));
 | 
					            addSlotToContainer(new SlotFilterType((NetworkNodeExporter) exporter.getNode(), i, 8 + (18 * i), 20, ((NetworkNodeExporter) exporter.getNode()).isRegulator() ? SlotFilter.FILTER_ALLOW_SIZE : 0));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addPlayerInventory(8, 55);
 | 
					        addPlayerInventory(8, 55);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,8 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container;
 | 
					package com.raoulvdberge.refinedstorage.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.externalstorage.NetworkNodeExternalStorage;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
 | 
					import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.externalstorage.TileExternalStorage;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileExternalStorage;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
import net.minecraft.inventory.Slot;
 | 
					import net.minecraft.inventory.Slot;
 | 
				
			||||||
import net.minecraft.item.ItemStack;
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
@@ -11,7 +12,7 @@ public class ContainerExternalStorage extends ContainerBase {
 | 
				
			|||||||
        super(tile, player);
 | 
					        super(tile, player);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 9; ++i) {
 | 
					        for (int i = 0; i < 9; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotFilterType(tile, i, 8 + (18 * i), 20));
 | 
					            addSlotToContainer(new SlotFilterType((NetworkNodeExternalStorage) tile.getNode(), i, 8 + (18 * i), 20));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addPlayerInventory(8, 141);
 | 
					        addPlayerInventory(8, 141);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container;
 | 
					package com.raoulvdberge.refinedstorage.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeFluidInterface;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterFluid;
 | 
					import com.raoulvdberge.refinedstorage.container.slot.SlotFilterFluid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
@@ -12,11 +13,11 @@ public class ContainerFluidInterface extends ContainerBase {
 | 
				
			|||||||
        super(fluidInterface, player);
 | 
					        super(fluidInterface, player);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 4; ++i) {
 | 
					        for (int i = 0; i < 4; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotItemHandler(fluidInterface.getUpgrades(), i, 187, 6 + (i * 18)));
 | 
					            addSlotToContainer(new SlotItemHandler(((NetworkNodeFluidInterface) fluidInterface.getNode()).getUpgrades(), i, 187, 6 + (i * 18)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addSlotToContainer(new SlotItemHandler(fluidInterface.getIn(), 0, 44, 32));
 | 
					        addSlotToContainer(new SlotItemHandler(((NetworkNodeFluidInterface) fluidInterface.getNode()).getIn(), 0, 44, 32));
 | 
				
			||||||
        addSlotToContainer(new SlotFilterFluid(!fluidInterface.getWorld().isRemote, fluidInterface.getOut(), 0, 116, 32));
 | 
					        addSlotToContainer(new SlotFilterFluid(!fluidInterface.getWorld().isRemote, ((NetworkNodeFluidInterface) fluidInterface.getNode()).getOut(), 0, 116, 32));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addPlayerInventory(8, 122);
 | 
					        addPlayerInventory(8, 122);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container;
 | 
					package com.raoulvdberge.refinedstorage.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeFluidStorage;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterFluid;
 | 
					import com.raoulvdberge.refinedstorage.container.slot.SlotFilterFluid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileFluidStorage;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileFluidStorage;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
@@ -11,7 +12,7 @@ public class ContainerFluidStorage extends ContainerBase {
 | 
				
			|||||||
        super(tile, player);
 | 
					        super(tile, player);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 9; ++i) {
 | 
					        for (int i = 0; i < 9; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotFilterFluid(!tile.getWorld().isRemote, tile.getFilters(), i, 8 + (18 * i), 20));
 | 
					            addSlotToContainer(new SlotFilterFluid(!tile.getWorld().isRemote, ((NetworkNodeFluidStorage) tile.getNode()).getFilters(), i, 8 + (18 * i), 20));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addPlayerInventory(8, 141);
 | 
					        addPlayerInventory(8, 141);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container;
 | 
					package com.raoulvdberge.refinedstorage.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSUtils;
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.block.EnumGridType;
 | 
					import com.raoulvdberge.refinedstorage.block.EnumGridType;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.slot.*;
 | 
					import com.raoulvdberge.refinedstorage.container.slot.*;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.grid.IGridDisplay;
 | 
					import com.raoulvdberge.refinedstorage.gui.grid.IGridDisplay;
 | 
				
			||||||
@@ -42,12 +43,13 @@ public class ContainerGrid extends ContainerBase {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        addPlayerInventory(8, display.getYPlayerInventory());
 | 
					        addPlayerInventory(8, display.getYPlayerInventory());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // @todo: move crafting logic to IGrid..
 | 
				
			||||||
        if (grid.getType() == EnumGridType.CRAFTING) {
 | 
					        if (grid.getType() == EnumGridType.CRAFTING) {
 | 
				
			||||||
            int x = 26;
 | 
					            int x = 26;
 | 
				
			||||||
            int y = headerAndSlots + 4;
 | 
					            int y = headerAndSlots + 4;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (int i = 0; i < 9; ++i) {
 | 
					            for (int i = 0; i < 9; ++i) {
 | 
				
			||||||
                addSlotToContainer(new SlotGridCrafting(((TileGrid) grid).getMatrix(), i, x, y));
 | 
					                addSlotToContainer(new SlotGridCrafting(((NetworkNodeGrid) ((TileGrid) grid).getNode()).getMatrix(), i, x, y));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                x += 18;
 | 
					                x += 18;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -63,7 +65,7 @@ public class ContainerGrid extends ContainerBase {
 | 
				
			|||||||
            int y = headerAndSlots + 4;
 | 
					            int y = headerAndSlots + 4;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (int i = 0; i < 9; ++i) {
 | 
					            for (int i = 0; i < 9; ++i) {
 | 
				
			||||||
                addSlotToContainer(new SlotFilterLegacy(((TileGrid) grid).getMatrix(), i, x, y));
 | 
					                addSlotToContainer(new SlotFilterLegacy(((NetworkNodeGrid) ((TileGrid) grid).getNode()).getMatrix(), i, x, y));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                x += 18;
 | 
					                x += 18;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -73,10 +75,10 @@ public class ContainerGrid extends ContainerBase {
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            addSlotToContainer(patternResultSlot = new SlotDisabled(((TileGrid) grid).getResult(), 0, 112 + 4, headerAndSlots + 22));
 | 
					            addSlotToContainer(patternResultSlot = new SlotDisabled(((NetworkNodeGrid) ((TileGrid) grid).getNode()).getResult(), 0, 112 + 4, headerAndSlots + 22));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            addSlotToContainer(new SlotItemHandler(((TileGrid) grid).getPatterns(), 0, 152, headerAndSlots + 4));
 | 
					            addSlotToContainer(new SlotItemHandler(((NetworkNodeGrid) ((TileGrid) grid).getNode()).getPatterns(), 0, 152, headerAndSlots + 4));
 | 
				
			||||||
            addSlotToContainer(new SlotOutput(((TileGrid) grid).getPatterns(), 1, 152, headerAndSlots + 40));
 | 
					            addSlotToContainer(new SlotOutput(((NetworkNodeGrid) ((TileGrid) grid).getNode()).getPatterns(), 1, 152, headerAndSlots + 40));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (grid.getType() != EnumGridType.FLUID) {
 | 
					        if (grid.getType() != EnumGridType.FLUID) {
 | 
				
			||||||
@@ -127,7 +129,7 @@ public class ContainerGrid extends ContainerBase {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            if (slot.getHasStack()) {
 | 
					            if (slot.getHasStack()) {
 | 
				
			||||||
                if (slot == craftingResultSlot) {
 | 
					                if (slot == craftingResultSlot) {
 | 
				
			||||||
                    ((TileGrid) grid).onCraftedShift(this, player);
 | 
					                    ((NetworkNodeGrid) ((TileGrid) grid).getNode()).onCraftedShift(this, player);
 | 
				
			||||||
                } else if (slot != patternResultSlot && !(slot instanceof SlotFilterLegacy)) {
 | 
					                } else if (slot != patternResultSlot && !(slot instanceof SlotFilterLegacy)) {
 | 
				
			||||||
                    if (grid.getType() != EnumGridType.FLUID && grid.getItemHandler() != null) {
 | 
					                    if (grid.getType() != EnumGridType.FLUID && grid.getItemHandler() != null) {
 | 
				
			||||||
                        slot.putStack(RSUtils.getStack(grid.getItemHandler().onInsert((EntityPlayerMP) player, slot.getStack())));
 | 
					                        slot.putStack(RSUtils.getStack(grid.getItemHandler().onInsert((EntityPlayerMP) player, slot.getStack())));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container;
 | 
					package com.raoulvdberge.refinedstorage.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeImporter;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
 | 
					import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileImporter;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileImporter;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
@@ -12,11 +13,11 @@ public class ContainerImporter extends ContainerBase {
 | 
				
			|||||||
        super(importer, player);
 | 
					        super(importer, player);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 4; ++i) {
 | 
					        for (int i = 0; i < 4; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotItemHandler(importer.getUpgrades(), i, 187, 6 + (i * 18)));
 | 
					            addSlotToContainer(new SlotItemHandler(((NetworkNodeImporter) importer.getNode()).getUpgrades(), i, 187, 6 + (i * 18)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 9; ++i) {
 | 
					        for (int i = 0; i < 9; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotFilterType(importer, i, 8 + (18 * i), 20));
 | 
					            addSlotToContainer(new SlotFilterType((NetworkNodeImporter) importer.getNode(), i, 8 + (18 * i), 20));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addPlayerInventory(8, 55);
 | 
					        addPlayerInventory(8, 55);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container;
 | 
					package com.raoulvdberge.refinedstorage.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeInterface;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilter;
 | 
					import com.raoulvdberge.refinedstorage.container.slot.SlotFilter;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotOutput;
 | 
					import com.raoulvdberge.refinedstorage.container.slot.SlotOutput;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileInterface;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileInterface;
 | 
				
			||||||
@@ -13,19 +14,19 @@ public class ContainerInterface extends ContainerBase {
 | 
				
			|||||||
        super(tile, player);
 | 
					        super(tile, player);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 9; ++i) {
 | 
					        for (int i = 0; i < 9; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotItemHandler(tile.getImportItems(), i, 8 + (18 * i), 20));
 | 
					            addSlotToContainer(new SlotItemHandler(((NetworkNodeInterface) tile.getNode()).getImportItems(), i, 8 + (18 * i), 20));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 9; ++i) {
 | 
					        for (int i = 0; i < 9; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotFilter(tile.getExportSpecimenItems(), i, 8 + (18 * i), 54, SlotFilter.FILTER_ALLOW_SIZE));
 | 
					            addSlotToContainer(new SlotFilter(((NetworkNodeInterface) tile.getNode()).getExportSpecimenItems(), i, 8 + (18 * i), 54, SlotFilter.FILTER_ALLOW_SIZE));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 9; ++i) {
 | 
					        for (int i = 0; i < 9; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotOutput(tile.getExportItems(), i, 8 + (18 * i), 100));
 | 
					            addSlotToContainer(new SlotOutput(((NetworkNodeInterface) tile.getNode()).getExportItems(), i, 8 + (18 * i), 100));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 4; ++i) {
 | 
					        for (int i = 0; i < 4; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotItemHandler(tile.getUpgrades(), i, 187, 6 + (i * 18)));
 | 
					            addSlotToContainer(new SlotItemHandler(((NetworkNodeInterface) tile.getNode()).getUpgrades(), i, 187, 6 + (i * 18)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addPlayerInventory(8, 134);
 | 
					        addPlayerInventory(8, 134);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container;
 | 
					package com.raoulvdberge.refinedstorage.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeNetworkTransmitter;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileNetworkTransmitter;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileNetworkTransmitter;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
import net.minecraft.inventory.Slot;
 | 
					import net.minecraft.inventory.Slot;
 | 
				
			||||||
@@ -10,9 +11,9 @@ public class ContainerNetworkTransmitter extends ContainerBase {
 | 
				
			|||||||
    public ContainerNetworkTransmitter(TileNetworkTransmitter networkTransmitter, EntityPlayer player) {
 | 
					    public ContainerNetworkTransmitter(TileNetworkTransmitter networkTransmitter, EntityPlayer player) {
 | 
				
			||||||
        super(networkTransmitter, player);
 | 
					        super(networkTransmitter, player);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addSlotToContainer(new SlotItemHandler(networkTransmitter.getNetworkCard(), 0, 8, 20));
 | 
					        addSlotToContainer(new SlotItemHandler(((NetworkNodeNetworkTransmitter) networkTransmitter.getNode()).getNetworkCard(), 0, 8, 20));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addSlotToContainer(new SlotItemHandler(networkTransmitter.getUpgrades(), 0, 187, 6));
 | 
					        addSlotToContainer(new SlotItemHandler(((NetworkNodeNetworkTransmitter) networkTransmitter.getNode()).getUpgrades(), 0, 187, 6));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addPlayerInventory(8, 55);
 | 
					        addPlayerInventory(8, 55);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container;
 | 
					package com.raoulvdberge.refinedstorage.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeSecurityManager;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileSecurityManager;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileSecurityManager;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
import net.minecraft.inventory.Slot;
 | 
					import net.minecraft.inventory.Slot;
 | 
				
			||||||
@@ -14,7 +15,7 @@ public class ContainerSecurityManager extends ContainerBase {
 | 
				
			|||||||
        int y = 20;
 | 
					        int y = 20;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 9 * 2; ++i) {
 | 
					        for (int i = 0; i < 9 * 2; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotItemHandler(tile.getCardsItems(), i, x, y));
 | 
					            addSlotToContainer(new SlotItemHandler(((NetworkNodeSecurityManager) tile.getNode()).getCardsItems(), i, x, y));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (((i + 1) % 9) == 0) {
 | 
					            if (((i + 1) % 9) == 0) {
 | 
				
			||||||
                x = 8;
 | 
					                x = 8;
 | 
				
			||||||
@@ -24,7 +25,7 @@ public class ContainerSecurityManager extends ContainerBase {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addSlotToContainer(new SlotItemHandler(tile.getEditCard(), 0, 80, 70));
 | 
					        addSlotToContainer(new SlotItemHandler(((NetworkNodeSecurityManager) tile.getNode()).getEditCard(), 0, 80, 70));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addPlayerInventory(8, 152);
 | 
					        addPlayerInventory(8, 152);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container;
 | 
					package com.raoulvdberge.refinedstorage.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSItems;
 | 
					import com.raoulvdberge.refinedstorage.RSItems;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeSolderer;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotOutput;
 | 
					import com.raoulvdberge.refinedstorage.container.slot.SlotOutput;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileSolderer;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileSolderer;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
@@ -16,15 +17,15 @@ public class ContainerSolderer extends ContainerBase {
 | 
				
			|||||||
        int y = 20;
 | 
					        int y = 20;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 3; ++i) {
 | 
					        for (int i = 0; i < 3; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotItemHandler(solderer.getItems(), i, x, y));
 | 
					            addSlotToContainer(new SlotItemHandler(((NetworkNodeSolderer) solderer.getNode()).getItems(), i, x, y));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            y += 18;
 | 
					            y += 18;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addSlotToContainer(new SlotOutput(solderer.getResult(), 0, 127, 38));
 | 
					        addSlotToContainer(new SlotOutput(((NetworkNodeSolderer) solderer.getNode()).getResult(), 0, 127, 38));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 4; ++i) {
 | 
					        for (int i = 0; i < 4; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotItemHandler(solderer.getUpgrades(), i, 187, 6 + (i * 18)));
 | 
					            addSlotToContainer(new SlotItemHandler(((NetworkNodeSolderer) solderer.getNode()).getUpgrades(), i, 187, 6 + (i * 18)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addPlayerInventory(8, 89);
 | 
					        addPlayerInventory(8, 89);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container;
 | 
					package com.raoulvdberge.refinedstorage.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeStorage;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilter;
 | 
					import com.raoulvdberge.refinedstorage.container.slot.SlotFilter;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileStorage;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileStorage;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
@@ -11,7 +12,7 @@ public class ContainerStorage extends ContainerBase {
 | 
				
			|||||||
        super(tile, player);
 | 
					        super(tile, player);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 9; ++i) {
 | 
					        for (int i = 0; i < 9; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotFilter(tile.getFilters(), i, 8 + (18 * i), 20));
 | 
					            addSlotToContainer(new SlotFilter(((NetworkNodeStorage) tile.getNode()).getFilters(), i, 8 + (18 * i), 20));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addPlayerInventory(8, 141);
 | 
					        addPlayerInventory(8, 141);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container;
 | 
					package com.raoulvdberge.refinedstorage.container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeWirelessTransmitter;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileWirelessTransmitter;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileWirelessTransmitter;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
import net.minecraft.inventory.Slot;
 | 
					import net.minecraft.inventory.Slot;
 | 
				
			||||||
@@ -11,7 +12,7 @@ public class ContainerWirelessTransmitter extends ContainerBase {
 | 
				
			|||||||
        super(wirelessTransmitter, player);
 | 
					        super(wirelessTransmitter, player);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 4; ++i) {
 | 
					        for (int i = 0; i < 4; ++i) {
 | 
				
			||||||
            addSlotToContainer(new SlotItemHandler(wirelessTransmitter.getUpgrades(), i, 187, 6 + (i * 18)));
 | 
					            addSlotToContainer(new SlotItemHandler(((NetworkNodeWirelessTransmitter) wirelessTransmitter.getNode()).getUpgrades(), i, 187, 6 + (i * 18)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        addPlayerInventory(8, 55);
 | 
					        addPlayerInventory(8, 55);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.container.slot;
 | 
					package com.raoulvdberge.refinedstorage.container.slot;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.ContainerGrid;
 | 
					import com.raoulvdberge.refinedstorage.container.ContainerGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
					import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
@@ -14,7 +15,7 @@ public class SlotGridCraftingResult extends SlotCrafting {
 | 
				
			|||||||
    private TileGrid grid;
 | 
					    private TileGrid grid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public SlotGridCraftingResult(ContainerGrid container, EntityPlayer player, TileGrid grid, int id, int x, int y) {
 | 
					    public SlotGridCraftingResult(ContainerGrid container, EntityPlayer player, TileGrid grid, int id, int x, int y) {
 | 
				
			||||||
        super(player, grid.getMatrix(), grid.getResult(), id, x, y);
 | 
					        super(player, ((NetworkNodeGrid) grid.getNode()).getMatrix(), ((NetworkNodeGrid) grid.getNode()).getResult(), id, x, y);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.container = container;
 | 
					        this.container = container;
 | 
				
			||||||
        this.grid = grid;
 | 
					        this.grid = grid;
 | 
				
			||||||
@@ -23,12 +24,12 @@ public class SlotGridCraftingResult extends SlotCrafting {
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    @Nonnull
 | 
					    @Nonnull
 | 
				
			||||||
    public ItemStack onTake(EntityPlayer player, @Nonnull ItemStack stack) {
 | 
					    public ItemStack onTake(EntityPlayer player, @Nonnull ItemStack stack) {
 | 
				
			||||||
        FMLCommonHandler.instance().firePlayerCraftingEvent(player, stack, grid.getMatrix());
 | 
					        FMLCommonHandler.instance().firePlayerCraftingEvent(player, stack, ((NetworkNodeGrid) grid.getNode()).getMatrix());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        onCrafting(stack);
 | 
					        onCrafting(stack);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!player.getEntityWorld().isRemote) {
 | 
					        if (!player.getEntityWorld().isRemote) {
 | 
				
			||||||
            grid.onCrafted(player);
 | 
					            ((NetworkNodeGrid) grid.getNode()).onCrafted(player);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            container.sendCraftingSlots();
 | 
					            container.sendCraftingSlots();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,13 +2,14 @@ package com.raoulvdberge.refinedstorage.gui;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSUtils;
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
 | 
					import com.raoulvdberge.refinedstorage.api.util.IComparer;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeFluidInterface;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.ContainerFluidInterface;
 | 
					import com.raoulvdberge.refinedstorage.container.ContainerFluidInterface;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonCompare;
 | 
					import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonCompare;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
 | 
					import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class GuiFluidInterface extends GuiBase {
 | 
					public class GuiFluidInterface extends GuiBase {
 | 
				
			||||||
    private static final RSUtils.FluidRenderer TANK_RENDERER = new RSUtils.FluidRenderer(TileFluidInterface.TANK_CAPACITY, 12, 47);
 | 
					    private static final RSUtils.FluidRenderer TANK_RENDERER = new RSUtils.FluidRenderer(NetworkNodeFluidInterface.TANK_CAPACITY, 12, 47);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public GuiFluidInterface(ContainerFluidInterface container) {
 | 
					    public GuiFluidInterface(ContainerFluidInterface container) {
 | 
				
			||||||
        super(container, 211, 204);
 | 
					        super(container, 211, 204);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,13 +3,17 @@ package com.raoulvdberge.refinedstorage.gui;
 | 
				
			|||||||
import com.raoulvdberge.refinedstorage.RSGui;
 | 
					import com.raoulvdberge.refinedstorage.RSGui;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.item.NetworkItemWirelessFluidGrid;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.item.NetworkItemWirelessFluidGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.item.NetworkItemWirelessGrid;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.item.NetworkItemWirelessGrid;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCraftingMonitor;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeFluidStorage;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeStorage;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.externalstorage.NetworkNodeExternalStorage;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.*;
 | 
					import com.raoulvdberge.refinedstorage.container.*;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.grid.GridDisplayDummy;
 | 
					import com.raoulvdberge.refinedstorage.gui.grid.GridDisplayDummy;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
 | 
					import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.*;
 | 
					import com.raoulvdberge.refinedstorage.tile.*;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.craftingmonitor.TileCraftingMonitor;
 | 
					import com.raoulvdberge.refinedstorage.tile.craftingmonitor.TileCraftingMonitor;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.craftingmonitor.WirelessCraftingMonitor;
 | 
					import com.raoulvdberge.refinedstorage.tile.craftingmonitor.WirelessCraftingMonitor;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.externalstorage.TileExternalStorage;
 | 
					 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
 | 
					import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
					import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.WirelessFluidGrid;
 | 
					import com.raoulvdberge.refinedstorage.tile.grid.WirelessFluidGrid;
 | 
				
			||||||
@@ -29,7 +33,7 @@ public class GuiHandler implements IGuiHandler {
 | 
				
			|||||||
            case RSGui.CONTROLLER:
 | 
					            case RSGui.CONTROLLER:
 | 
				
			||||||
                return new ContainerController((TileController) tile, player);
 | 
					                return new ContainerController((TileController) tile, player);
 | 
				
			||||||
            case RSGui.GRID:
 | 
					            case RSGui.GRID:
 | 
				
			||||||
                return new ContainerGrid((TileGrid) tile, new GridDisplayDummy(), player);
 | 
					                return new ContainerGrid((NetworkNodeGrid) ((TileGrid) tile).getNode(), new GridDisplayDummy(), player);
 | 
				
			||||||
            case RSGui.DISK_DRIVE:
 | 
					            case RSGui.DISK_DRIVE:
 | 
				
			||||||
                return new ContainerDiskDrive((TileDiskDrive) tile, player);
 | 
					                return new ContainerDiskDrive((TileDiskDrive) tile, player);
 | 
				
			||||||
            case RSGui.IMPORTER:
 | 
					            case RSGui.IMPORTER:
 | 
				
			||||||
@@ -53,7 +57,7 @@ public class GuiHandler implements IGuiHandler {
 | 
				
			|||||||
            case RSGui.INTERFACE:
 | 
					            case RSGui.INTERFACE:
 | 
				
			||||||
                return new ContainerInterface((TileInterface) tile, player);
 | 
					                return new ContainerInterface((TileInterface) tile, player);
 | 
				
			||||||
            case RSGui.CRAFTING_MONITOR:
 | 
					            case RSGui.CRAFTING_MONITOR:
 | 
				
			||||||
                return new ContainerCraftingMonitor((TileCraftingMonitor) tile, player);
 | 
					                return new ContainerCraftingMonitor((NetworkNodeCraftingMonitor) ((TileCraftingMonitor) tile).getNode(), player);
 | 
				
			||||||
            case RSGui.WIRELESS_TRANSMITTER:
 | 
					            case RSGui.WIRELESS_TRANSMITTER:
 | 
				
			||||||
                return new ContainerWirelessTransmitter((TileWirelessTransmitter) tile, player);
 | 
					                return new ContainerWirelessTransmitter((TileWirelessTransmitter) tile, player);
 | 
				
			||||||
            case RSGui.CRAFTER:
 | 
					            case RSGui.CRAFTER:
 | 
				
			||||||
@@ -98,8 +102,9 @@ public class GuiHandler implements IGuiHandler {
 | 
				
			|||||||
            case RSGui.CONTROLLER:
 | 
					            case RSGui.CONTROLLER:
 | 
				
			||||||
                return new GuiController((ContainerController) getContainer(ID, player, tile), (TileController) tile);
 | 
					                return new GuiController((ContainerController) getContainer(ID, player, tile), (TileController) tile);
 | 
				
			||||||
            case RSGui.GRID:
 | 
					            case RSGui.GRID:
 | 
				
			||||||
                GuiGrid gui = new GuiGrid(null, (TileGrid) tile);
 | 
					                IGrid grid = (NetworkNodeGrid) ((TileGrid) tile).getNode();
 | 
				
			||||||
                gui.inventorySlots = new ContainerGrid((TileGrid) tile, gui, player);
 | 
					                GuiGrid gui = new GuiGrid(null, grid);
 | 
				
			||||||
 | 
					                gui.inventorySlots = new ContainerGrid(grid, gui, player);
 | 
				
			||||||
                return gui;
 | 
					                return gui;
 | 
				
			||||||
            case RSGui.WIRELESS_GRID:
 | 
					            case RSGui.WIRELESS_GRID:
 | 
				
			||||||
                return getWirelessGridGui(player, x, y, z);
 | 
					                return getWirelessGridGui(player, x, y, z);
 | 
				
			||||||
@@ -118,15 +123,15 @@ public class GuiHandler implements IGuiHandler {
 | 
				
			|||||||
            case RSGui.CONSTRUCTOR:
 | 
					            case RSGui.CONSTRUCTOR:
 | 
				
			||||||
                return new GuiConstructor((ContainerConstructor) getContainer(ID, player, tile));
 | 
					                return new GuiConstructor((ContainerConstructor) getContainer(ID, player, tile));
 | 
				
			||||||
            case RSGui.STORAGE:
 | 
					            case RSGui.STORAGE:
 | 
				
			||||||
                return new GuiStorage((ContainerStorage) getContainer(ID, player, tile), (TileStorage) tile);
 | 
					                return new GuiStorage((ContainerStorage) getContainer(ID, player, tile), (NetworkNodeStorage) ((TileStorage) tile).getNode());
 | 
				
			||||||
            case RSGui.EXTERNAL_STORAGE:
 | 
					            case RSGui.EXTERNAL_STORAGE:
 | 
				
			||||||
                return new GuiStorage((ContainerExternalStorage) getContainer(ID, player, tile), (TileExternalStorage) tile);
 | 
					                return new GuiStorage((ContainerExternalStorage) getContainer(ID, player, tile), (NetworkNodeExternalStorage) ((TileExternalStorage) tile).getNode());
 | 
				
			||||||
            case RSGui.RELAY:
 | 
					            case RSGui.RELAY:
 | 
				
			||||||
                return new GuiRelay((ContainerRelay) getContainer(ID, player, tile));
 | 
					                return new GuiRelay((ContainerRelay) getContainer(ID, player, tile));
 | 
				
			||||||
            case RSGui.INTERFACE:
 | 
					            case RSGui.INTERFACE:
 | 
				
			||||||
                return new GuiInterface((ContainerInterface) getContainer(ID, player, tile));
 | 
					                return new GuiInterface((ContainerInterface) getContainer(ID, player, tile));
 | 
				
			||||||
            case RSGui.CRAFTING_MONITOR:
 | 
					            case RSGui.CRAFTING_MONITOR:
 | 
				
			||||||
                return new GuiCraftingMonitor((ContainerCraftingMonitor) getContainer(ID, player, tile), (TileCraftingMonitor) tile);
 | 
					                return new GuiCraftingMonitor((ContainerCraftingMonitor) getContainer(ID, player, tile), (NetworkNodeCraftingMonitor) ((TileCraftingMonitor) tile).getNode());
 | 
				
			||||||
            case RSGui.WIRELESS_TRANSMITTER:
 | 
					            case RSGui.WIRELESS_TRANSMITTER:
 | 
				
			||||||
                return new GuiWirelessTransmitter((ContainerWirelessTransmitter) getContainer(ID, player, tile));
 | 
					                return new GuiWirelessTransmitter((ContainerWirelessTransmitter) getContainer(ID, player, tile));
 | 
				
			||||||
            case RSGui.CRAFTER:
 | 
					            case RSGui.CRAFTER:
 | 
				
			||||||
@@ -140,7 +145,7 @@ public class GuiHandler implements IGuiHandler {
 | 
				
			|||||||
            case RSGui.FLUID_INTERFACE:
 | 
					            case RSGui.FLUID_INTERFACE:
 | 
				
			||||||
                return new GuiFluidInterface((ContainerFluidInterface) getContainer(ID, player, tile));
 | 
					                return new GuiFluidInterface((ContainerFluidInterface) getContainer(ID, player, tile));
 | 
				
			||||||
            case RSGui.FLUID_STORAGE:
 | 
					            case RSGui.FLUID_STORAGE:
 | 
				
			||||||
                return new GuiStorage((ContainerFluidStorage) getContainer(ID, player, tile), (TileFluidStorage) tile);
 | 
					                return new GuiStorage((ContainerFluidStorage) getContainer(ID, player, tile), (NetworkNodeFluidStorage) ((TileFluidStorage) tile).getNode());
 | 
				
			||||||
            case RSGui.DISK_MANIPULATOR:
 | 
					            case RSGui.DISK_MANIPULATOR:
 | 
				
			||||||
                return new GuiDiskManipulator((ContainerDiskManipulator) getContainer(ID, player, tile));
 | 
					                return new GuiDiskManipulator((ContainerDiskManipulator) getContainer(ID, player, tile));
 | 
				
			||||||
            case RSGui.WIRELESS_CRAFTING_MONITOR:
 | 
					            case RSGui.WIRELESS_CRAFTING_MONITOR:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.gui;
 | 
					package com.raoulvdberge.refinedstorage.gui;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeNetworkTransmitter;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.ContainerNetworkTransmitter;
 | 
					import com.raoulvdberge.refinedstorage.container.ContainerNetworkTransmitter;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
 | 
					import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileNetworkTransmitter;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileNetworkTransmitter;
 | 
				
			||||||
@@ -35,7 +36,7 @@ public class GuiNetworkTransmitter extends GuiBase {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        String distance;
 | 
					        String distance;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (networkTransmitter.getNetworkCard().getStackInSlot(0).isEmpty()) {
 | 
					        if (((NetworkNodeNetworkTransmitter) networkTransmitter.getNode()).getNetworkCard().getStackInSlot(0).isEmpty()) {
 | 
				
			||||||
            distance = t("gui.refinedstorage:network_transmitter.missing_card");
 | 
					            distance = t("gui.refinedstorage:network_transmitter.missing_card");
 | 
				
			||||||
        } else if (!TileNetworkTransmitter.RECEIVER_DIMENSION_SUPPORTED.getValue()) {
 | 
					        } else if (!TileNetworkTransmitter.RECEIVER_DIMENSION_SUPPORTED.getValue()) {
 | 
				
			||||||
            distance = t("gui.refinedstorage:network_transmitter.missing_upgrade");
 | 
					            distance = t("gui.refinedstorage:network_transmitter.missing_upgrade");
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -193,6 +193,6 @@ public class GuiReaderWriter extends GuiBase {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private List<String> getChannels() {
 | 
					    private List<String> getChannels() {
 | 
				
			||||||
        return readerWriter.isActive() ? CHANNELS : Collections.emptyList();
 | 
					        return readerWriter.canUpdate() ? CHANNELS : Collections.emptyList();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.gui;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RS;
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
 | 
					import com.raoulvdberge.refinedstorage.api.network.security.Permission;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeSecurityManager;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.ContainerSecurityManager;
 | 
					import com.raoulvdberge.refinedstorage.container.ContainerSecurityManager;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
 | 
					import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.item.ItemSecurityCard;
 | 
					import com.raoulvdberge.refinedstorage.item.ItemSecurityCard;
 | 
				
			||||||
@@ -40,7 +41,7 @@ public class GuiSecurityManager extends GuiBase {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void update(int x, int y) {
 | 
					    public void update(int x, int y) {
 | 
				
			||||||
        ItemStack card = securityManager.getEditCard().getStackInSlot(0);
 | 
					        ItemStack card = ((NetworkNodeSecurityManager) securityManager.getNode()).getEditCard().getStackInSlot(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (Permission permission : Permission.values()) {
 | 
					        for (Permission permission : Permission.values()) {
 | 
				
			||||||
            permissions[permission.getId()].setIsChecked(!card.isEmpty() && ItemSecurityCard.hasPermission(card, permission));
 | 
					            permissions[permission.getId()].setIsChecked(!card.isEmpty() && ItemSecurityCard.hasPermission(card, permission));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,6 +5,7 @@ import com.google.common.collect.ListMultimap;
 | 
				
			|||||||
import com.google.common.collect.Multimaps;
 | 
					import com.google.common.collect.Multimaps;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RS;
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IItemGridHandler;
 | 
					import com.raoulvdberge.refinedstorage.api.network.grid.IItemGridHandler;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.block.EnumGridType;
 | 
					import com.raoulvdberge.refinedstorage.block.EnumGridType;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.ContainerGrid;
 | 
					import com.raoulvdberge.refinedstorage.container.ContainerGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
 | 
					import com.raoulvdberge.refinedstorage.gui.GuiBase;
 | 
				
			||||||
@@ -187,7 +188,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            Collections.sort(stacks, SORTING_NAME);
 | 
					            Collections.sort(stacks, SORTING_NAME);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (grid.getSortingType() == TileGrid.SORTING_TYPE_QUANTITY) {
 | 
					            if (grid.getSortingType() == NetworkNodeGrid.SORTING_TYPE_QUANTITY) {
 | 
				
			||||||
                Collections.sort(stacks, SORTING_QUANTITY);
 | 
					                Collections.sort(stacks, SORTING_QUANTITY);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -289,7 +290,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private boolean isOverCreatePattern(int mouseX, int mouseY) {
 | 
					    private boolean isOverCreatePattern(int mouseX, int mouseY) {
 | 
				
			||||||
        return grid.getType() == EnumGridType.PATTERN && inBounds(152, getTabDelta() + getHeader() + (getVisibleRows() * 18) + 22, 16, 16, mouseX, mouseY) && ((TileGrid) grid).canCreatePattern();
 | 
					        return grid.getType() == EnumGridType.PATTERN && inBounds(152, getTabDelta() + getHeader() + (getVisibleRows() * 18) + 22, 16, 16, mouseX, mouseY) && ((NetworkNodeGrid) ((TileGrid) grid).getNode()).canCreatePattern();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private int getTabDelta() {
 | 
					    private int getTabDelta() {
 | 
				
			||||||
@@ -389,7 +390,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
 | 
				
			|||||||
                ty = 1;
 | 
					                ty = 1;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (!((TileGrid) grid).canCreatePattern()) {
 | 
					            if (!((NetworkNodeGrid) ((TileGrid) grid).getNode()).canCreatePattern()) {
 | 
				
			||||||
                ty = 2;
 | 
					                ty = 2;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -564,15 +565,15 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void updateJEI() {
 | 
					    private void updateJEI() {
 | 
				
			||||||
        if (IntegrationJEI.isLoaded() && (grid.getSearchBoxMode() == TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED || grid.getSearchBoxMode() == TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED)) {
 | 
					        if (IntegrationJEI.isLoaded() && (grid.getSearchBoxMode() == NetworkNodeGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED || grid.getSearchBoxMode() == NetworkNodeGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED)) {
 | 
				
			||||||
            RSJEIPlugin.INSTANCE.getRuntime().getItemListOverlay().setFilterText(searchField.getText());
 | 
					            RSJEIPlugin.INSTANCE.getRuntime().getItemListOverlay().setFilterText(searchField.getText());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void updateSearchFieldFocus(int mode) {
 | 
					    public void updateSearchFieldFocus(int mode) {
 | 
				
			||||||
        if (searchField != null) {
 | 
					        if (searchField != null) {
 | 
				
			||||||
            searchField.setCanLoseFocus(!TileGrid.isSearchBoxModeWithAutoselection(mode));
 | 
					            searchField.setCanLoseFocus(!NetworkNodeGrid.isSearchBoxModeWithAutoselection(mode));
 | 
				
			||||||
            searchField.setFocused(TileGrid.isSearchBoxModeWithAutoselection(mode));
 | 
					            searchField.setFocused(NetworkNodeGrid.isSearchBoxModeWithAutoselection(mode));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,9 +1,9 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.gui.grid.filtering;
 | 
					package com.raoulvdberge.refinedstorage.gui.grid.filtering;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.grid.GridFilter;
 | 
					import com.raoulvdberge.refinedstorage.gui.grid.GridFilter;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
 | 
					import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
 | 
					import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.LinkedList;
 | 
					import java.util.LinkedList;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
@@ -23,9 +23,9 @@ public class GridFilterParser {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (grid.getViewType() == TileGrid.VIEW_TYPE_NON_CRAFTABLES) {
 | 
					        if (grid.getViewType() == NetworkNodeGrid.VIEW_TYPE_NON_CRAFTABLES) {
 | 
				
			||||||
            filters.add(new GridFilterCraftable(false));
 | 
					            filters.add(new GridFilterCraftable(false));
 | 
				
			||||||
        } else if (grid.getViewType() == TileGrid.VIEW_TYPE_CRAFTABLES) {
 | 
					        } else if (grid.getViewType() == NetworkNodeGrid.VIEW_TYPE_CRAFTABLES) {
 | 
				
			||||||
            filters.add(new GridFilterCraftable(true));
 | 
					            filters.add(new GridFilterCraftable(true));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.gui.grid.sorting;
 | 
					package com.raoulvdberge.refinedstorage.gui.grid.sorting;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
 | 
					import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class GridSortingName extends GridSorting {
 | 
					public class GridSortingName extends GridSorting {
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -9,9 +9,9 @@ public class GridSortingName extends GridSorting {
 | 
				
			|||||||
        String leftName = left.getName();
 | 
					        String leftName = left.getName();
 | 
				
			||||||
        String rightName = right.getName();
 | 
					        String rightName = right.getName();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (sortingDirection == TileGrid.SORTING_DIRECTION_ASCENDING) {
 | 
					        if (sortingDirection == NetworkNodeGrid.SORTING_DIRECTION_ASCENDING) {
 | 
				
			||||||
            return leftName.compareTo(rightName);
 | 
					            return leftName.compareTo(rightName);
 | 
				
			||||||
        } else if (sortingDirection == TileGrid.SORTING_DIRECTION_DESCENDING) {
 | 
					        } else if (sortingDirection == NetworkNodeGrid.SORTING_DIRECTION_DESCENDING) {
 | 
				
			||||||
            return rightName.compareTo(leftName);
 | 
					            return rightName.compareTo(leftName);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.gui.grid.sorting;
 | 
					package com.raoulvdberge.refinedstorage.gui.grid.sorting;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
 | 
					import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class GridSortingQuantity extends GridSorting {
 | 
					public class GridSortingQuantity extends GridSorting {
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -10,9 +10,9 @@ public class GridSortingQuantity extends GridSorting {
 | 
				
			|||||||
        int rightSize = right.getQuantity();
 | 
					        int rightSize = right.getQuantity();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (leftSize != rightSize) {
 | 
					        if (leftSize != rightSize) {
 | 
				
			||||||
            if (sortingDirection == TileGrid.SORTING_DIRECTION_ASCENDING) {
 | 
					            if (sortingDirection == NetworkNodeGrid.SORTING_DIRECTION_ASCENDING) {
 | 
				
			||||||
                return (leftSize > rightSize) ? 1 : -1;
 | 
					                return (leftSize > rightSize) ? 1 : -1;
 | 
				
			||||||
            } else if (sortingDirection == TileGrid.SORTING_DIRECTION_DESCENDING) {
 | 
					            } else if (sortingDirection == NetworkNodeGrid.SORTING_DIRECTION_DESCENDING) {
 | 
				
			||||||
                return (rightSize > leftSize) ? 1 : -1;
 | 
					                return (rightSize > leftSize) ? 1 : -1;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.gui.sidebutton;
 | 
					package com.raoulvdberge.refinedstorage.gui.sidebutton;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeDetector;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
 | 
					import com.raoulvdberge.refinedstorage.gui.GuiBase;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileDetector;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileDetector;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
 | 
					import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
 | 
				
			||||||
@@ -24,14 +25,14 @@ public class SideButtonDetectorMode extends SideButton {
 | 
				
			|||||||
    public void actionPerformed() {
 | 
					    public void actionPerformed() {
 | 
				
			||||||
        int mode = TileDetector.MODE.getValue();
 | 
					        int mode = TileDetector.MODE.getValue();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (mode == TileDetector.MODE_EQUAL) {
 | 
					        if (mode == NetworkNodeDetector.MODE_EQUAL) {
 | 
				
			||||||
            mode = TileDetector.MODE_ABOVE;
 | 
					            mode = NetworkNodeDetector.MODE_ABOVE;
 | 
				
			||||||
        } else if (mode == TileDetector.MODE_ABOVE) {
 | 
					        } else if (mode == NetworkNodeDetector.MODE_ABOVE) {
 | 
				
			||||||
            mode = TileDetector.MODE_UNDER;
 | 
					            mode = NetworkNodeDetector.MODE_UNDER;
 | 
				
			||||||
        } else if (mode == TileDetector.MODE_UNDER) {
 | 
					        } else if (mode == NetworkNodeDetector.MODE_UNDER) {
 | 
				
			||||||
            mode = TileDetector.MODE_AUTOCRAFTING;
 | 
					            mode = NetworkNodeDetector.MODE_AUTOCRAFTING;
 | 
				
			||||||
        } else if (mode == TileDetector.MODE_AUTOCRAFTING) {
 | 
					        } else if (mode == NetworkNodeDetector.MODE_AUTOCRAFTING) {
 | 
				
			||||||
            mode = TileDetector.MODE_EQUAL;
 | 
					            mode = NetworkNodeDetector.MODE_EQUAL;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        TileDataManager.setParameter(TileDetector.MODE, mode);
 | 
					        TileDataManager.setParameter(TileDetector.MODE, mode);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,9 +1,9 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.gui.sidebutton;
 | 
					package com.raoulvdberge.refinedstorage.gui.sidebutton;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
 | 
					import com.raoulvdberge.refinedstorage.gui.GuiBase;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
 | 
					import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.integration.jei.IntegrationJEI;
 | 
					import com.raoulvdberge.refinedstorage.integration.jei.IntegrationJEI;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
					 | 
				
			||||||
import net.minecraft.util.text.TextFormatting;
 | 
					import net.minecraft.util.text.TextFormatting;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class SideButtonGridSearchBoxMode extends SideButton {
 | 
					public class SideButtonGridSearchBoxMode extends SideButton {
 | 
				
			||||||
@@ -20,25 +20,25 @@ public class SideButtonGridSearchBoxMode extends SideButton {
 | 
				
			|||||||
    protected void drawButtonIcon(int x, int y) {
 | 
					    protected void drawButtonIcon(int x, int y) {
 | 
				
			||||||
        int mode = ((GuiGrid) gui).getGrid().getSearchBoxMode();
 | 
					        int mode = ((GuiGrid) gui).getGrid().getSearchBoxMode();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        gui.drawTexture(x, y, mode == TileGrid.SEARCH_BOX_MODE_NORMAL_AUTOSELECTED || mode == TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED ? 16 : 0, 96, 16, 16);
 | 
					        gui.drawTexture(x, y, mode == NetworkNodeGrid.SEARCH_BOX_MODE_NORMAL_AUTOSELECTED || mode == NetworkNodeGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED ? 16 : 0, 96, 16, 16);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void actionPerformed() {
 | 
					    public void actionPerformed() {
 | 
				
			||||||
        int mode = ((GuiGrid) gui).getGrid().getSearchBoxMode();
 | 
					        int mode = ((GuiGrid) gui).getGrid().getSearchBoxMode();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (mode == TileGrid.SEARCH_BOX_MODE_NORMAL) {
 | 
					        if (mode == NetworkNodeGrid.SEARCH_BOX_MODE_NORMAL) {
 | 
				
			||||||
            mode = TileGrid.SEARCH_BOX_MODE_NORMAL_AUTOSELECTED;
 | 
					            mode = NetworkNodeGrid.SEARCH_BOX_MODE_NORMAL_AUTOSELECTED;
 | 
				
			||||||
        } else if (mode == TileGrid.SEARCH_BOX_MODE_NORMAL_AUTOSELECTED) {
 | 
					        } else if (mode == NetworkNodeGrid.SEARCH_BOX_MODE_NORMAL_AUTOSELECTED) {
 | 
				
			||||||
            if (IntegrationJEI.isLoaded()) {
 | 
					            if (IntegrationJEI.isLoaded()) {
 | 
				
			||||||
                mode = TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED;
 | 
					                mode = NetworkNodeGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED;
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                mode = TileGrid.SEARCH_BOX_MODE_NORMAL;
 | 
					                mode = NetworkNodeGrid.SEARCH_BOX_MODE_NORMAL;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else if (mode == TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED) {
 | 
					        } else if (mode == NetworkNodeGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED) {
 | 
				
			||||||
            mode = TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED;
 | 
					            mode = NetworkNodeGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED;
 | 
				
			||||||
        } else if (mode == TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED) {
 | 
					        } else if (mode == NetworkNodeGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED) {
 | 
				
			||||||
            mode = TileGrid.SEARCH_BOX_MODE_NORMAL;
 | 
					            mode = NetworkNodeGrid.SEARCH_BOX_MODE_NORMAL;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ((GuiGrid) gui).getGrid().onSearchBoxModeChanged(mode);
 | 
					        ((GuiGrid) gui).getGrid().onSearchBoxModeChanged(mode);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,8 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.gui.sidebutton;
 | 
					package com.raoulvdberge.refinedstorage.gui.sidebutton;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
 | 
					import com.raoulvdberge.refinedstorage.gui.GuiBase;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
 | 
					import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
					 | 
				
			||||||
import net.minecraft.util.text.TextFormatting;
 | 
					import net.minecraft.util.text.TextFormatting;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class SideButtonGridSortingDirection extends SideButton {
 | 
					public class SideButtonGridSortingDirection extends SideButton {
 | 
				
			||||||
@@ -28,10 +28,10 @@ public class SideButtonGridSortingDirection extends SideButton {
 | 
				
			|||||||
    public void actionPerformed() {
 | 
					    public void actionPerformed() {
 | 
				
			||||||
        int dir = grid.getSortingDirection();
 | 
					        int dir = grid.getSortingDirection();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (dir == TileGrid.SORTING_DIRECTION_ASCENDING) {
 | 
					        if (dir == NetworkNodeGrid.SORTING_DIRECTION_ASCENDING) {
 | 
				
			||||||
            dir = TileGrid.SORTING_DIRECTION_DESCENDING;
 | 
					            dir = NetworkNodeGrid.SORTING_DIRECTION_DESCENDING;
 | 
				
			||||||
        } else if (dir == TileGrid.SORTING_DIRECTION_DESCENDING) {
 | 
					        } else if (dir == NetworkNodeGrid.SORTING_DIRECTION_DESCENDING) {
 | 
				
			||||||
            dir = TileGrid.SORTING_DIRECTION_ASCENDING;
 | 
					            dir = NetworkNodeGrid.SORTING_DIRECTION_ASCENDING;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        grid.onSortingDirectionChanged(dir);
 | 
					        grid.onSortingDirectionChanged(dir);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,8 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.gui.sidebutton;
 | 
					package com.raoulvdberge.refinedstorage.gui.sidebutton;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
 | 
					import com.raoulvdberge.refinedstorage.gui.GuiBase;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
 | 
					import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
					 | 
				
			||||||
import net.minecraft.util.text.TextFormatting;
 | 
					import net.minecraft.util.text.TextFormatting;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class SideButtonGridSortingType extends SideButton {
 | 
					public class SideButtonGridSortingType extends SideButton {
 | 
				
			||||||
@@ -28,10 +28,10 @@ public class SideButtonGridSortingType extends SideButton {
 | 
				
			|||||||
    public void actionPerformed() {
 | 
					    public void actionPerformed() {
 | 
				
			||||||
        int type = grid.getSortingType();
 | 
					        int type = grid.getSortingType();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (type == TileGrid.SORTING_TYPE_QUANTITY) {
 | 
					        if (type == NetworkNodeGrid.SORTING_TYPE_QUANTITY) {
 | 
				
			||||||
            type = TileGrid.SORTING_TYPE_NAME;
 | 
					            type = NetworkNodeGrid.SORTING_TYPE_NAME;
 | 
				
			||||||
        } else if (type == TileGrid.SORTING_TYPE_NAME) {
 | 
					        } else if (type == NetworkNodeGrid.SORTING_TYPE_NAME) {
 | 
				
			||||||
            type = TileGrid.SORTING_TYPE_QUANTITY;
 | 
					            type = NetworkNodeGrid.SORTING_TYPE_QUANTITY;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        grid.onSortingTypeChanged(type);
 | 
					        grid.onSortingTypeChanged(type);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,8 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.gui.sidebutton;
 | 
					package com.raoulvdberge.refinedstorage.gui.sidebutton;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
 | 
					import com.raoulvdberge.refinedstorage.gui.GuiBase;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
 | 
					import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
					 | 
				
			||||||
import net.minecraft.util.text.TextFormatting;
 | 
					import net.minecraft.util.text.TextFormatting;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class SideButtonGridViewType extends SideButton {
 | 
					public class SideButtonGridViewType extends SideButton {
 | 
				
			||||||
@@ -28,12 +28,12 @@ public class SideButtonGridViewType extends SideButton {
 | 
				
			|||||||
    public void actionPerformed() {
 | 
					    public void actionPerformed() {
 | 
				
			||||||
        int type = grid.getViewType();
 | 
					        int type = grid.getViewType();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (type == TileGrid.VIEW_TYPE_NORMAL) {
 | 
					        if (type == NetworkNodeGrid.VIEW_TYPE_NORMAL) {
 | 
				
			||||||
            type = TileGrid.VIEW_TYPE_NON_CRAFTABLES;
 | 
					            type = NetworkNodeGrid.VIEW_TYPE_NON_CRAFTABLES;
 | 
				
			||||||
        } else if (type == TileGrid.VIEW_TYPE_NON_CRAFTABLES) {
 | 
					        } else if (type == NetworkNodeGrid.VIEW_TYPE_NON_CRAFTABLES) {
 | 
				
			||||||
            type = TileGrid.VIEW_TYPE_CRAFTABLES;
 | 
					            type = NetworkNodeGrid.VIEW_TYPE_CRAFTABLES;
 | 
				
			||||||
        } else if (type == TileGrid.VIEW_TYPE_CRAFTABLES) {
 | 
					        } else if (type == NetworkNodeGrid.VIEW_TYPE_CRAFTABLES) {
 | 
				
			||||||
            type = TileGrid.VIEW_TYPE_NORMAL;
 | 
					            type = NetworkNodeGrid.VIEW_TYPE_NORMAL;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        grid.onViewTypeChanged(type);
 | 
					        grid.onViewTypeChanged(type);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.gui.sidebutton;
 | 
					package com.raoulvdberge.refinedstorage.gui.sidebutton;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeDiskManipulator;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
 | 
					import com.raoulvdberge.refinedstorage.gui.GuiBase;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileDiskManipulator;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileDiskManipulator;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
 | 
					import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
 | 
				
			||||||
@@ -12,16 +13,16 @@ public class SideButtonIOMode extends SideButton {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String getTooltip() {
 | 
					    public String getTooltip() {
 | 
				
			||||||
        return TextFormatting.GREEN + GuiBase.t("sidebutton.refinedstorage:iomode") + TextFormatting.RESET + "\n" + GuiBase.t("sidebutton.refinedstorage:iomode." + (TileDiskManipulator.IO_MODE.getValue() == TileDiskManipulator.IO_MODE_INSERT ? "insert" : "extract"));
 | 
					        return TextFormatting.GREEN + GuiBase.t("sidebutton.refinedstorage:iomode") + TextFormatting.RESET + "\n" + GuiBase.t("sidebutton.refinedstorage:iomode." + (TileDiskManipulator.IO_MODE.getValue() == NetworkNodeDiskManipulator.IO_MODE_INSERT ? "insert" : "extract"));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void drawButtonIcon(int x, int y) {
 | 
					    protected void drawButtonIcon(int x, int y) {
 | 
				
			||||||
        gui.drawTexture(x, y, TileDiskManipulator.IO_MODE.getValue() == TileDiskManipulator.IO_MODE_EXTRACT ? 0 : 16, 160, 16, 16);
 | 
					        gui.drawTexture(x, y, TileDiskManipulator.IO_MODE.getValue() == NetworkNodeDiskManipulator.IO_MODE_EXTRACT ? 0 : 16, 160, 16, 16);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void actionPerformed() {
 | 
					    public void actionPerformed() {
 | 
				
			||||||
        TileDataManager.setParameter(TileDiskManipulator.IO_MODE, TileDiskManipulator.IO_MODE.getValue() == TileDiskManipulator.IO_MODE_INSERT ? TileDiskManipulator.IO_MODE_EXTRACT : TileDiskManipulator.IO_MODE_INSERT);
 | 
					        TileDataManager.setParameter(TileDiskManipulator.IO_MODE, TileDiskManipulator.IO_MODE.getValue() == NetworkNodeDiskManipulator.IO_MODE_INSERT ? NetworkNodeDiskManipulator.IO_MODE_EXTRACT : NetworkNodeDiskManipulator.IO_MODE_INSERT);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.inventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public interface IItemHandlerChangeListener {
 | 
				
			||||||
 | 
					    void onChanged(int slot);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,20 +1,19 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.inventory;
 | 
					package com.raoulvdberge.refinedstorage.inventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import net.minecraft.item.ItemStack;
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
import net.minecraft.tileentity.TileEntity;
 | 
					 | 
				
			||||||
import net.minecraftforge.items.ItemStackHandler;
 | 
					import net.minecraftforge.items.ItemStackHandler;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.annotation.Nonnull;
 | 
					import javax.annotation.Nonnull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class ItemHandlerBasic extends ItemStackHandler {
 | 
					public class ItemHandlerBasic extends ItemStackHandler {
 | 
				
			||||||
    private TileEntity tile;
 | 
					    private IItemHandlerChangeListener listener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected IItemValidator[] validators;
 | 
					    protected IItemValidator[] validators;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public ItemHandlerBasic(int size, TileEntity tile, IItemValidator... validators) {
 | 
					    public ItemHandlerBasic(int size, IItemHandlerChangeListener listener, IItemValidator... validators) {
 | 
				
			||||||
        super(size);
 | 
					        super(size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.tile = tile;
 | 
					        this.listener = listener;
 | 
				
			||||||
        this.validators = validators;
 | 
					        this.validators = validators;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -51,8 +50,8 @@ public class ItemHandlerBasic extends ItemStackHandler {
 | 
				
			|||||||
    protected void onContentsChanged(int slot) {
 | 
					    protected void onContentsChanged(int slot) {
 | 
				
			||||||
        super.onContentsChanged(slot);
 | 
					        super.onContentsChanged(slot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (tile != null) {
 | 
					        if (listener != null) {
 | 
				
			||||||
            tile.markDirty();
 | 
					            listener.onChanged(slot);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.inventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class ItemHandlerChangeListenerNode implements IItemHandlerChangeListener {
 | 
				
			||||||
 | 
					    private INetworkNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ItemHandlerChangeListenerNode(INetworkNode node) {
 | 
				
			||||||
 | 
					        this.node = node;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onChanged(int slot) {
 | 
				
			||||||
 | 
					        node.markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.inventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import net.minecraft.tileentity.TileEntity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class ItemHandlerChangeListenerTile implements IItemHandlerChangeListener {
 | 
				
			||||||
 | 
					    private TileEntity tile;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ItemHandlerChangeListenerTile(TileEntity tile) {
 | 
				
			||||||
 | 
					        this.tile = tile;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onChanged(int slot) {
 | 
				
			||||||
 | 
					        tile.markDirty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -2,15 +2,14 @@ package com.raoulvdberge.refinedstorage.inventory;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSUtils;
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
import net.minecraft.item.ItemStack;
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
import net.minecraft.tileentity.TileEntity;
 | 
					 | 
				
			||||||
import net.minecraftforge.fluids.FluidStack;
 | 
					import net.minecraftforge.fluids.FluidStack;
 | 
				
			||||||
import net.minecraftforge.items.ItemHandlerHelper;
 | 
					import net.minecraftforge.items.ItemHandlerHelper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class ItemHandlerFluid extends ItemHandlerBasic {
 | 
					public class ItemHandlerFluid extends ItemHandlerBasic {
 | 
				
			||||||
    private FluidStack[] fluids;
 | 
					    private FluidStack[] fluids;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public ItemHandlerFluid(int size, TileEntity tile) {
 | 
					    public ItemHandlerFluid(int size, IItemHandlerChangeListener listener) {
 | 
				
			||||||
        super(size, tile, s -> RSUtils.getFluidFromStack(ItemHandlerHelper.copyStackWithSize(s, 1), true).getValue() != null);
 | 
					        super(size, listener, s -> RSUtils.getFluidFromStack(ItemHandlerHelper.copyStackWithSize(s, 1), true).getValue() != null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.fluids = new FluidStack[size];
 | 
					        this.fluids = new FluidStack[size];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,11 +2,10 @@ package com.raoulvdberge.refinedstorage.inventory;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSItems;
 | 
					import com.raoulvdberge.refinedstorage.RSItems;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
 | 
					import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
 | 
				
			||||||
import net.minecraft.tileentity.TileEntity;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class ItemHandlerUpgrade extends ItemHandlerBasic {
 | 
					public class ItemHandlerUpgrade extends ItemHandlerBasic {
 | 
				
			||||||
    public ItemHandlerUpgrade(int size, TileEntity tile, int... supportedUpgrades) {
 | 
					    public ItemHandlerUpgrade(int size, IItemHandlerChangeListener listener, int... supportedUpgrades) {
 | 
				
			||||||
        super(size, tile, new IItemValidator[supportedUpgrades.length]);
 | 
					        super(size, listener, new IItemValidator[supportedUpgrades.length]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < supportedUpgrades.length; ++i) {
 | 
					        for (int i = 0; i < supportedUpgrades.length; ++i) {
 | 
				
			||||||
            this.validators[i] = new ItemValidatorBasic(RSItems.UPGRADE, supportedUpgrades[i]);
 | 
					            this.validators[i] = new ItemValidatorBasic(RSItems.UPGRADE, supportedUpgrades[i]);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,9 +2,9 @@ package com.raoulvdberge.refinedstorage.item;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
					import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSItems;
 | 
					import com.raoulvdberge.refinedstorage.RSItems;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeFluidStorage;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageFluidNBT;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageFluidNBT;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.block.EnumFluidStorageType;
 | 
					import com.raoulvdberge.refinedstorage.block.EnumFluidStorageType;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileFluidStorage;
 | 
					 | 
				
			||||||
import net.minecraft.client.resources.I18n;
 | 
					import net.minecraft.client.resources.I18n;
 | 
				
			||||||
import net.minecraft.entity.Entity;
 | 
					import net.minecraft.entity.Entity;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
@@ -28,7 +28,7 @@ public class ItemBlockFluidStorage extends ItemBlockBase {
 | 
				
			|||||||
        EnumFluidStorageType type = EnumFluidStorageType.getById(stack.getMetadata());
 | 
					        EnumFluidStorageType type = EnumFluidStorageType.getById(stack.getMetadata());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (type != null && isValid(stack)) {
 | 
					        if (type != null && isValid(stack)) {
 | 
				
			||||||
            NBTTagCompound tag = stack.getTagCompound().getCompoundTag(TileFluidStorage.NBT_STORAGE);
 | 
					            NBTTagCompound tag = stack.getTagCompound().getCompoundTag(NetworkNodeFluidStorage.NBT_STORAGE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (type == EnumFluidStorageType.TYPE_CREATIVE) {
 | 
					            if (type == EnumFluidStorageType.TYPE_CREATIVE) {
 | 
				
			||||||
                tooltip.add(I18n.format("misc.refinedstorage:storage.stored", StorageFluidNBT.getStoredFromNBT(tag)));
 | 
					                tooltip.add(I18n.format("misc.refinedstorage:storage.stored", StorageFluidNBT.getStoredFromNBT(tag)));
 | 
				
			||||||
@@ -44,7 +44,7 @@ public class ItemBlockFluidStorage extends ItemBlockBase {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        EnumFluidStorageType type = EnumFluidStorageType.getById(stack.getMetadata());
 | 
					        EnumFluidStorageType type = EnumFluidStorageType.getById(stack.getMetadata());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        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()) {
 | 
					        if (type != null && stack.getCount() == 1 && isValid(stack) && StorageFluidNBT.getStoredFromNBT(stack.getTagCompound().getCompoundTag(NetworkNodeFluidStorage.NBT_STORAGE)) <= 0 && stack.getMetadata() != ItemFluidStorageDisk.TYPE_CREATIVE && !world.isRemote && player.isSneaking()) {
 | 
				
			||||||
            ItemStack storagePart = new ItemStack(RSItems.FLUID_STORAGE_PART, 1, stack.getMetadata());
 | 
					            ItemStack storagePart = new ItemStack(RSItems.FLUID_STORAGE_PART, 1, stack.getMetadata());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (!player.inventory.addItemStackToInventory(storagePart.copy())) {
 | 
					            if (!player.inventory.addItemStackToInventory(storagePart.copy())) {
 | 
				
			||||||
@@ -64,7 +64,7 @@ public class ItemBlockFluidStorage extends ItemBlockBase {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static boolean isValid(ItemStack stack) {
 | 
					    private static boolean isValid(ItemStack stack) {
 | 
				
			||||||
        return stack.getTagCompound() != null && stack.getTagCompound().hasKey(TileFluidStorage.NBT_STORAGE);
 | 
					        return stack.getTagCompound() != null && stack.getTagCompound().hasKey(NetworkNodeFluidStorage.NBT_STORAGE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -94,14 +94,14 @@ public class ItemBlockFluidStorage extends ItemBlockBase {
 | 
				
			|||||||
            return super.getNBTShareTag(stack);
 | 
					            return super.getNBTShareTag(stack);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            NBTTagCompound shareTag = new NBTTagCompound();
 | 
					            NBTTagCompound shareTag = new NBTTagCompound();
 | 
				
			||||||
            shareTag.setTag(TileFluidStorage.NBT_STORAGE, StorageFluidNBT.getNBTShareTag(stack.getTagCompound().getCompoundTag(TileFluidStorage.NBT_STORAGE)));
 | 
					            shareTag.setTag(NetworkNodeFluidStorage.NBT_STORAGE, StorageFluidNBT.getNBTShareTag(stack.getTagCompound().getCompoundTag(NetworkNodeFluidStorage.NBT_STORAGE)));
 | 
				
			||||||
            return shareTag;
 | 
					            return shareTag;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static ItemStack initNBT(ItemStack stack) {
 | 
					    public static ItemStack initNBT(ItemStack stack) {
 | 
				
			||||||
        NBTTagCompound tag = new NBTTagCompound();
 | 
					        NBTTagCompound tag = new NBTTagCompound();
 | 
				
			||||||
        tag.setTag(TileFluidStorage.NBT_STORAGE, StorageFluidNBT.createNBT());
 | 
					        tag.setTag(NetworkNodeFluidStorage.NBT_STORAGE, StorageFluidNBT.createNBT());
 | 
				
			||||||
        stack.setTagCompound(tag);
 | 
					        stack.setTagCompound(tag);
 | 
				
			||||||
        return stack;
 | 
					        return stack;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,9 +2,9 @@ package com.raoulvdberge.refinedstorage.item;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
					import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSItems;
 | 
					import com.raoulvdberge.refinedstorage.RSItems;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeStorage;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageItemNBT;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageItemNBT;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.block.EnumItemStorageType;
 | 
					import com.raoulvdberge.refinedstorage.block.EnumItemStorageType;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileStorage;
 | 
					 | 
				
			||||||
import net.minecraft.client.resources.I18n;
 | 
					import net.minecraft.client.resources.I18n;
 | 
				
			||||||
import net.minecraft.entity.Entity;
 | 
					import net.minecraft.entity.Entity;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
@@ -28,7 +28,7 @@ public class ItemBlockStorage extends ItemBlockBase {
 | 
				
			|||||||
        EnumItemStorageType type = EnumItemStorageType.getById(stack.getMetadata());
 | 
					        EnumItemStorageType type = EnumItemStorageType.getById(stack.getMetadata());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (type != null && isValid(stack)) {
 | 
					        if (type != null && isValid(stack)) {
 | 
				
			||||||
            NBTTagCompound tag = stack.getTagCompound().getCompoundTag(TileStorage.NBT_STORAGE);
 | 
					            NBTTagCompound tag = stack.getTagCompound().getCompoundTag(NetworkNodeStorage.NBT_STORAGE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (type == EnumItemStorageType.TYPE_CREATIVE) {
 | 
					            if (type == EnumItemStorageType.TYPE_CREATIVE) {
 | 
				
			||||||
                tooltip.add(I18n.format("misc.refinedstorage:storage.stored", StorageItemNBT.getStoredFromNBT(tag)));
 | 
					                tooltip.add(I18n.format("misc.refinedstorage:storage.stored", StorageItemNBT.getStoredFromNBT(tag)));
 | 
				
			||||||
@@ -44,7 +44,7 @@ public class ItemBlockStorage extends ItemBlockBase {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        EnumItemStorageType type = EnumItemStorageType.getById(stack.getMetadata());
 | 
					        EnumItemStorageType type = EnumItemStorageType.getById(stack.getMetadata());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        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()) {
 | 
					        if (type != null && stack.getCount() == 1 && isValid(stack) && StorageItemNBT.getStoredFromNBT(stack.getTagCompound().getCompoundTag(NetworkNodeStorage.NBT_STORAGE)) <= 0 && stack.getMetadata() != ItemStorageDisk.TYPE_CREATIVE && !world.isRemote && player.isSneaking()) {
 | 
				
			||||||
            ItemStack storagePart = new ItemStack(RSItems.STORAGE_PART, 1, stack.getMetadata());
 | 
					            ItemStack storagePart = new ItemStack(RSItems.STORAGE_PART, 1, stack.getMetadata());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (!player.inventory.addItemStackToInventory(storagePart.copy())) {
 | 
					            if (!player.inventory.addItemStackToInventory(storagePart.copy())) {
 | 
				
			||||||
@@ -64,7 +64,7 @@ public class ItemBlockStorage extends ItemBlockBase {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static boolean isValid(ItemStack stack) {
 | 
					    private static boolean isValid(ItemStack stack) {
 | 
				
			||||||
        return stack.getTagCompound() != null && stack.getTagCompound().hasKey(TileStorage.NBT_STORAGE);
 | 
					        return stack.getTagCompound() != null && stack.getTagCompound().hasKey(NetworkNodeStorage.NBT_STORAGE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -94,14 +94,14 @@ public class ItemBlockStorage extends ItemBlockBase {
 | 
				
			|||||||
            return super.getNBTShareTag(stack);
 | 
					            return super.getNBTShareTag(stack);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            NBTTagCompound shareTag = new NBTTagCompound();
 | 
					            NBTTagCompound shareTag = new NBTTagCompound();
 | 
				
			||||||
            shareTag.setTag(TileStorage.NBT_STORAGE, StorageItemNBT.getNBTShareTag(stack.getTagCompound().getCompoundTag(TileStorage.NBT_STORAGE)));
 | 
					            shareTag.setTag(NetworkNodeStorage.NBT_STORAGE, StorageItemNBT.getNBTShareTag(stack.getTagCompound().getCompoundTag(NetworkNodeStorage.NBT_STORAGE)));
 | 
				
			||||||
            return shareTag;
 | 
					            return shareTag;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static ItemStack initNBT(ItemStack stack) {
 | 
					    public static ItemStack initNBT(ItemStack stack) {
 | 
				
			||||||
        NBTTagCompound tag = new NBTTagCompound();
 | 
					        NBTTagCompound tag = new NBTTagCompound();
 | 
				
			||||||
        tag.setTag(TileStorage.NBT_STORAGE, StorageItemNBT.createNBT());
 | 
					        tag.setTag(NetworkNodeStorage.NBT_STORAGE, StorageItemNBT.createNBT());
 | 
				
			||||||
        stack.setTagCompound(tag);
 | 
					        stack.setTagCompound(tag);
 | 
				
			||||||
        return stack;
 | 
					        return stack;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,7 @@ package com.raoulvdberge.refinedstorage.item;
 | 
				
			|||||||
import com.raoulvdberge.refinedstorage.api.network.item.INetworkItem;
 | 
					import com.raoulvdberge.refinedstorage.api.network.item.INetworkItem;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.item.INetworkItemHandler;
 | 
					import com.raoulvdberge.refinedstorage.api.network.item.INetworkItemHandler;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.item.NetworkItemWirelessFluidGrid;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.item.NetworkItemWirelessFluidGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
import net.minecraft.item.ItemStack;
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
import net.minecraft.nbt.NBTTagCompound;
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
@@ -17,17 +17,17 @@ public class ItemWirelessFluidGrid extends ItemNetworkItem {
 | 
				
			|||||||
    public void initializeDefaults(NBTTagCompound tag) {
 | 
					    public void initializeDefaults(NBTTagCompound tag) {
 | 
				
			||||||
        super.initializeDefaults(tag);
 | 
					        super.initializeDefaults(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        tag.setInteger(TileGrid.NBT_SORTING_DIRECTION, TileGrid.SORTING_DIRECTION_DESCENDING);
 | 
					        tag.setInteger(NetworkNodeGrid.NBT_SORTING_DIRECTION, NetworkNodeGrid.SORTING_DIRECTION_DESCENDING);
 | 
				
			||||||
        tag.setInteger(TileGrid.NBT_SORTING_TYPE, TileGrid.SORTING_TYPE_QUANTITY);
 | 
					        tag.setInteger(NetworkNodeGrid.NBT_SORTING_TYPE, NetworkNodeGrid.SORTING_TYPE_QUANTITY);
 | 
				
			||||||
        tag.setInteger(TileGrid.NBT_SEARCH_BOX_MODE, TileGrid.SEARCH_BOX_MODE_NORMAL);
 | 
					        tag.setInteger(NetworkNodeGrid.NBT_SEARCH_BOX_MODE, NetworkNodeGrid.SEARCH_BOX_MODE_NORMAL);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public boolean isValid(ItemStack stack) {
 | 
					    public boolean isValid(ItemStack stack) {
 | 
				
			||||||
        return super.isValid(stack)
 | 
					        return super.isValid(stack)
 | 
				
			||||||
            && stack.getTagCompound().hasKey(TileGrid.NBT_SORTING_DIRECTION)
 | 
					                && stack.getTagCompound().hasKey(NetworkNodeGrid.NBT_SORTING_DIRECTION)
 | 
				
			||||||
            && stack.getTagCompound().hasKey(TileGrid.NBT_SORTING_TYPE)
 | 
					                && stack.getTagCompound().hasKey(NetworkNodeGrid.NBT_SORTING_TYPE)
 | 
				
			||||||
            && stack.getTagCompound().hasKey(TileGrid.NBT_SEARCH_BOX_MODE);
 | 
					                && stack.getTagCompound().hasKey(NetworkNodeGrid.NBT_SEARCH_BOX_MODE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -36,14 +36,14 @@ public class ItemWirelessFluidGrid extends ItemNetworkItem {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static int getSortingType(ItemStack stack) {
 | 
					    public static int getSortingType(ItemStack stack) {
 | 
				
			||||||
        return stack.getTagCompound().getInteger(TileGrid.NBT_SORTING_TYPE);
 | 
					        return stack.getTagCompound().getInteger(NetworkNodeGrid.NBT_SORTING_TYPE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static int getSortingDirection(ItemStack stack) {
 | 
					    public static int getSortingDirection(ItemStack stack) {
 | 
				
			||||||
        return stack.getTagCompound().getInteger(TileGrid.NBT_SORTING_DIRECTION);
 | 
					        return stack.getTagCompound().getInteger(NetworkNodeGrid.NBT_SORTING_DIRECTION);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static int getSearchBoxMode(ItemStack stack) {
 | 
					    public static int getSearchBoxMode(ItemStack stack) {
 | 
				
			||||||
        return stack.getTagCompound().getInteger(TileGrid.NBT_SEARCH_BOX_MODE);
 | 
					        return stack.getTagCompound().getInteger(NetworkNodeGrid.NBT_SEARCH_BOX_MODE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,7 @@ package com.raoulvdberge.refinedstorage.item;
 | 
				
			|||||||
import com.raoulvdberge.refinedstorage.api.network.item.INetworkItem;
 | 
					import com.raoulvdberge.refinedstorage.api.network.item.INetworkItem;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.item.INetworkItemHandler;
 | 
					import com.raoulvdberge.refinedstorage.api.network.item.INetworkItemHandler;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.item.NetworkItemWirelessGrid;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.item.NetworkItemWirelessGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
import net.minecraft.item.ItemStack;
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
import net.minecraft.nbt.NBTTagCompound;
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
@@ -17,20 +17,20 @@ public class ItemWirelessGrid extends ItemNetworkItem {
 | 
				
			|||||||
    public void initializeDefaults(NBTTagCompound tag) {
 | 
					    public void initializeDefaults(NBTTagCompound tag) {
 | 
				
			||||||
        super.initializeDefaults(tag);
 | 
					        super.initializeDefaults(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        tag.setInteger(TileGrid.NBT_VIEW_TYPE, TileGrid.VIEW_TYPE_NORMAL);
 | 
					        tag.setInteger(NetworkNodeGrid.NBT_VIEW_TYPE, NetworkNodeGrid.VIEW_TYPE_NORMAL);
 | 
				
			||||||
        tag.setInteger(TileGrid.NBT_SORTING_DIRECTION, TileGrid.SORTING_DIRECTION_DESCENDING);
 | 
					        tag.setInteger(NetworkNodeGrid.NBT_SORTING_DIRECTION, NetworkNodeGrid.SORTING_DIRECTION_DESCENDING);
 | 
				
			||||||
        tag.setInteger(TileGrid.NBT_SORTING_TYPE, TileGrid.SORTING_TYPE_QUANTITY);
 | 
					        tag.setInteger(NetworkNodeGrid.NBT_SORTING_TYPE, NetworkNodeGrid.SORTING_TYPE_QUANTITY);
 | 
				
			||||||
        tag.setInteger(TileGrid.NBT_SEARCH_BOX_MODE, TileGrid.SEARCH_BOX_MODE_NORMAL);
 | 
					        tag.setInteger(NetworkNodeGrid.NBT_SEARCH_BOX_MODE, NetworkNodeGrid.SEARCH_BOX_MODE_NORMAL);
 | 
				
			||||||
        tag.setInteger(TileGrid.NBT_TAB_SELECTED, -1);
 | 
					        tag.setInteger(NetworkNodeGrid.NBT_TAB_SELECTED, -1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public boolean isValid(ItemStack stack) {
 | 
					    public boolean isValid(ItemStack stack) {
 | 
				
			||||||
        return super.isValid(stack)
 | 
					        return super.isValid(stack)
 | 
				
			||||||
            && stack.getTagCompound().hasKey(TileGrid.NBT_VIEW_TYPE)
 | 
					                && stack.getTagCompound().hasKey(NetworkNodeGrid.NBT_VIEW_TYPE)
 | 
				
			||||||
            && stack.getTagCompound().hasKey(TileGrid.NBT_SORTING_DIRECTION)
 | 
					                && stack.getTagCompound().hasKey(NetworkNodeGrid.NBT_SORTING_DIRECTION)
 | 
				
			||||||
            && stack.getTagCompound().hasKey(TileGrid.NBT_SORTING_TYPE)
 | 
					                && stack.getTagCompound().hasKey(NetworkNodeGrid.NBT_SORTING_TYPE)
 | 
				
			||||||
            && stack.getTagCompound().hasKey(TileGrid.NBT_SEARCH_BOX_MODE);
 | 
					                && stack.getTagCompound().hasKey(NetworkNodeGrid.NBT_SEARCH_BOX_MODE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -39,22 +39,22 @@ public class ItemWirelessGrid extends ItemNetworkItem {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static int getViewType(ItemStack stack) {
 | 
					    public static int getViewType(ItemStack stack) {
 | 
				
			||||||
        return stack.getTagCompound().getInteger(TileGrid.NBT_VIEW_TYPE);
 | 
					        return stack.getTagCompound().getInteger(NetworkNodeGrid.NBT_VIEW_TYPE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static int getSortingType(ItemStack stack) {
 | 
					    public static int getSortingType(ItemStack stack) {
 | 
				
			||||||
        return stack.getTagCompound().getInteger(TileGrid.NBT_SORTING_TYPE);
 | 
					        return stack.getTagCompound().getInteger(NetworkNodeGrid.NBT_SORTING_TYPE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static int getSortingDirection(ItemStack stack) {
 | 
					    public static int getSortingDirection(ItemStack stack) {
 | 
				
			||||||
        return stack.getTagCompound().getInteger(TileGrid.NBT_SORTING_DIRECTION);
 | 
					        return stack.getTagCompound().getInteger(NetworkNodeGrid.NBT_SORTING_DIRECTION);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static int getSearchBoxMode(ItemStack stack) {
 | 
					    public static int getSearchBoxMode(ItemStack stack) {
 | 
				
			||||||
        return stack.getTagCompound().getInteger(TileGrid.NBT_SEARCH_BOX_MODE);
 | 
					        return stack.getTagCompound().getInteger(NetworkNodeGrid.NBT_SEARCH_BOX_MODE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static int getTabSelected(ItemStack stack) {
 | 
					    public static int getTabSelected(ItemStack stack) {
 | 
				
			||||||
        return (stack.hasTagCompound() && stack.getTagCompound().hasKey(TileGrid.NBT_TAB_SELECTED)) ? stack.getTagCompound().getInteger(TileGrid.NBT_TAB_SELECTED) : -1;
 | 
					        return (stack.hasTagCompound() && stack.getTagCompound().hasKey(NetworkNodeGrid.NBT_TAB_SELECTED)) ? stack.getTagCompound().getInteger(NetworkNodeGrid.NBT_TAB_SELECTED) : -1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.network;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSUtils;
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
 | 
					import com.raoulvdberge.refinedstorage.api.network.security.Permission;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.block.EnumGridType;
 | 
					import com.raoulvdberge.refinedstorage.block.EnumGridType;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
					import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
				
			||||||
import io.netty.buffer.ByteBuf;
 | 
					import io.netty.buffer.ByteBuf;
 | 
				
			||||||
@@ -44,9 +45,9 @@ public class MessageGridCraftingClear extends MessageHandlerPlayerToServer<Messa
 | 
				
			|||||||
        TileEntity tile = player.getEntityWorld().getTileEntity(new BlockPos(message.x, message.y, message.z));
 | 
					        TileEntity tile = player.getEntityWorld().getTileEntity(new BlockPos(message.x, message.y, message.z));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (tile instanceof TileGrid) {
 | 
					        if (tile instanceof TileGrid) {
 | 
				
			||||||
            TileGrid grid = (TileGrid) tile;
 | 
					            NetworkNodeGrid grid = (NetworkNodeGrid) ((TileGrid) tile).getNode();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (grid.hasNetwork()) {
 | 
					            if (grid.getNetwork() != null) {
 | 
				
			||||||
                if (grid.getType() == EnumGridType.CRAFTING && grid.getNetwork().getSecurityManager().hasPermission(Permission.INSERT, player)) {
 | 
					                if (grid.getType() == EnumGridType.CRAFTING && grid.getNetwork().getSecurityManager().hasPermission(Permission.INSERT, player)) {
 | 
				
			||||||
                    for (int i = 0; i < grid.getMatrix().getSizeInventory(); ++i) {
 | 
					                    for (int i = 0; i < grid.getMatrix().getSizeInventory(); ++i) {
 | 
				
			||||||
                        ItemStack slot = grid.getMatrix().getStackInSlot(i);
 | 
					                        ItemStack slot = grid.getMatrix().getStackInSlot(i);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.network;
 | 
					package com.raoulvdberge.refinedstorage.network;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.block.EnumGridType;
 | 
					import com.raoulvdberge.refinedstorage.block.EnumGridType;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.ContainerGrid;
 | 
					import com.raoulvdberge.refinedstorage.container.ContainerGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
 | 
					import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
 | 
				
			||||||
@@ -53,7 +54,7 @@ public class MessageGridCraftingTransfer extends MessageHandlerPlayerToServer<Me
 | 
				
			|||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                ((TileGrid) grid).onRecipeTransfer(player, actualRecipe);
 | 
					                ((NetworkNodeGrid) ((TileGrid) grid).getNode()).onRecipeTransfer(player, actualRecipe);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.network;
 | 
					package com.raoulvdberge.refinedstorage.network;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.block.EnumGridType;
 | 
					import com.raoulvdberge.refinedstorage.block.EnumGridType;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileProcessingPatternEncoder;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileProcessingPatternEncoder;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
					import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
				
			||||||
@@ -41,8 +42,8 @@ public class MessageGridPatternCreate extends MessageHandlerPlayerToServer<Messa
 | 
				
			|||||||
    public void handle(MessageGridPatternCreate message, EntityPlayerMP player) {
 | 
					    public void handle(MessageGridPatternCreate message, EntityPlayerMP player) {
 | 
				
			||||||
        TileEntity tile = player.getEntityWorld().getTileEntity(new BlockPos(message.x, message.y, message.z));
 | 
					        TileEntity tile = player.getEntityWorld().getTileEntity(new BlockPos(message.x, message.y, message.z));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (tile instanceof TileGrid && ((TileGrid) tile).getType() == EnumGridType.PATTERN) {
 | 
					        if (tile instanceof TileGrid && ((NetworkNodeGrid) ((TileGrid) tile).getNode()).getType() == EnumGridType.PATTERN) {
 | 
				
			||||||
            ((TileGrid) tile).onCreatePattern();
 | 
					            ((NetworkNodeGrid) ((TileGrid) tile).getNode()).onCreatePattern();
 | 
				
			||||||
        } else if (tile instanceof TileProcessingPatternEncoder) {
 | 
					        } else if (tile instanceof TileProcessingPatternEncoder) {
 | 
				
			||||||
            ((TileProcessingPatternEncoder) tile).onCreatePattern();
 | 
					            ((TileProcessingPatternEncoder) tile).onCreatePattern();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.network;
 | 
					package com.raoulvdberge.refinedstorage.network;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
 | 
					import com.raoulvdberge.refinedstorage.api.network.security.Permission;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeSecurityManager;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.TileSecurityManager;
 | 
					import com.raoulvdberge.refinedstorage.tile.TileSecurityManager;
 | 
				
			||||||
import io.netty.buffer.ByteBuf;
 | 
					import io.netty.buffer.ByteBuf;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayerMP;
 | 
					import net.minecraft.entity.player.EntityPlayerMP;
 | 
				
			||||||
@@ -60,7 +61,7 @@ public class MessageSecurityManagerUpdate extends MessageHandlerPlayerToServer<M
 | 
				
			|||||||
        TileEntity tile = player.getEntityWorld().getTileEntity(new BlockPos(message.x, message.y, message.z));
 | 
					        TileEntity tile = player.getEntityWorld().getTileEntity(new BlockPos(message.x, message.y, message.z));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (tile instanceof TileSecurityManager) {
 | 
					        if (tile instanceof TileSecurityManager) {
 | 
				
			||||||
            ((TileSecurityManager) tile).updatePermission(message.permission, message.state);
 | 
					            ((NetworkNodeSecurityManager) ((TileSecurityManager) tile).getNode()).updatePermission(message.permission, message.state);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,8 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.network;
 | 
					package com.raoulvdberge.refinedstorage.network;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.ContainerGrid;
 | 
					import com.raoulvdberge.refinedstorage.container.ContainerGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
 | 
					import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
					 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.WirelessFluidGrid;
 | 
					import com.raoulvdberge.refinedstorage.tile.grid.WirelessFluidGrid;
 | 
				
			||||||
import io.netty.buffer.ByteBuf;
 | 
					import io.netty.buffer.ByteBuf;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayerMP;
 | 
					import net.minecraft.entity.player.EntityPlayerMP;
 | 
				
			||||||
@@ -45,16 +45,16 @@ public class MessageWirelessFluidGridSettingsUpdate extends MessageHandlerPlayer
 | 
				
			|||||||
            if (grid instanceof WirelessFluidGrid) {
 | 
					            if (grid instanceof WirelessFluidGrid) {
 | 
				
			||||||
                ItemStack stack = ((WirelessFluidGrid) grid).getStack();
 | 
					                ItemStack stack = ((WirelessFluidGrid) grid).getStack();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (TileGrid.isValidSortingDirection(message.sortingDirection)) {
 | 
					                if (NetworkNodeGrid.isValidSortingDirection(message.sortingDirection)) {
 | 
				
			||||||
                    stack.getTagCompound().setInteger(TileGrid.NBT_SORTING_DIRECTION, message.sortingDirection);
 | 
					                    stack.getTagCompound().setInteger(NetworkNodeGrid.NBT_SORTING_DIRECTION, message.sortingDirection);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (TileGrid.isValidSortingType(message.sortingType)) {
 | 
					                if (NetworkNodeGrid.isValidSortingType(message.sortingType)) {
 | 
				
			||||||
                    stack.getTagCompound().setInteger(TileGrid.NBT_SORTING_TYPE, message.sortingType);
 | 
					                    stack.getTagCompound().setInteger(NetworkNodeGrid.NBT_SORTING_TYPE, message.sortingType);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (TileGrid.isValidSearchBoxMode(message.searchBoxMode)) {
 | 
					                if (NetworkNodeGrid.isValidSearchBoxMode(message.searchBoxMode)) {
 | 
				
			||||||
                    stack.getTagCompound().setInteger(TileGrid.NBT_SEARCH_BOX_MODE, message.searchBoxMode);
 | 
					                    stack.getTagCompound().setInteger(NetworkNodeGrid.NBT_SEARCH_BOX_MODE, message.searchBoxMode);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,8 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.network;
 | 
					package com.raoulvdberge.refinedstorage.network;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.container.ContainerGrid;
 | 
					import com.raoulvdberge.refinedstorage.container.ContainerGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
 | 
					import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
 | 
					 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.grid.WirelessGrid;
 | 
					import com.raoulvdberge.refinedstorage.tile.grid.WirelessGrid;
 | 
				
			||||||
import io.netty.buffer.ByteBuf;
 | 
					import io.netty.buffer.ByteBuf;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayerMP;
 | 
					import net.minecraft.entity.player.EntityPlayerMP;
 | 
				
			||||||
@@ -53,23 +53,23 @@ public class MessageWirelessGridSettingsUpdate extends MessageHandlerPlayerToSer
 | 
				
			|||||||
            if (grid instanceof WirelessGrid) {
 | 
					            if (grid instanceof WirelessGrid) {
 | 
				
			||||||
                ItemStack stack = ((WirelessGrid) grid).getStack();
 | 
					                ItemStack stack = ((WirelessGrid) grid).getStack();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (TileGrid.isValidViewType(message.viewType)) {
 | 
					                if (NetworkNodeGrid.isValidViewType(message.viewType)) {
 | 
				
			||||||
                    stack.getTagCompound().setInteger(TileGrid.NBT_VIEW_TYPE, message.viewType);
 | 
					                    stack.getTagCompound().setInteger(NetworkNodeGrid.NBT_VIEW_TYPE, message.viewType);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (TileGrid.isValidSortingDirection(message.sortingDirection)) {
 | 
					                if (NetworkNodeGrid.isValidSortingDirection(message.sortingDirection)) {
 | 
				
			||||||
                    stack.getTagCompound().setInteger(TileGrid.NBT_SORTING_DIRECTION, message.sortingDirection);
 | 
					                    stack.getTagCompound().setInteger(NetworkNodeGrid.NBT_SORTING_DIRECTION, message.sortingDirection);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (TileGrid.isValidSortingType(message.sortingType)) {
 | 
					                if (NetworkNodeGrid.isValidSortingType(message.sortingType)) {
 | 
				
			||||||
                    stack.getTagCompound().setInteger(TileGrid.NBT_SORTING_TYPE, message.sortingType);
 | 
					                    stack.getTagCompound().setInteger(NetworkNodeGrid.NBT_SORTING_TYPE, message.sortingType);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (TileGrid.isValidSearchBoxMode(message.searchBoxMode)) {
 | 
					                if (NetworkNodeGrid.isValidSearchBoxMode(message.searchBoxMode)) {
 | 
				
			||||||
                    stack.getTagCompound().setInteger(TileGrid.NBT_SEARCH_BOX_MODE, message.searchBoxMode);
 | 
					                    stack.getTagCompound().setInteger(NetworkNodeGrid.NBT_SEARCH_BOX_MODE, message.searchBoxMode);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                stack.getTagCompound().setInteger(TileGrid.NBT_TAB_SELECTED, message.tabSelected);
 | 
					                stack.getTagCompound().setInteger(NetworkNodeGrid.NBT_TAB_SELECTED, message.tabSelected);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user