[1.11] INetworkNode needs to be a capability (#687)
* Remove INetworkNode.getPosition(), add INetworkNode.getItemStack() * Remove INetworkNode.getNodeWorld(), add IWirelessTransmitter.getDimension() * Add INetworkNode Capability, Remove INetworkNode.canConduct(...), use tile.hasCapability(...) to test conductivity. WirelessTransmitter conduct on DOWN side. * Remove isConnected() from INetworkNode Use "active" instead of "connected" for client(remote) state Replace isConnected by isActive in IGrid, ICraftingMonitor, IReaderWriter * Refactor getConnectableConditions to use side and capability * INetworkNode capability Refactor rebuild network graph * Clean code and fix rebuild for other mods * Make TileController a INetworkNode, and some cleaning * Fix dropping controller * Use EnumFacing.VALUES * Make getItemStack return @Notnull, return ItemStack.EMPTY by default
This commit is contained in:
		@@ -12,11 +12,12 @@ import com.raoulvdberge.refinedstorage.api.util.IComparer;
 | 
				
			|||||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
 | 
					import com.raoulvdberge.refinedstorage.api.util.IStackList;
 | 
				
			||||||
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.minecraftforge.fluids.FluidStack;
 | 
					import net.minecraftforge.fluids.FluidStack;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.annotation.Nonnull;
 | 
					import javax.annotation.Nonnull;
 | 
				
			||||||
import java.util.Set;
 | 
					import java.util.Set;
 | 
				
			||||||
import java.util.function.Predicate;
 | 
					import java.util.function.BiPredicate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Represents a Refined Storage API implementation.
 | 
					 * Represents a Refined Storage API implementation.
 | 
				
			||||||
@@ -95,5 +96,5 @@ public interface IRSAPI {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @return a set with the predicates to check if a block is connectable
 | 
					     * @return a set with the predicates to check if a block is connectable
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    Set<Predicate<TileEntity>> getConnectableConditions();
 | 
					    Set<BiPredicate<TileEntity, EnumFacing>> getConnectableConditions();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.api.network;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import net.minecraft.util.EnumFacing;
 | 
				
			||||||
 | 
					import net.minecraft.util.math.BlockPos;
 | 
				
			||||||
 | 
					import net.minecraft.world.World;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Allow the network nodes to implement more optimal or non-regular discovery of neighbor nodes
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public interface INetworkNeighborhoodAware {
 | 
				
			||||||
 | 
					    void walkNeighborhood(Operator operator);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @FunctionalInterface
 | 
				
			||||||
 | 
					    interface Operator {
 | 
				
			||||||
 | 
					        void apply(World world, BlockPos pos, EnumFacing side);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,8 +1,8 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.api.network;
 | 
					package com.raoulvdberge.refinedstorage.api.network;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import net.minecraft.util.EnumFacing;
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
import net.minecraft.util.math.BlockPos;
 | 
					
 | 
				
			||||||
import net.minecraft.world.World;
 | 
					import javax.annotation.Nonnull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Represents a node in the network.
 | 
					 * Represents a node in the network.
 | 
				
			||||||
@@ -14,9 +14,10 @@ public interface INetworkNode {
 | 
				
			|||||||
    int getEnergyUsage();
 | 
					    int getEnergyUsage();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @return the position of this node in the world
 | 
					     * @return the item of the node
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    BlockPos getPosition();
 | 
					    @Nonnull
 | 
				
			||||||
 | 
					    ItemStack getItemStack();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Called when this node is connected to a network.
 | 
					     * Called when this node is connected to a network.
 | 
				
			||||||
@@ -32,29 +33,13 @@ public interface INetworkNode {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    void onDisconnected(INetworkMaster network);
 | 
					    void onDisconnected(INetworkMaster network);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * @return true if this is node is connected to a network, or false otherwise
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    boolean isConnected();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @return true if this node can be treated as active, typically checks the redstone configuration
 | 
					     * @return true if this node can be treated as active, typically checks the redstone configuration
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    boolean canUpdate();
 | 
					    boolean canUpdate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * @param direction the direction to do a conduction check
 | 
					 | 
				
			||||||
     * @return true if this node can conduct a connection to the given direction, false otherwise
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    boolean canConduct(EnumFacing direction);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @return the network
 | 
					     * @return the network
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    INetworkMaster getNetwork();
 | 
					    INetworkMaster getNetwork();
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * @return the world where this node is in
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    World getNodeWorld();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,5 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.api.network;
 | 
					package com.raoulvdberge.refinedstorage.api.network;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import net.minecraft.util.math.BlockPos;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import javax.annotation.Nullable;
 | 
					 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -10,19 +7,10 @@ import java.util.List;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
public interface INetworkNodeGraph {
 | 
					public interface INetworkNodeGraph {
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Rebuilds the node graph.
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param start  the starting position to start looking for nodes, or null to start at network begin position
 | 
					 | 
				
			||||||
     * @param notify true to notify the nodes of a connection change, false to not notify
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    void rebuild(@Nullable BlockPos start, boolean notify);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Rebuilds the network graph.
 | 
					     * Rebuilds the network graph.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    default void rebuild() {
 | 
					    void rebuild();
 | 
				
			||||||
        rebuild(null, true);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @return a list of all connected nodes
 | 
					     * @return a list of all connected nodes
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,4 +15,9 @@ public interface IWirelessTransmitter {
 | 
				
			|||||||
     * @return the position where the wireless signal starts
 | 
					     * @return the position where the wireless signal starts
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    BlockPos getOrigin();
 | 
					    BlockPos getOrigin();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @return the dimension in which the transmitter is
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    int getDimension();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.util.StackListFluid;
 | 
				
			|||||||
import com.raoulvdberge.refinedstorage.apiimpl.util.StackListItem;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.util.StackListItem;
 | 
				
			||||||
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.minecraftforge.fluids.FluidStack;
 | 
					import net.minecraftforge.fluids.FluidStack;
 | 
				
			||||||
import net.minecraftforge.fml.common.discovery.ASMDataTable;
 | 
					import net.minecraftforge.fml.common.discovery.ASMDataTable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -31,7 +32,7 @@ import javax.annotation.Nonnull;
 | 
				
			|||||||
import java.lang.reflect.Field;
 | 
					import java.lang.reflect.Field;
 | 
				
			||||||
import java.util.HashSet;
 | 
					import java.util.HashSet;
 | 
				
			||||||
import java.util.Set;
 | 
					import java.util.Set;
 | 
				
			||||||
import java.util.function.Predicate;
 | 
					import java.util.function.BiPredicate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class API implements IRSAPI {
 | 
					public class API implements IRSAPI {
 | 
				
			||||||
    private static final IRSAPI INSTANCE = new API();
 | 
					    private static final IRSAPI INSTANCE = new API();
 | 
				
			||||||
@@ -42,7 +43,30 @@ public class API implements IRSAPI {
 | 
				
			|||||||
    private ICraftingMonitorElementRegistry craftingMonitorElementRegistry = new CraftingMonitorElementRegistry();
 | 
					    private ICraftingMonitorElementRegistry craftingMonitorElementRegistry = new CraftingMonitorElementRegistry();
 | 
				
			||||||
    private ICraftingPreviewElementRegistry craftingPreviewElementRegistry = new CraftingPreviewElementRegistry();
 | 
					    private ICraftingPreviewElementRegistry craftingPreviewElementRegistry = new CraftingPreviewElementRegistry();
 | 
				
			||||||
    private IReaderWriterHandlerRegistry readerWriterHandlerRegistry = new ReaderWriterHandlerRegistry();
 | 
					    private IReaderWriterHandlerRegistry readerWriterHandlerRegistry = new ReaderWriterHandlerRegistry();
 | 
				
			||||||
    private Set<Predicate<TileEntity>> connectableConditions = new HashSet<>();
 | 
					    private Set<BiPredicate<TileEntity, EnumFacing>> connectableConditions = new HashSet<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static IRSAPI instance() {
 | 
				
			||||||
 | 
					        return INSTANCE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static void deliver(ASMDataTable asmDataTable) {
 | 
				
			||||||
 | 
					        String annotationClassName = RSAPIInject.class.getCanonicalName();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Set<ASMDataTable.ASMData> asmDataSet = asmDataTable.getAll(annotationClassName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (ASMDataTable.ASMData asmData : asmDataSet) {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                Class clazz = Class.forName(asmData.getClassName());
 | 
				
			||||||
 | 
					                Field field = clazz.getField(asmData.getObjectName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (field.getType() == IRSAPI.class) {
 | 
				
			||||||
 | 
					                    field.set(null, INSTANCE);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
 | 
				
			||||||
 | 
					                throw new RuntimeException("Failed to set: {}" + asmData.getClassName() + "." + asmData.getObjectName(), e);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Nonnull
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -115,30 +139,7 @@ public class API implements IRSAPI {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public Set<Predicate<TileEntity>> getConnectableConditions() {
 | 
					    public Set<BiPredicate<TileEntity, EnumFacing>> getConnectableConditions() {
 | 
				
			||||||
        return connectableConditions;
 | 
					        return connectableConditions;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    public static IRSAPI instance() {
 | 
					 | 
				
			||||||
        return INSTANCE;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public static void deliver(ASMDataTable asmDataTable) {
 | 
					 | 
				
			||||||
        String annotationClassName = RSAPIInject.class.getCanonicalName();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Set<ASMDataTable.ASMData> asmDataSet = asmDataTable.getAll(annotationClassName);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        for (ASMDataTable.ASMData asmData : asmDataSet) {
 | 
					 | 
				
			||||||
            try {
 | 
					 | 
				
			||||||
                Class clazz = Class.forName(asmData.getClassName());
 | 
					 | 
				
			||||||
                Field field = clazz.getField(asmData.getObjectName());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (field.getType() == IRSAPI.class) {
 | 
					 | 
				
			||||||
                    field.set(null, INSTANCE);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            } catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
 | 
					 | 
				
			||||||
                throw new RuntimeException("Failed to set: {}" + asmData.getClassName() + "." + asmData.getObjectName(), e);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,12 +2,12 @@ package com.raoulvdberge.refinedstorage.apiimpl.network;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
					import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternContainer;
 | 
					import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternContainer;
 | 
				
			||||||
 | 
					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.storage.IStorageProvider;
 | 
					import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
 | 
				
			||||||
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 com.raoulvdberge.refinedstorage.tile.TileNetworkTransmitter;
 | 
					 | 
				
			||||||
import net.minecraft.block.state.IBlockState;
 | 
					import net.minecraft.block.state.IBlockState;
 | 
				
			||||||
import net.minecraft.inventory.InventoryHelper;
 | 
					import net.minecraft.inventory.InventoryHelper;
 | 
				
			||||||
import net.minecraft.item.ItemStack;
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
@@ -15,10 +15,11 @@ import net.minecraft.tileentity.TileEntity;
 | 
				
			|||||||
import net.minecraft.util.EnumFacing;
 | 
					import net.minecraft.util.EnumFacing;
 | 
				
			||||||
import net.minecraft.util.math.BlockPos;
 | 
					import net.minecraft.util.math.BlockPos;
 | 
				
			||||||
import net.minecraft.world.World;
 | 
					import net.minecraft.world.World;
 | 
				
			||||||
import net.minecraftforge.common.DimensionManager;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.*;
 | 
					import java.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import static com.raoulvdberge.refinedstorage.proxy.CapabilityNetworkNode.NETWORK_NODE_CAPABILITY;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class NetworkNodeGraph implements INetworkNodeGraph {
 | 
					public class NetworkNodeGraph implements INetworkNodeGraph {
 | 
				
			||||||
    private TileController controller;
 | 
					    private TileController controller;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -29,11 +30,7 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void rebuild(BlockPos start, boolean notify) {
 | 
					    public void rebuild() {
 | 
				
			||||||
        if (start == null) {
 | 
					 | 
				
			||||||
            start = controller.getPosition();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (!controller.canRun()) {
 | 
					        if (!controller.canRun()) {
 | 
				
			||||||
            if (!nodes.isEmpty()) {
 | 
					            if (!nodes.isEmpty()) {
 | 
				
			||||||
                disconnectAll();
 | 
					                disconnectAll();
 | 
				
			||||||
@@ -42,112 +39,53 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
 | 
				
			|||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        World world = getWorld();
 | 
					        Set<INetworkNode> newNodes = new HashSet<>();
 | 
				
			||||||
 | 
					        Queue<NodeToCheck> toCheck = new ArrayDeque<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        List<INetworkNode> newNodes = new ArrayList<>();
 | 
					        INetworkNeighborhoodAware.Operator operator = (world, pos, side) -> {
 | 
				
			||||||
 | 
					            TileEntity tile = world.getTileEntity(pos);
 | 
				
			||||||
        Set<BlockPos> checked = new HashSet<>();
 | 
					            if (tile != null) {
 | 
				
			||||||
        Queue<BlockPos> toCheck = new ArrayDeque<>();
 | 
					                if (tile instanceof TileController) {
 | 
				
			||||||
 | 
					                    removeOtherControler(world, pos);
 | 
				
			||||||
        checked.add(start);
 | 
					                } else {
 | 
				
			||||||
        toCheck.add(start);
 | 
					                    INetworkNode otherNode = NETWORK_NODE_CAPABILITY.cast(tile.getCapability(NETWORK_NODE_CAPABILITY, side));
 | 
				
			||||||
 | 
					                    if (otherNode != null && newNodes.add(otherNode)) {
 | 
				
			||||||
 | 
					                        toCheck.add(new NodeToCheck(otherNode, world, pos, side, tile));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        BlockPos controllerPos = controller.getPos();
 | 
				
			||||||
 | 
					        World controlerWorld = controller.getWorld();
 | 
				
			||||||
        for (EnumFacing facing : EnumFacing.VALUES) {
 | 
					        for (EnumFacing facing : EnumFacing.VALUES) {
 | 
				
			||||||
            BlockPos pos = start.offset(facing);
 | 
					            BlockPos pos = controllerPos.offset(facing);
 | 
				
			||||||
 | 
					            operator.apply(controlerWorld, pos, facing.getOpposite());
 | 
				
			||||||
            checked.add(pos);
 | 
					 | 
				
			||||||
            toCheck.add(pos);
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        BlockPos currentPos;
 | 
					        NodeToCheck currentNodeToCheck;
 | 
				
			||||||
        while ((currentPos = toCheck.poll()) != null) {
 | 
					        while ((currentNodeToCheck = toCheck.poll()) != null) {
 | 
				
			||||||
            TileEntity tile = world.getTileEntity(currentPos);
 | 
					            currentNodeToCheck.walkNeighborhood(operator);
 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (tile instanceof TileController && !controller.getPos().equals(currentPos)) {
 | 
					 | 
				
			||||||
                world.setBlockToAir(currentPos);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                IBlockState state = world.getBlockState(currentPos);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                InventoryHelper.spawnItemStack(
 | 
					 | 
				
			||||||
                    world,
 | 
					 | 
				
			||||||
                    currentPos.getX(),
 | 
					 | 
				
			||||||
                    currentPos.getY(),
 | 
					 | 
				
			||||||
                    currentPos.getZ(),
 | 
					 | 
				
			||||||
                    ItemBlockController.createStackWithNBT(new ItemStack(RSBlocks.CONTROLLER, 1, state.getBlock().getMetaFromState(state)))
 | 
					 | 
				
			||||||
                );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                continue;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (!(tile instanceof INetworkNode)) {
 | 
					 | 
				
			||||||
                continue;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            INetworkNode node = (INetworkNode) tile;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            newNodes.add(node);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (tile instanceof TileNetworkTransmitter) {
 | 
					 | 
				
			||||||
                final TileNetworkTransmitter transmitter = (TileNetworkTransmitter) tile;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (transmitter.canTransmit()) {
 | 
					 | 
				
			||||||
                    if (!transmitter.isSameDimension()) {
 | 
					 | 
				
			||||||
                        final World dimensionWorld = DimensionManager.getWorld(transmitter.getReceiverDimension());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (dimensionWorld != null) {
 | 
					 | 
				
			||||||
                            NetworkNodeGraph dimensionGraph = new NetworkNodeGraph(controller) {
 | 
					 | 
				
			||||||
                                @Override
 | 
					 | 
				
			||||||
                                public World getWorld() {
 | 
					 | 
				
			||||||
                                    return dimensionWorld;
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                            };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            dimensionGraph.rebuild(transmitter.getReceiver(), false);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            newNodes.addAll(dimensionGraph.all());
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    } else {
 | 
					 | 
				
			||||||
                        BlockPos receiver = transmitter.getReceiver();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (checked.add(receiver)) {
 | 
					 | 
				
			||||||
                            toCheck.add(receiver);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            for (EnumFacing facing : EnumFacing.VALUES) {
 | 
					 | 
				
			||||||
                if (node.canConduct(facing)) {
 | 
					 | 
				
			||||||
                    BlockPos pos = currentPos.offset(facing);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    if (checked.add(pos)) {
 | 
					 | 
				
			||||||
                        toCheck.add(pos);
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        List<INetworkNode> oldNodes = new ArrayList<>(nodes);
 | 
					        List<INetworkNode> oldNodes = nodes;
 | 
				
			||||||
 | 
					        nodes = new ArrayList<>(newNodes);
 | 
				
			||||||
        this.nodes = newNodes;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        boolean changed = false;
 | 
					        boolean changed = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (notify) {
 | 
					        for (INetworkNode node : nodes) {
 | 
				
			||||||
            for (INetworkNode node : nodes) {
 | 
					            if (!oldNodes.contains(node)) {
 | 
				
			||||||
                if (!oldNodes.contains(node)) {
 | 
					                node.onConnected(controller);
 | 
				
			||||||
                    node.onConnected(controller);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    changed = true;
 | 
					                changed = true;
 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (INetworkNode oldNode : oldNodes) {
 | 
					        for (INetworkNode oldNode : oldNodes) {
 | 
				
			||||||
                if (!nodes.contains(oldNode)) {
 | 
					            if (!nodes.contains(oldNode)) {
 | 
				
			||||||
                    oldNode.onDisconnected(controller);
 | 
					                oldNode.onDisconnected(controller);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    changed = true;
 | 
					                changed = true;
 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -185,7 +123,7 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
 | 
				
			|||||||
        nodes.clear();
 | 
					        nodes.clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (INetworkNode node : oldNodes) {
 | 
					        for (INetworkNode node : oldNodes) {
 | 
				
			||||||
            if (node.isConnected()) {
 | 
					            if (node.getNetwork() == controller) {
 | 
				
			||||||
                node.onDisconnected(controller);
 | 
					                node.onDisconnected(controller);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -196,4 +134,54 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
 | 
				
			|||||||
    protected World getWorld() {
 | 
					    protected World getWorld() {
 | 
				
			||||||
        return controller.getWorld();
 | 
					        return controller.getWorld();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void removeOtherControler(World world, BlockPos otherControllerPos) {
 | 
				
			||||||
 | 
					        if (!controller.getPos().equals(otherControllerPos)) {
 | 
				
			||||||
 | 
					            IBlockState state = world.getBlockState(otherControllerPos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ItemStack itemStackToSpawn = ItemBlockController.createStackWithNBT(new ItemStack(RSBlocks.CONTROLLER, 1, state.getBlock().getMetaFromState(state)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            world.setBlockToAir(otherControllerPos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            InventoryHelper.spawnItemStack(
 | 
				
			||||||
 | 
					                    world,
 | 
				
			||||||
 | 
					                    otherControllerPos.getX(),
 | 
				
			||||||
 | 
					                    otherControllerPos.getY(),
 | 
				
			||||||
 | 
					                    otherControllerPos.getZ(),
 | 
				
			||||||
 | 
					                    itemStackToSpawn
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private class NodeToCheck implements INetworkNeighborhoodAware {
 | 
				
			||||||
 | 
					        private final INetworkNode node;
 | 
				
			||||||
 | 
					        private final World world;
 | 
				
			||||||
 | 
					        private final BlockPos pos;
 | 
				
			||||||
 | 
					        private final EnumFacing side;
 | 
				
			||||||
 | 
					        private final TileEntity tile;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        NodeToCheck(INetworkNode node, World world, BlockPos pos, EnumFacing side, TileEntity tile) {
 | 
				
			||||||
 | 
					            this.node = node;
 | 
				
			||||||
 | 
					            this.world = world;
 | 
				
			||||||
 | 
					            this.pos = pos;
 | 
				
			||||||
 | 
					            this.side = side;
 | 
				
			||||||
 | 
					            this.tile = tile;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public void walkNeighborhood(Operator operator) {
 | 
				
			||||||
 | 
					            if (node instanceof INetworkNeighborhoodAware) {
 | 
				
			||||||
 | 
					                ((INetworkNeighborhoodAware) node).walkNeighborhood(operator);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                for (EnumFacing checkSide : EnumFacing.VALUES) {
 | 
				
			||||||
 | 
					                    if (checkSide != side) { // Avoid going backward
 | 
				
			||||||
 | 
					                        INetworkNode nodeOnSide = NETWORK_NODE_CAPABILITY.cast(tile.getCapability(NETWORK_NODE_CAPABILITY, checkSide));
 | 
				
			||||||
 | 
					                        if (nodeOnSide == node) {
 | 
				
			||||||
 | 
					                            operator.apply(world, pos.offset(checkSide), checkSide.getOpposite());
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,7 +36,7 @@ public class NetworkItemHandler implements INetworkItemHandler {
 | 
				
			|||||||
        boolean inRange = false;
 | 
					        boolean inRange = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (INetworkNode node : network.getNodeGraph().all()) {
 | 
					        for (INetworkNode node : network.getNodeGraph().all()) {
 | 
				
			||||||
            if (node instanceof IWirelessTransmitter && node.getNodeWorld().provider.getDimension() == player.dimension) {
 | 
					            if (node instanceof IWirelessTransmitter && ((IWirelessTransmitter) node).getDimension() == player.dimension) {
 | 
				
			||||||
                IWirelessTransmitter transmitter = (IWirelessTransmitter) node;
 | 
					                IWirelessTransmitter transmitter = (IWirelessTransmitter) node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                double distance = Math.sqrt(Math.pow(transmitter.getOrigin().getX() - player.posX, 2) + Math.pow(transmitter.getOrigin().getY() - player.posY, 2) + Math.pow(transmitter.getOrigin().getZ() - player.posZ, 2));
 | 
					                double distance = Math.sqrt(Math.pow(transmitter.getOrigin().getX() - player.posX, 2) + Math.pow(transmitter.getOrigin().getY() - player.posY, 2) + Math.pow(transmitter.getOrigin().getZ() - player.posZ, 2));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -90,9 +90,10 @@ public class BlockCable extends BlockNode {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private boolean hasConnectionWith(IBlockAccess world, BlockPos pos, EnumFacing direction) {
 | 
					    private boolean hasConnectionWith(IBlockAccess world, BlockPos pos, EnumFacing direction) {
 | 
				
			||||||
        TileEntity facing = world.getTileEntity(pos.offset(direction));
 | 
					        TileEntity otherTile = world.getTileEntity(pos.offset(direction));
 | 
				
			||||||
 | 
					        EnumFacing otherTileSide = direction.getOpposite();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return API.instance().getConnectableConditions().stream().anyMatch(p -> p.test(facing));
 | 
					        return API.instance().getConnectableConditions().stream().anyMatch(p -> p.test(otherTile, otherTileSide));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private boolean isInAABB(AxisAlignedBB aabb, float hitX, float hitY, float hitZ) {
 | 
					    private boolean isInAABB(AxisAlignedBB aabb, float hitX, float hitY, float hitZ) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -87,7 +87,7 @@ public class BlockExternalStorage extends BlockCable {
 | 
				
			|||||||
        if (!world.isRemote) {
 | 
					        if (!world.isRemote) {
 | 
				
			||||||
            TileExternalStorage externalStorage = (TileExternalStorage) world.getTileEntity(pos);
 | 
					            TileExternalStorage externalStorage = (TileExternalStorage) world.getTileEntity(pos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (externalStorage.getNetwork() != null) {
 | 
					            if (externalStorage.hasNetwork()) {
 | 
				
			||||||
                externalStorage.updateStorage(externalStorage.getNetwork());
 | 
					                externalStorage.updateStorage(externalStorage.getNetwork());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,7 +44,7 @@ public abstract class BlockNode extends BlockBase {
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
 | 
					    public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
 | 
				
			||||||
        if (hasConnectivityState()) {
 | 
					        if (hasConnectivityState()) {
 | 
				
			||||||
            return super.getActualState(state, world, pos).withProperty(CONNECTED, ((TileNode) world.getTileEntity(pos)).isConnected());
 | 
					            return super.getActualState(state, world, pos).withProperty(CONNECTED, ((TileNode) world.getTileEntity(pos)).isActive());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return super.getActualState(state, world, pos);
 | 
					        return super.getActualState(state, world, pos);
 | 
				
			||||||
@@ -58,7 +58,7 @@ public abstract class BlockNode extends BlockBase {
 | 
				
			|||||||
            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 instanceof TileNode && ((TileNode) tile).isConnected()) {
 | 
					                if (tile instanceof TileNode && ((TileNode) tile).hasNetwork()) {
 | 
				
			||||||
                    ((TileNode) tile).getNetwork().getNodeGraph().rebuild();
 | 
					                    ((TileNode) tile).getNetwork().getNodeGraph().rebuild();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -58,7 +58,7 @@ public class GuiCraftingMonitor extends GuiBase {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private List<ICraftingMonitorElement> getElements() {
 | 
					    private List<ICraftingMonitorElement> getElements() {
 | 
				
			||||||
        return craftingMonitor.isConnected() ? ELEMENTS : Collections.emptyList();
 | 
					        return craftingMonitor.isActive() ? ELEMENTS : Collections.emptyList();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -193,6 +193,6 @@ public class GuiReaderWriter extends GuiBase {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private List<String> getChannels() {
 | 
					    private List<String> getChannels() {
 | 
				
			||||||
        return readerWriter.isConnected() ? CHANNELS : Collections.emptyList();
 | 
					        return readerWriter.isActive() ? CHANNELS : Collections.emptyList();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -88,7 +88,7 @@ public class GuiGrid extends GuiBase {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        this.container = container;
 | 
					        this.container = container;
 | 
				
			||||||
        this.grid = grid;
 | 
					        this.grid = grid;
 | 
				
			||||||
        this.wasConnected = grid.isConnected();
 | 
					        this.wasConnected = this.grid.isActive();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.scrollbar = new Scrollbar(174, 20, 12, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN || grid.getType() == EnumGridType.FLUID) ? 70 : 88);
 | 
					        this.scrollbar = new Scrollbar(174, 20, 12, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN || grid.getType() == EnumGridType.FLUID) ? 70 : 88);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -139,7 +139,7 @@ public class GuiGrid extends GuiBase {
 | 
				
			|||||||
    private void sortItems() {
 | 
					    private void sortItems() {
 | 
				
			||||||
        List<IClientStack> stacks = new ArrayList<>();
 | 
					        List<IClientStack> stacks = new ArrayList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (grid.isConnected()) {
 | 
					        if (grid.isActive()) {
 | 
				
			||||||
            stacks.addAll(grid.getType() == EnumGridType.FLUID ? FLUIDS.values() : ITEMS.values());
 | 
					            stacks.addAll(grid.getType() == EnumGridType.FLUID ? FLUIDS.values() : ITEMS.values());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            List<IGridFilter> filters = GridFilterParser.getFilters(grid, searchField.getText());
 | 
					            List<IGridFilter> filters = GridFilterParser.getFilters(grid, searchField.getText());
 | 
				
			||||||
@@ -183,8 +183,8 @@ public class GuiGrid extends GuiBase {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (wasConnected != grid.isConnected()) {
 | 
					        if (wasConnected != grid.isActive()) {
 | 
				
			||||||
            wasConnected = grid.isConnected();
 | 
					            wasConnected = grid.isActive();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            markForSorting();
 | 
					            markForSorting();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -201,7 +201,7 @@ public class GuiGrid extends GuiBase {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private boolean isOverSlotWithItem() {
 | 
					    private boolean isOverSlotWithItem() {
 | 
				
			||||||
        return grid.isConnected() && isOverSlot() && slotNumber < STACKS.size();
 | 
					        return grid.isActive() && isOverSlot() && slotNumber < STACKS.size();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private boolean isOverSlot() {
 | 
					    private boolean isOverSlot() {
 | 
				
			||||||
@@ -278,7 +278,7 @@ public class GuiGrid extends GuiBase {
 | 
				
			|||||||
            int xx = x + (konami.isEmpty() ? konamiOffsetsX[i] : 0);
 | 
					            int xx = x + (konami.isEmpty() ? konamiOffsetsX[i] : 0);
 | 
				
			||||||
            int yy = y + (konami.isEmpty() ? konamiOffsetsY[i] : 0);
 | 
					            int yy = y + (konami.isEmpty() ? konamiOffsetsY[i] : 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (inBounds(xx, yy, 16, 16, mouseX, mouseY) || !grid.isConnected()) {
 | 
					            if (inBounds(xx, yy, 16, 16, mouseX, mouseY) || !grid.isActive()) {
 | 
				
			||||||
                this.slotNumber = slot;
 | 
					                this.slotNumber = slot;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -286,8 +286,8 @@ public class GuiGrid extends GuiBase {
 | 
				
			|||||||
                STACKS.get(slot).draw(this, xx, yy, GuiScreen.isShiftKeyDown() && slotNumber == slot);
 | 
					                STACKS.get(slot).draw(this, xx, yy, GuiScreen.isShiftKeyDown() && slotNumber == slot);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (inBounds(xx, yy, 16, 16, mouseX, mouseY) || !grid.isConnected()) {
 | 
					            if (inBounds(xx, yy, 16, 16, mouseX, mouseY) || !grid.isActive()) {
 | 
				
			||||||
                int color = grid.isConnected() ? -2130706433 : 0xFF5B5B5B;
 | 
					                int color = grid.isActive() ? -2130706433 : 0xFF5B5B5B;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                GlStateManager.disableLighting();
 | 
					                GlStateManager.disableLighting();
 | 
				
			||||||
                GlStateManager.disableDepth();
 | 
					                GlStateManager.disableDepth();
 | 
				
			||||||
@@ -354,7 +354,7 @@ public class GuiGrid extends GuiBase {
 | 
				
			|||||||
            BlockPos gridPos = ((TileGrid) grid).getPos();
 | 
					            BlockPos gridPos = ((TileGrid) grid).getPos();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            RS.INSTANCE.network.sendToServer(new MessageGridPatternCreate(gridPos.getX(), gridPos.getY(), gridPos.getZ()));
 | 
					            RS.INSTANCE.network.sendToServer(new MessageGridPatternCreate(gridPos.getX(), gridPos.getY(), gridPos.getZ()));
 | 
				
			||||||
        } else if (grid.isConnected()) {
 | 
					        } else if (grid.isActive()) {
 | 
				
			||||||
            if (clickedClear) {
 | 
					            if (clickedClear) {
 | 
				
			||||||
                RS.INSTANCE.network.sendToServer(new MessageGridCraftingClear((TileGrid) grid));
 | 
					                RS.INSTANCE.network.sendToServer(new MessageGridCraftingClear((TileGrid) grid));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,7 +45,7 @@ public class MessageGridCraftingClear extends MessageHandlerPlayerToServer<Messa
 | 
				
			|||||||
        if (tile instanceof TileGrid) {
 | 
					        if (tile instanceof TileGrid) {
 | 
				
			||||||
            TileGrid grid = (TileGrid) tile;
 | 
					            TileGrid grid = (TileGrid) tile;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (grid.isConnected()) {
 | 
					            if (grid.hasNetwork()) {
 | 
				
			||||||
                if (grid.getType() == EnumGridType.CRAFTING) {
 | 
					                if (grid.getType() == EnumGridType.CRAFTING) {
 | 
				
			||||||
                    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);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,65 @@
 | 
				
			|||||||
 | 
					package com.raoulvdberge.refinedstorage.proxy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.google.common.base.Preconditions;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTBase;
 | 
				
			||||||
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
 | 
					import net.minecraft.util.EnumFacing;
 | 
				
			||||||
 | 
					import net.minecraftforge.common.capabilities.Capability;
 | 
				
			||||||
 | 
					import net.minecraftforge.common.capabilities.CapabilityInject;
 | 
				
			||||||
 | 
					import net.minecraftforge.common.capabilities.CapabilityManager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nonnull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class CapabilityNetworkNode {
 | 
				
			||||||
 | 
					    @CapabilityInject(INetworkNode.class)
 | 
				
			||||||
 | 
					    public static Capability<INetworkNode> NETWORK_NODE_CAPABILITY = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static void register() {
 | 
				
			||||||
 | 
					        CapabilityManager.INSTANCE.register(INetworkNode.class, new Capability.IStorage<INetworkNode>() {
 | 
				
			||||||
 | 
					            public NBTBase writeNBT(Capability<INetworkNode> capability, INetworkNode instance, EnumFacing side) {
 | 
				
			||||||
 | 
					                return new NBTTagCompound();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            public void readNBT(Capability<INetworkNode> capability, INetworkNode instance, EnumFacing side, NBTBase base) {
 | 
				
			||||||
 | 
					                // no-op
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }, () -> new INetworkNode() {
 | 
				
			||||||
 | 
					            private INetworkMaster network;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public int getEnergyUsage() {
 | 
				
			||||||
 | 
					                return 0;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Nonnull
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public ItemStack getItemStack() {
 | 
				
			||||||
 | 
					                return ItemStack.EMPTY;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onConnected(INetworkMaster network) {
 | 
				
			||||||
 | 
					                this.network = network;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onDisconnected(INetworkMaster network) {
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public boolean canUpdate() {
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public INetworkMaster getNetwork() {
 | 
				
			||||||
 | 
					                return network;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Preconditions.checkNotNull(NETWORK_NODE_CAPABILITY, "Capability not registered");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -5,7 +5,6 @@ import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
				
			|||||||
import com.raoulvdberge.refinedstorage.RSItems;
 | 
					import com.raoulvdberge.refinedstorage.RSItems;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSUtils;
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
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.apiimpl.API;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.API;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor.*;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor.*;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewElementFluidStack;
 | 
					import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewElementFluidStack;
 | 
				
			||||||
@@ -60,6 +59,8 @@ public class ProxyCommon {
 | 
				
			|||||||
            IntegrationCraftingTweaks.register();
 | 
					            IntegrationCraftingTweaks.register();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        CapabilityNetworkNode.register();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        API.deliver(e.getAsmData());
 | 
					        API.deliver(e.getAsmData());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        API.instance().getCraftingTaskRegistry().addFactory(CraftingTaskFactory.ID, new CraftingTaskFactory());
 | 
					        API.instance().getCraftingTaskRegistry().addFactory(CraftingTaskFactory.ID, new CraftingTaskFactory());
 | 
				
			||||||
@@ -88,7 +89,8 @@ public class ProxyCommon {
 | 
				
			|||||||
        API.instance().getReaderWriterHandlerRegistry().add(ReaderWriterHandlerRedstone.ID, tag -> new ReaderWriterHandlerRedstone());
 | 
					        API.instance().getReaderWriterHandlerRegistry().add(ReaderWriterHandlerRedstone.ID, tag -> new ReaderWriterHandlerRedstone());
 | 
				
			||||||
        API.instance().getReaderWriterHandlerRegistry().add(ReaderWriterHandlerForgeEnergy.ID, ReaderWriterHandlerForgeEnergy::new);
 | 
					        API.instance().getReaderWriterHandlerRegistry().add(ReaderWriterHandlerForgeEnergy.ID, ReaderWriterHandlerForgeEnergy::new);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        API.instance().getConnectableConditions().add(tile -> tile instanceof INetworkMaster || tile instanceof INetworkNode);
 | 
					        API.instance().getConnectableConditions().add((tile, side) -> tile != null &&
 | 
				
			||||||
 | 
					                (tile instanceof INetworkMaster || tile.hasCapability(CapabilityNetworkNode.NETWORK_NODE_CAPABILITY, side)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (IntegrationTesla.isLoaded()) {
 | 
					        if (IntegrationTesla.isLoaded()) {
 | 
				
			||||||
            API.instance().getReaderWriterHandlerRegistry().add(ReaderWriterHandlerTesla.ID, ReaderWriterHandlerTesla::new);
 | 
					            API.instance().getReaderWriterHandlerRegistry().add(ReaderWriterHandlerTesla.ID, ReaderWriterHandlerTesla::new);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,6 +13,8 @@ public interface IReaderWriter extends INetworkNode {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    TileDataParameter<String> getChannelParameter();
 | 
					    TileDataParameter<String> getChannelParameter();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    boolean isActive();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    default void onAdd(String name) {
 | 
					    default void onAdd(String name) {
 | 
				
			||||||
        INetworkMaster network = getNetwork();
 | 
					        INetworkMaster network = getNetwork();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.tile;
 | 
					package com.raoulvdberge.refinedstorage.tile;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.google.common.base.Preconditions;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RS;
 | 
					import com.raoulvdberge.refinedstorage.RS;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
					import com.raoulvdberge.refinedstorage.RSBlocks;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.RSUtils;
 | 
					import com.raoulvdberge.refinedstorage.RSUtils;
 | 
				
			||||||
@@ -40,6 +41,7 @@ import com.raoulvdberge.refinedstorage.integration.forgeenergy.ControllerEnergyF
 | 
				
			|||||||
import com.raoulvdberge.refinedstorage.integration.tesla.ControllerEnergyTesla;
 | 
					import com.raoulvdberge.refinedstorage.integration.tesla.ControllerEnergyTesla;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.integration.tesla.IntegrationTesla;
 | 
					import com.raoulvdberge.refinedstorage.integration.tesla.IntegrationTesla;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.network.*;
 | 
					import com.raoulvdberge.refinedstorage.network.*;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.proxy.CapabilityNetworkNode;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable;
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
 | 
					import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
 | 
					import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
 | 
				
			||||||
@@ -52,6 +54,7 @@ import net.darkhax.tesla.capability.TeslaCapabilities;
 | 
				
			|||||||
import net.minecraft.block.state.IBlockState;
 | 
					import net.minecraft.block.state.IBlockState;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayer;
 | 
					import net.minecraft.entity.player.EntityPlayer;
 | 
				
			||||||
import net.minecraft.entity.player.EntityPlayerMP;
 | 
					import net.minecraft.entity.player.EntityPlayerMP;
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
@@ -71,7 +74,7 @@ import javax.annotation.Nullable;
 | 
				
			|||||||
import java.util.*;
 | 
					import java.util.*;
 | 
				
			||||||
import java.util.stream.Collectors;
 | 
					import java.util.stream.Collectors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class TileController extends TileBase implements INetworkMaster, IRedstoneConfigurable {
 | 
					public class TileController extends TileBase implements INetworkMaster, IRedstoneConfigurable, INetworkNode {
 | 
				
			||||||
    public static final TileDataParameter<Integer> REDSTONE_MODE = RedstoneMode.createParameter();
 | 
					    public static final TileDataParameter<Integer> REDSTONE_MODE = RedstoneMode.createParameter();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static final TileDataParameter<Integer> ENERGY_USAGE = new TileDataParameter<>(DataSerializers.VARINT, 0, new ITileDataProducer<Integer, TileController>() {
 | 
					    public static final TileDataParameter<Integer> ENERGY_USAGE = new TileDataParameter<>(DataSerializers.VARINT, 0, new ITileDataProducer<Integer, TileController>() {
 | 
				
			||||||
@@ -102,18 +105,17 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            for (INetworkNode node : tile.nodeGraph.all()) {
 | 
					            for (INetworkNode node : tile.nodeGraph.all()) {
 | 
				
			||||||
                if (node.canUpdate()) {
 | 
					                if (node.canUpdate()) {
 | 
				
			||||||
                    IBlockState state = tile.getWorld().getBlockState(node.getPosition());
 | 
					                    ItemStack itemStack = node.getItemStack();
 | 
				
			||||||
 | 
					                    if (itemStack.isEmpty()) {
 | 
				
			||||||
                    ClientNode clientNode = new ClientNode(
 | 
					 | 
				
			||||||
                        new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)),
 | 
					 | 
				
			||||||
                        1,
 | 
					 | 
				
			||||||
                        node.getEnergyUsage()
 | 
					 | 
				
			||||||
                    );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    if (clientNode.getStack().getItem() == null) {
 | 
					 | 
				
			||||||
                        continue;
 | 
					                        continue;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    ClientNode clientNode = new ClientNode(
 | 
				
			||||||
 | 
					                            itemStack,
 | 
				
			||||||
 | 
					                            1,
 | 
				
			||||||
 | 
					                            node.getEnergyUsage()
 | 
				
			||||||
 | 
					                    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (nodes.contains(clientNode)) {
 | 
					                    if (nodes.contains(clientNode)) {
 | 
				
			||||||
                        ClientNode other = nodes.get(nodes.indexOf(clientNode));
 | 
					                        ClientNode other = nodes.get(nodes.indexOf(clientNode));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -558,7 +560,7 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
 | 
				
			|||||||
    public void sendReaderWriterChannelUpdate() {
 | 
					    public void sendReaderWriterChannelUpdate() {
 | 
				
			||||||
        getWorld().getMinecraftServer().getPlayerList().getPlayers().stream()
 | 
					        getWorld().getMinecraftServer().getPlayerList().getPlayers().stream()
 | 
				
			||||||
            .filter(player -> player.openContainer instanceof ContainerReaderWriter &&
 | 
					            .filter(player -> player.openContainer instanceof ContainerReaderWriter &&
 | 
				
			||||||
                ((ContainerReaderWriter) player.openContainer).getReaderWriter().isConnected() &&
 | 
					                ((ContainerReaderWriter) player.openContainer).getReaderWriter().getNetwork() != null &&
 | 
				
			||||||
                pos.equals(((ContainerReaderWriter) player.openContainer).getReaderWriter().getNetwork().getPosition()))
 | 
					                pos.equals(((ContainerReaderWriter) player.openContainer).getReaderWriter().getNetwork().getPosition()))
 | 
				
			||||||
            .forEach(this::sendReaderWriterChannelUpdate);
 | 
					            .forEach(this::sendReaderWriterChannelUpdate);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -900,6 +902,34 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
 | 
				
			|||||||
        return usage;
 | 
					        return usage;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public ItemStack getItemStack() {
 | 
				
			||||||
 | 
					        IBlockState state = getWorld().getBlockState(pos);
 | 
				
			||||||
 | 
					        Item item = Item.getItemFromBlock(state.getBlock());
 | 
				
			||||||
 | 
					        return new ItemStack(item, 1, state.getBlock().getMetaFromState(state));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onConnected(INetworkMaster network) {
 | 
				
			||||||
 | 
					        Preconditions.checkArgument(this == network, "Should not be connected to another controller");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onDisconnected(INetworkMaster network) {
 | 
				
			||||||
 | 
					        Preconditions.checkArgument(this == network, "Should not be connected to another controller");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean canUpdate() {
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public INetworkMaster getNetwork() {
 | 
				
			||||||
 | 
					        return this;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public EnumControllerType getType() {
 | 
					    public EnumControllerType getType() {
 | 
				
			||||||
        if (type == null && getWorld().getBlockState(pos).getBlock() == RSBlocks.CONTROLLER) {
 | 
					        if (type == null && getWorld().getBlockState(pos).getBlock() == RSBlocks.CONTROLLER) {
 | 
				
			||||||
            this.type = (EnumControllerType) getWorld().getBlockState(pos).getValue(BlockController.TYPE);
 | 
					            this.type = (EnumControllerType) getWorld().getBlockState(pos).getValue(BlockController.TYPE);
 | 
				
			||||||
@@ -911,11 +941,20 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
 | 
					    public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
 | 
				
			||||||
        if (capability == CapabilityEnergy.ENERGY) {
 | 
					        if (capability == CapabilityEnergy.ENERGY) {
 | 
				
			||||||
            return (T) energy;
 | 
					            return CapabilityEnergy.ENERGY.cast(energy);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (energyTesla != null && (capability == TeslaCapabilities.CAPABILITY_HOLDER || capability == TeslaCapabilities.CAPABILITY_CONSUMER)) {
 | 
					        if (energyTesla != null) {
 | 
				
			||||||
            return (T) energyTesla;
 | 
					            if (capability == TeslaCapabilities.CAPABILITY_HOLDER) {
 | 
				
			||||||
 | 
					                return TeslaCapabilities.CAPABILITY_HOLDER.cast(energyTesla);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (capability == TeslaCapabilities.CAPABILITY_CONSUMER) {
 | 
				
			||||||
 | 
					                return TeslaCapabilities.CAPABILITY_CONSUMER.cast(energyTesla);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (capability == CapabilityNetworkNode.NETWORK_NODE_CAPABILITY) {
 | 
				
			||||||
 | 
					            return CapabilityNetworkNode.NETWORK_NODE_CAPABILITY.cast(this);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return super.getCapability(capability, facing);
 | 
					        return super.getCapability(capability, facing);
 | 
				
			||||||
@@ -925,6 +964,7 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
 | 
				
			|||||||
    public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
 | 
					    public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
 | 
				
			||||||
        return capability == CapabilityEnergy.ENERGY
 | 
					        return capability == CapabilityEnergy.ENERGY
 | 
				
			||||||
            || (energyTesla != null && (capability == TeslaCapabilities.CAPABILITY_HOLDER || capability == TeslaCapabilities.CAPABILITY_CONSUMER))
 | 
					            || (energyTesla != null && (capability == TeslaCapabilities.CAPABILITY_HOLDER || capability == TeslaCapabilities.CAPABILITY_CONSUMER))
 | 
				
			||||||
 | 
					            || capability == CapabilityNetworkNode.NETWORK_NODE_CAPABILITY
 | 
				
			||||||
            || super.hasCapability(capability, facing);
 | 
					            || super.hasCapability(capability, facing);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,6 +17,7 @@ import net.minecraft.item.ItemStack;
 | 
				
			|||||||
import net.minecraft.nbt.NBTTagCompound;
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
import net.minecraft.network.datasync.DataSerializers;
 | 
					import net.minecraft.network.datasync.DataSerializers;
 | 
				
			||||||
import net.minecraft.util.EnumFacing;
 | 
					import net.minecraft.util.EnumFacing;
 | 
				
			||||||
 | 
					import net.minecraft.util.math.BlockPos;
 | 
				
			||||||
import net.minecraftforge.common.capabilities.Capability;
 | 
					import net.minecraftforge.common.capabilities.Capability;
 | 
				
			||||||
import net.minecraftforge.items.CapabilityItemHandler;
 | 
					import net.minecraftforge.items.CapabilityItemHandler;
 | 
				
			||||||
import net.minecraftforge.items.IItemHandler;
 | 
					import net.minecraftforge.items.IItemHandler;
 | 
				
			||||||
@@ -187,6 +188,11 @@ public class TileCrafter extends TileNode implements ICraftingPatternContainer {
 | 
				
			|||||||
        return actualPatterns;
 | 
					        return actualPatterns;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public BlockPos getPosition() {
 | 
				
			||||||
 | 
					        return pos;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public IItemHandler getPatternItems() {
 | 
					    public IItemHandler getPatternItems() {
 | 
				
			||||||
        return patterns;
 | 
					        return patterns;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -341,7 +341,7 @@ public class TileDiskDrive extends TileNode implements IStorageProvider, IStorag
 | 
				
			|||||||
    public NBTTagCompound writeUpdate(NBTTagCompound tag) {
 | 
					    public NBTTagCompound writeUpdate(NBTTagCompound tag) {
 | 
				
			||||||
        super.writeUpdate(tag);
 | 
					        super.writeUpdate(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        writeDiskState(tag, 8, connected, itemStorages, fluidStorages);
 | 
					        writeDiskState(tag, 8, hasNetwork(), itemStorages, fluidStorages);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return tag;
 | 
					        return tag;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -578,7 +578,7 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
 | 
				
			|||||||
    public NBTTagCompound writeUpdate(NBTTagCompound tag) {
 | 
					    public NBTTagCompound writeUpdate(NBTTagCompound tag) {
 | 
				
			||||||
        super.writeUpdate(tag);
 | 
					        super.writeUpdate(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        TileDiskDrive.writeDiskState(tag, 6, connected, itemStorages, fluidStorages);
 | 
					        TileDiskDrive.writeDiskState(tag, 6, hasNetwork(), itemStorages, fluidStorages);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return tag;
 | 
					        return tag;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,6 +14,8 @@ import net.minecraft.item.ItemStack;
 | 
				
			|||||||
import net.minecraft.nbt.NBTTagCompound;
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
import net.minecraft.network.datasync.DataSerializers;
 | 
					import net.minecraft.network.datasync.DataSerializers;
 | 
				
			||||||
import net.minecraft.util.math.BlockPos;
 | 
					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.IItemHandler;
 | 
				
			||||||
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
 | 
					import net.minecraftforge.items.wrapper.CombinedInvWrapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -156,4 +158,17 @@ public class TileNetworkTransmitter extends TileNode {
 | 
				
			|||||||
    public boolean hasConnectivityState() {
 | 
					    public boolean hasConnectivityState() {
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void walkNeighborhood(Operator operator) {
 | 
				
			||||||
 | 
					        super.walkNeighborhood(operator);
 | 
				
			||||||
 | 
					        if (canTransmit()) {
 | 
				
			||||||
 | 
					            if (!isSameDimension()) {
 | 
				
			||||||
 | 
					                final World dimensionWorld = DimensionManager.getWorld(receiverDimension);
 | 
				
			||||||
 | 
					                operator.apply(dimensionWorld, receiver, null);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                operator.apply(getWorld(), receiver, null);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,21 +1,29 @@
 | 
				
			|||||||
package com.raoulvdberge.refinedstorage.tile;
 | 
					package com.raoulvdberge.refinedstorage.tile;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
 | 
					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.network.INetworkNode;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.api.util.IWrenchable;
 | 
					import com.raoulvdberge.refinedstorage.api.util.IWrenchable;
 | 
				
			||||||
 | 
					import com.raoulvdberge.refinedstorage.proxy.CapabilityNetworkNode;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable;
 | 
					import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
 | 
					import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
 | 
				
			||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
 | 
					import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
 | 
				
			||||||
 | 
					import net.minecraft.block.state.IBlockState;
 | 
				
			||||||
 | 
					import net.minecraft.item.Item;
 | 
				
			||||||
 | 
					import net.minecraft.item.ItemStack;
 | 
				
			||||||
import net.minecraft.nbt.NBTTagCompound;
 | 
					import net.minecraft.nbt.NBTTagCompound;
 | 
				
			||||||
import net.minecraft.tileentity.TileEntity;
 | 
					import net.minecraft.tileentity.TileEntity;
 | 
				
			||||||
import net.minecraft.util.EnumFacing;
 | 
					import net.minecraft.util.EnumFacing;
 | 
				
			||||||
import net.minecraft.util.math.BlockPos;
 | 
					import net.minecraft.util.math.BlockPos;
 | 
				
			||||||
import net.minecraft.world.World;
 | 
					import net.minecraftforge.common.capabilities.Capability;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public abstract class TileNode extends TileBase implements INetworkNode, IRedstoneConfigurable, IWrenchable {
 | 
					import javax.annotation.Nonnull;
 | 
				
			||||||
 | 
					import javax.annotation.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public abstract class TileNode extends TileBase implements INetworkNode, IRedstoneConfigurable, IWrenchable, INetworkNeighborhoodAware {
 | 
				
			||||||
    public static final TileDataParameter<Integer> REDSTONE_MODE = RedstoneMode.createParameter();
 | 
					    public static final TileDataParameter<Integer> REDSTONE_MODE = RedstoneMode.createParameter();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static final String NBT_CONNECTED = "Connected";
 | 
					    private static final String NBT_ACTIVE = "Connected";
 | 
				
			||||||
    private static final String NBT_NETWORK = "Network";
 | 
					    private static final String NBT_NETWORK = "Network";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private RedstoneMode redstoneMode = RedstoneMode.IGNORE;
 | 
					    private RedstoneMode redstoneMode = RedstoneMode.IGNORE;
 | 
				
			||||||
@@ -24,7 +32,6 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private BlockPos networkPos;
 | 
					    private BlockPos networkPos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected boolean connected;
 | 
					 | 
				
			||||||
    protected INetworkMaster network;
 | 
					    protected INetworkMaster network;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected boolean rebuildOnUpdateChange;
 | 
					    protected boolean rebuildOnUpdateChange;
 | 
				
			||||||
@@ -39,7 +46,7 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public boolean isActive() {
 | 
					    public boolean isActive() {
 | 
				
			||||||
        return isConnected() && canUpdate();
 | 
					        return active;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public abstract void updateNode();
 | 
					    public abstract void updateNode();
 | 
				
			||||||
@@ -69,13 +76,13 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (active != isActive() && hasConnectivityState()) {
 | 
					            boolean wasActive = active;
 | 
				
			||||||
 | 
					            active = hasNetwork() && canUpdate();
 | 
				
			||||||
 | 
					            if (active != wasActive && hasConnectivityState()) {
 | 
				
			||||||
                updateBlock();
 | 
					                updateBlock();
 | 
				
			||||||
 | 
					 | 
				
			||||||
                active = isActive();
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (isActive()) {
 | 
					            if (active) {
 | 
				
			||||||
                updateNode();
 | 
					                updateNode();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -85,7 +92,6 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void onConnected(INetworkMaster network) {
 | 
					    public void onConnected(INetworkMaster network) {
 | 
				
			||||||
        this.connected = true;
 | 
					 | 
				
			||||||
        this.network = network;
 | 
					        this.network = network;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        onConnectionChange(network, true);
 | 
					        onConnectionChange(network, true);
 | 
				
			||||||
@@ -97,7 +103,6 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
 | 
				
			|||||||
    public void onDisconnected(INetworkMaster network) {
 | 
					    public void onDisconnected(INetworkMaster network) {
 | 
				
			||||||
        onConnectionChange(network, false);
 | 
					        onConnectionChange(network, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.connected = false;
 | 
					 | 
				
			||||||
        this.network = null;
 | 
					        this.network = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        markDirty();
 | 
					        markDirty();
 | 
				
			||||||
@@ -107,29 +112,41 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
 | 
				
			|||||||
        // NO OP
 | 
					        // NO OP
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    public boolean canConduct(@Nullable EnumFacing direction) {
 | 
				
			||||||
    public boolean canConduct(EnumFacing direction) {
 | 
					 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing side) {
 | 
				
			||||||
 | 
					        if (capability == CapabilityNetworkNode.NETWORK_NODE_CAPABILITY && canConduct(side)) {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return super.hasCapability(capability, side);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing side) {
 | 
				
			||||||
 | 
					        if (capability == CapabilityNetworkNode.NETWORK_NODE_CAPABILITY && canConduct(side)) {
 | 
				
			||||||
 | 
					            return CapabilityNetworkNode.NETWORK_NODE_CAPABILITY.cast(this);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return super.getCapability(capability, side);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public INetworkMaster getNetwork() {
 | 
					    public INetworkMaster getNetwork() {
 | 
				
			||||||
        return network;
 | 
					        return network;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    public boolean hasNetwork() {
 | 
				
			||||||
    public World getNodeWorld() {
 | 
					        return network != null;
 | 
				
			||||||
        return getWorld();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nonnull
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public BlockPos getPosition() {
 | 
					    public ItemStack getItemStack() {
 | 
				
			||||||
        return pos;
 | 
					        IBlockState state = getWorld().getBlockState(pos);
 | 
				
			||||||
    }
 | 
					        Item item = Item.getItemFromBlock(state.getBlock());
 | 
				
			||||||
 | 
					        return new ItemStack(item, 1, state.getBlock().getMetaFromState(state));
 | 
				
			||||||
    @Override
 | 
					 | 
				
			||||||
    public boolean isConnected() {
 | 
					 | 
				
			||||||
        return connected;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -184,7 +201,7 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
 | 
				
			|||||||
        super.writeUpdate(tag);
 | 
					        super.writeUpdate(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (hasConnectivityState()) {
 | 
					        if (hasConnectivityState()) {
 | 
				
			||||||
            tag.setBoolean(NBT_CONNECTED, isActive());
 | 
					            tag.setBoolean(NBT_ACTIVE, active);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return tag;
 | 
					        return tag;
 | 
				
			||||||
@@ -192,7 +209,7 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public void readUpdate(NBTTagCompound tag) {
 | 
					    public void readUpdate(NBTTagCompound tag) {
 | 
				
			||||||
        if (hasConnectivityState()) {
 | 
					        if (hasConnectivityState()) {
 | 
				
			||||||
            connected = tag.getBoolean(NBT_CONNECTED);
 | 
					            active = tag.getBoolean(NBT_ACTIVE);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        super.readUpdate(tag);
 | 
					        super.readUpdate(tag);
 | 
				
			||||||
@@ -201,4 +218,11 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
 | 
				
			|||||||
    public boolean hasConnectivityState() {
 | 
					    public boolean hasConnectivityState() {
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void walkNeighborhood(Operator operator) {
 | 
				
			||||||
 | 
					        for (EnumFacing facing : EnumFacing.VALUES) {
 | 
				
			||||||
 | 
					            operator.apply(getWorld(), pos.offset(facing), facing.getOpposite());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -161,7 +161,7 @@ public class TileReader extends TileNode implements IReader {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void onOpened(EntityPlayer entity) {
 | 
					    public void onOpened(EntityPlayer entity) {
 | 
				
			||||||
        if (isConnected()) {
 | 
					        if (hasNetwork()) {
 | 
				
			||||||
            network.sendReaderWriterChannelUpdate((EntityPlayerMP) entity);
 | 
					            network.sendReaderWriterChannelUpdate((EntityPlayerMP) entity);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,6 +4,8 @@ import com.raoulvdberge.refinedstorage.RS;
 | 
				
			|||||||
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
 | 
					import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
 | 
				
			||||||
import net.minecraft.util.EnumFacing;
 | 
					import net.minecraft.util.EnumFacing;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class TileRelay extends TileNode {
 | 
					public class TileRelay extends TileNode {
 | 
				
			||||||
    public TileRelay() {
 | 
					    public TileRelay() {
 | 
				
			||||||
        setRedstoneMode(RedstoneMode.LOW);
 | 
					        setRedstoneMode(RedstoneMode.LOW);
 | 
				
			||||||
@@ -21,7 +23,7 @@ public class TileRelay extends TileNode {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public boolean canConduct(EnumFacing direction) {
 | 
					    public boolean canConduct(@Nullable EnumFacing direction) {
 | 
				
			||||||
        return canUpdate();
 | 
					        return canUpdate();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -67,6 +67,11 @@ public class TileWirelessTransmitter extends TileNode implements IWirelessTransm
 | 
				
			|||||||
        return pos;
 | 
					        return pos;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getDimension() {
 | 
				
			||||||
 | 
					        return getWorld().provider.getDimension();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public ItemHandlerBasic getUpgrades() {
 | 
					    public ItemHandlerBasic getUpgrades() {
 | 
				
			||||||
        return upgrades;
 | 
					        return upgrades;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -77,8 +82,8 @@ public class TileWirelessTransmitter extends TileNode implements IWirelessTransm
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public boolean canConduct(EnumFacing direction) {
 | 
					    public boolean canConduct(@Nullable EnumFacing direction) {
 | 
				
			||||||
        return false;
 | 
					        return direction != null && EnumFacing.DOWN.equals(direction);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -99,4 +104,9 @@ public class TileWirelessTransmitter extends TileNode implements IWirelessTransm
 | 
				
			|||||||
    public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
 | 
					    public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
 | 
				
			||||||
        return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
 | 
					        return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void walkNeighborhood(Operator operator) {
 | 
				
			||||||
 | 
					        operator.apply(getWorld(), pos.offset(EnumFacing.DOWN), EnumFacing.UP);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -51,7 +51,7 @@ public class TileWriter extends TileNode implements IWriter {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public int getRedstoneStrength() {
 | 
					    public int getRedstoneStrength() {
 | 
				
			||||||
        return connected ? redstoneStrength : 0;
 | 
					        return network != null ? redstoneStrength : 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -172,7 +172,7 @@ public class TileWriter extends TileNode implements IWriter {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void onOpened(EntityPlayer entity) {
 | 
					    public void onOpened(EntityPlayer entity) {
 | 
				
			||||||
        if (isConnected()) {
 | 
					        if (hasNetwork()) {
 | 
				
			||||||
            network.sendReaderWriterChannelUpdate((EntityPlayerMP) entity);
 | 
					            network.sendReaderWriterChannelUpdate((EntityPlayerMP) entity);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,12 +4,15 @@ import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
 | 
				
			|||||||
import net.minecraft.entity.player.EntityPlayerMP;
 | 
					import net.minecraft.entity.player.EntityPlayerMP;
 | 
				
			||||||
import net.minecraft.util.math.BlockPos;
 | 
					import net.minecraft.util.math.BlockPos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public interface ICraftingMonitor {
 | 
					public interface ICraftingMonitor {
 | 
				
			||||||
    void onCancelled(EntityPlayerMP player, int id);
 | 
					    void onCancelled(EntityPlayerMP player, int id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    TileDataParameter<Integer> getRedstoneModeParameter();
 | 
					    TileDataParameter<Integer> getRedstoneModeParameter();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nullable
 | 
				
			||||||
    BlockPos getNetworkPosition();
 | 
					    BlockPos getNetworkPosition();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    boolean isConnected();
 | 
					    boolean isActive();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,8 @@ import net.minecraft.entity.player.EntityPlayer;
 | 
				
			|||||||
import net.minecraft.entity.player.EntityPlayerMP;
 | 
					import net.minecraft.entity.player.EntityPlayerMP;
 | 
				
			||||||
import net.minecraft.util.math.BlockPos;
 | 
					import net.minecraft.util.math.BlockPos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class TileCraftingMonitor extends TileNode implements ICraftingMonitor {
 | 
					public class TileCraftingMonitor extends TileNode implements ICraftingMonitor {
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public int getEnergyUsage() {
 | 
					    public int getEnergyUsage() {
 | 
				
			||||||
@@ -24,7 +26,7 @@ public class TileCraftingMonitor extends TileNode implements ICraftingMonitor {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void onCancelled(EntityPlayerMP player, int id) {
 | 
					    public void onCancelled(EntityPlayerMP player, int id) {
 | 
				
			||||||
        if (isConnected()) {
 | 
					        if (hasNetwork()) {
 | 
				
			||||||
            network.getItemGridHandler().onCraftingCancelRequested(player, id);
 | 
					            network.getItemGridHandler().onCraftingCancelRequested(player, id);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -34,13 +36,14 @@ public class TileCraftingMonitor extends TileNode implements ICraftingMonitor {
 | 
				
			|||||||
        return REDSTONE_MODE;
 | 
					        return REDSTONE_MODE;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nullable
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public BlockPos getNetworkPosition() {
 | 
					    public BlockPos getNetworkPosition() {
 | 
				
			||||||
        return network != null ? network.getPosition() : null;
 | 
					        return network != null ? network.getPosition() : null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void onOpened(EntityPlayer player) {
 | 
					    public void onOpened(EntityPlayer player) {
 | 
				
			||||||
        if (isConnected()) {
 | 
					        if (hasNetwork()) {
 | 
				
			||||||
            network.sendCraftingMonitorUpdate((EntityPlayerMP) player);
 | 
					            network.sendCraftingMonitorUpdate((EntityPlayerMP) player);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,11 +38,6 @@ public class WirelessCraftingMonitor implements ICraftingMonitor {
 | 
				
			|||||||
        return controller;
 | 
					        return controller;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					 | 
				
			||||||
    public boolean isConnected() {
 | 
					 | 
				
			||||||
        return true;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private TileController getController() {
 | 
					    private TileController getController() {
 | 
				
			||||||
        World world = DimensionManager.getWorld(controllerDimension);
 | 
					        World world = DimensionManager.getWorld(controllerDimension);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -54,4 +49,9 @@ public class WirelessCraftingMonitor implements ICraftingMonitor {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        return null;
 | 
					        return null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean isActive() {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,11 +8,13 @@ import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
 | 
				
			|||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
 | 
					import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
 | 
				
			||||||
import net.minecraft.util.math.BlockPos;
 | 
					import net.minecraft.util.math.BlockPos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nullable;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public interface IGrid {
 | 
					public interface IGrid {
 | 
				
			||||||
    EnumGridType getType();
 | 
					    EnumGridType getType();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nullable
 | 
				
			||||||
    BlockPos getNetworkPosition();
 | 
					    BlockPos getNetworkPosition();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    IItemGridHandler getItemHandler();
 | 
					    IItemGridHandler getItemHandler();
 | 
				
			||||||
@@ -43,5 +45,5 @@ public interface IGrid {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    TileDataParameter<Integer> getRedstoneModeConfig();
 | 
					    TileDataParameter<Integer> getRedstoneModeConfig();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    boolean isConnected();
 | 
					    boolean isActive();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,6 +36,7 @@ import net.minecraftforge.items.ItemHandlerHelper;
 | 
				
			|||||||
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
 | 
					import net.minecraftforge.items.wrapper.CombinedInvWrapper;
 | 
				
			||||||
import net.minecraftforge.items.wrapper.InvWrapper;
 | 
					import net.minecraftforge.items.wrapper.InvWrapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nullable;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -210,13 +211,14 @@ public class TileGrid extends TileNode implements IGrid {
 | 
				
			|||||||
        return type == null ? EnumGridType.NORMAL : type;
 | 
					        return type == null ? EnumGridType.NORMAL : type;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nullable
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public BlockPos getNetworkPosition() {
 | 
					    public BlockPos getNetworkPosition() {
 | 
				
			||||||
        return network != null ? network.getPosition() : null;
 | 
					        return network != null ? network.getPosition() : null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void onOpened(EntityPlayer player) {
 | 
					    public void onOpened(EntityPlayer player) {
 | 
				
			||||||
        if (isConnected()) {
 | 
					        if (hasNetwork()) {
 | 
				
			||||||
            if (getType() == EnumGridType.FLUID) {
 | 
					            if (getType() == EnumGridType.FLUID) {
 | 
				
			||||||
                network.sendFluidStorageToClient((EntityPlayerMP) player);
 | 
					                network.sendFluidStorageToClient((EntityPlayerMP) player);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
@@ -227,12 +229,12 @@ public class TileGrid extends TileNode implements IGrid {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public IItemGridHandler getItemHandler() {
 | 
					    public IItemGridHandler getItemHandler() {
 | 
				
			||||||
        return connected ? network.getItemGridHandler() : null;
 | 
					        return hasNetwork() ? network.getItemGridHandler() : null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public IFluidGridHandler getFluidHandler() {
 | 
					    public IFluidGridHandler getFluidHandler() {
 | 
				
			||||||
        return connected ? network.getFluidGridHandler() : null;
 | 
					        return hasNetwork() ? network.getFluidGridHandler() : null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -290,7 +292,7 @@ public class TileGrid extends TileNode implements IGrid {
 | 
				
			|||||||
                    matrix.setInventorySlotContents(i, remainder.get(i).copy());
 | 
					                    matrix.setInventorySlotContents(i, remainder.get(i).copy());
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            } else if (!slot.isEmpty()) {
 | 
					            } else if (!slot.isEmpty()) {
 | 
				
			||||||
                if (slot.getCount() == 1 && isConnected()) {
 | 
					                if (slot.getCount() == 1 && hasNetwork()) {
 | 
				
			||||||
                    matrix.setInventorySlotContents(i, RSUtils.getStack(network.extractItem(slot, 1, false)));
 | 
					                    matrix.setInventorySlotContents(i, RSUtils.getStack(network.extractItem(slot, 1, false)));
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    matrix.decrStackSize(i, 1);
 | 
					                    matrix.decrStackSize(i, 1);
 | 
				
			||||||
@@ -364,7 +366,7 @@ public class TileGrid extends TileNode implements IGrid {
 | 
				
			|||||||
                // Only if we are a crafting grid. Pattern grids can just be emptied.
 | 
					                // Only if we are a crafting grid. Pattern grids can just be emptied.
 | 
				
			||||||
                if (getType() == EnumGridType.CRAFTING) {
 | 
					                if (getType() == EnumGridType.CRAFTING) {
 | 
				
			||||||
                    // If we are connected, try to insert into network. If it fails, stop.
 | 
					                    // If we are connected, try to insert into network. If it fails, stop.
 | 
				
			||||||
                    if (isConnected()) {
 | 
					                    if (hasNetwork()) {
 | 
				
			||||||
                        if (network.insertItem(slot, slot.getCount(), true) != null) {
 | 
					                        if (network.insertItem(slot, slot.getCount(), true) != null) {
 | 
				
			||||||
                            return;
 | 
					                            return;
 | 
				
			||||||
                        } else {
 | 
					                        } else {
 | 
				
			||||||
@@ -392,7 +394,7 @@ public class TileGrid extends TileNode implements IGrid {
 | 
				
			|||||||
                    boolean found = false;
 | 
					                    boolean found = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    // If we are connected, first try to get the possibilities from the network
 | 
					                    // If we are connected, first try to get the possibilities from the network
 | 
				
			||||||
                    if (isConnected()) {
 | 
					                    if (hasNetwork()) {
 | 
				
			||||||
                        for (ItemStack possibility : possibilities) {
 | 
					                        for (ItemStack possibility : possibilities) {
 | 
				
			||||||
                            ItemStack took = network.extractItem(possibility, 1, false);
 | 
					                            ItemStack took = network.extractItem(possibility, 1, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -172,7 +172,7 @@ public class WirelessGrid implements IGrid {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public boolean isConnected() {
 | 
					    public boolean isActive() {
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user