diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2019-11-18 23:19:56 -0500 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2019-11-18 23:19:56 -0500 |
commit | cd5fc531b48770883d411783cc2f626b11d16b6f (patch) | |
tree | f7d639bfd6d072963e687dee558eadc6e992cc38 /src/main |
[Initial] Update lib to 0.0.2
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/net/corecg/transit/impl/IAcceptor.java | 13 | ||||
-rw-r--r-- | src/main/java/net/corecg/transit/impl/IConsumer.java | 10 | ||||
-rw-r--r-- | src/main/java/net/corecg/transit/impl/IGenerator.java | 10 | ||||
-rw-r--r-- | src/main/java/net/corecg/transit/impl/IProvider.java | 17 | ||||
-rw-r--r-- | src/main/java/net/corecg/transit/type/IBaseType.java | 7 | ||||
-rw-r--r-- | src/main/java/net/corecg/transit/type/IType.java | 10 | ||||
-rw-r--r-- | src/main/java/net/corecg/transit/type/typebase/MetaBase.java | 26 | ||||
-rw-r--r-- | src/main/java/net/corecg/transit/type/typebase/NumberBase.java | 18 | ||||
-rw-r--r-- | src/main/java/net/corecg/transit/type/typebase/StringBase.java | 18 | ||||
-rw-r--r-- | src/main/java/net/corecg/transit/type/typegroup/TypeGroup.java | 53 | ||||
-rw-r--r-- | src/main/java/net/corecg/transit/type/typegroup/TypeRegister.java | 42 | ||||
-rw-r--r-- | src/main/resources/assets/corecg-transfer/transit.png | bin | 0 -> 21254 bytes | |||
-rw-r--r-- | src/main/resources/fabric.mod.json | 26 |
13 files changed, 250 insertions, 0 deletions
diff --git a/src/main/java/net/corecg/transit/impl/IAcceptor.java b/src/main/java/net/corecg/transit/impl/IAcceptor.java new file mode 100644 index 0000000..2561a04 --- /dev/null +++ b/src/main/java/net/corecg/transit/impl/IAcceptor.java @@ -0,0 +1,13 @@ +package net.corecg.transit.impl; + +import net.corecg.transit.type.IType; +import net.minecraft.util.math.Direction; + +public interface IAcceptor<T extends IType<?, ?>> +{ + // Direction given if acceptor is a block + public boolean canAccept(Direction d); + + // Accept (or not) a provided T (should trigger ITransferEvent) + public boolean accept(T provided); +}
\ No newline at end of file diff --git a/src/main/java/net/corecg/transit/impl/IConsumer.java b/src/main/java/net/corecg/transit/impl/IConsumer.java new file mode 100644 index 0000000..cca2b5c --- /dev/null +++ b/src/main/java/net/corecg/transit/impl/IConsumer.java @@ -0,0 +1,10 @@ +package net.corecg.transit.impl; + +import net.corecg.transit.type.IType; + +public interface IConsumer<T extends IType<?, ?>> extends IAcceptor<T> +{ + public boolean canConsume(); + + +}
\ No newline at end of file diff --git a/src/main/java/net/corecg/transit/impl/IGenerator.java b/src/main/java/net/corecg/transit/impl/IGenerator.java new file mode 100644 index 0000000..e8aa791 --- /dev/null +++ b/src/main/java/net/corecg/transit/impl/IGenerator.java @@ -0,0 +1,10 @@ +package net.corecg.transit.impl; + +import net.corecg.transit.type.IType; + +public interface IGenerator<T extends IType<?, ?>> extends IProvider<T> +{ + public boolean canGenerate(); + + +}
\ No newline at end of file diff --git a/src/main/java/net/corecg/transit/impl/IProvider.java b/src/main/java/net/corecg/transit/impl/IProvider.java new file mode 100644 index 0000000..082ef07 --- /dev/null +++ b/src/main/java/net/corecg/transit/impl/IProvider.java @@ -0,0 +1,17 @@ +package net.corecg.transit.impl; + +import net.corecg.transit.type.IType; +import net.minecraft.util.math.Direction; + +public interface IProvider<T extends IType<?, ?>> +{ + + // Direction given if provider is a block + public boolean canProvide(Direction d); + + // Provide the next T (should trigger ITransferEvent) + public T provide(); + + // Retain the rejected T if the acceptor did not accept it (should trigger ITransferEvent) + public void accept(T rejected); +}
\ No newline at end of file diff --git a/src/main/java/net/corecg/transit/type/IBaseType.java b/src/main/java/net/corecg/transit/type/IBaseType.java new file mode 100644 index 0000000..4cf5ada --- /dev/null +++ b/src/main/java/net/corecg/transit/type/IBaseType.java @@ -0,0 +1,7 @@ +package net.corecg.transit.type; + +public interface IBaseType<T> +{ + + public T getData(); +}
\ No newline at end of file diff --git a/src/main/java/net/corecg/transit/type/IType.java b/src/main/java/net/corecg/transit/type/IType.java new file mode 100644 index 0000000..c7b1854 --- /dev/null +++ b/src/main/java/net/corecg/transit/type/IType.java @@ -0,0 +1,10 @@ +package net.corecg.transit.type; + +public interface IType<T, B> extends IBaseType<B> +{ + public String getTypeName(); + + public IBaseType<B> convertToBase(); + + public IType<T, B> convertFromBase(IBaseType<B> base); +}
\ No newline at end of file diff --git a/src/main/java/net/corecg/transit/type/typebase/MetaBase.java b/src/main/java/net/corecg/transit/type/typebase/MetaBase.java new file mode 100644 index 0000000..b890e54 --- /dev/null +++ b/src/main/java/net/corecg/transit/type/typebase/MetaBase.java @@ -0,0 +1,26 @@ +package net.corecg.transit.type.typebase; + +import net.corecg.transit.type.IBaseType; + +public class MetaBase<T extends IBaseType<?>> implements IBaseType<T> +{ + private T data; + private String metaData; + + 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/corecg/transit/type/typebase/NumberBase.java b/src/main/java/net/corecg/transit/type/typebase/NumberBase.java new file mode 100644 index 0000000..5f30cf2 --- /dev/null +++ b/src/main/java/net/corecg/transit/type/typebase/NumberBase.java @@ -0,0 +1,18 @@ +package net.corecg.transit.type.typebase; + +import net.corecg.transit.type.IBaseType; + +public class NumberBase implements IBaseType<Number> +{ + private Number data; + + public NumberBase(Number dat) + { + data = dat; + } + + public Number getData() + { + return data; + } +}
\ No newline at end of file diff --git a/src/main/java/net/corecg/transit/type/typebase/StringBase.java b/src/main/java/net/corecg/transit/type/typebase/StringBase.java new file mode 100644 index 0000000..1e2e4b8 --- /dev/null +++ b/src/main/java/net/corecg/transit/type/typebase/StringBase.java @@ -0,0 +1,18 @@ +package net.corecg.transit.type.typebase; + +import net.corecg.transit.type.IBaseType; + +public class StringBase implements IBaseType<String> +{ + private String data; + + public StringBase(String dat) + { + data = dat; + } + + public String getData() + { + return data; + } +}
\ No newline at end of file diff --git a/src/main/java/net/corecg/transit/type/typegroup/TypeGroup.java b/src/main/java/net/corecg/transit/type/typegroup/TypeGroup.java new file mode 100644 index 0000000..d5a8101 --- /dev/null +++ b/src/main/java/net/corecg/transit/type/typegroup/TypeGroup.java @@ -0,0 +1,53 @@ +package net.corecg.transit.type.typegroup; + +import java.util.ArrayList; + +import net.corecg.transit.type.IType; +import net.corecg.transit.type.IBaseType; + +public class TypeGroup<B> +{ + private IBaseType<B> baseType; + + private String groupName; + + private ArrayList<IType<?, 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(IBaseType<B> base, String name) + { + baseType = base; + types = new ArrayList<IType<?, B>>(0); + groupName = name; + } + + // Return the base type + public IBaseType<B> getBaseType() + { + return baseType; + } + + // Returns if the type is supported by the group + public boolean hasType(IType t) + { + + for(IType gtype : types) + { + + if(t.getTypeName() == gtype.getTypeName()) 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/corecg/transit/type/typegroup/TypeRegister.java b/src/main/java/net/corecg/transit/type/typegroup/TypeRegister.java new file mode 100644 index 0000000..4791e5b --- /dev/null +++ b/src/main/java/net/corecg/transit/type/typegroup/TypeRegister.java @@ -0,0 +1,42 @@ +package net.corecg.transit.type.typegroup; + +import java.util.ArrayList; + +import net.corecg.transit.type.IType; + +public final class TypeRegister +{ + private TypeRegister(){} + + // Hold all the groups + private static ArrayList<TypeGroup<?>> groups = new ArrayList<TypeGroup<?>>(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(IType<?, ?> t) + { + for(TypeGroup<?> g : groups) + { + if(g.hasType(t)) return g.getGroupName(); + } + + return null; + } +}
\ No newline at end of file diff --git a/src/main/resources/assets/corecg-transfer/transit.png b/src/main/resources/assets/corecg-transfer/transit.png Binary files differnew file mode 100644 index 0000000..ab04337 --- /dev/null +++ b/src/main/resources/assets/corecg-transfer/transit.png diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..e978042 --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,26 @@ +{ + "schemaVersion": 1, + "id": "corecg-transfer", + "version": "${version}", + + "name": "CoreCG Transfer", + "description": "General purpose API for transfering fluid, items, energy, anything.", + "authors": [ + "CCG Kyle" + ], + "contact": { + }, + + "license": "CC0-1.0", + "icon": "assets/corecg-transfer/transit.png", + + "environment": "*", + + "depends": { + "fabricloader": ">=0.4.0", + "fabric": "*" + }, + "suggests": { + "flamingo": "*" + } +} |