diff --git a/src/main/java/li/cil/oc/api/API.java b/src/main/java/li/cil/oc/api/API.java index 4feef4c06..44dfd0b4a 100644 --- a/src/main/java/li/cil/oc/api/API.java +++ b/src/main/java/li/cil/oc/api/API.java @@ -11,7 +11,7 @@ import li.cil.oc.api.detail.*; */ public class API { public static final String ID_OWNER = "OpenComputers|Core"; - public static final String VERSION = "4.2.2"; + public static final String VERSION = "4.2.3"; public static DriverAPI driver = null; public static FileSystemAPI fileSystem = null; diff --git a/src/main/java/li/cil/oc/api/network/ManagedPeripheral.java b/src/main/java/li/cil/oc/api/network/ManagedPeripheral.java index b12c8ff9e..3e69def05 100644 --- a/src/main/java/li/cil/oc/api/network/ManagedPeripheral.java +++ b/src/main/java/li/cil/oc/api/network/ManagedPeripheral.java @@ -6,7 +6,7 @@ import li.cil.oc.api.machine.Context; /** * This interface can be used with an {@link li.cil.oc.api.network.Environment} * and is intended to be used for environments wrapping a ComputerCraft - * peripheral. Tt could be used for other purposes as well, though. It allows + * peripheral. It could be used for other purposes as well, though. It allows * providing method names in addition to those defined via the * {@link li.cil.oc.api.machine.Callback} annotation, and invoking said methods. */ diff --git a/src/main/java/li/cil/oc/api/network/SidedComponent.java b/src/main/java/li/cil/oc/api/network/SidedComponent.java new file mode 100644 index 000000000..68dd76866 --- /dev/null +++ b/src/main/java/li/cil/oc/api/network/SidedComponent.java @@ -0,0 +1,26 @@ +package li.cil.oc.api.network; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * This is an extended version of {@link li.cil.oc.api.network.SimpleComponent} + * which allows controlling connectivity on a side-by-side basis. + *

+ * Like the SimpleComponent interface, this is intended to be used + * with tile entities that should act as OC components. Please see the + * SimpleComponent interface for more information. + */ +public interface SidedComponent { + /** + * Whether this component can connect to a node on the specified side. + *

+ * The provided side is relative to the component, i.e. when the tile + * entity sits at (0, 0, 0) and is asked for its southern node (positive + * Z axis) it has to return the connectivity for the face between it and + * the block at (0, 0, 1). + * + * @param side the side to check for. + * @return whether the component may be connected to from the specified side. + */ + boolean canConnectNode(ForgeDirection side); +} diff --git a/src/main/scala/li/cil/oc/common/block/Cable.scala b/src/main/scala/li/cil/oc/common/block/Cable.scala index 27a884b97..f7a4038b8 100644 --- a/src/main/scala/li/cil/oc/common/block/Cable.scala +++ b/src/main/scala/li/cil/oc/common/block/Cable.scala @@ -9,6 +9,7 @@ import cpw.mods.fml.relauncher.Side import cpw.mods.fml.relauncher.SideOnly import li.cil.oc.Settings import li.cil.oc.api.network.Environment +import li.cil.oc.api.network.SidedComponent import li.cil.oc.api.network.SidedEnvironment import li.cil.oc.client.Textures import li.cil.oc.common.tileentity @@ -124,6 +125,8 @@ object Cable { case host: SidedEnvironment => if (host.getWorldObj.isRemote) host.canConnect(side) else host.sidedNode(side) != null + case host: Environment with SidedComponent => + host.canConnectNode(side) case host: Environment => true case host if Mods.ForgeMultipart.isAvailable => hasMultiPartNode(tileEntity) case _ => false diff --git a/src/main/scala/li/cil/oc/server/network/Network.scala b/src/main/scala/li/cil/oc/server/network/Network.scala index 9727aa3f1..fccfdd871 100644 --- a/src/main/scala/li/cil/oc/server/network/Network.scala +++ b/src/main/scala/li/cil/oc/server/network/Network.scala @@ -9,11 +9,7 @@ import li.cil.oc.OpenComputers import li.cil.oc.Settings import li.cil.oc.api import li.cil.oc.api.network -import li.cil.oc.api.network.Environment -import li.cil.oc.api.network.SidedEnvironment -import li.cil.oc.api.network.Visibility -import li.cil.oc.api.network.WirelessEndpoint -import li.cil.oc.api.network.{Node => ImmutableNode} +import li.cil.oc.api.network.{Node => ImmutableNode, _} import li.cil.oc.common.block.Cable import li.cil.oc.common.tileentity import li.cil.oc.integration.Mods @@ -439,7 +435,10 @@ object Network extends api.detail.NetworkAPI { private def getNetworkNode(tileEntity: TileEntity, side: ForgeDirection) = tileEntity match { case host: SidedEnvironment => Option(host.sidedNode(side)) - case host: Environment => Some(host.node) + case host: Environment with SidedComponent => + if (host.canConnectNode(side)) Option(host.node) + else None + case host: Environment => Option(host.node) case host if Mods.ForgeMultipart.isAvailable => getMultiPartNode(host) case _ => None }