diff --git a/build.gradle b/build.gradle index 0c22c8f59..90d6078de 100644 --- a/build.gradle +++ b/build.gradle @@ -80,6 +80,7 @@ minecraft { replace "@MODVERSION@", project.version makeObfSourceJar = false useDepAts = true + runDir = "run" } group = 'TechReborn' @@ -91,9 +92,9 @@ dependencies { // compile "codechicken:CodeChickenCore:1.7.10-1.0.7.+:dev" // compile "codechicken:NotEnoughItems:1.7.10-1.0.5.+:dev" // compile "codechicken:ForgeMultipart:1.7.10-1.2.0.345:dev" - // compile ("mcp.mobius.waila:Waila:1.5.10_1.7.10:dev") { - // exclude group: 'mcp.mobius.waila' - // } +// deobfCompile ("mcp.mobius.waila:Waila:1.6.0_B1_1.8.1") { +// exclude group: 'mcp.mobius.waila' +// } // compile name: 'buildcraft', version: '7.1.13', classifier: "dev", ext: 'jar' // compile "qmunity:QmunityLib:0.2.+:deobf" // compile "com.pahimar.ee3:EquivalentExchange3:1.7.10-0.3.507:dev" @@ -105,10 +106,10 @@ dependencies { // compile "com.github.glitchfiend.biomesoplenty:BiomesOPlenty:1.7.10-2.1.0.1465:deobf" // compile 'Azanor:Thaumcraft:4.2.3.5:deobf@jar' // compile "com.github.azanor:baubles:1.0.1.10:deobf@jar" - // compile name: "MineTweaker3", version: "1.7.10-3.0.9C", classifier: "Dev" + // deobfCompile name: "MineTweaker3", version: "1.8-3.0.10B", classifier: "Dev" // shade 'IC2-Classic-API-STANDALONE:IC2-Classic-API-STANDALONE:1.1.0.19-5:api' compile 'RebornCore:RebornCore-1.8.8:1.0.0.+:dev' - deobfCompile "mezz.jei:jei_1.8.8:2.0.4.5" + deobfCompile "mezz.jei:jei_1.8.8:2.0.5.6" testCompile 'junit:junit:4.12' } diff --git a/src/main/java/techreborn/Core.java b/src/main/java/techreborn/Core.java index 6860833d9..b40b5f896 100644 --- a/src/main/java/techreborn/Core.java +++ b/src/main/java/techreborn/Core.java @@ -23,6 +23,8 @@ import techreborn.api.recipe.RecipeHandler; import techreborn.api.recipe.recipeConfig.RecipeConfigManager; import techreborn.client.GuiHandler; import techreborn.command.TechRebornDevCommand; +import techreborn.compat.CompatManager; +import techreborn.compat.ICompatModule; import techreborn.config.ConfigTechReborn; import techreborn.events.OreUnifier; import techreborn.events.TRTickHandler; @@ -61,10 +63,10 @@ public class Core { .replace(ModInfo.MOD_ID, "TechReborn"); config = ConfigTechReborn.initialize(new File(path)); -// -// for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) { -// compatModule.preInit(event); -// } + + for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) { + compatModule.preInit(event); + } RecipeConfigManager.load(event.getModConfigurationDirectory()); versionChecker = new VersionChecker("TechReborn", new ModInfo()); @@ -91,9 +93,9 @@ public class Core { //Client only init, needs to be done before parts system proxy.init(); // Compat -// for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) { -// compatModule.init(event); -// } + for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) { + compatModule.init(event); + } // WorldGen GameRegistry.registerWorldGenerator(new TROreGen(), 0); // DungeonLoot.init(); @@ -116,9 +118,9 @@ public class Core { @Mod.EventHandler public void postinit(FMLPostInitializationEvent event) throws Exception { // Has to be done here as Buildcraft registers their recipes late -// for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) { -// compatModule.postInit(event); -// } + for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) { + compatModule.postInit(event); + } logHelper.info(RecipeHandler.recipeList.size() + " recipes loaded"); // RecipeHandler.scanForDupeRecipes(); @@ -129,9 +131,9 @@ public class Core { @Mod.EventHandler public void serverStarting(FMLServerStartingEvent event) { event.registerServerCommand(new TechRebornDevCommand()); -// for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) { -// compatModule.serverStarting(event); -// } + for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) { + compatModule.serverStarting(event); + } } @SubscribeEvent diff --git a/src/main/java/techreborn/client/gui/GuiFusionReactor.java b/src/main/java/techreborn/client/gui/GuiFusionReactor.java index 790c0f0fe..1380789c6 100644 --- a/src/main/java/techreborn/client/gui/GuiFusionReactor.java +++ b/src/main/java/techreborn/client/gui/GuiFusionReactor.java @@ -20,7 +20,7 @@ import java.io.IOException; public class GuiFusionReactor extends GuiContainer { - private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/fusion_reactor.png"); + public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/fusion_reactor.png"); ContainerFusionReactor containerFusionReactor; TileEntityFusionController fusionController; diff --git a/ToAddBack/compat/CompatManager.java b/src/main/java/techreborn/compat/CompatManager.java similarity index 68% rename from ToAddBack/compat/CompatManager.java rename to src/main/java/techreborn/compat/CompatManager.java index b4cb94312..31208faed 100644 --- a/ToAddBack/compat/CompatManager.java +++ b/src/main/java/techreborn/compat/CompatManager.java @@ -1,11 +1,7 @@ package techreborn.compat; import net.minecraftforge.fml.common.Loader; -import ic2.api.info.IC2Classic; -import techreborn.compat.ee3.EmcValues; -import techreborn.compat.minetweaker.MinetweakerCompat; -import techreborn.compat.recipes.*; -import techreborn.compat.waila.CompatModuleWaila; +import techreborn.compat.jei.JEIPlugin; import java.util.ArrayList; @@ -22,7 +18,7 @@ public class CompatManager { public CompatManager() { isIC2Loaded = Loader.isModLoaded("IC2"); - isIC2ClassicLoaded = IC2Classic.isIc2ClassicLoaded(); + isIC2ClassicLoaded = false; if(isIC2ClassicLoaded){ isClassicEnet = true; } @@ -32,17 +28,8 @@ public class CompatManager { if(Loader.isModLoaded("gregtech")){ isGregTechLoaded = true; } + registerCompact(JEIPlugin.class, "JEI"); - registerCompact(CompatModuleWaila.class, "Waila"); - registerCompact(RecipesIC2.class, "IC2"); - registerCompact(RecipesBuildcraft.class, "BuildCraft|Core", "IC2"); - registerCompact(RecipesThermalExpansion.class, "ThermalExpansion"); - registerCompact(EmcValues.class, "EE3"); - registerCompact(RecipesNatura.class, "Natura"); - registerCompact(RecipesBiomesOPlenty.class, "BiomesOPlenty"); - registerCompact(RecipesThaumcraft.class, "Thaumcraft"); - registerCompact(RecipesForestry.class, "Forestry", isForestry4()); - registerCompact(MinetweakerCompat.class, "MineTweaker3"); } public void registerCompact(Class moduleClass, Object... objs) { diff --git a/ToAddBack/compat/ICompatModule.java b/src/main/java/techreborn/compat/ICompatModule.java similarity index 100% rename from ToAddBack/compat/ICompatModule.java rename to src/main/java/techreborn/compat/ICompatModule.java diff --git a/src/main/java/techreborn/compat/jei/JEIPlugin.java b/src/main/java/techreborn/compat/jei/JEIPlugin.java new file mode 100644 index 000000000..4c7634ec3 --- /dev/null +++ b/src/main/java/techreborn/compat/jei/JEIPlugin.java @@ -0,0 +1,30 @@ +package techreborn.compat.jei; + +import mezz.jei.api.JEIManager; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.event.FMLServerStartingEvent; +import techreborn.compat.ICompatModule; + +public class JEIPlugin implements ICompatModule { + @Override + public void preInit(FMLPreInitializationEvent event) { + JEIManager.pluginRegistry.registerPlugin(new TechRebornPlugin()); + } + + @Override + public void init(FMLInitializationEvent event) { + + } + + @Override + public void postInit(FMLPostInitializationEvent event) { + + } + + @Override + public void serverStarting(FMLServerStartingEvent event) { + + } +} diff --git a/src/main/java/techreborn/compat/jei/TechRebornPlugin.java b/src/main/java/techreborn/compat/jei/TechRebornPlugin.java new file mode 100644 index 000000000..36ae7e2f2 --- /dev/null +++ b/src/main/java/techreborn/compat/jei/TechRebornPlugin.java @@ -0,0 +1,44 @@ +package techreborn.compat.jei; + +import mezz.jei.api.IModPlugin; +import mezz.jei.api.recipe.IRecipeCategory; +import mezz.jei.api.recipe.IRecipeHandler; +import net.minecraftforge.fml.common.Loader; +import techreborn.api.reactor.FusionReactorRecipeHelper; +import techreborn.api.recipe.RecipeHandler; +import techreborn.compat.jei.fusionReactor.FusionReactorRecipeCategory; +import techreborn.compat.jei.fusionReactor.FusionReactorRecipeHandler; +import techreborn.lib.ModInfo; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + + +public class TechRebornPlugin implements IModPlugin { + @Override + public boolean isModLoaded() { + return Loader.isModLoaded(ModInfo.MOD_ID); + } + + @Override + public Iterable getRecipeCategories() { + return Arrays.asList( + new FusionReactorRecipeCategory() + ); + } + + @Override + public Iterable getRecipeHandlers() { + return Arrays.asList( + new FusionReactorRecipeHandler() + ); + } + + @Override + public Iterable getRecipes() { + List recipes = new ArrayList<>(); + recipes.addAll(FusionReactorRecipeHelper.reactorRecipes); + return recipes; + } +} diff --git a/src/main/java/techreborn/compat/jei/fusionReactor/FusionReactorRecipeCategory.java b/src/main/java/techreborn/compat/jei/fusionReactor/FusionReactorRecipeCategory.java new file mode 100644 index 000000000..88a3c616c --- /dev/null +++ b/src/main/java/techreborn/compat/jei/fusionReactor/FusionReactorRecipeCategory.java @@ -0,0 +1,56 @@ +package techreborn.compat.jei.fusionReactor; + +import mezz.jei.api.JEIManager; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IGuiFluidTanks; +import mezz.jei.api.gui.IGuiItemStacks; +import mezz.jei.api.recipe.IRecipeCategory; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.item.ItemStack; +import techreborn.client.gui.GuiFusionReactor; + +import javax.annotation.Nonnull; +import java.util.Collection; + +public class FusionReactorRecipeCategory implements IRecipeCategory { + + private static final int inputSlot1 = 0; + private static final int inputSlot2 = 1; + private static final int outputSlot = 2; + + @Nonnull + private final IDrawable background; + + public FusionReactorRecipeCategory() { + background = JEIManager.guiHelper.createDrawable(GuiFusionReactor.texture, 55, 16, 82, 54); + } + + @Nonnull + @Override + public String getTitle() { + return "Fustion Reactor"; + } + + @Nonnull + @Override + public IDrawable getBackground() { + return background; + } + + @Override + public void init(@Nonnull IGuiItemStacks guiItemStacks, @Nonnull IGuiFluidTanks guiFluidTanks) { + guiItemStacks.init(inputSlot1, 0, 0); + guiItemStacks.init(inputSlot2, 0, 25); + guiItemStacks.init(outputSlot, 60, 18); + } + + @Override + public void setRecipe(@Nonnull IGuiItemStacks guiItemStacks, @Nonnull IGuiFluidTanks guiFluidTanks, @Nonnull IRecipeWrapper recipeWrapper) { + if(recipeWrapper instanceof FusionReactorRecipeWrapper){ + guiItemStacks.set(inputSlot1, (ItemStack) recipeWrapper.getInputs().get(0)); + guiItemStacks.set(inputSlot2, (ItemStack) recipeWrapper.getInputs().get(1)); + guiItemStacks.set(outputSlot, recipeWrapper.getOutputs()); + } + } + +} diff --git a/src/main/java/techreborn/compat/jei/fusionReactor/FusionReactorRecipeHandler.java b/src/main/java/techreborn/compat/jei/fusionReactor/FusionReactorRecipeHandler.java new file mode 100644 index 000000000..11c9bc231 --- /dev/null +++ b/src/main/java/techreborn/compat/jei/fusionReactor/FusionReactorRecipeHandler.java @@ -0,0 +1,35 @@ +package techreborn.compat.jei.fusionReactor; + +import mezz.jei.api.recipe.IRecipeCategory; +import mezz.jei.api.recipe.IRecipeHandler; +import mezz.jei.api.recipe.IRecipeWrapper; +import techreborn.api.reactor.FusionReactorRecipe; + +import javax.annotation.Nonnull; + + +public class FusionReactorRecipeHandler implements IRecipeHandler { + + @Nonnull + @Override + public Class getRecipeClass() { + return FusionReactorRecipe.class; + } + + @Nonnull + @Override + public Class getRecipeCategoryClass() { + return FusionReactorRecipeCategory.class; + } + + @Nonnull + @Override + public IRecipeWrapper getRecipeWrapper(@Nonnull FusionReactorRecipe recipe) { + return new FusionReactorRecipeWrapper(recipe); + } + + @Override + public boolean isRecipeValid(@Nonnull FusionReactorRecipe recipe) { + return true; + } +} diff --git a/src/main/java/techreborn/compat/jei/fusionReactor/FusionReactorRecipeWrapper.java b/src/main/java/techreborn/compat/jei/fusionReactor/FusionReactorRecipeWrapper.java new file mode 100644 index 000000000..2a6dc1808 --- /dev/null +++ b/src/main/java/techreborn/compat/jei/fusionReactor/FusionReactorRecipeWrapper.java @@ -0,0 +1,67 @@ +package techreborn.compat.jei.fusionReactor; + + +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +import techreborn.api.reactor.FusionReactorRecipe; + +import java.awt.*; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Locale; + +public class FusionReactorRecipeWrapper implements IRecipeWrapper { + + FusionReactorRecipe baseRecipe; + + public FusionReactorRecipeWrapper(FusionReactorRecipe baseRecipe) { + this.baseRecipe = baseRecipe; + } + + @Override + public List getInputs() { + List inputs = new ArrayList<>(); + inputs.add(baseRecipe.getTopInput()); + inputs.add(baseRecipe.getBottomInput()); + return inputs; + } + + @Override + public List getFluidInputs() { + return Collections.emptyList(); + } + + @Override + public List getOutputs() { + List outputs = new ArrayList<>(); + outputs.add(baseRecipe.getOutput()); + return outputs; + } + + @Override + public List getFluidOutputs() { + return Collections.emptyList(); + } + + @Override + public void drawInfo(Minecraft minecraft) { + FontRenderer fontRendererObj = minecraft.fontRendererObj; + // fontRendererObj.drawString(baseRecipe.getEuTick() + "", 69 - fontRendererObj.getStringWidth(baseRecipe.getEuTick() + "") / 2, 0, Color.gray.getRGB()); + + DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US); + DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols(); + symbols.setGroupingSeparator('.'); + formatter.setDecimalFormatSymbols(symbols); + fontRendererObj.drawString("Start: " + formatter.format(baseRecipe.getStartEU()) + "EU", 16, 0, -1); + fontRendererObj.drawString("EU/t: " + baseRecipe.getEuTick() , 16, 10, -1); + fontRendererObj.drawString("Ticks to process: " + baseRecipe.getTickTime(), 14, 20, -1); + fontRendererObj.drawString("Time to process: " + baseRecipe.getTickTime() / 20 + " seconds", 14, 30, -1); + } +}