diff --git a/.gitignore b/.gitignore index 8d7404b..b0fce42 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,13 @@ eclipse/ src/META-INF/ /*.iws /*.ipr -/*.iml \ No newline at end of file +/*.iml + +# Eclipse IDE files +.classpath +.project +.settings +bin/ + +# Minecraft files +*.launch \ No newline at end of file diff --git a/build.gradle b/build.gradle index 8bd2fc2..ca9d1e3 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,7 @@ compileJava { minecraft { version = "1.11.2-13.20.0.2282" runDir = "run" - + // the mappings can be changed at any time, and must be in the following format. // snapshot_YYYYMMDD snapshot are built nightly. // stable_# stables are built at the discretion of the MCP team. @@ -38,7 +38,7 @@ dependencies { // or you may define them like so.. //compile "some.group:artifact:version:classifier" //compile "some.group:artifact:version" - + // real examples //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env @@ -65,11 +65,11 @@ processResources { // replace stuff in mcmod.info, nothing else from(sourceSets.main.resources.srcDirs) { include 'mcmod.info' - + // replace version and mcversion expand 'version':project.version, 'mcversion':project.minecraft.version } - + // copy everything else except the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' diff --git a/libs/AdvancedRocketry-1.11.2-1.2.0f.jar b/libs/AdvancedRocketry-1.11.2-1.2.0f.jar new file mode 100644 index 0000000..461bed3 Binary files /dev/null and b/libs/AdvancedRocketry-1.11.2-1.2.0f.jar differ diff --git a/libs/CoFHCore-1.11.2-4.2.0.2-universal.jar b/libs/CoFHCore-1.11.2-4.2.0.2-universal.jar new file mode 100644 index 0000000..0624387 Binary files /dev/null and b/libs/CoFHCore-1.11.2-4.2.0.2-universal.jar differ diff --git a/libs/CodeChickenLib-1.11.2-2.7.0.268-deobf.jar b/libs/CodeChickenLib-1.11.2-2.7.0.268-deobf.jar new file mode 100644 index 0000000..3b9ce48 Binary files /dev/null and b/libs/CodeChickenLib-1.11.2-2.7.0.268-deobf.jar differ diff --git a/libs/LibVulpes-1.11.2-0.2.3b-universal.jar b/libs/LibVulpes-1.11.2-0.2.3b-universal.jar new file mode 100644 index 0000000..cbf150e Binary files /dev/null and b/libs/LibVulpes-1.11.2-0.2.3b-universal.jar differ diff --git a/libs/ThermalExpansion-1.11.2-5.2.0.1-universal.jar b/libs/ThermalExpansion-1.11.2-5.2.0.1-universal.jar new file mode 100644 index 0000000..8ab95c3 Binary files /dev/null and b/libs/ThermalExpansion-1.11.2-5.2.0.1-universal.jar differ diff --git a/libs/ThermalFoundation-1.11.2-2.2.0.2-universal.jar b/libs/ThermalFoundation-1.11.2-2.2.0.2-universal.jar new file mode 100644 index 0000000..3c88327 Binary files /dev/null and b/libs/ThermalFoundation-1.11.2-2.2.0.2-universal.jar differ diff --git a/src/main/java/wanion/unidict/common/Reference.java b/src/main/java/wanion/unidict/common/Reference.java index 01ab4ae..01e4d12 100644 --- a/src/main/java/wanion/unidict/common/Reference.java +++ b/src/main/java/wanion/unidict/common/Reference.java @@ -20,4 +20,4 @@ public final class Reference public static final String MC_VERSION = "[1.11.2]"; private Reference() {} -} \ No newline at end of file +} diff --git a/src/main/java/wanion/unidict/integration/AdvancedRocketryIntegration.java b/src/main/java/wanion/unidict/integration/AdvancedRocketryIntegration.java new file mode 100644 index 0000000..9652031 --- /dev/null +++ b/src/main/java/wanion/unidict/integration/AdvancedRocketryIntegration.java @@ -0,0 +1,54 @@ +package wanion.unidict.integration; + +/* + * Created by WanionCane(https://github.com/WanionCane). + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +import net.minecraft.item.ItemStack; +import wanion.unidict.UniDict; +import zmaster587.libVulpes.recipe.RecipesMachine; + +import java.lang.reflect.Field; +import java.util.List; + +final class AdvancedRocketryIntegration extends AbstractIntegrationThread +{ + private final Field outputField; + AdvancedRocketryIntegration() + { + super("Advanced Rocketry"); + try { + (outputField = RecipesMachine.Recipe.class.getDeclaredField("output")).setAccessible(true); + } catch (NoSuchFieldException e) { + throw new RuntimeException("Couldn't find the fields!"); + } + } + + @Override + public String call() + { + try { + fixRecipes(); + } catch (Exception e) { + UniDict.getLogger().error(threadName + e); + } + return threadName + "10. 9...3 2 1... BOOOOM!!"; + } + + @SuppressWarnings("unchecked") + private void fixRecipes() + { + RecipesMachine.getInstance().recipeList.values().forEach(iRecipes -> iRecipes.forEach(iRecipe -> { + if (iRecipe instanceof RecipesMachine.Recipe) + try { + resourceHandler.setMainItemStacks((List) outputField.get(iRecipe)); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + })); + } +} \ No newline at end of file diff --git a/src/main/java/wanion/unidict/integration/IntegrationModule.java b/src/main/java/wanion/unidict/integration/IntegrationModule.java index dab25ce..16eded2 100644 --- a/src/main/java/wanion/unidict/integration/IntegrationModule.java +++ b/src/main/java/wanion/unidict/integration/IntegrationModule.java @@ -43,10 +43,12 @@ private enum Integration CRAFTING(CraftingIntegration.class), FURNACE(FurnaceIntegration.class), ABYSSAL_CRAFT("abyssalcraft", AbyssalCraftIntegration.class), + ADVANCED_ROCKETRY("advancedrocketry", AdvancedRocketryIntegration.class), BLOOD_MAGIC("bloodmagic", BloodMagicIntegration.class), EMBERS("embers", EmbersIntegration.class), INDUSTRIAL_CRAFT_2("ic2", IC2Integration.class), REFINED_STORAGE("refinedstorage", RefinedStorageIntegration.class, false), + THERMAL_EXPANSION("thermalexpansion", TEIntegration.class), TECH_REBORN("techreborn", TechRebornIntegration.class); private final String modId; @@ -72,4 +74,4 @@ private enum Integration this.enabledByDefault = enabledByDefault; } } -} \ No newline at end of file +} diff --git a/src/main/java/wanion/unidict/integration/TEIntegration.java b/src/main/java/wanion/unidict/integration/TEIntegration.java new file mode 100644 index 0000000..ade0bc2 --- /dev/null +++ b/src/main/java/wanion/unidict/integration/TEIntegration.java @@ -0,0 +1,188 @@ +package wanion.unidict.integration; + +/* + * Created by WanionCane(https://github.com/WanionCane). + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +import cofh.thermalexpansion.util.managers.machine.*; +import gnu.trove.map.TIntObjectMap; +import gnu.trove.map.hash.TIntObjectHashMap; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +import wanion.lib.common.Util; +import wanion.unidict.UniDict; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +final class TEIntegration extends AbstractIntegrationThread +{ + TEIntegration() + { + super("Thermal Expansion"); + } + + @Override + public String call() + { + try { + fixCompactorRecipes(); + fixRefineryRecipes(); + fixInductionSmelterRecipes(); + fixRedstoneFurnaceRecipes(); + fixPulverizerRecipes(); + } catch (Exception e) { + UniDict.getLogger().error(threadName + e); + } + return threadName + "The world seems to be more thermally involved."; + } + + private void fixCompactorRecipes() + { + final Map recipeMapPress = Util.getField(CompactorManager.class, "recipeMapPress", null, Map.class); + final Map recipeMapStorage = Util.getField(CompactorManager.class, "recipeMapStorage", null, Map.class); + if (recipeMapPress == null || recipeMapStorage == null) + return; + Constructor recipeCompactorConstructor = null; + try { + recipeCompactorConstructor = CompactorManager.RecipeCompactor.class.getDeclaredConstructor(ItemStack.class, ItemStack.class, int.class); + recipeCompactorConstructor.setAccessible(true); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + if (recipeCompactorConstructor == null) + return; + final List> recipeMaps = new ArrayList<>(); + recipeMaps.add(recipeMapPress); + recipeMaps.add(recipeMapStorage); + for (final Map recipeMap : recipeMaps) + for (final CompactorManager.ComparableItemStackCompactor recipeMapKey : recipeMap.keySet()) { + final CompactorManager.RecipeCompactor recipeCompactor = recipeMap.get(recipeMapKey); + final ItemStack correctOutput = resourceHandler.getMainItemStack(recipeCompactor.getOutput()); + if (correctOutput == recipeCompactor.getOutput()) + continue; + try { + recipeMap.put(recipeMapKey, recipeCompactorConstructor.newInstance(recipeCompactor.getInput(), correctOutput, recipeCompactor.getEnergy())); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } + + private void fixInductionSmelterRecipes() + { + final Map, SmelterManager.RecipeSmelter> recipeMap = Util.getField(SmelterManager.class, "recipeMap", null, Map.class); + if (recipeMap == null) + return; + Constructor smelterRecipeConstructor = null; + try { + smelterRecipeConstructor = SmelterManager.RecipeSmelter.class.getDeclaredConstructor(ItemStack.class, ItemStack.class, ItemStack.class, ItemStack.class, int.class, int.class); + smelterRecipeConstructor.setAccessible(true); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + if (smelterRecipeConstructor == null) + return; + for (final List recipeMapKey : recipeMap.keySet()) { + final SmelterManager.RecipeSmelter smelterRecipe = recipeMap.get(recipeMapKey); + final ItemStack correctOutput = resourceHandler.getMainItemStack(smelterRecipe.getPrimaryOutput()); + final ItemStack correctSecondaryOutput = resourceHandler.getMainItemStack(smelterRecipe.getSecondaryOutput()); + if (correctOutput == smelterRecipe.getPrimaryOutput() && correctSecondaryOutput == smelterRecipe.getSecondaryOutput()) + continue; + try { + recipeMap.put(recipeMapKey, smelterRecipeConstructor.newInstance(smelterRecipe.getPrimaryInput(), smelterRecipe.getSecondaryInput(), correctOutput, correctSecondaryOutput, smelterRecipe.getSecondaryOutputChance(), smelterRecipe.getEnergy())); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } + + private void fixRefineryRecipes() + { + final TIntObjectHashMap recipeMap = Util.getField(RefineryManager.class, "recipeMap", null, TIntObjectMap.class); + if (recipeMap == null) + return; + Constructor refineryRecipeConstructor = null; + try { + refineryRecipeConstructor = RefineryManager.RecipeRefinery.class.getDeclaredConstructor(FluidStack.class, FluidStack.class, ItemStack.class, int.class); + refineryRecipeConstructor.setAccessible(true); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + if (refineryRecipeConstructor == null) + return; + for (final int recipeMapKey : recipeMap.keys()) { + final RefineryManager.RecipeRefinery refineryRecipe = recipeMap.get(recipeMapKey); + final ItemStack correctOutput = resourceHandler.getMainItemStack(refineryRecipe.getOutputItem()); + if (correctOutput == refineryRecipe.getOutputItem()) + continue; + try { + recipeMap.put(recipeMapKey, refineryRecipeConstructor.newInstance(refineryRecipe.getInput(), refineryRecipe.getOutputFluid(), correctOutput, refineryRecipe.getEnergy())); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } + + private void fixRedstoneFurnaceRecipes() + { + final Map recipeMap = Util.getField(FurnaceManager.class, "recipeMap", null, Map.class); + if (recipeMap == null) + return; + Constructor redstoneFurnaceRecipeConstructor = null; + try { + redstoneFurnaceRecipeConstructor = FurnaceManager.RecipeFurnace.class.getDeclaredConstructor(ItemStack.class, ItemStack.class, int.class); + redstoneFurnaceRecipeConstructor.setAccessible(true); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + if (redstoneFurnaceRecipeConstructor == null) + return; + for (final FurnaceManager.ComparableItemStackFurnace recipeMapKey : recipeMap.keySet()) { + final FurnaceManager.RecipeFurnace redstoneFurnaceRecipe = recipeMap.get(recipeMapKey); + final ItemStack correctOutput = resourceHandler.getMainItemStack(redstoneFurnaceRecipe.getOutput()); + if (correctOutput == redstoneFurnaceRecipe.getOutput()) + continue; + try { + recipeMap.put(recipeMapKey, redstoneFurnaceRecipeConstructor.newInstance(redstoneFurnaceRecipe.getInput(), correctOutput, redstoneFurnaceRecipe.getEnergy())); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } + + private void fixPulverizerRecipes() + { + final Map recipeMap = Util.getField(PulverizerManager.class, "recipeMap", null, Map.class); + if (recipeMap == null) + return; + Constructor pulverizerRecipeConstructor = null; + try { + pulverizerRecipeConstructor = PulverizerManager.RecipePulverizer.class.getDeclaredConstructor(ItemStack.class, ItemStack.class, ItemStack.class, int.class, int.class); + pulverizerRecipeConstructor.setAccessible(true); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + if (pulverizerRecipeConstructor == null) + return; + for (final PulverizerManager.ComparableItemStackPulverizer recipeMapKey : recipeMap.keySet()) { + final PulverizerManager.RecipePulverizer pulverizerRecipe = recipeMap.get(recipeMapKey); + final ItemStack correctOutput = resourceHandler.getMainItemStack(pulverizerRecipe.getPrimaryOutput()); + final ItemStack correctSecondaryOutput = resourceHandler.getMainItemStack(pulverizerRecipe.getSecondaryOutput()); + if (correctOutput == pulverizerRecipe.getPrimaryOutput() && correctSecondaryOutput == pulverizerRecipe.getSecondaryOutput()) + continue; + try { + recipeMap.put(recipeMapKey, pulverizerRecipeConstructor.newInstance(pulverizerRecipe.getInput(), correctOutput, correctSecondaryOutput, pulverizerRecipe.getSecondaryOutputChance(), pulverizerRecipe.getEnergy())); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 77e56b7..efdd43f 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -13,4 +13,4 @@ "screenshots": [], "dependencies": [] } -] \ No newline at end of file +]