summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2019-11-20 12:45:16 -0500
committerKyle Gunger <kgunger12@gmail.com>2019-11-20 12:45:16 -0500
commitdf044930bca4252ff6e4814c654a612c6aee2136 (patch)
tree906eddbbfdecb63e3525657cd4e6f75c8ba91bc3 /src/main/java
parentebc33c58c8a3669822a0dba99cbfe8a451782813 (diff)
[0.1.7 REWRITE] Codebase overhaul.
~ Codebase split into two sub-packages ~ net.transit.network for transfering between objects ~ net.transit.type for type registering and conversion + Added new interfaces (INode and ISystem) + More documentation + (Kinda) Working build - Removed unnessairy interfaces (IGenerator and IConsumer) - Removed base types ~ Restructured type system
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/net/transit/InitTransit.java15
-rw-r--r--src/main/java/net/transit/impl/IAcceptor.java13
-rw-r--r--src/main/java/net/transit/impl/IConsumer.java8
-rw-r--r--src/main/java/net/transit/impl/IGenerator.java8
-rw-r--r--src/main/java/net/transit/impl/IProvider.java17
-rw-r--r--src/main/java/net/transit/network/packet/ArrayPacket.java (renamed from src/main/java/net/transit/packet/ArrayPacket.java)12
-rw-r--r--src/main/java/net/transit/network/packet/IPacket.java23
-rw-r--r--src/main/java/net/transit/network/packet/MetaPacket.java33
-rw-r--r--src/main/java/net/transit/network/packet/StaticPacket.java25
-rw-r--r--src/main/java/net/transit/network/swap/IAcceptor.java31
-rw-r--r--src/main/java/net/transit/network/swap/IProvider.java37
-rw-r--r--src/main/java/net/transit/network/system/INode.java50
-rw-r--r--src/main/java/net/transit/network/system/ISystem.java17
-rw-r--r--src/main/java/net/transit/packet/IPacket.java6
-rw-r--r--src/main/java/net/transit/packet/StaticPacket.java16
-rw-r--r--src/main/java/net/transit/type/BaseType.java14
-rw-r--r--src/main/java/net/transit/type/Type.java51
-rw-r--r--src/main/java/net/transit/type/group/GroupRegistry.java51
-rw-r--r--src/main/java/net/transit/type/group/TypeGroup.java137
-rw-r--r--src/main/java/net/transit/type/group/simple/EnergyGroup.java10
-rw-r--r--src/main/java/net/transit/type/group/simple/FluidGroup.java11
-rw-r--r--src/main/java/net/transit/type/group/simple/ItemGroup.java11
-rw-r--r--src/main/java/net/transit/type/group/simple/ManaGroup.java10
-rw-r--r--src/main/java/net/transit/type/group/simple/SimpleGroups.java26
-rw-r--r--src/main/java/net/transit/type/simple/EnergyType.java11
-rw-r--r--src/main/java/net/transit/type/simple/FluidType.java11
-rw-r--r--src/main/java/net/transit/type/simple/ItemType.java11
-rw-r--r--src/main/java/net/transit/type/simple/ManaType.java10
-rw-r--r--src/main/java/net/transit/type/simple/SimpleTypes.java27
-rw-r--r--src/main/java/net/transit/type/typebase/MetaBase.java28
-rw-r--r--src/main/java/net/transit/type/typebase/NumberBase.java20
-rw-r--r--src/main/java/net/transit/type/typebase/StringBase.java20
-rw-r--r--src/main/java/net/transit/type/typegroup/TypeGroup.java53
-rw-r--r--src/main/java/net/transit/type/typegroup/TypeRegister.java44
34 files changed, 604 insertions, 263 deletions
diff --git a/src/main/java/net/transit/InitTransit.java b/src/main/java/net/transit/InitTransit.java
new file mode 100644
index 0000000..1d4941e
--- /dev/null
+++ b/src/main/java/net/transit/InitTransit.java
@@ -0,0 +1,15 @@
+package net.transit;
+
+import net.fabricmc.api.ModInitializer;
+import net.transit.type.group.simple.SimpleGroups;
+import net.transit.type.simple.SimpleTypes;
+
+public class InitTransit implements ModInitializer {
+
+ @Override
+ public void onInitialize() {
+ SimpleGroups.initGroups();
+ SimpleTypes.initTypes();
+ }
+
+}
diff --git a/src/main/java/net/transit/impl/IAcceptor.java b/src/main/java/net/transit/impl/IAcceptor.java
deleted file mode 100644
index 7fe06aa..0000000
--- a/src/main/java/net/transit/impl/IAcceptor.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package net.transit.impl;
-
-import net.transit.packet.IPacket;
-import net.minecraft.util.math.Direction;
-
-public interface IAcceptor<T>
-{
- // Direction given if acceptor is a block
- public boolean canAccept(Direction d);
-
- // Accept (or not) a provided T (should trigger ITransferEvent)
- public boolean accept(IPacket<T> provided);
-} \ No newline at end of file
diff --git a/src/main/java/net/transit/impl/IConsumer.java b/src/main/java/net/transit/impl/IConsumer.java
deleted file mode 100644
index 7b3b070..0000000
--- a/src/main/java/net/transit/impl/IConsumer.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package net.transit.impl;
-
-public interface IConsumer<T> extends IAcceptor<T>
-{
- public boolean canConsume();
-
-
-} \ No newline at end of file
diff --git a/src/main/java/net/transit/impl/IGenerator.java b/src/main/java/net/transit/impl/IGenerator.java
deleted file mode 100644
index f69de2f..0000000
--- a/src/main/java/net/transit/impl/IGenerator.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package net.transit.impl;
-
-public interface IGenerator<T> extends IProvider<T>
-{
- public boolean canGenerate();
-
-
-} \ No newline at end of file
diff --git a/src/main/java/net/transit/impl/IProvider.java b/src/main/java/net/transit/impl/IProvider.java
deleted file mode 100644
index 94e903f..0000000
--- a/src/main/java/net/transit/impl/IProvider.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package net.transit.impl;
-
-import net.transit.packet.IPacket;
-import net.minecraft.util.math.Direction;
-
-public interface IProvider<T>
-{
-
- // Direction given if provider is a block
- public boolean canProvide(Direction d);
-
- // Provide the next T (should trigger ITransferEvent)
- public IPacket<T> provide();
-
- // Retain the rejected T if the acceptor did not accept it (should trigger ITransferEvent)
- public void retain(IPacket<T> rejected);
-} \ No newline at end of file
diff --git a/src/main/java/net/transit/packet/ArrayPacket.java b/src/main/java/net/transit/network/packet/ArrayPacket.java
index 09ef5f1..9cbd300 100644
--- a/src/main/java/net/transit/packet/ArrayPacket.java
+++ b/src/main/java/net/transit/network/packet/ArrayPacket.java
@@ -1,12 +1,15 @@
-package net.transit.packet;
+package net.transit.network.packet;
import java.util.ArrayList;
+import net.transit.type.Type;
+
public class ArrayPacket<D> implements IPacket<D>
{
private ArrayList<D> arrayData;
+ private Type<D> type;
- public ArrayPacket(D startValue)
+ public ArrayPacket(D startValue, Type<D> t)
{
arrayData = new ArrayList<D>(0);
arrayData.add(startValue);
@@ -34,4 +37,9 @@ public class ArrayPacket<D> implements IPacket<D>
return temp;
}
+
+ @Override
+ public Type<D> getType() {
+ return type;
+ }
} \ No newline at end of file
diff --git a/src/main/java/net/transit/network/packet/IPacket.java b/src/main/java/net/transit/network/packet/IPacket.java
new file mode 100644
index 0000000..deafdf8
--- /dev/null
+++ b/src/main/java/net/transit/network/packet/IPacket.java
@@ -0,0 +1,23 @@
+package net.transit.network.packet;
+
+import net.transit.type.Type;
+
+/**
+ * @author Kyle Gunger
+ *
+ * @param <D> The data type (Object) that the packet transfers.
+ */
+public interface IPacket<D>
+{
+ /**Get the packet's data
+ *
+ * @return <D> The packet's data
+ */
+ public D getData();
+
+ /**Get the packet's type
+ *
+ * @return IType<<D>> The type of the packet
+ */
+ public Type<D> getType();
+} \ No newline at end of file
diff --git a/src/main/java/net/transit/network/packet/MetaPacket.java b/src/main/java/net/transit/network/packet/MetaPacket.java
new file mode 100644
index 0000000..e4cffdf
--- /dev/null
+++ b/src/main/java/net/transit/network/packet/MetaPacket.java
@@ -0,0 +1,33 @@
+package net.transit.network.packet;
+
+import net.transit.type.Type;
+
+public class MetaPacket<D, M> implements IPacket<D>
+{
+
+ private D data;
+ private M metaData;
+ private Type<D> type;
+
+ public MetaPacket(D dat, Type<D> t, M meta)
+ {
+ data = dat;
+ type = t;
+ metaData = meta;
+ }
+
+ public D getData()
+ {
+ return data;
+ }
+
+ public M getMetaData()
+ {
+ return metaData;
+ }
+
+ @Override
+ public Type<D> getType() {
+ return type;
+ }
+}
diff --git a/src/main/java/net/transit/network/packet/StaticPacket.java b/src/main/java/net/transit/network/packet/StaticPacket.java
new file mode 100644
index 0000000..8399041
--- /dev/null
+++ b/src/main/java/net/transit/network/packet/StaticPacket.java
@@ -0,0 +1,25 @@
+package net.transit.network.packet;
+
+import net.transit.type.Type;
+
+public class StaticPacket<D> implements IPacket<D>
+{
+ private D data;
+ private Type<D> type;
+
+ public StaticPacket(D dat, Type<D> t)
+ {
+ data = dat;
+ type = t;
+ }
+
+ public D getData()
+ {
+ return data;
+ }
+
+ @Override
+ public Type<D> getType() {
+ return type;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/net/transit/network/swap/IAcceptor.java b/src/main/java/net/transit/network/swap/IAcceptor.java
new file mode 100644
index 0000000..6966b9a
--- /dev/null
+++ b/src/main/java/net/transit/network/swap/IAcceptor.java
@@ -0,0 +1,31 @@
+package net.transit.network.swap;
+
+import net.transit.network.packet.IPacket;
+
+/**
+ * @author Kyle Gunger
+ *
+ * @param <T> The type of data accepted (in IPacket<<T>> form)
+ */
+public interface IAcceptor<T>
+{
+ /**
+ * @return <b>True</b> if the acceptor can accept packets.
+ */
+ public boolean canAccept();
+
+ /**
+ * @param provided The packet provided.
+ * @return <b>True</b> if the acceptor accepted the packet.
+ */
+ public boolean accept(IPacket<T> provided);
+
+ /**
+ * @return <b>True</b> if the acceptor has a provider assigned to it.
+ */
+ public boolean hasProvider();
+
+ /**Set the provider of the acceptor. The acceptor can decide if it wants to adopt the provider.
+ */
+ public void setProvider(IProvider<T> provider);
+} \ No newline at end of file
diff --git a/src/main/java/net/transit/network/swap/IProvider.java b/src/main/java/net/transit/network/swap/IProvider.java
new file mode 100644
index 0000000..03c9ca9
--- /dev/null
+++ b/src/main/java/net/transit/network/swap/IProvider.java
@@ -0,0 +1,37 @@
+package net.transit.network.swap;
+
+import net.transit.network.packet.IPacket;
+
+/**
+ * @author Kyle Gunger
+ *
+ * @param <T> The type of data provided (in IPacket<<T>> form)
+ */
+public interface IProvider<T>
+{
+ /**
+ * @return <b>True</b> if the provider can provide a packet.
+ */
+ public boolean canProvide();
+
+ /**Get the next packet from the provider
+ *
+ * @return IPacket<<T>>
+ */
+ public IPacket<T> provide();
+
+ /**Retain the packet if the acceptor did not accept the packet.
+ *
+ * @param rejected The rejected packet
+ */
+ public void retain(IPacket<T> rejected);
+
+ /**
+ * @return <b>True</b> if the acceptor has a provider assigned to it
+ */
+ public boolean hasAcceptor();
+
+ /**Set the acceptor of the provider. The provider can decide if it wants to adopt the acceptor.
+ */
+ public void setAcceptor();
+} \ No newline at end of file
diff --git a/src/main/java/net/transit/network/system/INode.java b/src/main/java/net/transit/network/system/INode.java
new file mode 100644
index 0000000..2dc3686
--- /dev/null
+++ b/src/main/java/net/transit/network/system/INode.java
@@ -0,0 +1,50 @@
+package net.transit.network.system;
+
+import net.transit.network.swap.IAcceptor;
+import net.transit.network.swap.IProvider;
+
+/**
+ * @author Kyle Gunger
+ * @apiNote A node inside or outside a system. Provides acceptors and providers to other nodes.
+ */
+public interface INode
+{
+ /**Returns the groupIDs of groups the node provide
+ *
+ * @return String[]
+ */
+ public String[] groupsProvided();
+
+ /**Get the system managing the node or {@code null} if there isn't one
+ *
+ * @return ISystem
+ */
+ public ISystem getSystem();
+
+ /**Returns {@code true} if the node provides IAcceptors
+ *
+ * @return boolean
+ */
+ public boolean isAcceptor();
+
+ /**Returns an IAcceptor or {@code null} depending on the requester and group
+ *
+ * @param requester The object requesting the IAcceptor
+ * @param group
+ * @return IAcceptor
+ */
+ public IAcceptor<?> requestAcceptor(Object requester, String group);
+
+ /**Returns {@code true} if the node provides IProviders
+ *
+ */
+ public boolean isProvider();
+
+ /**Returns an IProvider or {@code null} depending on the requester and group
+ *
+ * @param requester The object requesting the IProvider
+ * @param group
+ * @return IProvider
+ */
+ public IProvider<?> requestProvider(Object requestor, String group);
+}
diff --git a/src/main/java/net/transit/network/system/ISystem.java b/src/main/java/net/transit/network/system/ISystem.java
new file mode 100644
index 0000000..fd2fa51
--- /dev/null
+++ b/src/main/java/net/transit/network/system/ISystem.java
@@ -0,0 +1,17 @@
+package net.transit.network.system;
+
+
+/**ISystem - a group of nodes optimized for performance
+ *
+ * A node can exist without a system, but a system can not exist without at least one root node.
+ *
+ * @param T The object type stored in the system.
+ */
+public interface ISystem
+{
+ /**The nodes stored by the system
+ *
+ * @return INode[]
+ */
+ public INode[] getNodes();
+}
diff --git a/src/main/java/net/transit/packet/IPacket.java b/src/main/java/net/transit/packet/IPacket.java
deleted file mode 100644
index 2b1753b..0000000
--- a/src/main/java/net/transit/packet/IPacket.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package net.transit.packet;
-
-public interface IPacket<D>
-{
- public D getData();
-} \ No newline at end of file
diff --git a/src/main/java/net/transit/packet/StaticPacket.java b/src/main/java/net/transit/packet/StaticPacket.java
deleted file mode 100644
index fb11dd7..0000000
--- a/src/main/java/net/transit/packet/StaticPacket.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package net.transit.packet;
-
-public class StaticPacket<D> implements IPacket<D>
-{
- private D data;
-
- public StaticPacket(D dat)
- {
- data = dat;
- }
-
- public D getData()
- {
- return data;
- }
-} \ No newline at end of file
diff --git a/src/main/java/net/transit/type/BaseType.java b/src/main/java/net/transit/type/BaseType.java
deleted file mode 100644
index 1202f95..0000000
--- a/src/main/java/net/transit/type/BaseType.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package net.transit.type;
-
-public abstract class BaseType<T>
-{
-
- public static final String TYPE_NAME = "BASE";
-
- private T data;
-
- public T getData()
- {
- return data;
- }
-} \ No newline at end of file
diff --git a/src/main/java/net/transit/type/Type.java b/src/main/java/net/transit/type/Type.java
index 0c6fc91..7c7f839 100644
--- a/src/main/java/net/transit/type/Type.java
+++ b/src/main/java/net/transit/type/Type.java
@@ -1,18 +1,41 @@
package net.transit.type;
-import net.transit.packet.IPacket;
+import net.transit.network.packet.IPacket;
+import net.transit.network.packet.StaticPacket;
-public abstract class Type<T, B> extends BaseType<T>
+/**@author Kyle Gunger
+ *
+ * @param <T> The type of object transfered by packets of this type
+ */
+public abstract class Type<T>
{
- public static final String TYPE_NAME = "TYPE";
-
- public B convertToBase()
- {
- return null;
- }
-
- public IPacket<T> convertFromBase(B base)
- {
- return null;
- }
-} \ No newline at end of file
+
+ /**Return the packet's data formatted in the group's base type.
+ *
+ * @param packet The packet (of this type)
+ * @return <T> The packet's data in the default type
+ */
+ public T toBase(IPacket<T> packet)
+ {
+ return packet.getData();
+ }
+
+ /**Create a packet which has the current type from the data in the base type.
+ *
+ * @param base The base data
+ * @return IPacket<<T>> The packet
+ */
+ public IPacket<T> fromBase(T base)
+ {
+ return new StaticPacket<T>(base, this);
+ }
+
+ /** The type identifier. Must be overridden for any class implementing IType
+ *
+ * @return String
+ */
+ public String getType()
+ {
+ return "ITYPE";
+ }
+}
diff --git a/src/main/java/net/transit/type/group/GroupRegistry.java b/src/main/java/net/transit/type/group/GroupRegistry.java
new file mode 100644
index 0000000..47ee4db
--- /dev/null
+++ b/src/main/java/net/transit/type/group/GroupRegistry.java
@@ -0,0 +1,51 @@
+package net.transit.type.group;
+
+import java.util.ArrayList;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public abstract class GroupRegistry {
+ private static final ArrayList<TypeGroup<?>> GROUPS = new ArrayList<TypeGroup<?>>(0);
+ private static final ArrayList<String> GROUPIDS = new ArrayList<String>(0);
+
+ private static final Logger LOG = LogManager.getFormatterLogger("Transit|GroupRegistry");
+
+ public static final boolean addGroup(TypeGroup<?> group, String groupID)
+ {
+ for(String s : GROUPIDS)
+ {
+ if(s.equals(groupID))
+ {
+ LOG.warn("Failed to add group " + group.getGroup() + " to the registry. Did another mod add a group with the same name?");
+ return false;
+ }
+ }
+
+ for(TypeGroup<?> g : GROUPS)
+ {
+ if(g.equals(group))
+ {
+ LOG.warn("Failed to add group " + group.getGroup() + " to the registry. Was the group alreay added?");
+ return false;
+ }
+ }
+
+ GROUPS.add(group);
+ GROUPIDS.add(groupID);
+ LOG.info("Successfully added group " + group.getGroup() + " to the registry.");
+ return true;
+ }
+
+ public static final TypeGroup<?> groupByID(String groupID)
+ {
+ for(String s : GROUPIDS)
+ {
+ if(s.equals(groupID)) return GROUPS.get(GROUPIDS.indexOf(s));
+ }
+
+ return null;
+
+ }
+
+}
diff --git a/src/main/java/net/transit/type/group/TypeGroup.java b/src/main/java/net/transit/type/group/TypeGroup.java
new file mode 100644
index 0000000..2602641
--- /dev/null
+++ b/src/main/java/net/transit/type/group/TypeGroup.java
@@ -0,0 +1,137 @@
+package net.transit.type.group;
+
+import java.util.ArrayList;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import net.transit.network.packet.IPacket;
+import net.transit.type.Type;
+
+/**
+ * @author Kyle Gunger
+ * @param <B> The base object which all grouped Types should convert between.
+ */
+public class TypeGroup<B>
+{
+ /** The list of types. */
+ private final ArrayList<Type<?>> TYPES = new ArrayList<Type<?>>(0);
+ private final ArrayList<String> TYPEIDS = new ArrayList<String>(0);
+
+ /** Logger for events in the group. Should not be overridden.*/
+ private static final Logger LOG = LogManager.getFormatterLogger("Transit|Group");
+
+ /**Check if the type is in the group
+ *
+ * @param type
+ * @return boolean
+ */
+ public boolean isInGroup(Type<B> type)
+ {
+ return TYPES.contains(type);
+ }
+
+ /**Check if the type is in the group
+ *
+ * @param type
+ * @return boolean
+ */
+ public boolean isInGroup(String type)
+ {
+ return TYPEIDS.contains(type);
+ }
+
+ /**Get the type from the group
+ *
+ * @param type
+ * @return IType<<B>>
+ */
+ public Type<B> getType(String type)
+ {
+ if(isInGroup(type))
+ {
+ return (Type<B>) TYPES.get(TYPEIDS.indexOf(type));
+ }
+
+ return null;
+ }
+
+ // Type conversion
+ /**Convert a packet to a new type
+ *
+ * @param packet The packet to convert
+ * @param type The type to convert to
+ * @return IPacket<<B>>
+ */
+ public IPacket<B> convertPacket(IPacket<B> packet, Type<B> type)
+ {
+ if(isInGroup(packet.getType()) && isInGroup(type))
+ {
+ return type.fromBase(packet.getType().toBase(packet));
+ }
+
+ return null;
+ }
+
+ public IPacket<B> convertPacket(IPacket<B> packet, String type)
+ {
+ if(isInGroup(packet.getType()) && isInGroup(type))
+ {
+ return getType(type).fromBase(packet.getType().toBase(packet));
+ }
+
+ return null;
+ }
+
+ // Type management
+
+ public boolean addType(Type<B> type, String typeID)
+ {
+ if(!isInGroup(type.getType()) && !isInGroup(typeID))
+ {
+ TYPES.add(type);
+ TYPEIDS.add(typeID);
+ LOG.info("Added type " + typeID + " to group " + this.getGroup());
+ return true;
+ }
+
+ return false;
+ }
+
+
+ public boolean removeType(Type<B> type)
+ {
+
+ if(isInGroup(type) && TYPES.indexOf(type) != -1)
+ {
+ String id = TYPEIDS.remove(TYPES.indexOf(type));
+ TYPES.remove(type);
+ LOG.info("Removed type " + id + " from group " + this.getGroup());
+ return true;
+ }
+ LOG.warn("Failed to remove type " + type.getType() + " from group " + this.getGroup() + ". Are we sure that the type was added to the group first?");
+ return false;
+ }
+
+ public boolean removeType(String typeID)
+ {
+ if(isInGroup(typeID) && TYPEIDS.indexOf(typeID) != -1)
+ {
+ TYPES.remove(TYPEIDS.indexOf(typeID));
+ TYPEIDS.remove(typeID);
+ LOG.info("Removed type " + typeID + " from group " + this.getGroup());
+ return true;
+ }
+
+ LOG.warn("Failed to remove type " + typeID + " from group " + this.getGroup() + ". Are we sure that the type was added to the group first?");
+ return false;
+ }
+
+ /** The group identifier. Must be overridden for any class implementing ITypeGroup
+ * @return String
+ */
+ public String getGroup()
+ {
+ return "ITYPEGROUP";
+ }
+}
diff --git a/src/main/java/net/transit/type/group/simple/EnergyGroup.java b/src/main/java/net/transit/type/group/simple/EnergyGroup.java
new file mode 100644
index 0000000..2d1eadc
--- /dev/null
+++ b/src/main/java/net/transit/type/group/simple/EnergyGroup.java
@@ -0,0 +1,10 @@
+package net.transit.type.group.simple;
+
+import net.transit.type.group.TypeGroup;
+
+public class EnergyGroup extends TypeGroup<Number>{
+ public String getGroup()
+ {
+ return "ENERGY";
+ }
+}
diff --git a/src/main/java/net/transit/type/group/simple/FluidGroup.java b/src/main/java/net/transit/type/group/simple/FluidGroup.java
new file mode 100644
index 0000000..3272c94
--- /dev/null
+++ b/src/main/java/net/transit/type/group/simple/FluidGroup.java
@@ -0,0 +1,11 @@
+package net.transit.type.group.simple;
+
+import net.minecraft.block.FluidBlock;
+import net.transit.type.group.TypeGroup;
+
+public class FluidGroup extends TypeGroup<FluidBlock>{
+ public String getGroup()
+ {
+ return "FLUID";
+ }
+}
diff --git a/src/main/java/net/transit/type/group/simple/ItemGroup.java b/src/main/java/net/transit/type/group/simple/ItemGroup.java
new file mode 100644
index 0000000..b7df90b
--- /dev/null
+++ b/src/main/java/net/transit/type/group/simple/ItemGroup.java
@@ -0,0 +1,11 @@
+package net.transit.type.group.simple;
+
+import net.minecraft.item.Item;
+import net.transit.type.group.TypeGroup;
+
+public class ItemGroup extends TypeGroup<Item>{
+ public String getGroup()
+ {
+ return "ITEM";
+ }
+}
diff --git a/src/main/java/net/transit/type/group/simple/ManaGroup.java b/src/main/java/net/transit/type/group/simple/ManaGroup.java
new file mode 100644
index 0000000..6ed6ff1
--- /dev/null
+++ b/src/main/java/net/transit/type/group/simple/ManaGroup.java
@@ -0,0 +1,10 @@
+package net.transit.type.group.simple;
+
+import net.transit.type.group.TypeGroup;
+
+public class ManaGroup extends TypeGroup<Number>{
+ public String getGroup()
+ {
+ return "MANA";
+ }
+}
diff --git a/src/main/java/net/transit/type/group/simple/SimpleGroups.java b/src/main/java/net/transit/type/group/simple/SimpleGroups.java
new file mode 100644
index 0000000..57ab2e9
--- /dev/null
+++ b/src/main/java/net/transit/type/group/simple/SimpleGroups.java
@@ -0,0 +1,26 @@
+package net.transit.type.group.simple;
+
+import net.minecraft.block.FluidBlock;
+import net.minecraft.item.Item;
+import net.transit.type.group.GroupRegistry;
+import net.transit.type.group.TypeGroup;
+
+/**
+ * @author Kyle Gunger
+ *
+ * @apiNote Basic default groups which all mods are welcome to add themselves to.
+ */
+public class SimpleGroups
+{
+ public static final TypeGroup<Number> ENERGY_GROUP = new EnergyGroup();
+ public static final TypeGroup<Number> MANA_GROUP = new ManaGroup();
+ public static final TypeGroup<Item> ITEM_GROUP = new ItemGroup();
+ public static final TypeGroup<FluidBlock> FLUID_GROUP = new FluidGroup();
+ public static void initGroups()
+ {
+ GroupRegistry.addGroup(ENERGY_GROUP, "ENERGY");
+ GroupRegistry.addGroup(MANA_GROUP, "MANA");
+ GroupRegistry.addGroup(ITEM_GROUP, "ITEM");
+ GroupRegistry.addGroup(FLUID_GROUP, "FLUID");
+ }
+}
diff --git a/src/main/java/net/transit/type/simple/EnergyType.java b/src/main/java/net/transit/type/simple/EnergyType.java
new file mode 100644
index 0000000..113b881
--- /dev/null
+++ b/src/main/java/net/transit/type/simple/EnergyType.java
@@ -0,0 +1,11 @@
+package net.transit.type.simple;
+
+import net.transit.type.Type;
+
+public class EnergyType extends Type<Number>
+{
+ public String getType() {
+ return "ENERGY_TYPE";
+ }
+
+}
diff --git a/src/main/java/net/transit/type/simple/FluidType.java b/src/main/java/net/transit/type/simple/FluidType.java
new file mode 100644
index 0000000..86a3fb0
--- /dev/null
+++ b/src/main/java/net/transit/type/simple/FluidType.java
@@ -0,0 +1,11 @@
+package net.transit.type.simple;
+
+import net.minecraft.block.FluidBlock;
+import net.transit.type.Type;
+
+public class FluidType extends Type<FluidBlock>
+{
+ public String getType() {
+ return "FLUID_TYPE";
+ }
+}
diff --git a/src/main/java/net/transit/type/simple/ItemType.java b/src/main/java/net/transit/type/simple/ItemType.java
new file mode 100644
index 0000000..6e860fc
--- /dev/null
+++ b/src/main/java/net/transit/type/simple/ItemType.java
@@ -0,0 +1,11 @@
+package net.transit.type.simple;
+
+import net.minecraft.item.Item;
+import net.transit.type.Type;
+
+public class ItemType extends Type<Item>
+{
+ public String getType() {
+ return "ITEM_TYPE";
+ }
+}
diff --git a/src/main/java/net/transit/type/simple/ManaType.java b/src/main/java/net/transit/type/simple/ManaType.java
new file mode 100644
index 0000000..6959216
--- /dev/null
+++ b/src/main/java/net/transit/type/simple/ManaType.java
@@ -0,0 +1,10 @@
+package net.transit.type.simple;
+
+import net.transit.type.Type;
+
+public class ManaType extends Type<Number>
+{
+ public String getType() {
+ return "MANA_TYPE";
+ }
+}
diff --git a/src/main/java/net/transit/type/simple/SimpleTypes.java b/src/main/java/net/transit/type/simple/SimpleTypes.java
new file mode 100644
index 0000000..e01af77
--- /dev/null
+++ b/src/main/java/net/transit/type/simple/SimpleTypes.java
@@ -0,0 +1,27 @@
+package net.transit.type.simple;
+
+import net.minecraft.block.FluidBlock;
+import net.minecraft.item.Item;
+import net.transit.type.Type;
+import net.transit.type.group.simple.SimpleGroups;
+
+/**
+ * @author Kyle Gunger
+ *
+ * @apiNote Simple types which work as the base types for the simple groups.
+ */
+public class SimpleTypes
+{
+ public static final Type<Number> ENERGY_TYPE = new EnergyType();
+ public static final Type<Number> MANA_TYPE = new ManaType();
+ public static final Type<Item> ITEM_TYPE = new ItemType();
+ public static final Type<FluidBlock> FLUID_TYPE = new FluidType();
+ public static void initTypes()
+ {
+ SimpleGroups.ENERGY_GROUP.addType(ENERGY_TYPE, "ENERGY");
+ SimpleGroups.MANA_GROUP.addType(MANA_TYPE, "MANA");
+ SimpleGroups.ITEM_GROUP.addType(ITEM_TYPE, "ITEM");
+ SimpleGroups.FLUID_GROUP.addType(FLUID_TYPE, "FLUID");
+ System.out.println(SimpleGroups.ENERGY_GROUP.isInGroup("ENERGY"));
+ }
+}
diff --git a/src/main/java/net/transit/type/typebase/MetaBase.java b/src/main/java/net/transit/type/typebase/MetaBase.java
deleted file mode 100644
index e1e6f5c..0000000
--- a/src/main/java/net/transit/type/typebase/MetaBase.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package net.transit.type.typebase;
-
-import net.transit.type.BaseType;
-
-public class MetaBase<T extends BaseType<?>> extends BaseType<T>
-{
- private T data;
- private String metaData;
-
- public static final String TYPE_NAME = "BASE_META";
-
- public MetaBase(T dat, String meta)
- {
- data = dat;
- metaData = meta;
- }
-
- public T getData()
- {
- return data;
- }
-
- public String getMetaData()
- {
- return metaData;
- }
-
-} \ No newline at end of file
diff --git a/src/main/java/net/transit/type/typebase/NumberBase.java b/src/main/java/net/transit/type/typebase/NumberBase.java
deleted file mode 100644
index a8d5ca3..0000000
--- a/src/main/java/net/transit/type/typebase/NumberBase.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package net.transit.type.typebase;
-
-import net.transit.type.BaseType;
-
-public class NumberBase extends BaseType<Number>
-{
- private Number data;
-
- public static final String TYPE_NAME = "BASE_NUMBER";
-
- public NumberBase(Number dat)
- {
- data = dat;
- }
-
- public Number getData()
- {
- return data;
- }
-} \ No newline at end of file
diff --git a/src/main/java/net/transit/type/typebase/StringBase.java b/src/main/java/net/transit/type/typebase/StringBase.java
deleted file mode 100644
index 8138b8d..0000000
--- a/src/main/java/net/transit/type/typebase/StringBase.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package net.transit.type.typebase;
-
-import net.transit.type.BaseType;
-
-public class StringBase extends BaseType<String>
-{
- private String data;
-
- public static final String TYPE_NAME = "BASE_STRING";
-
- public StringBase(String dat)
- {
- data = dat;
- }
-
- public String getData()
- {
- return data;
- }
-} \ No newline at end of file
diff --git a/src/main/java/net/transit/type/typegroup/TypeGroup.java b/src/main/java/net/transit/type/typegroup/TypeGroup.java
deleted file mode 100644
index 4349df6..0000000
--- a/src/main/java/net/transit/type/typegroup/TypeGroup.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package net.transit.type.typegroup;
-
-import java.util.ArrayList;
-
-import net.transit.type.Type;
-import net.transit.type.BaseType;
-
-public class TypeGroup<B>
-{
- private BaseType<B> baseType;
-
- private String groupName;
-
- private ArrayList<Type<?, B>> types;
-
- /**Create a new TypeGroup
- *
- * @param base The base type of the group.
- * @param name The identifier of the group. Should be in all caps.
- */
- public TypeGroup(BaseType<B> base, String name)
- {
- baseType = base;
- types = new ArrayList<Type<?, B>>(0);
- groupName = name;
- }
-
- // Return the base type
- public BaseType<B> getBaseType()
- {
- return baseType;
- }
-
- // Returns if the type is supported by the group
- public boolean hasType(Type<?, ?> t)
- {
-
- for(Type<?, B> gtype : types)
- {
-
- if(t.TYPE_NAME == gtype.TYPE_NAME) return true;
- }
-
- return false;
- }
-
- // Group name/identifier
- public String getGroupName()
- {
-
- return groupName;
- }
-} \ No newline at end of file
diff --git a/src/main/java/net/transit/type/typegroup/TypeRegister.java b/src/main/java/net/transit/type/typegroup/TypeRegister.java
deleted file mode 100644
index d226cbe..0000000
--- a/src/main/java/net/transit/type/typegroup/TypeRegister.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package net.transit.type.typegroup;
-
-import java.util.ArrayList;
-
-import net.transit.type.Type;
-
-public final class TypeRegister
-{
- private TypeRegister(){}
-
- // Hold all the groups
- private static ArrayList<TypeGroup<?>> groups = new ArrayList<TypeGroup<?>>(0);
-
- private static ArrayList<Class> caster = new ArrayList<Class>(0);
-
- // Add a group
- public static void addTypeGroup(TypeGroup<?> g)
- {
- if(getTypeGroup(g.getGroupName()) != null) return;
-
- groups.add(g);
- }
-
- // Get a group by it's identifier
- public static TypeGroup<?> getTypeGroup(String name)
- {
- for(TypeGroup<?> g : groups)
- {
- if(g.getGroupName().toUpperCase() == name.toUpperCase()) return g;
- }
-
- return null;
- }
-
- public static String groupOf(Type<?, ?> t)
- {
- for(TypeGroup<?> g : groups)
- {
- if(g.hasType(t)) return g.getGroupName();
- }
-
- return null;
- }
-} \ No newline at end of file