summaryrefslogtreecommitdiff
path: root/src/main/java/net/cshift/transit/basic/AbstractAcceptorNode.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/cshift/transit/basic/AbstractAcceptorNode.java')
-rw-r--r--src/main/java/net/cshift/transit/basic/AbstractAcceptorNode.java51
1 files changed, 51 insertions, 0 deletions
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 <T> boolean accept(IStaticPacket<T> 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;
+ }
+
+}