diff --git a/common/buildcraft/api/liquids/LiquidDictionary.java b/common/buildcraft/api/liquids/LiquidDictionary.java new file mode 100644 index 00000000..42c8b406 --- /dev/null +++ b/common/buildcraft/api/liquids/LiquidDictionary.java @@ -0,0 +1,36 @@ +package buildcraft.api.liquids; + +import java.util.HashMap; +import java.util.Map; + +/** + * When creating liquids you should register them with this class. + * + * @author CovertJaguar + */ +public abstract class LiquidDictionary +{ + + private static Map liquids = new HashMap(); + + /** + * When creating liquids you should call this function. + * + * Upon passing it a name and liquid item it will return either + * a preexisting implementation of that liquid or the liquid passed in. + * + * + * @param name the name of the liquid + * @param liquid the liquid to use if one doesn't exist + * @return + */ + public static LiquidStack getOrCreateLiquid(String name, LiquidStack liquid) + { + LiquidStack existing = liquids.get(name); + if(existing != null) { + return existing; + } + liquids.put(name, liquid); + return liquid; + } +}