diff options
Diffstat (limited to 'src/Java/miscutil/core')
51 files changed, 4387 insertions, 137 deletions
diff --git a/src/Java/miscutil/core/lib/CORE.java b/src/Java/miscutil/core/lib/CORE.java index 19ace0bf47..270ebee91c 100644 --- a/src/Java/miscutil/core/lib/CORE.java +++ b/src/Java/miscutil/core/lib/CORE.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; import miscutil.core.creative.AddToCreativeTab; +import miscutil.core.util.aeonbits.owner.ConfigFactory; import miscutil.core.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import miscutil.core.xmod.gregtech.api.interfaces.internal.IGregtech_RecipeAdder; import miscutil.core.xmod.gregtech.common.Meta_GT_Proxy; @@ -31,6 +32,7 @@ public class CORE { public static IIconRegister GT_BlockIcons, GT_ItemIcons; public static List<Runnable> GT_BlockIconload = new ArrayList<Runnable>(); public static final Class<AddToCreativeTab> TAB = AddToCreativeTab.class; + public static ConfigHandler cfg = ConfigFactory.create(ConfigHandler.class); /** * A List containing all the Materials, which are somehow in use by GT and therefor receive a specific Set of Items. */ diff --git a/src/Java/miscutil/core/lib/ConfigHandler.java b/src/Java/miscutil/core/lib/ConfigHandler.java new file mode 100644 index 0000000000..d8ec0d6ff9 --- /dev/null +++ b/src/Java/miscutil/core/lib/ConfigHandler.java @@ -0,0 +1,14 @@ +package miscutil.core.lib; + +import miscutil.core.util.aeonbits.owner.Config; + +public interface ConfigHandler extends Config{ + + @DefaultValue("false") + boolean debugMode(); + + @DefaultValue("true") + boolean disableEnderIOIntegration(); + + +} diff --git a/src/Java/miscutil/core/lib/LoadedMods.java b/src/Java/miscutil/core/lib/LoadedMods.java index 9ea04cfa1a..2412482f6b 100644 --- a/src/Java/miscutil/core/lib/LoadedMods.java +++ b/src/Java/miscutil/core/lib/LoadedMods.java @@ -53,7 +53,7 @@ public class LoadedMods { totalMods++; } - if (Loader.isModLoaded("EnderIO") == true){ + if (Loader.isModLoaded("EnderIO") == true && !CORE.cfg.disableEnderIOIntegration()){ EnderIO = true; Utils.LOG_INFO("Components enabled for: EnderIO"); totalMods++; diff --git a/src/Java/miscutil/core/recipe/Gregtech_Recipe_Adder.java b/src/Java/miscutil/core/recipe/Gregtech_Recipe_Adder.java new file mode 100644 index 0000000000..631d4d4bea --- /dev/null +++ b/src/Java/miscutil/core/recipe/Gregtech_Recipe_Adder.java @@ -0,0 +1,98 @@ +package miscutil.core.recipe; + +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_ModHandler; +import miscutil.core.util.Utils; +import miscutil.core.util.item.UtilsItems; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class Gregtech_Recipe_Adder { + + private static int euT; + private static int ticks; + private static ItemStack inputStack1; + private static ItemStack inputStack2; + private static ItemStack outputStack1; + private static ItemStack outputStack2; + + public static void addRecipe( + Item maceratorInput, int maceratorInputAmount1, + Item maceratorOutput, int maceratorOutputAmount1, + Item compressorInput, int compressorInputAmount1, + Item compressorOutput, int compressorOutputAmount1, + Item blastFurnaceInput, int blastFurnaceInputAmount1, + Item blastFurnaceOutput, int blastFurnaceOutputAmount1, + Item blastFurnaceInput2, int blastFurnaceInputAmount2, + Item blastFurnaceOutput2, int blastFurnaceOutputAmount2, + Item smeltingInput, int smeltingInputAmount1, + Item smeltingOutput, int smeltingOutputAmount1, + + int euPerTick, int timeInTicks, + boolean addMaceratorRecipe, boolean addCompressorRecipe, boolean addBlastFurnaceRecipe, int blastFurnaceTemp, boolean addSmeltingRecipe, boolean addMixerRecipe){ + euT = euPerTick; + ticks = timeInTicks; + + resetVars(); + if (addMaceratorRecipe){ + inputStack1 = UtilsItems.getSimpleStack(maceratorInput, maceratorInputAmount1); + outputStack1 = UtilsItems.getSimpleStack(maceratorOutput, maceratorOutputAmount1); + addMaceratorRecipe(inputStack1, outputStack1); + } + resetVars(); + if (addCompressorRecipe){ + inputStack1 = UtilsItems.getSimpleStack(compressorInput, compressorInputAmount1); + outputStack1 = UtilsItems.getSimpleStack(compressorOutput, compressorOutputAmount1); + addCompressorRecipe(inputStack1, outputStack1); + } + resetVars(); + if (addBlastFurnaceRecipe){ + inputStack1 = UtilsItems.getSimpleStack(blastFurnaceInput, blastFurnaceInputAmount1); + inputStack2 = UtilsItems.getSimpleStack(blastFurnaceInput2, blastFurnaceInputAmount2); + outputStack1 = UtilsItems.getSimpleStack(blastFurnaceOutput, blastFurnaceOutputAmount1); + outputStack2 = UtilsItems.getSimpleStack(blastFurnaceOutput2, blastFurnaceOutputAmount2); + addBlastFurnaceRecipe(inputStack1, inputStack2, outputStack1, outputStack2, blastFurnaceTemp); + } + resetVars(); + if (addSmeltingRecipe){ + inputStack1 = UtilsItems.getSimpleStack(smeltingInput, smeltingInputAmount1); + outputStack1 = UtilsItems.getSimpleStack(smeltingOutput, smeltingOutputAmount1); + addSmeltingRecipe(inputStack1, outputStack1); + } + resetVars(); + + } + + private static void resetVars(){ + inputStack1 = null; + inputStack2 = null; + outputStack1 = null; + outputStack2 = null; + } + + private static void addMaceratorRecipe(ItemStack input1, ItemStack output1){ + GT_ModHandler.addPulverisationRecipe(input1, output1); + } + + private static void addCompressorRecipe(ItemStack input1, ItemStack output1){ + GT_ModHandler.addCompressionRecipe(input1, output1); + } + + private static void addBlastFurnaceRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, int tempRequired){ + Utils.LOG_INFO("Registering Blast Furnace Recipes."); + GT_Values.RA.addBlastRecipe( + input1, + input2, + GT_Values.NF, GT_Values.NF, + output1, + output2, + ticks, + euT, + tempRequired); + } + + private static void addSmeltingRecipe(ItemStack input1, ItemStack output1){ + GT_ModHandler.addSmeltingRecipe(input1, output1); + } + +} diff --git a/src/Java/miscutil/core/recipe/RECIPES_GREGTECH.java b/src/Java/miscutil/core/recipe/RECIPES_GREGTECH.java index 4b5c2613b2..89e6f9a86b 100644 --- a/src/Java/miscutil/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/miscutil/core/recipe/RECIPES_GREGTECH.java @@ -29,6 +29,7 @@ public class RECIPES_GREGTECH { mixerRecipes(); extractorRecipes(); addFuels(); + blastFurnaceRecipes(); } private static void cokeOvenRecipes(){ @@ -118,17 +119,12 @@ public class RECIPES_GREGTECH { private static void distilleryRecipes(){ Utils.LOG_INFO("Registering Distillery/Distillation Tower Recipes."); - //Distillery GT_Values.RA.addDistilleryRecipe(ItemList.Circuit_Integrated.getWithDamage(0L, 4L, new Object[0]), FluidUtils.getFluidStack("air", 20000), FluidUtils.getFluidStack("helium", 1), 400, 30, false); GT_Values.RA.addDistillationTowerRecipe(FluidUtils.getFluidStack("air", 20000), FluidUtils.getFluidStackArray("helium", 1), null, 160, 60); } private static void addFuels(){ Utils.LOG_INFO("Registering New Fuels."); - //CORE.RA.addFuel(GT_ModHandler.getModItem("Minecraft", "bucket_lava", 1L, 1), null, 2800, 1); - //CORE.RA.addFuel(GT_ModHandler.getModItem("EnderIO", "bucketRocket_fuel", 1L, 1), null, 2800, 0); - //CORE.RA.addFuel(GT_ModHandler.getModItem("EnderIO", "bucketHootch", 1L, 1), null, 2800, 0); - //CORE.RA.addFuel(GT_ModHandler.getModItem("EnderIO", "bucketFire_water", 1L, 1), null, 2800, 0); GT_Values.RA.addFuel(UtilsItems.simpleMetaStack("EnderIO:bucketFire_water", 0, 1), null, 120, 0); GT_Values.RA.addFuel(UtilsItems.simpleMetaStack("EnderIO:bucketRocket_fuel", 0, 1), null, 112, 0); GT_Values.RA.addFuel(UtilsItems.simpleMetaStack("EnderIO:bucketHootch", 0, 1), null, 36, 0); @@ -143,6 +139,7 @@ public class RECIPES_GREGTECH { } private static void extractorRecipes(){ + Utils.LOG_INFO("Registering Extractor Recipes."); GT_ModHandler.addExtractionRecipe(GregtechItemList.Battery_RE_EV_Sodium.get(1L, new Object[0]), ItemList.Battery_Hull_HV.get(4L, new Object[0])); GT_ModHandler.addExtractionRecipe(GregtechItemList.Battery_RE_EV_Cadmium.get(1L, new Object[0]), ItemList.Battery_Hull_HV.get(4L, new Object[0])); GT_ModHandler.addExtractionRecipe(GregtechItemList.Battery_RE_EV_Lithium.get(1L, new Object[0]), ItemList.Battery_Hull_HV.get(4L, new Object[0])); @@ -153,20 +150,37 @@ public class RECIPES_GREGTECH { } private static void blastFurnaceRecipes(){ + Utils.LOG_INFO("Registering Blast Furnace Recipes."); + GT_Values.RA.addBlastRecipe( - UtilsItems.getItemStackOfAmountFromOreDict("ingotTitanium", 1), - UtilsItems.getItemStackOfAmountFromOreDict("ingotUranium", 8), + UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 11028, 1), + UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 11098, 1), GT_Values.NF, GT_Values.NF, - GT_OreDictUnificator.get(OrePrefixes.ingotHot, GT_Materials.Staballoy, 1L), + UtilsItems.getSimpleStack(ModItems.itemIngotStaballoy, 1), GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Titanium, 1L), (int) Math.max(GT_Materials.Staballoy.getMass() / 80L, 1L) * GT_Materials.Staballoy.mBlastFurnaceTemp, 1000, GT_Materials.Staballoy.mBlastFurnaceTemp); - GT_Values.RA.addBlastRecipe( - UtilsItems.getItemStackOfAmountFromOreDict("dustStaballoy", 1), + UtilsItems.getSimpleStack(ModItems.itemDustStaballoy, 1), + null, + GT_Values.NF, GT_Values.NF, + UtilsItems.getSimpleStack(ModItems.itemIngotStaballoy, 1), + GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Titanium, 1L), + (int) Math.max(GT_Materials.Staballoy.getMass() / 80L, 1L) * GT_Materials.Staballoy.mBlastFurnaceTemp, + 2000, GT_Materials.Staballoy.mBlastFurnaceTemp); + GT_Values.RA.addBlastRecipe( + UtilsItems.getSimpleStack(ModItems.itemDustSmallStaballoy, 4), + null, + GT_Values.NF, GT_Values.NF, + UtilsItems.getSimpleStack(ModItems.itemIngotStaballoy, 1), + GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Titanium, 1L), + (int) Math.max(GT_Materials.Staballoy.getMass() / 80L, 1L) * GT_Materials.Staballoy.mBlastFurnaceTemp, + 2000, GT_Materials.Staballoy.mBlastFurnaceTemp); + GT_Values.RA.addBlastRecipe( + UtilsItems.getSimpleStack(ModItems.itemDustTinyStaballoy, 9), null, GT_Values.NF, GT_Values.NF, - GT_OreDictUnificator.get(OrePrefixes.ingotHot, GT_Materials.Staballoy, 1L), + UtilsItems.getSimpleStack(ModItems.itemIngotStaballoy, 1), GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Titanium, 1L), (int) Math.max(GT_Materials.Staballoy.getMass() / 80L, 1L) * GT_Materials.Staballoy.mBlastFurnaceTemp, 2000, GT_Materials.Staballoy.mBlastFurnaceTemp); diff --git a/src/Java/miscutil/core/util/aeonbits/owner/Accessible.java b/src/Java/miscutil/core/util/aeonbits/owner/Accessible.java new file mode 100644 index 0000000000..cbd770f4a8 --- /dev/null +++ b/src/Java/miscutil/core/util/aeonbits/owner/Accessible.java @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2012-2015, Luigi R. Viggiano + * All rights reserved. + * + * This software is distributable under the BSD license. + * See the terms of the BSD license in the documentation provided with this software. + */ + +package miscutil.core.util.aeonbits.owner; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.util.Map; +import java.util.Set; + +/** + * <p>Allows a <tt>Config</tt> object to access the contents of the properties, providing utility methods to perform + * consequent operations.</p> + * <p>Example:</p> + * <pre> + * public interface MyConfig extends Config, Accessible { + * int someProperty(); + * } + * + * public void doSomething() { + * MyConfig cfg = ConfigFactory.create(MyConfig.class); + * cfg.list(System.out); + * } + * </pre> + * <p>These methods will print the list of properties, see {@link java.util.Properties#list(java.io.PrintStream)} and + * {@link java.util.Properties#list(java.io.PrintWriter)}.</p> + * + * @author Luigi R. Viggiano + * @since 1.0.4 + */ +public interface Accessible extends Config { + + /** + * Prints this property list out to the specified output stream. This method is useful for debugging. + * + * @param out an output stream. + * @throws ClassCastException if any key in this property list is not a string. + * @see java.util.Properties#list(java.io.PrintStream) + * @since 1.0.4 + */ + void list(PrintStream out); + + /** + * Prints this property list out to the specified output stream. This method is useful for debugging. + * + * @param out an output stream. + * @throws ClassCastException if any key in this property list is not a string. + * @see java.util.Properties#list(java.io.PrintWriter) + * @since 1.0.4 + */ + void list(PrintWriter out); + + /** + * Stores the underlying properties into an {@link java.io.OutputStream}. + * <p> + * Notice that method {@link java.util.Properties#store(java.io.Writer, String)} is not implemented since it's not + * available in JDK 1.5 (while the target of this library is Java 1.5+). + * + * @param out an output stream. + * @param comments a description of the property list. + * @throws IOException if writing this property list to the specified output stream throws an <tt>IOException</tt>. + * @see java.util.Properties#store(java.io.OutputStream, String) + * @since 1.0.4 + */ + void store(OutputStream out, String comments) throws IOException; + + /** + * Fills the given {@link java.util.Map} with the properties contained by this object. <br> + * This is useful to extract the content of the config object into a {@link java.util.Map}. + * <p> + * Notice that you can specify a properties object as parameter instead of a map, + * since {@link java.util.Properties} implements the {@link java.util.Map} interface. + * + * @param map the {@link java.util.Map} to fill. + * @since 1.0.9 + */ + void fill(Map map); + + /** + * Searches for the property with the specified key in this property list. + * If the key is not found in this property list, the default property list, + * and its defaults, recursively, are then checked. The method returns + * <code>null</code> if the property is not found. + * + * @param key the property key. + * @return the value in this property list with the specified key value. + * @see java.util.Properties#getProperty(String) + * @since 1.0.4 + */ + String getProperty(String key); + + /** + * Searches for the property with the specified key in this property list. + * If the key is not found in this property list, the default property list, + * and its defaults, recursively, are then checked. The method returns the + * default value argument if the property is not found. + * + * @param key the property key. + * @param defaultValue a default value. + * @return the value in this property list with the specified key value. + * @see java.util.Properties#getProperty(String, String) + * + * @since 1.0.4 + */ + String getProperty(String key, String defaultValue); + + /** + * Emits an XML document representing all of the properties contained + * in this table. + * + * <p> An invocation of this method of the form <tt>props.storeToXML(os, + * comment)</tt> behaves in exactly the same way as the invocation + * <tt>props.storeToXML(os, comment, "UTF-8");</tt>. + * + * @param os the output stream on which to emit the XML document. + * @param comment a description of the property list, or <code>null</code> + * if no comment is desired. + * @throws IOException if writing to the specified output stream + * results in an <tt>IOException</tt>. + * @throws NullPointerException if <code>os</code> is null. + * @throws ClassCastException if this <code>Properties</code> object + * contains any keys or values that are not + * <code>Strings</code>. + * @since 1.0.5 + */ + void storeToXML(OutputStream os, String comment) throws IOException; + + /** + * Returns a set of keys in this property list + * including distinct keys in the default property list if a key + * of the same name has not already been found from the main + * properties list. + * <p> + * The returned set is not backed by the <tt>Properties</tt> object. + * Changes to this <tt>Properties</tt> are not reflected in the set, + * or vice versa. + * + * @return a set of keys in this property list, including the keys in the + * default property list. + * @throws ClassCastException if any key in this property list + * is not a string. + * @see java.util.Properties#defaults + * @see java.util.Properties#stringPropertyNames() + * @see java.util.Properties#propertyNames() + * @since 1.0.5 + */ + Set<String> propertyNames(); + +} diff --git a/src/Java/miscutil/core/util/aeonbits/owner/Config.java b/src/Java/miscutil/core/util/aeonbits/owner/Config.java new file mode 100644 index 0000000000..ab7fa23cc1 --- /dev/null +++ b/src/Java/miscutil/core/util/aeonbits/owner/Config.java @@ -0,0 +1,345 @@ +/* + * Copyright (c) 2012-2015, Luigi R. Viggiano + * All rights reserved. + * + * This software is distributable under the BSD license. + * See the terms of the BSD license in the documentation provided with this software. + */ + +package miscutil.core.util.aeonbits.owner; + + +import java.io.IOException; +import java.io.Serializable; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +import java.net.URI; +import java.util.List; +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static java.util.concurrent.TimeUnit.SECONDS; +import static miscutil.core.util.aeonbits.owner.Config.HotReloadType.SYNC; +import static miscutil.core.util.aeonbits.owner.Config.LoadType.FIRST; +import static miscutil.core.util.aeonbits.owner.Util.ignore; +import static miscutil.core.util.aeonbits.owner.Util.reverse; + +/** + * Marker interface that must be implemented by all Config sub-interfaces. + * <p> + * Sub-interfaces may also extend {@link Accessible} to allow some debugging facility, or {@link Reloadable} to allow the + * user to programmatically reload properties. + * </p> + * + * @author Luigi R. Viggiano + * @see java.util.Properties + */ +public interface Config extends Serializable { + + /** + * Specifies the policy for loading the properties files. By default the first available properties file specified + * by {@link Sources} will be loaded, see {@link LoadType#FIRST}. User can also specify that the load policy is + * {@link LoadType#MERGE} to have the properties files merged: properties are loaded in order from the first file to + * the last, if there are conflicts in properties names the earlier files loaded prevail. + * + * @since 1.0.2 + */ + @Retention(RUNTIME) + @Target(TYPE) + @Documented + @interface LoadPolicy { + LoadType value() default FIRST; + } + + /** + * Specifies the source from which to load the properties file. It has to be specified in a URI string format. + * By default, allowed protocols are the ones allowed by {@link java.net.URL} plus + * <tt>classpath:path/to/resource.properties</tt>, but user can specify his own additional protocols. + * + * @since 1.0.2 + */ |
