Added Extractor JEI support thanks @mezz for making this so easy :)

This commit is contained in:
gigabit101 2016-03-06 13:20:38 +00:00
parent 087c97780f
commit 391b28e50f
6 changed files with 153 additions and 4 deletions

View file

@ -17,4 +17,5 @@ public class RecipeCategoryUids {
public static final String ROLLING_MACHINE = "TechReborn.RollingMachine";
public static final String VACUUM_FREEZER = "TechReborn.VacuumFreezer";
public static final String GRINDER = "TechReborn.Grinder";
public static final String EXTRACTOR = "TechReborn.Extractor";
}

View file

@ -24,6 +24,7 @@ import techreborn.client.container.ContainerAssemblingMachine;
import techreborn.client.container.ContainerBlastFurnace;
import techreborn.client.container.ContainerCentrifuge;
import techreborn.client.container.ContainerChemicalReactor;
import techreborn.client.container.ContainerExtractor;
import techreborn.client.container.ContainerFusionReactor;
import techreborn.client.container.ContainerGrinder;
import techreborn.client.container.ContainerImplosionCompressor;
@ -38,6 +39,7 @@ import techreborn.client.gui.GuiAssemblingMachine;
import techreborn.client.gui.GuiBlastFurnace;
import techreborn.client.gui.GuiCentrifuge;
import techreborn.client.gui.GuiChemicalReactor;
import techreborn.client.gui.GuiExtractor;
import techreborn.client.gui.GuiFusionReactor;
import techreborn.client.gui.GuiGrinder;
import techreborn.client.gui.GuiImplosionCompressor;
@ -56,6 +58,8 @@ import techreborn.compat.jei.centrifuge.CentrifugeRecipeCategory;
import techreborn.compat.jei.centrifuge.CentrifugeRecipeHandler;
import techreborn.compat.jei.chemicalReactor.ChemicalReactorRecipeCategory;
import techreborn.compat.jei.chemicalReactor.ChemicalReactorRecipeHandler;
import techreborn.compat.jei.extractor.ExtractorRecipeCategory;
import techreborn.compat.jei.extractor.ExtractorRecipeHandler;
import techreborn.compat.jei.fusionReactor.FusionReactorRecipeCategory;
import techreborn.compat.jei.fusionReactor.FusionReactorRecipeHandler;
import techreborn.compat.jei.grinder.GrinderRecipeCategory;
@ -94,7 +98,8 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
new IndustrialSawmillRecipeCategory(guiHelper),
new RollingMachineRecipeCategory(guiHelper),
new VacuumFreezerRecipeCategory(guiHelper),
new GrinderRecipeCategory(guiHelper)
new GrinderRecipeCategory(guiHelper),
new ExtractorRecipeCategory(guiHelper)
);
registry.addRecipeHandlers(
@ -110,7 +115,8 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
new IndustrialSawmillRecipeHandler(jeiHelpers),
new RollingMachineRecipeHandler(),
new VacuumFreezerRecipeHandler(jeiHelpers),
new GrinderRecipeHandler(jeiHelpers)
new GrinderRecipeHandler(jeiHelpers),
new ExtractorRecipeHandler(jeiHelpers)
);
registry.addRecipes(RecipeHandler.recipeList);
@ -144,6 +150,7 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
registry.addRecipeClickArea(GuiRollingMachine.class, 89, 32, 26, 25, RecipeCategoryUids.ROLLING_MACHINE);
registry.addRecipeClickArea(GuiVacuumFreezer.class, 78, 36, 24, 16, RecipeCategoryUids.VACUUM_FREEZER);
registry.addRecipeClickArea(GuiGrinder.class, 78, 36, 24, 16, RecipeCategoryUids.GRINDER);
registry.addRecipeClickArea(GuiExtractor.class, 78, 36, 24, 16, RecipeCategoryUids.EXTRACTOR);
IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry();
@ -162,7 +169,7 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
recipeTransferRegistry.addRecipeTransferHandler(ContainerRollingMachine.class, RecipeCategoryUids.ROLLING_MACHINE, 0, 9, 11, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerVacuumFreezer.class, RecipeCategoryUids.VACUUM_FREEZER, 0, 1, 2, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerGrinder.class, RecipeCategoryUids.GRINDER, 0, 1, 2, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerExtractor.class, RecipeCategoryUids.EXTRACTOR, 0, 1, 2, 36);
}
private static void addDebugRecipes(IModRegistry registry) {

View file

@ -0,0 +1,59 @@
package techreborn.compat.jei.extractor;
import javax.annotation.Nonnull;
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.GuiExtractor;
import techreborn.client.gui.GuiGrinder;
import techreborn.compat.jei.RecipeCategoryUids;
import techreborn.compat.jei.RecipeUtil;
public class ExtractorRecipeCategory 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 ExtractorRecipeCategory(IGuiHelper guiHelper) {
background = guiHelper.createDrawable(GuiExtractor.texture, 55, 30, 82, 26);
title = StatCollector.translateToLocal("tile.techreborn.extractor.name");
}
@Nonnull
@Override
public String getUid() {
return RecipeCategoryUids.EXTRACTOR;
}
@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 ExtractorRecipeWrapper) {
ExtractorRecipeWrapper recipe = (ExtractorRecipeWrapper) recipeWrapper;
RecipeUtil.setRecipeItems(recipeLayout, recipe, INPUT_SLOTS, OUTPUT_SLOTS, null, null);
}
}
}

View file

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

View file

@ -0,0 +1,33 @@
package techreborn.compat.jei.extractor;
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 net.minecraft.client.Minecraft;
import techreborn.api.recipe.machines.ExtractorRecipe;
import techreborn.api.recipe.machines.GrinderRecipe;
import techreborn.client.gui.GuiExtractor;
import techreborn.client.gui.GuiGrinder;
import techreborn.compat.jei.BaseRecipeWrapper;
public class ExtractorRecipeWrapper extends BaseRecipeWrapper<ExtractorRecipe> {
private final IDrawableAnimated progress;
public ExtractorRecipeWrapper(@Nonnull IJeiHelpers jeiHelpers, @Nonnull ExtractorRecipe baseRecipe) {
super(baseRecipe);
IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
IDrawableStatic progressStatic = guiHelper.createDrawable(GuiExtractor.texture, 176, 17, 22, 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

@ -23,6 +23,7 @@ import techreborn.api.recipe.machines.AlloySmelterRecipe;
import techreborn.api.recipe.machines.BlastFurnaceRecipe;
import techreborn.api.recipe.machines.CentrifugeRecipe;
import techreborn.api.recipe.machines.ChemicalReactorRecipe;
import techreborn.api.recipe.machines.ExtractorRecipe;
import techreborn.api.recipe.machines.GrinderRecipe;
import techreborn.api.recipe.machines.ImplosionCompressorRecipe;
import techreborn.api.recipe.machines.IndustrialElectrolyzerRecipe;
@ -73,6 +74,12 @@ public class
addGrinderRecipes();
addHammerRecipes();
addIc2ReplacementReicpes();
addExtractorRecipes();
}
static void addExtractorRecipes() {
RecipeHandler.addRecipe(new ExtractorRecipe(ItemParts.getPartByName("rubberSap"), ItemParts.getPartByName("rubber", 3), 400, 20));
RecipeHandler.addRecipe(new ExtractorRecipe(new ItemStack(ModBlocks.rubberLog), ItemParts.getPartByName("rubber"), 400, 20));
}
static void addIc2ReplacementReicpes(){