diff options
Diffstat (limited to 'src/main/java')
26 files changed, 385 insertions, 351 deletions
diff --git a/src/main/java/net/transit/InitTransit.java b/src/main/java/net/transit/InitTransit.java index 1d4941e..a89f91a 100644 --- a/src/main/java/net/transit/InitTransit.java +++ b/src/main/java/net/transit/InitTransit.java @@ -1,15 +1,13 @@ package net.transit; import net.fabricmc.api.ModInitializer; -import net.transit.type.group.simple.SimpleGroups; -import net.transit.type.simple.SimpleTypes; +import net.transit.type.group.simple.InitSimpleGroups; public class InitTransit implements ModInitializer { @Override public void onInitialize() { - SimpleGroups.initGroups(); - SimpleTypes.initTypes(); + InitSimpleGroups.init(); } } diff --git a/src/main/java/net/transit/network/packet/ArrayPacket.java b/src/main/java/net/transit/network/packet/ArrayPacket.java index 9cbd300..fbea811 100644 --- a/src/main/java/net/transit/network/packet/ArrayPacket.java +++ b/src/main/java/net/transit/network/packet/ArrayPacket.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import net.transit.type.Type; -public class ArrayPacket<D> implements IPacket<D> +public class ArrayPacket<D> implements Packet<D> { private ArrayList<D> arrayData; private Type<D> type; @@ -13,8 +13,10 @@ public class ArrayPacket<D> implements IPacket<D> { arrayData = new ArrayList<D>(0); arrayData.add(startValue); + type = t; } - + + @Override public D getData() { if(arrayData.size() > 0) return arrayData.get(0); @@ -25,6 +27,11 @@ public class ArrayPacket<D> implements IPacket<D> { arrayData.add(data); } + + public int dataStored() + { + return arrayData.size(); + } public D popAndShift() { diff --git a/src/main/java/net/transit/network/packet/MetaPacket.java b/src/main/java/net/transit/network/packet/MetaPacket.java index e4cffdf..0240519 100644 --- a/src/main/java/net/transit/network/packet/MetaPacket.java +++ b/src/main/java/net/transit/network/packet/MetaPacket.java @@ -2,7 +2,7 @@ package net.transit.network.packet; import net.transit.type.Type; -public class MetaPacket<D, M> implements IPacket<D> +public class MetaPacket<D, M> implements Packet<D> { private D data; diff --git a/src/main/java/net/transit/network/packet/IPacket.java b/src/main/java/net/transit/network/packet/Packet.java index deafdf8..0b7c832 100644 --- a/src/main/java/net/transit/network/packet/IPacket.java +++ b/src/main/java/net/transit/network/packet/Packet.java @@ -7,7 +7,7 @@ import net.transit.type.Type; * * @param <D> The data type (Object) that the packet transfers. */ -public interface IPacket<D> +public interface Packet<D> { /**Get the packet's data * diff --git a/src/main/java/net/transit/network/packet/StaticPacket.java b/src/main/java/net/transit/network/packet/StaticPacket.java index 8399041..b14e442 100644 --- a/src/main/java/net/transit/network/packet/StaticPacket.java +++ b/src/main/java/net/transit/network/packet/StaticPacket.java @@ -2,7 +2,7 @@ package net.transit.network.packet; import net.transit.type.Type; -public class StaticPacket<D> implements IPacket<D> +public class StaticPacket<D> implements Packet<D> { private D data; private Type<D> type; diff --git a/src/main/java/net/transit/network/swap/Acceptor.java b/src/main/java/net/transit/network/swap/Acceptor.java new file mode 100644 index 0000000..9778095 --- /dev/null +++ b/src/main/java/net/transit/network/swap/Acceptor.java @@ -0,0 +1,44 @@ +package net.transit.network.swap; + +import net.transit.network.packet.Packet; +import net.transit.network.system.Node; + +/** + * @author Kyle Gunger + * + * @param <T> The type of data accepted (in IPacket<<T>> form) + */ +public interface Acceptor<T> +{ + /** Returns the INode this Acceptor is attached to. All Acceptors and Provider must be attached to an INode to function. + * + * @return INode + */ + public Node getNode(); + + /** + * @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(Packet<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(Provider<T> provider); + + /** Request that the Acceptor close it's connection to a Provider. The Acceptor may also shut itself down if no more Providers are attached. + * + * @param provider The Provider + */ + public void shutdown(Provider<T> provider); +}
\ 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 deleted file mode 100644 index 6966b9a..0000000 --- a/src/main/java/net/transit/network/swap/IAcceptor.java +++ /dev/null @@ -1,31 +0,0 @@ -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 deleted file mode 100644 index 03c9ca9..0000000 --- a/src/main/java/net/transit/network/swap/IProvider.java +++ /dev/null @@ -1,37 +0,0 @@ -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/swap/Provider.java b/src/main/java/net/transit/network/swap/Provider.java new file mode 100644 index 0000000..20656b8 --- /dev/null +++ b/src/main/java/net/transit/network/swap/Provider.java @@ -0,0 +1,50 @@ +package net.transit.network.swap; + +import net.transit.network.packet.Packet; +import net.transit.network.system.Node; + +/** + * @author Kyle Gunger + * + * @param <T> The type of data provided (in IPacket<<T>> form) + */ +public interface Provider<T> +{ + /** Returns the INode this Provider is attached to. All Acceptors and Providers must be attached to an INode to function. + * + * @return INode + */ + public Node getNode(); + + /** + * @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 Packet<T> provide(); + + /**Retain the packet if the Acceptor did not accept the packet. + * + * @param rejected The rejected packet + */ + public void retain(Packet<T> rejected); + + /** + * @return <b>True</b> if the Provider has an Acceptor 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(Acceptor<T> acceptor); + + /** Request that the Provider close it's connection to a Acceptor. The Provider may also shut itself down if no more Acceptors are attached. + * + * @param acceptor The Acceptor + */ + public void shutdown(Acceptor<T> acceptor); +}
\ 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 deleted file mode 100644 index 2dc3686..0000000 --- a/src/main/java/net/transit/network/system/INode.java +++ /dev/null @@ -1,50 +0,0 @@ -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/Node.java b/src/main/java/net/transit/network/system/Node.java new file mode 100644 index 0000000..8e0fcbb --- /dev/null +++ b/src/main/java/net/transit/network/system/Node.java @@ -0,0 +1,50 @@ +package net.transit.network.system; + +import net.transit.network.swap.Acceptor; +import net.transit.network.swap.Provider; + +/** + * @author Kyle Gunger + * @apiNote A node inside or outside a system. Provides acceptors and providers to other nodes. + */ +public interface Node +{ + /**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 System getSystem(); + + /**Returns {@code true} if the node provides Acceptors + * + * @return boolean + */ + public boolean isAcceptor(); + + /**Returns an Acceptor or {@code null} depending on the requester and group + * + * @param requester The object requesting the Acceptor + * @param group + * @return Acceptor + */ + public Acceptor<?> requestAcceptor(Object requester, String group); + + /**Returns {@code true} if the node provides Providers + * + */ + public boolean isProvider(); + + /**Returns an Provider or {@code null} depending on the requester and group + * + * @param requester The object requesting the Provider + * @param group + * @return Provider + */ + public Provider<?> 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/System.java index fd2fa51..c70292a 100644 --- a/src/main/java/net/transit/network/system/ISystem.java +++ b/src/main/java/net/transit/network/system/System.java @@ -7,11 +7,11 @@ package net.transit.network.system; * * @param T The object type stored in the system. */ -public interface ISystem +public interface System { /**The nodes stored by the system * * @return INode[] */ - public INode[] getNodes(); + public Node[] getNodes(); } diff --git a/src/main/java/net/transit/type/Type.java b/src/main/java/net/transit/type/Type.java index 7c7f839..d140da5 100644 --- a/src/main/java/net/transit/type/Type.java +++ b/src/main/java/net/transit/type/Type.java @@ -1,41 +1,60 @@ package net.transit.type; -import net.transit.network.packet.IPacket; +import net.transit.network.packet.Packet; import net.transit.network.packet.StaticPacket; /**@author Kyle Gunger * * @param <T> The type of object transfered by packets of this type */ -public abstract class Type<T> +public class Type<T> { + protected String typeID; + protected String groupID; - /**Return the packet's data formatted in the group's base type. + public Type(String tID, String gID) + { + typeID = tID; + groupID = gID; + } + + /** Return the packet's data formatted in the group's base type. * * @param packet The packet (of this type) + * @param group The group asking for the conversion * @return <T> The packet's data in the default type */ - public T toBase(IPacket<T> packet) + public T toBase(Packet<T> packet, String group) { return packet.getData(); } - /**Create a packet which has the current type from the data in the base type. + /** Create a packet which has the current type from the data in the base type. * * @param base The base data + * @param group The group that the data comes from * @return IPacket<<T>> The packet */ - public IPacket<T> fromBase(T base) + public Packet<T> fromBase(T base, String group) { return new StaticPacket<T>(base, this); } - /** The type identifier. Must be overridden for any class implementing IType + /** The type identifier. Must be overridden for any class implementing IType. + * + * @return String + */ + public final String getType() + { + return typeID; + } + + /** The group identifier. Gives the normal group identity of the type. * * @return String */ - public String getType() + public final String getGroup() { - return "ITYPE"; + return groupID; } } diff --git a/src/main/java/net/transit/type/group/GroupRegistry.java b/src/main/java/net/transit/type/group/GroupRegistry.java index 47ee4db..8f8a612 100644 --- a/src/main/java/net/transit/type/group/GroupRegistry.java +++ b/src/main/java/net/transit/type/group/GroupRegistry.java @@ -5,47 +5,46 @@ import java.util.ArrayList; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public abstract class GroupRegistry { +import net.transit.type.Type; + +public 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"); + private static final String prefix = "[" + LOG.getName() + "] "; + + private GroupRegistry() {} - public static final boolean addGroup(TypeGroup<?> group, String groupID) + public static final boolean addGroup(TypeGroup<?> group) { - 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)) + if(g.getGroup().equals(group.getGroup())) { - LOG.warn("Failed to add group " + group.getGroup() + " to the registry. Was the group alreay added?"); + LOG.warn(prefix + "Failed to add group " + group.getGroup() + " to the registry. Did another mod add a group with the same name?"); return false; } } GROUPS.add(group); - GROUPIDS.add(groupID); - LOG.info("Successfully added group " + group.getGroup() + " to the registry."); + LOG.info(prefix + "Successfully added group " + group.getGroup() + " to the registry."); return true; } public static final TypeGroup<?> groupByID(String groupID) { - for(String s : GROUPIDS) + for(TypeGroup<?> g : GROUPS) { - if(s.equals(groupID)) return GROUPS.get(GROUPIDS.indexOf(s)); + if(g.getGroup().equals(groupID)) return g; } return null; } + public static final Type<?> typeByIdentity(String groupID, String typeID) + { + return groupByID(groupID).getType(typeID); + } + } diff --git a/src/main/java/net/transit/type/group/TypeGroup.java b/src/main/java/net/transit/type/group/TypeGroup.java index 2602641..8929252 100644 --- a/src/main/java/net/transit/type/group/TypeGroup.java +++ b/src/main/java/net/transit/type/group/TypeGroup.java @@ -5,7 +5,7 @@ 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.network.packet.Packet; import net.transit.type.Type; /** @@ -14,124 +14,213 @@ import net.transit.type.Type; */ public class TypeGroup<B> { - /** The list of types. */ + // The base Type (provides the group's identifier) + private Type<B> baseType; + + // 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.*/ + // Logger for events in the TypeGroup. private static final Logger LOG = LogManager.getFormatterLogger("Transit|Group"); + private static final String prefix = "[" + LOG.getName() + "] "; - /**Check if the type is in the group - * - * @param type - * @return boolean + + public TypeGroup(Type<B> base) + { + baseType = base; + addType(base); + } + + + // Type management + + /** Add a Type to the TypeGroup. + * The Type must have a group-type combo not already found in this TypeGroup. + * Returns {@code true} if the group was added. + * + * @param type The Type to add + * @return */ - public boolean isInGroup(Type<B> type) + public boolean addType(Type<B> type) { - return TYPES.contains(type); + if(!isInGroup(type.getGroup(), type.getType()) && !isInGroup(type)) + { + TYPES.add(type); + LOG.info(prefix + "Added type " + type.getType() + " to group " + getGroup()); + return true; + } + + return false; } - /**Check if the type is in the group + /** Remove a Type from the TypeGroup. * - * @param type - * @return boolean + * @param type The Type to remove + * @return */ - public boolean isInGroup(String type) + public boolean removeType(Type<B> type) { - return TYPEIDS.contains(type); + + if(isInGroup(type) && TYPES.indexOf(type) != -1) + { + LOG.info(prefix + "Removed type " + TYPES.remove(TYPES.indexOf(type)).getType() + " from group " + getGroup()); + return true; + } + + LOG.warn(prefix + "[WARN] Failed to remove type " + type.getGroup() + ":" + type.getType() + " from group " + getGroup() + ". Are we sure that the type was added to the group first?"); + return false; } - /**Get the type from the group + /** Remove a type from the group based on it's group-type identifier. * * @param type - * @return IType<<B>> + * @return */ - public Type<B> getType(String type) + public boolean removeType(String groupID, String typeID) { - if(isInGroup(type)) + + for(Type<?> type : TYPES) { - return (Type<B>) TYPES.get(TYPEIDS.indexOf(type)); + if(type.getGroup().equals(groupID) && type.getType().equals(typeID)) + { + LOG.info(prefix + "Removed type " + TYPES.remove(TYPES.indexOf(type)).getType() + " from group " + getGroup()); + return true; + } } - return null; + LOG.warn(prefix + "[WARN] Failed to remove type " + groupID + ":" + typeID + " from group " + getGroup() + ". Are we sure that the type was added to the group first?"); + return false; } - // Type conversion - /**Convert a packet to a new type + /** Remove a type from the group based on it's group-type identifier. * - * @param packet The packet to convert - * @param type The type to convert to - * @return IPacket<<B>> + * @param type + * @return */ - public IPacket<B> convertPacket(IPacket<B> packet, Type<B> type) + public boolean removeType(String typeID) { - if(isInGroup(packet.getType()) && isInGroup(type)) + + return removeType(getGroup(), typeID); + } + + + // Check if a type is in the group + + /**Check if the type is in the group + * + * @param type + * @return boolean + */ + public boolean isInGroup(Type<B> type) + { + for(Type<?> t : TYPES) { - return type.fromBase(packet.getType().toBase(packet)); + if(t.equals(type)) return true; } - - return null; + return false; } - public IPacket<B> convertPacket(IPacket<B> packet, String type) + /**Check if the type is in the group + * + * @param groupID + * @param typeID + * @return boolean + */ + public boolean isInGroup(String groupID, String typeID) { - if(isInGroup(packet.getType()) && isInGroup(type)) + for(Type<?> t : TYPES) { - return getType(type).fromBase(packet.getType().toBase(packet)); + if(t.getGroup().equals(groupID) && t.getType().equals(typeID)) return true; } - - return null; + return false; + } + + /**Check if the type is in the group + * + * @param typeID + * @return boolean + */ + public boolean isInGroup(String typeID) + { + return isInGroup(getGroup(), typeID); } - // Type management + // Get a type in the group - public boolean addType(Type<B> type, String typeID) + /**Get the type from the group + * + * @param type + * @return Type + */ + @SuppressWarnings("unchecked") + public Type<B> getType(String groupID, String typeID) { - if(!isInGroup(type.getType()) && !isInGroup(typeID)) + for(Type<?> t : TYPES) { - TYPES.add(type); - TYPEIDS.add(typeID); - LOG.info("Added type " + typeID + " to group " + this.getGroup()); - return true; + if(t.getGroup().equals(groupID) && t.getType().equals(typeID)) return (Type<B>) t; } - return false; + return null; } + public Type<B> getType(String typeID) + { + return getType(getGroup(), typeID); + } - public boolean removeType(Type<B> type) + + // Type conversion + + /** Actually convert the packet + * + * @param packet + * @param type + * @return + */ + protected Packet<B> convertPacketRaw(Packet<B> packet, Type<B> type) { - - if(isInGroup(type) && TYPES.indexOf(type) != -1) + return type.fromBase(packet.getType().toBase(packet, getGroup()), getGroup()); + } + + /**Convert a packet to a new type + * + * @param packet The packet to convert + * @param type The type to convert to + * @return Packet + */ + public Packet<B> convertPacket(Packet<B> packet, Type<B> type) + { + if(isInGroup(packet.getType()) && isInGroup(type)) { - String id = TYPEIDS.remove(TYPES.indexOf(type)); - TYPES.remove(type); - LOG.info("Removed type " + id + " from group " + this.getGroup()); - return true; + return convertPacketRaw(packet, type); } - 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; + + return null; } - public boolean removeType(String typeID) + /**Convert a packet to a new type + * + * @param packet The packet to convert + * @param groupID The groupID of the Type to convert to + * @param typeID The typeID of the Type to convert to + * @return Packet + */ + public Packet<B> convertPacket(Packet<B> packet, String groupID, String typeID) { - if(isInGroup(typeID) && TYPEIDS.indexOf(typeID) != -1) + Type<B> toType = getType(groupID, typeID); + if(toType != null) { - TYPES.remove(TYPEIDS.indexOf(typeID)); - TYPEIDS.remove(typeID); - LOG.info("Removed type " + typeID + " from group " + this.getGroup()); - return true; + return convertPacketRaw(packet, toType); } - 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; + return null; } - /** The group identifier. Must be overridden for any class implementing ITypeGroup + /** The group identifier. Given by the Base Group * @return String */ - public String getGroup() + public final String getGroup() { - return "ITYPEGROUP"; + return baseType.getGroup(); } } diff --git a/src/main/java/net/transit/type/group/simple/EnergyGroup.java b/src/main/java/net/transit/type/group/simple/EnergyGroup.java deleted file mode 100644 index 2d1eadc..0000000 --- a/src/main/java/net/transit/type/group/simple/EnergyGroup.java +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 3272c94..0000000 --- a/src/main/java/net/transit/type/group/simple/FluidGroup.java +++ /dev/null @@ -1,11 +0,0 @@ -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/InitSimpleGroups.java b/src/main/java/net/transit/type/group/simple/InitSimpleGroups.java new file mode 100644 index 0000000..50a268a --- /dev/null +++ b/src/main/java/net/transit/type/group/simple/InitSimpleGroups.java @@ -0,0 +1,22 @@ +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; +import net.transit.type.simple.SimpleTypes; + +public final class InitSimpleGroups { + public static final TypeGroup<Number> ENERGY_GROUP = new TypeGroup<Number>(SimpleTypes.ENERGY); + public static final TypeGroup<Number> MANA_GROUP = new TypeGroup<Number>(SimpleTypes.MANA); + public static final TypeGroup<Item> ITEM_GROUP = new TypeGroup<Item>(SimpleTypes.ITEM); + public static final TypeGroup<FluidBlock> FLUID_GROUP = new TypeGroup<FluidBlock>(SimpleTypes.FLUID); + + public static final void init() + { + GroupRegistry.addGroup(ENERGY_GROUP); + GroupRegistry.addGroup(MANA_GROUP); + GroupRegistry.addGroup(ITEM_GROUP); + GroupRegistry.addGroup(FLUID_GROUP); + } +} diff --git a/src/main/java/net/transit/type/group/simple/ItemGroup.java b/src/main/java/net/transit/type/group/simple/ItemGroup.java deleted file mode 100644 index b7df90b..0000000 --- a/src/main/java/net/transit/type/group/simple/ItemGroup.java +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index 6ed6ff1..0000000 --- a/src/main/java/net/transit/type/group/simple/ManaGroup.java +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 57ab2e9..0000000 --- a/src/main/java/net/transit/type/group/simple/SimpleGroups.java +++ /dev/null @@ -1,26 +0,0 @@ -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 deleted file mode 100644 index 113b881..0000000 --- a/src/main/java/net/transit/type/simple/EnergyType.java +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index 86a3fb0..0000000 --- a/src/main/java/net/transit/type/simple/FluidType.java +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index 6e860fc..0000000 --- a/src/main/java/net/transit/type/simple/ItemType.java +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index 6959216..0000000 --- a/src/main/java/net/transit/type/simple/ManaType.java +++ /dev/null @@ -1,10 +0,0 @@ -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 index e01af77..b1f1b98 100644 --- a/src/main/java/net/transit/type/simple/SimpleTypes.java +++ b/src/main/java/net/transit/type/simple/SimpleTypes.java @@ -3,25 +3,10 @@ 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")); - } +public final class SimpleTypes { + public static final Type<Number> ENERGY = new Type<Number>("ENERGY", "ENERGY"); + public static final Type<Number> MANA = new Type<Number>("MANA", "MANA"); + public static final Type<Item> ITEM = new Type<Item>("ITEM", "ITEM"); + public static final Type<FluidBlock> FLUID = new Type<FluidBlock>("FLUID", "FLUID"); } |