From e0a6cfb0aba631d3a1cd27971f87b0d4a677f294 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Sat, 16 Jan 2021 01:12:04 -0500 Subject: Update include paths --- .../cshift/transit/basic/AbstractAcceptorNode.java | 51 ++++++++++++++++++++++ .../net/cshift/transit/basic/AbstractNode.java | 45 +++++++++++++++++++ .../cshift/transit/basic/AbstractProviderNode.java | 47 ++++++++++++++++++++ .../cshift/transit/basic/AbstractTwoWayNode.java | 47 ++++++++++++++++++++ .../transit/basic/system/AbstractSystem.java | 13 ++++++ .../transit/basic/system/AbstractSystemNode.java | 12 +++++ 6 files changed, 215 insertions(+) create mode 100644 src/main/java/net/cshift/transit/basic/AbstractAcceptorNode.java create mode 100644 src/main/java/net/cshift/transit/basic/AbstractNode.java create mode 100644 src/main/java/net/cshift/transit/basic/AbstractProviderNode.java create mode 100644 src/main/java/net/cshift/transit/basic/AbstractTwoWayNode.java create mode 100644 src/main/java/net/cshift/transit/basic/system/AbstractSystem.java create mode 100644 src/main/java/net/cshift/transit/basic/system/AbstractSystemNode.java (limited to 'src/main/java/net/cshift/transit/basic') diff --git a/src/main/java/net/cshift/transit/basic/AbstractAcceptorNode.java b/src/main/java/net/cshift/transit/basic/AbstractAcceptorNode.java new file mode 100644 index 0000000..e2e6711 --- /dev/null +++ b/src/main/java/net/cshift/transit/basic/AbstractAcceptorNode.java @@ -0,0 +1,51 @@ +package net.cshift.transit.basic; + +import net.cshift.transit.network.packet.*; +import net.cshift.transit.network.system.*; +import net.cshift.transit.network.system.swap.*; +import net.minecraft.block.entity.*; + +public abstract class AbstractAcceptorNode extends AbstractNode implements IAcceptorNode { + + public AbstractAcceptorNode(BlockEntityType type) { + super(type); + } + + @Override + public abstract boolean accept(IStaticPacket packet, String group); + + @Override + public boolean linkProvider(IProviderNode requestor, String group) { + if(this.hasGroup(group)) + { + for (Connection c : connections) { + if(c.getNode() == requestor) + return false; + } + + connections.add(new Connection(requestor, (short) 2)); + + return true; + } + + return false; + } + + @Override + public boolean unlinkProvider(IProviderNode requestor) { + for (Connection c : connections) { + if(c.getNode() == requestor) + { + if(c.isAccepting()) + c.setProviding(false); + else + connections.remove(c); + + return true; + } + } + + return false; + } + +} diff --git a/src/main/java/net/cshift/transit/basic/AbstractNode.java b/src/main/java/net/cshift/transit/basic/AbstractNode.java new file mode 100644 index 0000000..a87fba4 --- /dev/null +++ b/src/main/java/net/cshift/transit/basic/AbstractNode.java @@ -0,0 +1,45 @@ +package net.cshift.transit.basic; + +import java.util.*; + +import net.cshift.transit.network.system.*; +import net.minecraft.block.entity.*; + +public abstract class AbstractNode extends BlockEntity implements INode { + + public AbstractNode(BlockEntityType type) { + super(type); + } + + HashMap data = new HashMap(); + ArrayList connections = new ArrayList(0); + + @Override + public abstract boolean hasGroup(String groupID); + + @Override + public ISystem getSystem() { + return null; + } + + @Override + public Object getData(String groupID) { + return data.get(groupID); + } + + @Override + public void setData(Object dat, String groupID) { + data.put(groupID, dat); + } + + @Override + public Connection[] getConnections() { + return (Connection[]) connections.toArray(); + } + + @Override + public int connectionCount() { + return connections.size(); + } + +} diff --git a/src/main/java/net/cshift/transit/basic/AbstractProviderNode.java b/src/main/java/net/cshift/transit/basic/AbstractProviderNode.java new file mode 100644 index 0000000..cc81544 --- /dev/null +++ b/src/main/java/net/cshift/transit/basic/AbstractProviderNode.java @@ -0,0 +1,47 @@ +package net.cshift.transit.basic; + +import net.cshift.transit.network.system.*; +import net.cshift.transit.network.system.swap.*; +import net.minecraft.block.entity.*; + +public abstract class AbstractProviderNode extends AbstractNode implements IProviderNode { + + public AbstractProviderNode(BlockEntityType type) { + super(type); + } + + @Override + public boolean linkAcceptor(IAcceptorNode requestor, String group) { + if(this.hasGroup(group)) + { + for (Connection c : connections) { + if(c.getNode() == requestor) + return false; + } + + connections.add(new Connection(requestor, (short) 1)); + + return true; + } + + return false; + } + + @Override + public boolean unlinkAcceptor(IAcceptorNode requestor) { + for (Connection c : connections) { + if(c.getNode() == requestor) + { + if(c.isProviding()) + c.setAccepting(false); + else + connections.remove(c); + + return true; + } + } + + return false; + } + +} diff --git a/src/main/java/net/cshift/transit/basic/AbstractTwoWayNode.java b/src/main/java/net/cshift/transit/basic/AbstractTwoWayNode.java new file mode 100644 index 0000000..cc06eeb --- /dev/null +++ b/src/main/java/net/cshift/transit/basic/AbstractTwoWayNode.java @@ -0,0 +1,47 @@ +package net.cshift.transit.basic; + +import net.cshift.transit.network.system.*; +import net.cshift.transit.network.system.swap.*; +import net.minecraft.block.entity.*; + +public abstract class AbstractTwoWayNode extends AbstractAcceptorNode implements IProviderNode { + + public AbstractTwoWayNode(BlockEntityType type) { + super(type); + } + + @Override + public boolean linkAcceptor(IAcceptorNode requestor, String group) { + if(this.hasGroup(group)) + { + for (Connection c : connections) { + if(c.getNode() == requestor) + return false; + } + + connections.add(new Connection(requestor, (short) 1)); + + return true; + } + + return false; + } + + @Override + public boolean unlinkAcceptor(IAcceptorNode requestor) { + for (Connection c : connections) { + if(c.getNode() == requestor) + { + if(c.isProviding()) + c.setAccepting(false); + else + connections.remove(c); + + return true; + } + } + + return false; + } + +} diff --git a/src/main/java/net/cshift/transit/basic/system/AbstractSystem.java b/src/main/java/net/cshift/transit/basic/system/AbstractSystem.java new file mode 100644 index 0000000..ef6254c --- /dev/null +++ b/src/main/java/net/cshift/transit/basic/system/AbstractSystem.java @@ -0,0 +1,13 @@ +package net.cshift.transit.basic.system; + +import net.cshift.transit.network.system.*; + +public abstract class AbstractSystem implements ISystem { + + @Override + public INode[] getNodes() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/main/java/net/cshift/transit/basic/system/AbstractSystemNode.java b/src/main/java/net/cshift/transit/basic/system/AbstractSystemNode.java new file mode 100644 index 0000000..a246588 --- /dev/null +++ b/src/main/java/net/cshift/transit/basic/system/AbstractSystemNode.java @@ -0,0 +1,12 @@ +package net.cshift.transit.basic.system; + +import net.cshift.transit.basic.*; +import net.minecraft.block.entity.*; + +public abstract class AbstractSystemNode extends AbstractNode { + + public AbstractSystemNode(BlockEntityType type) { + super(type); + } + +} -- cgit v1.2.3