diff --git a/src/main/java/techreborn/compat/jei/RecipeCategoryUids.java b/src/main/java/techreborn/compat/jei/RecipeCategoryUids.java index c8ba5c44b..43fab6811 100644 --- a/src/main/java/techreborn/compat/jei/RecipeCategoryUids.java +++ b/src/main/java/techreborn/compat/jei/RecipeCategoryUids.java @@ -40,6 +40,7 @@ public class RecipeCategoryUids { public static final String EXTRACTOR = "TechReborn.Extractor"; public static final String COMPRESSOR = "TechReborn.Compressor"; public static final String SCRAPBOX = "TechReborn.Scrapbox"; + public static final String INDUSTRIAL_SAWMILL = "TechReborn.IndustrialSawmill"; private RecipeCategoryUids() { } diff --git a/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java b/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java index 0b7ae3fb2..1328c37e9 100644 --- a/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java +++ b/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java @@ -76,6 +76,8 @@ import techreborn.compat.jei.scrapbox.ScrapboxRecipeCategory; import techreborn.compat.jei.scrapbox.ScrapboxRecipeHandler; import techreborn.compat.jei.vacuumFreezer.VacuumFreezerRecipeCategory; import techreborn.compat.jei.vacuumFreezer.VacuumFreezerRecipeHandler; +import techreborn.compat.jei.industrialSawmill.IndustrialSawmillRecipeCategory; +import techreborn.compat.jei.industrialSawmill.IndustrialSawmillRecipeHandler; import techreborn.config.ConfigTechReborn; import techreborn.init.IC2Duplicates; import techreborn.init.ModBlocks; @@ -184,7 +186,9 @@ public class TechRebornJeiPlugin extends BlankModPlugin { new ImplosionCompressorRecipeCategory(guiHelper), new IndustrialElectrolyzerRecipeCategory(guiHelper), new RollingMachineRecipeCategory(guiHelper), new VacuumFreezerRecipeCategory(guiHelper), new GrinderRecipeCategory(guiHelper), new ExtractorRecipeCategory(guiHelper), - new CompressorRecipeCategory(guiHelper), new ScrapboxRecipeCategory(guiHelper)); + new CompressorRecipeCategory(guiHelper), new ScrapboxRecipeCategory(guiHelper), + new IndustrialSawmillRecipeCategory(guiHelper)); + for (final EFluidGenerator type : EFluidGenerator.values()) registry.addRecipeCategories(new FluidGeneratorRecipeCategory(type, guiHelper)); @@ -197,8 +201,8 @@ public class TechRebornJeiPlugin extends BlankModPlugin { new RollingMachineRecipeHandler(), new VacuumFreezerRecipeHandler(jeiHelpers), new GrinderRecipeHandler(jeiHelpers), new ExtractorRecipeHandler(jeiHelpers), new CompressorRecipeHandler(jeiHelpers), new ScrapboxRecipeHandler(jeiHelpers), - new FluidGeneratorRecipeHandler(jeiHelpers)); - + new FluidGeneratorRecipeHandler(jeiHelpers), new IndustrialSawmillRecipeHandler(jeiHelpers)); + registry.addRecipes(RecipeHandler.recipeList); registry.addRecipes(FusionReactorRecipeHelper.reactorRecipes); @@ -237,6 +241,8 @@ public class TechRebornJeiPlugin extends BlankModPlugin { registry.addRecipeClickArea(GuiBlastFurnace.class, 150, 4, 20, 12, RecipeCategoryUids.BLAST_FURNACE); registry.addRecipeClickArea(GuiChemicalReactor.class, 150, 4, 20, 12, RecipeCategoryUids.CHEMICAL_REACTOR); registry.addRecipeClickArea(GuiIndustrialGrinder.class, 150, 4, 20, 12, RecipeCategoryUids.INDUSTRIAL_GRINDER); + + registry.addRecipeClickArea(GuiIndustrialSawmill.class, 55, 35, 20, 15, RecipeCategoryUids.INDUSTRIAL_SAWMILL); //OLD ONES registry.addRecipeClickArea(GuiAlloyFurnace.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER, @@ -296,6 +302,8 @@ public class TechRebornJeiPlugin extends BlankModPlugin { EFluidGenerator.DIESEL.getRecipeID()); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.THERMAL_GENERATOR), EFluidGenerator.THERMAL.getRecipeID()); + + registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_SAWMILL), RecipeCategoryUids.INDUSTRIAL_SAWMILL); final IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry(); @@ -334,7 +342,9 @@ public class TechRebornJeiPlugin extends BlankModPlugin { new BuiltContainerTransferInfo("extractor", RecipeCategoryUids.EXTRACTOR, 36, 1, 0, 36)); recipeTransferRegistry.addRecipeTransferHandler( new BuiltContainerTransferInfo("compressor", RecipeCategoryUids.COMPRESSOR, 36, 1, 0, 36)); - + recipeTransferRegistry.addRecipeTransferHandler( + new BuiltContainerTransferInfo("industrialsawmill", RecipeCategoryUids.INDUSTRIAL_SAWMILL, 36, 2, 0, 36)); + if (CompatManager.isQuantumStorageLoaded) { registry.getJeiHelpers().getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.QUANTUM_CHEST)); registry.getJeiHelpers().getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.QUANTUM_TANK)); diff --git a/src/main/java/techreborn/compat/jei/industrialSawmill/IndustrialSawmillRecipeCategory.java b/src/main/java/techreborn/compat/jei/industrialSawmill/IndustrialSawmillRecipeCategory.java new file mode 100644 index 000000000..05b19c0e8 --- /dev/null +++ b/src/main/java/techreborn/compat/jei/industrialSawmill/IndustrialSawmillRecipeCategory.java @@ -0,0 +1,95 @@ +/* + * This file is part of TechReborn, licensed under the MIT License (MIT). + * + * Copyright (c) 2017 TechReborn + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package techreborn.compat.jei.industrialSawmill; + +import javax.annotation.Nonnull; + +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IGuiFluidStackGroup; +import mezz.jei.api.gui.IGuiItemStackGroup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.BlankRecipeCategory; +import mezz.jei.util.Translator; +import net.minecraft.util.ResourceLocation; +import techreborn.Core; +import techreborn.compat.jei.RecipeCategoryUids; +import techreborn.compat.jei.RecipeUtil; +import techreborn.tiles.multiblock.TileIndustrialSawmill; + +public class IndustrialSawmillRecipeCategory extends BlankRecipeCategory { + + private final String title; + public static final ResourceLocation texture = new ResourceLocation("techreborn", + "textures/gui/industrial_sawmill.png"); + private final IDrawable background; + private final IDrawable tankOverlay; + private static final int[] INPUT_SLOTS = { 0, 1 }; + private static final int[] OUTPUT_SLOTS = { 2, 3, 4 }; + private static final int[] INPUT_TANKS = { 0 }; + + + public IndustrialSawmillRecipeCategory(IGuiHelper guiHelper){ + title = Translator.translateToLocal("tile.techreborn.industrialsawmill.name"); + background = guiHelper.createDrawable(texture, 7, 15, 141, 55); + tankOverlay = guiHelper.createDrawable(texture, 176, 86, 12, 47); + } + + @Nonnull + @Override + public String getUid() { + return RecipeCategoryUids.INDUSTRIAL_SAWMILL; + } + + @Nonnull + @Override + public String getTitle() { + return title; + } + + @Nonnull + @Override + public IDrawable getBackground() { + return background; + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, IndustrialSawmillRecipeWrapper recipeWrapper, IIngredients ingredients) { + IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); + guiItemStacks.init(INPUT_SLOTS[0], true, 24, 10); + guiItemStacks.init(INPUT_SLOTS[1], true, 24, 28); + + guiItemStacks.init(OUTPUT_SLOTS[0], false, 76, 19); + guiItemStacks.init(OUTPUT_SLOTS[1], false, 94, 19); + guiItemStacks.init(OUTPUT_SLOTS[2], false, 112, 19); + + IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks(); + guiFluidStacks.init(INPUT_TANKS[0], true, 4, 4, 12, 47, TileIndustrialSawmill.TANK_CAPACITY, true, tankOverlay); + + RecipeUtil.setRecipeItems(recipeLayout, ingredients, INPUT_SLOTS, OUTPUT_SLOTS, INPUT_TANKS, null); + + } +} diff --git a/src/main/java/techreborn/compat/jei/industrialSawmill/IndustrialSawmillRecipeHandler.java b/src/main/java/techreborn/compat/jei/industrialSawmill/IndustrialSawmillRecipeHandler.java new file mode 100644 index 000000000..f057a968e --- /dev/null +++ b/src/main/java/techreborn/compat/jei/industrialSawmill/IndustrialSawmillRecipeHandler.java @@ -0,0 +1,72 @@ +/* + * This file is part of TechReborn, licensed under the MIT License (MIT). + * + * Copyright (c) 2017 TechReborn + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package techreborn.compat.jei.industrialSawmill; + +import javax.annotation.Nonnull; + +import mezz.jei.api.IJeiHelpers; +import mezz.jei.api.recipe.IRecipeHandler; +import mezz.jei.api.recipe.IRecipeWrapper; +import techreborn.Core; +import techreborn.api.recipe.machines.IndustrialSawmillRecipe; +import techreborn.compat.jei.RecipeCategoryUids; + +public class IndustrialSawmillRecipeHandler implements IRecipeHandler { + @Nonnull + private final IJeiHelpers jeiHelpers; + + public IndustrialSawmillRecipeHandler(@Nonnull IJeiHelpers jeiHelpers) { + this.jeiHelpers = jeiHelpers; + } + + @Nonnull + @Override + public Class getRecipeClass() { + return IndustrialSawmillRecipe.class; + } + + @Nonnull + @Override + public String getRecipeCategoryUid( + @Nonnull + IndustrialSawmillRecipe recipe) { + return RecipeCategoryUids.INDUSTRIAL_SAWMILL; + } + + @Nonnull + @Override + public IRecipeWrapper getRecipeWrapper( + @Nonnull + IndustrialSawmillRecipe recipe) { + return new IndustrialSawmillRecipeWrapper(jeiHelpers, recipe); + } + + @Override + public boolean isRecipeValid( + @Nonnull + IndustrialSawmillRecipe recipe) { + return true; + } +} diff --git a/src/main/java/techreborn/compat/jei/industrialSawmill/IndustrialSawmillRecipeWrapper.java b/src/main/java/techreborn/compat/jei/industrialSawmill/IndustrialSawmillRecipeWrapper.java new file mode 100644 index 000000000..487cd6bfd --- /dev/null +++ b/src/main/java/techreborn/compat/jei/industrialSawmill/IndustrialSawmillRecipeWrapper.java @@ -0,0 +1,102 @@ +/* + * This file is part of TechReborn, licensed under the MIT License (MIT). + * + * Copyright (c) 2017 TechReborn + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package techreborn.compat.jei.industrialSawmill; + +import java.util.Collections; +import java.util.List; + +import javax.annotation.Nonnull; + +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.IJeiHelpers; +import mezz.jei.api.gui.IDrawableAnimated; +import mezz.jei.api.gui.IDrawableStatic; +import mezz.jei.api.ingredients.IIngredients; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; +import techreborn.api.recipe.machines.IndustrialSawmillRecipe; +import techreborn.compat.jei.BaseRecipeWrapper; + +/** + * @author drcrazy + * + */ +public class IndustrialSawmillRecipeWrapper extends BaseRecipeWrapper { + public static final ResourceLocation texture = new ResourceLocation("techreborn", + "textures/gui/industrial_sawmill.png"); + private final IDrawableAnimated progress; + + + public IndustrialSawmillRecipeWrapper( + @Nonnull + IJeiHelpers jeiHelpers, + @Nonnull + IndustrialSawmillRecipe baseRecipe) { + super(baseRecipe); + IGuiHelper guiHelper = jeiHelpers.getGuiHelper(); + IDrawableStatic progressStatic = guiHelper.createDrawable(texture, 176, 14, 20, 13); + int ticksPerCycle = baseRecipe.tickTime(); + this.progress = guiHelper.createAnimatedDrawable(progressStatic, ticksPerCycle, + IDrawableAnimated.StartDirection.LEFT, false); + } + + @Override + public void getIngredients( + @Nonnull + final IIngredients ingredients) { + ingredients.setInput(FluidStack.class, this.baseRecipe.fluidStack); + super.getIngredients(ingredients); + } + + @Override + @Nonnull + public List getFluidInputs() { + if (baseRecipe.fluidStack != null) { + return Collections.singletonList(baseRecipe.fluidStack); + } else { + return Collections.emptyList(); + } + } + + @Override + public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { + super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY); + progress.draw(minecraft, 48, 23); + + if (minecraft.fontRendererObj != null) { + int x = 70; + int y = 40; + int lineHeight = minecraft.fontRendererObj.FONT_HEIGHT; + + minecraft.fontRendererObj.drawString("Time: " + baseRecipe.tickTime / 20 + " s", x, y, 0x444444); + minecraft.fontRendererObj.drawString("FE: " + baseRecipe.euPerTick + " FE/t", x, y += lineHeight, 0x444444); + } + } + + + + +} diff --git a/src/main/java/techreborn/init/ModRecipes.java b/src/main/java/techreborn/init/ModRecipes.java index 1785a185a..fd02e7fe1 100644 --- a/src/main/java/techreborn/init/ModRecipes.java +++ b/src/main/java/techreborn/init/ModRecipes.java @@ -90,6 +90,8 @@ public class ModRecipes { addIc2Recipes(); addGrinderRecipes(); addCompressorRecipes(); + + IndustrialSawmillRecipes.init(); } public static void postInit(){ diff --git a/src/main/java/techreborn/init/recipes/IndustrialSawmillRecipes.java b/src/main/java/techreborn/init/recipes/IndustrialSawmillRecipes.java new file mode 100644 index 000000000..670579ac2 --- /dev/null +++ b/src/main/java/techreborn/init/recipes/IndustrialSawmillRecipes.java @@ -0,0 +1,65 @@ +/* + * This file is part of TechReborn, licensed under the MIT License (MIT). + * + * Copyright (c) 2017 TechReborn + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package techreborn.init.recipes; + +import java.security.InvalidParameterException; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import reborncore.api.recipe.RecipeHandler; +import reborncore.common.util.OreUtil; +import techreborn.api.recipe.machines.IndustrialSawmillRecipe; +import techreborn.items.ItemDusts; + +public class IndustrialSawmillRecipes extends RecipeMethods { + static FluidStack WATER = new FluidStack(FluidRegistry.WATER, 1000); + + public static void init() { + register(getStack(Blocks.LOG, 1, true), getMaterial("water", Type.CELL), WATER, 100, 128, getStack(Blocks.PLANKS, 8, true), ItemDusts.getDustByName("sawDust", 3), getStack(Items.PAPER,1)); + + } + + static void register(ItemStack input1, ItemStack input2, FluidStack fluid, int ticks, int euPerTick, ItemStack... outputs) { + if (outputs.length == 3) { + RecipeHandler.addRecipe(new IndustrialSawmillRecipe(input1, input2, + fluid, outputs[0], outputs[1], outputs[2], ticks, euPerTick)); + } + else if (outputs.length == 2) { + RecipeHandler.addRecipe(new IndustrialSawmillRecipe(input1, input2, + fluid, outputs[0], outputs[1], null, ticks, euPerTick)); + } + else if (outputs.length == 1) { + RecipeHandler.addRecipe(new IndustrialSawmillRecipe(input1, input2, + fluid, outputs[0], null, null, ticks, euPerTick)); + } + else { + throw new InvalidParameterException("Invalid industrial sawmill outputs: " + outputs); + } + } + +} diff --git a/src/main/java/techreborn/tiles/multiblock/TileIndustrialSawmill.java b/src/main/java/techreborn/tiles/multiblock/TileIndustrialSawmill.java index b5fce44f8..82534f4ce 100644 --- a/src/main/java/techreborn/tiles/multiblock/TileIndustrialSawmill.java +++ b/src/main/java/techreborn/tiles/multiblock/TileIndustrialSawmill.java @@ -54,9 +54,10 @@ import java.util.Random; public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, IContainerProvider { + public static final int TANK_CAPACITY = 16000; public Inventory inventory = new Inventory(5, "Sawmill", 64, this); - public Tank tank = new Tank("Sawmill", 16000, this); + public Tank tank = new Tank("Sawmill", TileIndustrialSawmill.TANK_CAPACITY, this); public int tickTime; public MultiblockChecker multiblockChecker;