Added grinder jei support

This commit is contained in:
gigabit101 2016-02-25 13:17:33 +00:00
parent 9c5aaae874
commit cebb49555a
7 changed files with 149 additions and 6 deletions

View file

@ -10,10 +10,11 @@ public class RecipeCategoryUids {
public static final String CENTRIFUGE = "TechReborn.Centrifuge"; public static final String CENTRIFUGE = "TechReborn.Centrifuge";
public static final String CHEMICAL_REACTOR = "TechReborn.ChemicalReactor"; public static final String CHEMICAL_REACTOR = "TechReborn.ChemicalReactor";
public static final String FUSION_REACTOR = "TechReborn.FusionReactor"; public static final String FUSION_REACTOR = "TechReborn.FusionReactor";
public static final String GRINDER = "TechReborn.Grinder"; public static final String INDUSTRIAL_GRINDER = "TechReborn.IndustrialGrinder";
public static final String IMPLOSION_COMPRESSOR = "TechReborn.ImplosionCompressor"; public static final String IMPLOSION_COMPRESSOR = "TechReborn.ImplosionCompressor";
public static final String INDUSTRIAL_ELECTROLYZER = "TechReborn.IndustrialElectrolyzer"; public static final String INDUSTRIAL_ELECTROLYZER = "TechReborn.IndustrialElectrolyzer";
public static final String INDUSTRIAL_SAWMILL = "TechReborn.IndustrialSawmill"; public static final String INDUSTRIAL_SAWMILL = "TechReborn.IndustrialSawmill";
public static final String ROLLING_MACHINE = "TechReborn.RollingMachine"; public static final String ROLLING_MACHINE = "TechReborn.RollingMachine";
public static final String VACUUM_FREEZER = "TechReborn.VacuumFreezer"; public static final String VACUUM_FREEZER = "TechReborn.VacuumFreezer";
public static final String GRINDER = "TechReborn.Grinder";
} }

View file

