Add Industrial Electrolyzer recipes

This commit is contained in:
mezz 2015-12-31 01:40:56 -08:00
parent ef1ee67c06
commit 3fde850448
6 changed files with 159 additions and 3 deletions

View file

@ -10,7 +10,7 @@ import techreborn.tiles.TileIndustrialElectrolyzer;
public class GuiIndustrialElectrolyzer extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/industrial_electrolyzer.png");
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/industrial_electrolyzer.png");
TileIndustrialElectrolyzer eletrolyzer;

View file

@ -12,4 +12,5 @@ public class RecipeCategoryUids {
public static final String FUSION_REACTOR = "TechReborn.FusionReactor";
public static final String GRINDER = "TechReborn.Grinder";
public static final String IMPLOSION_COMPRESSOR = "TechReborn.ImplosionCompressor";
public static final String INDUSTRIAL_ELECTROLYZER = "TechReborn.IndustrialElectrolyzer";
}

View file

@ -27,6 +27,7 @@ import techreborn.client.container.ContainerChemicalReactor;
import techreborn.client.container.ContainerFusionReactor;
import techreborn.client.container.ContainerGrinder;
import techreborn.client.container.ContainerImplosionCompressor;
import techreborn.client.container.ContainerIndustrialElectrolyzer;
import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeCategory;
import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeHandler;
import techreborn.compat.jei.assemblingMachine.AssemblingMachineRecipeCategory;
@ -43,6 +44,8 @@ import techreborn.compat.jei.grinder.GrinderRecipeCategory;
import techreborn.compat.jei.grinder.GrinderRecipeHandler;
import techreborn.compat.jei.implosionCompressor.ImplosionCompressorRecipeCategory;
import techreborn.compat.jei.implosionCompressor.ImplosionCompressorRecipeHandler;
import techreborn.compat.jei.industrialElectrolyzer.IndustrialElectrolyzerRecipeCategory;
import techreborn.compat.jei.industrialElectrolyzer.IndustrialElectrolyzerRecipeHandler;
@mezz.jei.api.JEIPlugin
public class TechRebornJeiPlugin implements IModPlugin {
@ -75,7 +78,8 @@ public class TechRebornJeiPlugin implements IModPlugin {
new ChemicalReactorRecipeCategory(guiHelper),
new FusionReactorRecipeCategory(guiHelper),
new GrinderRecipeCategory(guiHelper),
new ImplosionCompressorRecipeCategory(guiHelper)
new ImplosionCompressorRecipeCategory(guiHelper),
new IndustrialElectrolyzerRecipeCategory(guiHelper)
);
registry.addRecipeHandlers(
@ -86,7 +90,8 @@ public class TechRebornJeiPlugin implements IModPlugin {
new ChemicalReactorRecipeHandler(),
new FusionReactorRecipeHandler(),
new GrinderRecipeHandler(),
new ImplosionCompressorRecipeHandler()
new ImplosionCompressorRecipeHandler(),
new IndustrialElectrolyzerRecipeHandler()
);
registry.addRecipes(RecipeHandler.recipeList);
@ -107,6 +112,7 @@ public class TechRebornJeiPlugin implements IModPlugin {
recipeTransferRegistry.addRecipeTransferHandler(ContainerFusionReactor.class, RecipeCategoryUids.FUSION_REACTOR, 0, 2, 3, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerGrinder.class, RecipeCategoryUids.GRINDER, 0, 2, 6, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerImplosionCompressor.class, RecipeCategoryUids.IMPLOSION_COMPRESSOR, 0, 2, 4, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerIndustrialElectrolyzer.class, RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER, 0, 2, 7, 36);
}
@Override

View file

@ -0,0 +1,86 @@
package techreborn.compat.jei.industrialElectrolyzer;
import javax.annotation.Nonnull;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import techreborn.client.gui.GuiIndustrialElectrolyzer;
import techreborn.compat.jei.RecipeCategoryUids;
public class IndustrialElectrolyzerRecipeCategory implements IRecipeCategory {
private static final int[] INPUT_SLOTS = {0, 1};
private static final int[] OUTPUT_SLOTS = {2, 3, 4, 5};
private final IDrawable background;
private final String title;
public IndustrialElectrolyzerRecipeCategory(IGuiHelper guiHelper) {
background = guiHelper.createDrawable(GuiIndustrialElectrolyzer.texture, 49, 18, 78, 50);
title = StatCollector.translateToLocal("tile.techreborn.industrialelectrolyzer.name");
}
@Nonnull
@Override
public String getUid() {
return RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER;
}
@Nonnull
@Override
public String getTitle() {
return title;
}
@Nonnull
@Override
public IDrawable getBackground() {
return background;
}
@Override
public void drawExtras(Minecraft minecraft) {
}
@Override
public void drawAnimations(Minecraft minecraft) {
}
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
guiItemStacks.init(INPUT_SLOTS[0], true, 30, 32);
guiItemStacks.init(INPUT_SLOTS[1], true, 0, 32);
guiItemStacks.init(OUTPUT_SLOTS[0], false, 0, 0);
guiItemStacks.init(OUTPUT_SLOTS[1], false, 20, 0);
guiItemStacks.init(OUTPUT_SLOTS[2], false, 40, 0);
guiItemStacks.init(OUTPUT_SLOTS[3], false, 60, 0);
if (recipeWrapper instanceof IndustrialElectrolyzerRecipeWrapper) {
IndustrialElectrolyzerRecipeWrapper recipe = (IndustrialElectrolyzerRecipeWrapper) recipeWrapper;
List<List<ItemStack>> inputs = recipe.getInputs();
for (int i = 0; i < inputs.size() && i < INPUT_SLOTS.length; i++) {
int inputSlot = INPUT_SLOTS[i];
guiItemStacks.set(inputSlot, inputs.get(i));
}
List<ItemStack> outputs = recipe.getOutputs();
for (int i = 0; i < outputs.size() && i < OUTPUT_SLOTS.length; i++) {
int outputSlot = OUTPUT_SLOTS[i];
ItemStack output = outputs.get(i);
guiItemStacks.set(outputSlot, output);
}
}
}
}

View file

@ -0,0 +1,33 @@
package techreborn.compat.jei.industrialElectrolyzer;
import javax.annotation.Nonnull;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import techreborn.api.recipe.machines.IndustrialElectrolyzerRecipe;
import techreborn.compat.jei.RecipeCategoryUids;
public class IndustrialElectrolyzerRecipeHandler implements IRecipeHandler<IndustrialElectrolyzerRecipe> {
@Nonnull
@Override
public Class<IndustrialElectrolyzerRecipe> getRecipeClass() {
return IndustrialElectrolyzerRecipe.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() {
return RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull IndustrialElectrolyzerRecipe recipe) {
return new IndustrialElectrolyzerRecipeWrapper(recipe);
}
@Override
public boolean isRecipeValid(@Nonnull IndustrialElectrolyzerRecipe recipe) {
return true;
}
}

View file

@ -0,0 +1,30 @@
package techreborn.compat.jei.industrialElectrolyzer;
import javax.annotation.Nonnull;
import net.minecraft.client.Minecraft;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawableAnimated;
import mezz.jei.api.gui.IDrawableStatic;
import techreborn.api.recipe.machines.IndustrialElectrolyzerRecipe;
import techreborn.client.gui.GuiIndustrialElectrolyzer;
import techreborn.compat.jei.BaseRecipeWrapper;
import techreborn.compat.jei.TechRebornJeiPlugin;
public class IndustrialElectrolyzerRecipeWrapper extends BaseRecipeWrapper<IndustrialElectrolyzerRecipe> {
private final IDrawableAnimated progress;
public IndustrialElectrolyzerRecipeWrapper(IndustrialElectrolyzerRecipe baseRecipe) {
super(baseRecipe);
IGuiHelper guiHelper = TechRebornJeiPlugin.jeiHelpers.getGuiHelper();
IDrawableStatic progressStatic = guiHelper.createDrawable(GuiIndustrialElectrolyzer.texture, 176, 14, 30, 10);
this.progress = guiHelper.createAnimatedDrawable(progressStatic, baseRecipe.tickTime(), IDrawableAnimated.StartDirection.BOTTOM, false);
}
@Override
public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
super.drawAnimations(minecraft, recipeWidth, recipeHeight);
progress.draw(minecraft, 24, 20);
}
}