Merge pull request #1039 from drcrazy/saw_mill

Support for Sawmill recipe in JEI
This commit is contained in:
Modmuss50 2017-04-07 16:31:36 -07:00 committed by GitHub
commit 949aa2057d
8 changed files with 353 additions and 5 deletions

View file

@ -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() {
}

View file

@ -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,7 +201,7 @@ 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);
@ -238,6 +242,8 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
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,
VanillaRecipeCategoryUid.FUEL);
@ -297,6 +303,8 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
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();
recipeTransferRegistry.addRecipeTransferHandler(
@ -334,6 +342,8 @@ 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));

View file

@ -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<IndustrialSawmillRecipeWrapper> {
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);
}
}

View file

@ -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<IndustrialSawmillRecipe> {
@Nonnull
private final IJeiHelpers jeiHelpers;
public IndustrialSawmillRecipeHandler(@Nonnull IJeiHelpers jeiHelpers) {
this.jeiHelpers = jeiHelpers;
}
@Nonnull
@Override
public Class<IndustrialSawmillRecipe> 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;
}
}

View file

@ -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 <IndustrialSawmillRecipe>{
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<FluidStack> 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);
}
}
}

View file

@ -90,6 +90,8 @@ public class ModRecipes {
addIc2Recipes();
addGrinderRecipes();
addCompressorRecipes();
IndustrialSawmillRecipes.init();
}
public static void postInit(){

View file

@ -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);
}
}
}

View file

@ -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;