@ -27,6 +27,8 @@ import techreborn.compat.jei.chemicalReactor.ChemicalReactorRecipeCategory;
import techreborn.compat.jei.chemicalReactor.ChemicalReactorRecipeHandler; import techreborn.compat.jei.chemicalReactor.ChemicalReactorRecipeHandler;
import techreborn.compat.jei.fusionReactor.FusionReactorRecipeCategory; import techreborn.compat.jei.fusionReactor.FusionReactorRecipeCategory;
import techreborn.compat.jei.fusionReactor.FusionReactorRecipeHandler; import techreborn.compat.jei.fusionReactor.FusionReactorRecipeHandler;
import techreborn.compat.jei.grinder.GrinderRecipeCategory;
import techreborn.compat.jei.grinder.GrinderRecipeHandler;
import techreborn.compat.jei.implosionCompressor.ImplosionCompressorRecipeCategory; import techreborn.compat.jei.implosionCompressor.ImplosionCompressorRecipeCategory;
import techreborn.compat.jei.implosionCompressor.ImplosionCompressorRecipeHandler; import techreborn.compat.jei.implosionCompressor.ImplosionCompressorRecipeHandler;
import techreborn.compat.jei.industrialElectrolyzer.IndustrialElectrolyzerRecipeCategory; import techreborn.compat.jei.industrialElectrolyzer.IndustrialElectrolyzerRecipeCategory;
@ -64,7 +66,8 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
new IndustrialElectrolyzerRecipeCategory(guiHelper), new IndustrialElectrolyzerRecipeCategory(guiHelper),
new IndustrialSawmillRecipeCategory(guiHelper), new IndustrialSawmillRecipeCategory(guiHelper),
new RollingMachineRecipeCategory(guiHelper), new RollingMachineRecipeCategory(guiHelper),
new VacuumFreezerRecipeCategory(guiHelper) new VacuumFreezerRecipeCategory(guiHelper),
new GrinderRecipeCategory(guiHelper)
); );
registry.addRecipeHandlers( registry.addRecipeHandlers(
@ -79,7 +82,8 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
new IndustrialElectrolyzerRecipeHandler(jeiHelpers), new IndustrialElectrolyzerRecipeHandler(jeiHelpers),
new IndustrialSawmillRecipeHandler(jeiHelpers), new IndustrialSawmillRecipeHandler(jeiHelpers),
new RollingMachineRecipeHandler(), new RollingMachineRecipeHandler(),
new VacuumFreezerRecipeHandler(jeiHelpers) new VacuumFreezerRecipeHandler(jeiHelpers),
new GrinderRecipeHandler(jeiHelpers)
); );
registry.addRecipes(RecipeHandler.recipeList); registry.addRecipes(RecipeHandler.recipeList);
@ -106,12 +110,14 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
registry.addRecipeClickArea(GuiCentrifuge.class, 83, 53, 12, 9, RecipeCategoryUids.CENTRIFUGE); registry.addRecipeClickArea(GuiCentrifuge.class, 83, 53, 12, 9, RecipeCategoryUids.CENTRIFUGE);
registry.addRecipeClickArea(GuiChemicalReactor.class, 73, 39, 32, 12, RecipeCategoryUids.CHEMICAL_REACTOR); registry.addRecipeClickArea(GuiChemicalReactor.class, 73, 39, 32, 12, RecipeCategoryUids.CHEMICAL_REACTOR);
registry.addRecipeClickArea(GuiFusionReactor.class, 111, 34, 27, 19, RecipeCategoryUids.FUSION_REACTOR); registry.addRecipeClickArea(GuiFusionReactor.class, 111, 34, 27, 19, RecipeCategoryUids.FUSION_REACTOR);
registry.addRecipeClickArea(GuiIndustrialGrinder.class, 50, 35, 25, 16, RecipeCategoryUids.GRINDER); registry.addRecipeClickArea(GuiIndustrialGrinder.class, 50, 35, 25, 16, RecipeCategoryUids.INDUSTRIAL_GRINDER);
registry.addRecipeClickArea(GuiImplosionCompressor.class, 60, 37, 24, 15, RecipeCategoryUids.IMPLOSION_COMPRESSOR); registry.addRecipeClickArea(GuiImplosionCompressor.class, 60, 37, 24, 15, RecipeCategoryUids.IMPLOSION_COMPRESSOR);
registry.addRecipeClickArea(GuiIndustrialElectrolyzer.class, 72, 37, 33, 14, RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER); registry.addRecipeClickArea(GuiIndustrialElectrolyzer.class, 72, 37, 33, 14, RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER);
registry.addRecipeClickArea(GuiIndustrialSawmill.class, 55, 36, 24, 16, RecipeCategoryUids.INDUSTRIAL_SAWMILL); registry.addRecipeClickArea(GuiIndustrialSawmill.class, 55, 36, 24, 16, RecipeCategoryUids.INDUSTRIAL_SAWMILL);
registry.addRecipeClickArea(GuiRollingMachine.class, 89, 32, 26, 25, RecipeCategoryUids.ROLLING_MACHINE); registry.addRecipeClickArea(GuiRollingMachine.class, 89, 32, 26, 25, RecipeCategoryUids.ROLLING_MACHINE);
registry.addRecipeClickArea(GuiVacuumFreezer.class, 78, 36, 24, 16, RecipeCategoryUids.VACUUM_FREEZER); registry.addRecipeClickArea(GuiVacuumFreezer.class, 78, 36, 24, 16, RecipeCategoryUids.VACUUM_FREEZER);
registry.addRecipeClickArea(GuiGrinder.class, 78, 36, 24, 16, RecipeCategoryUids.GRINDER);
IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry(); IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry();
recipeTransferRegistry.addRecipeTransferHandler(ContainerAlloyFurnace.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 4, 36); recipeTransferRegistry.addRecipeTransferHandler(ContainerAlloyFurnace.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 4, 36);
@ -128,6 +134,8 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
recipeTransferRegistry.addRecipeTransferHandler(ContainerIndustrialSawmill.class, RecipeCategoryUids.INDUSTRIAL_SAWMILL, 0, 2, 5, 36); recipeTransferRegistry.addRecipeTransferHandler(ContainerIndustrialSawmill.class, RecipeCategoryUids.INDUSTRIAL_SAWMILL, 0, 2, 5, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerRollingMachine.class, RecipeCategoryUids.ROLLING_MACHINE, 0, 9, 11, 36); recipeTransferRegistry.addRecipeTransferHandler(ContainerRollingMachine.class, RecipeCategoryUids.ROLLING_MACHINE, 0, 9, 11, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerVacuumFreezer.class, RecipeCategoryUids.VACUUM_FREEZER, 0, 1, 2, 36); recipeTransferRegistry.addRecipeTransferHandler(ContainerVacuumFreezer.class, RecipeCategoryUids.VACUUM_FREEZER, 0, 1, 2, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerGrinder.class, RecipeCategoryUids.GRINDER, 0, 1, 2, 36);
} }
private static void addDebugRecipes(IModRegistry registry) { private static void addDebugRecipes(IModRegistry registry) {

View file

@ -0,0 +1,59 @@
package techreborn.compat.jei.grinder;
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.BlankRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.util.StatCollector;
import techreborn.client.gui.GuiGrinder;
import techreborn.client.gui.GuiVacuumFreezer;
import techreborn.compat.jei.RecipeCategoryUids;
import techreborn.compat.jei.RecipeUtil;
import javax.annotation.Nonnull;
public class GrinderRecipeCategory extends BlankRecipeCategory {
private static final int[] INPUT_SLOTS = {0};
private static final int[] OUTPUT_SLOTS = {1};
private final IDrawable background;
private final String title;
public GrinderRecipeCategory(IGuiHelper guiHelper) {
background = guiHelper.createDrawable(GuiGrinder.texture, 55, 30, 82, 26);
title = StatCollector.translateToLocal("tile.techreborn.grinder.name");
}
@Nonnull
@Override
public String getUid() {
return RecipeCategoryUids.GRINDER;
}
@Nonnull
@Override
public String getTitle() {
return title;
}
@Nonnull
@Override
public IDrawable getBackground() {
return background;
}
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
guiItemStacks.init(INPUT_SLOTS[0], true, 0, 3);
guiItemStacks.init(OUTPUT_SLOTS[0], false, 60, 4);
if (recipeWrapper instanceof GrinderRecipeWrapper) {
GrinderRecipeWrapper recipe = (GrinderRecipeWrapper) recipeWrapper;
RecipeUtil.setRecipeItems(recipeLayout, recipe, INPUT_SLOTS, OUTPUT_SLOTS, null, null);
}
}
}

View file

@ -0,0 +1,42 @@
package techreborn.compat.jei.grinder;
import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import techreborn.api.recipe.machines.GrinderRecipe;
import techreborn.api.recipe.machines.VacuumFreezerRecipe;
import techreborn.compat.jei.RecipeCategoryUids;
import javax.annotation.Nonnull;
public class GrinderRecipeHandler implements IRecipeHandler<GrinderRecipe> {
@Nonnull
private final IJeiHelpers jeiHelpers;
public GrinderRecipeHandler(@Nonnull IJeiHelpers jeiHelpers) {
this.jeiHelpers = jeiHelpers;
}
@Nonnull
@Override
public Class<GrinderRecipe> getRecipeClass() {
return GrinderRecipe.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() {
return RecipeCategoryUids.GRINDER;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull GrinderRecipe recipe) {
return new GrinderRecipeWrapper(jeiHelpers, recipe);
}
@Override
public boolean isRecipeValid(@Nonnull GrinderRecipe recipe) {
return true;
}
}

View file

@ -0,0 +1,33 @@
package techreborn.compat.jei.grinder;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.gui.IDrawableAnimated;
import mezz.jei.api.gui.IDrawableStatic;
import net.minecraft.client.Minecraft;
import techreborn.api.recipe.machines.GrinderRecipe;
import techreborn.api.recipe.machines.VacuumFreezerRecipe;
import techreborn.client.gui.GuiGrinder;
import techreborn.client.gui.GuiVacuumFreezer;
import techreborn.compat.jei.BaseRecipeWrapper;
import javax.annotation.Nonnull;
public class GrinderRecipeWrapper extends BaseRecipeWrapper<GrinderRecipe> {
private final IDrawableAnimated progress;
public GrinderRecipeWrapper(@Nonnull IJeiHelpers jeiHelpers, @Nonnull GrinderRecipe baseRecipe) {
super(baseRecipe);
IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
IDrawableStatic progressStatic = guiHelper.createDrawable(GuiGrinder.texture, 176, 14, 20, 11);
int ticksPerCycle = baseRecipe.tickTime();
this.progress = guiHelper.createAnimatedDrawable(progressStatic, ticksPerCycle, IDrawableAnimated.StartDirection.LEFT, false);
}
@Override
public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
super.drawAnimations(minecraft, recipeWidth, recipeHeight);
progress.draw(minecraft, 25, 7);
}
}

View file

@ -36,7 +36,7 @@ public class IndustrialGrinderRecipeCategory extends BlankRecipeCategory {
@Nonnull @Nonnull
@Override @Override
public String getUid() { public String getUid() {
return RecipeCategoryUids.GRINDER; return RecipeCategoryUids.INDUSTRIAL_GRINDER;
} }
@Nonnull @Nonnull

View file

@ -25,7 +25,7 @@ public class IndustrialGrinderRecipeHandler implements IRecipeHandler<Industrial
@Nonnull @Nonnull
@Override @Override
public String getRecipeCategoryUid() { public String getRecipeCategoryUid() {
return RecipeCategoryUids.GRINDER; return RecipeCategoryUids.INDUSTRIAL_GRINDER;
} }
@Nonnull @Nonnull