From 291eadfeed2bef5393364db2674c0c972105b4a3 Mon Sep 17 00:00:00 2001 From: drcrazy Date: Fri, 7 Apr 2017 18:22:37 +0300 Subject: [PATCH] More work for Sawmill --- .../compat/jei/TechRebornJeiPlugin.java | 19 +++- .../IndustrialSawmillRecipeCategory.java | 48 ++++++++- .../IndustrialSawmillRecipeHandler.java | 71 ++++++++++++ .../IndustrialSawmillRecipeWrapper.java | 101 +++++++++++++++--- .../recipes/IndustrialSawmillRecipes.java | 64 +++++++++++ .../multiblock/TileIndustrialSawmill.java | 3 +- 6 files changed, 286 insertions(+), 20 deletions(-) create mode 100644 src/main/java/techreborn/compat/jei/industrialSawmill/IndustrialSawmillRecipeHandler.java create mode 100644 src/main/java/techreborn/init/recipes/IndustrialSawmillRecipes.java diff --git a/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java b/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java index 0b7ae3fb2..900f28510 100644 --- a/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java +++ b/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java @@ -41,6 +41,7 @@ import techreborn.api.generator.GeneratorRecipeHelper; import techreborn.api.reactor.FusionReactorRecipeHelper; import techreborn.api.recipe.machines.AssemblingMachineRecipe; import techreborn.api.recipe.machines.ImplosionCompressorRecipe; +import techreborn.api.recipe.machines.IndustrialSawmillRecipe; import techreborn.client.gui.*; import techreborn.compat.CompatManager; import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeCategory; @@ -69,6 +70,7 @@ import techreborn.compat.jei.industrialElectrolyzer.IndustrialElectrolyzerRecipe import techreborn.compat.jei.industrialElectrolyzer.IndustrialElectrolyzerRecipeHandler; import techreborn.compat.jei.industrialGrinder.IndustrialGrinderRecipeCategory; import techreborn.compat.jei.industrialGrinder.IndustrialGrinderRecipeHandler; +import techreborn.compat.jei.industrialGrinder.IndustrialGrinderRecipeWrapper; import techreborn.compat.jei.rollingMachine.RollingMachineRecipeCategory; import techreborn.compat.jei.rollingMachine.RollingMachineRecipeHandler; import techreborn.compat.jei.rollingMachine.RollingMachineRecipeMaker; @@ -76,6 +78,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; @@ -185,6 +189,9 @@ public class TechRebornJeiPlugin extends BlankModPlugin { new RollingMachineRecipeCategory(guiHelper), new VacuumFreezerRecipeCategory(guiHelper), new GrinderRecipeCategory(guiHelper), new ExtractorRecipeCategory(guiHelper), new CompressorRecipeCategory(guiHelper), new ScrapboxRecipeCategory(guiHelper)); + + registry.addRecipeCategories(new IndustrialSawmillRecipeCategory(guiHelper)); + for (final EFluidGenerator type : EFluidGenerator.values()) registry.addRecipeCategories(new FluidGeneratorRecipeCategory(type, guiHelper)); @@ -198,7 +205,9 @@ public class TechRebornJeiPlugin extends BlankModPlugin { new GrinderRecipeHandler(jeiHelpers), new ExtractorRecipeHandler(jeiHelpers), new CompressorRecipeHandler(jeiHelpers), new ScrapboxRecipeHandler(jeiHelpers), new FluidGeneratorRecipeHandler(jeiHelpers)); - + + registry.addRecipeHandlers(new IndustrialSawmillRecipeHandler(jeiHelpers)); + registry.addRecipes(RecipeHandler.recipeList); registry.addRecipes(FusionReactorRecipeHelper.reactorRecipes); @@ -237,6 +246,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, 150, 4, 20, 12, RecipeCategoryUids.INDUSTRIAL_SAWMILL); //OLD ONES registry.addRecipeClickArea(GuiAlloyFurnace.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER, @@ -296,6 +307,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 +347,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 index a8bc3d287..856967839 100644 --- a/src/main/java/techreborn/compat/jei/industrialSawmill/IndustrialSawmillRecipeCategory.java +++ b/src/main/java/techreborn/compat/jei/industrialSawmill/IndustrialSawmillRecipeCategory.java @@ -1,15 +1,43 @@ +/* + * 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.compat.jei.RecipeCategoryUids; +import techreborn.compat.jei.RecipeUtil; +import techreborn.tiles.multiblock.TileIndustrialSawmill; public class IndustrialSawmillRecipeCategory extends BlankRecipeCategory { @@ -17,15 +45,19 @@ public class IndustrialSawmillRecipeCategory extends BlankRecipeCategory { + @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 index f9c43a79f..d00b1bfcc 100644 --- a/src/main/java/techreborn/compat/jei/industrialSawmill/IndustrialSawmillRecipeWrapper.java +++ b/src/main/java/techreborn/compat/jei/industrialSawmill/IndustrialSawmillRecipeWrapper.java @@ -1,31 +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 mezz.jei.api.recipe.BlankRecipeWrapper; +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 BlankRecipeWrapper { +public class IndustrialSawmillRecipeWrapper extends BaseRecipeWrapper { + public static final ResourceLocation texture = new ResourceLocation("techreborn", + "textures/gui/industrial_sawmill.png"); + private final IDrawableAnimated progress; - /** - * - */ - public IndustrialSawmillRecipeWrapper() { - // TODO Auto-generated constructor stub + + public IndustrialSawmillRecipeWrapper( + @Nonnull + IJeiHelpers jeiHelpers, + @Nonnull + IndustrialSawmillRecipe baseRecipe) { + super(baseRecipe); + IGuiHelper guiHelper = jeiHelpers.getGuiHelper(); + IDrawableStatic progressStatic = guiHelper.createDrawable(texture, 176, 14, 24, 17); + int ticksPerCycle = baseRecipe.tickTime(); + this.progress = guiHelper.createAnimatedDrawable(progressStatic, ticksPerCycle, + IDrawableAnimated.StartDirection.LEFT, false); } - /* (non-Javadoc) - * @see mezz.jei.api.recipe.IRecipeWrapper#getIngredients(mezz.jei.api.ingredients.IIngredients) - */ @Override - public void getIngredients(IIngredients ingredients) { - // TODO Auto-generated method stub - + 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, 44, 20); + + 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/recipes/IndustrialSawmillRecipes.java b/src/main/java/techreborn/init/recipes/IndustrialSawmillRecipes.java new file mode 100644 index 000000000..b26e37727 --- /dev/null +++ b/src/main/java/techreborn/init/recipes/IndustrialSawmillRecipes.java @@ -0,0 +1,64 @@ +/* + * 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.IndustrialGrinderRecipe; +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, 1), WATER, 100, 128, OreUtil.getStackFromName("plankWood", 8), ItemDusts.getDustByName("sawDust", 3), getStack(Items.PAPER,1)); + } + + static void register(ItemStack input, FluidStack fluid, int ticks, int euPerTick, ItemStack... outputs) { + if (outputs.length == 3) { + RecipeHandler.addRecipe(new IndustrialGrinderRecipe(input, + fluid, outputs[0], outputs[1], outputs[2], null, ticks, euPerTick)); + } + else if (outputs.length == 2) { + RecipeHandler.addRecipe(new IndustrialGrinderRecipe(input, + fluid, outputs[0], outputs[1], null, null, ticks, euPerTick)); + } + else if (outputs.length == 1) { + RecipeHandler.addRecipe(new IndustrialGrinderRecipe(input, + fluid, outputs[0], null, 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;