Add centrifuge recipes

This commit is contained in:
mezz 2015-12-30 23:13:02 -08:00
parent ff571d5444
commit bb82e2cfb2
6 changed files with 177 additions and 5 deletions

View file

@ -10,7 +10,7 @@ import techreborn.tiles.TileCentrifuge;
public class GuiCentrifuge extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/industrial_centrifuge.png");
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/industrial_centrifuge.png");
TileCentrifuge centrifuge;

View file

@ -4,8 +4,9 @@ public class RecipeCategoryUids {
private RecipeCategoryUids() {
}
public static final String ALLOY_SMELTER = "AlloySmelter";
public static final String ASSEMBLING_MACHINE = "AssemblingMachine";
public static final String BLAST_FURNACE = "BlastFurnace";
public static final String FUSION_REACTOR = "FusionReactor";
public static final String ALLOY_SMELTER = "TechReborn.AlloySmelter";
public static final String ASSEMBLING_MACHINE = "TechReborn.AssemblingMachine";
public static final String BLAST_FURNACE = "TechReborn.BlastFurnace";
public static final String CENTRIFUGE = "TechReborn.Centrifuge";
public static final String FUSION_REACTOR = "TechReborn.FusionReactor";
}

View file

@ -21,6 +21,7 @@ import techreborn.client.container.ContainerAlloyFurnace;
import techreborn.client.container.ContainerAlloySmelter;
import techreborn.client.container.ContainerAssemblingMachine;
import techreborn.client.container.ContainerBlastFurnace;
import techreborn.client.container.ContainerCentrifuge;
import techreborn.client.container.ContainerFusionReactor;
import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeCategory;
import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeHandler;
@ -28,6 +29,8 @@ import techreborn.compat.jei.assemblingMachine.AssemblingMachineRecipeCategory;
import techreborn.compat.jei.assemblingMachine.AssemblingMachineRecipeHandler;
import techreborn.compat.jei.blastFurnace.BlastFurnaceRecipeCategory;
import techreborn.compat.jei.blastFurnace.BlastFurnaceRecipeHandler;
import techreborn.compat.jei.centrifuge.CentrifugeRecipeCategory;
import techreborn.compat.jei.centrifuge.CentrifugeRecipeHandler;
import techreborn.compat.jei.fusionReactor.FusionReactorRecipeCategory;
import techreborn.compat.jei.fusionReactor.FusionReactorRecipeHandler;
@ -58,6 +61,7 @@ public class TechRebornJeiPlugin implements IModPlugin {
new AlloySmelterRecipeCategory(guiHelper),
new AssemblingMachineRecipeCategory(guiHelper),
new BlastFurnaceRecipeCategory(guiHelper),
new CentrifugeRecipeCategory(guiHelper),
new FusionReactorRecipeCategory(guiHelper)
);
@ -65,6 +69,7 @@ public class TechRebornJeiPlugin implements IModPlugin {
new AlloySmelterRecipeHandler(),
new AssemblingMachineRecipeHandler(),
new BlastFurnaceRecipeHandler(),
new CentrifugeRecipeHandler(),
new FusionReactorRecipeHandler()
);
@ -81,6 +86,7 @@ public class TechRebornJeiPlugin implements IModPlugin {
recipeTransferRegistry.addRecipeTransferHandler(ContainerAlloyFurnace.class, VanillaRecipeCategoryUid.FUEL, 3, 1, 4, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerAssemblingMachine.class, RecipeCategoryUids.ASSEMBLING_MACHINE, 0, 2, 8, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerBlastFurnace.class, RecipeCategoryUids.BLAST_FURNACE, 0, 2, 4, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerCentrifuge.class, RecipeCategoryUids.CENTRIFUGE, 0, 2, 11, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerFusionReactor.class, RecipeCategoryUids.FUSION_REACTOR, 0, 2, 3, 36);
}

View file

@ -0,0 +1,88 @@
package techreborn.compat.jei.centrifuge;
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.GuiCentrifuge;
import techreborn.compat.jei.RecipeCategoryUids;
public class CentrifugeRecipeCategory implements IRecipeCategory {
private static final int INPUT_SLOT = 0;
private static final int EMPTY_CELL_SLOT = 1;
private static final int[] OUTPUT_SLOTS = {2, 3, 4, 5};
private final IDrawable background;
private final String title;
public CentrifugeRecipeCategory(IGuiHelper guiHelper) {
background = guiHelper.createDrawable(GuiCentrifuge.texture, 49, 4, 78, 78);
title = StatCollector.translateToLocal("tile.techreborn.centrifuge.name");
}
@Nonnull
@Override
public String getUid() {
return RecipeCategoryUids.CENTRIFUGE;
}
@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_SLOT, true, 30, 30);
guiItemStacks.init(EMPTY_CELL_SLOT, true, 0, 0);
guiItemStacks.init(OUTPUT_SLOTS[0], false, 30, 0);
guiItemStacks.init(OUTPUT_SLOTS[1], false, 60, 30);
guiItemStacks.init(OUTPUT_SLOTS[2], false, 30, 60);
guiItemStacks.init(OUTPUT_SLOTS[3], false, 0, 30);
if (recipeWrapper instanceof CentrifugeRecipeWrapper) {
CentrifugeRecipeWrapper recipe = (CentrifugeRecipeWrapper) recipeWrapper;
List<ItemStack> inputs = recipe.getInputs();
guiItemStacks.set(INPUT_SLOT, inputs.get(0));
if (inputs.size() > 1) {
guiItemStacks.set(EMPTY_CELL_SLOT, inputs.get(1));
}
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.centrifuge;
import javax.annotation.Nonnull;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import techreborn.api.recipe.machines.CentrifugeRecipe;
import techreborn.compat.jei.RecipeCategoryUids;
public class CentrifugeRecipeHandler implements IRecipeHandler<CentrifugeRecipe> {
@Nonnull
@Override
public Class<CentrifugeRecipe> getRecipeClass() {
return CentrifugeRecipe.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() {
return RecipeCategoryUids.CENTRIFUGE;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull CentrifugeRecipe recipe) {
return new CentrifugeRecipeWrapper(recipe);
}
@Override
public boolean isRecipeValid(@Nonnull CentrifugeRecipe recipe) {
return true;
}
}

View file

@ -0,0 +1,44 @@
package techreborn.compat.jei.centrifuge;
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.CentrifugeRecipe;
import techreborn.client.gui.GuiCentrifuge;
import techreborn.compat.jei.BaseRecipeWrapper;
import techreborn.compat.jei.TechRebornJeiPlugin;
public class CentrifugeRecipeWrapper extends BaseRecipeWrapper {
private final IDrawableAnimated progressUp;
private final IDrawableAnimated progressLeft;
private final IDrawableAnimated progressDown;
private final IDrawableAnimated progressRight;
public CentrifugeRecipeWrapper(CentrifugeRecipe baseRecipe) {
super(baseRecipe);
IGuiHelper guiHelper = TechRebornJeiPlugin.jeiHelpers.getGuiHelper();
IDrawableStatic progressUpStatic = guiHelper.createDrawable(GuiCentrifuge.texture, 176, 14, 12, 12);
IDrawableStatic progressLeftStatic = guiHelper.createDrawable(GuiCentrifuge.texture, 176, 26, 12, 12);
IDrawableStatic progressDownStatic = guiHelper.createDrawable(GuiCentrifuge.texture, 176, 38, 12, 12);
IDrawableStatic progressRightStatic = guiHelper.createDrawable(GuiCentrifuge.texture, 176, 50, 12, 12);
int ticksPerCycle = baseRecipe.tickTime() / 4; // speed up the animation a bit
this.progressUp = guiHelper.createAnimatedDrawable(progressUpStatic, ticksPerCycle, IDrawableAnimated.StartDirection.BOTTOM, false);
this.progressLeft = guiHelper.createAnimatedDrawable(progressLeftStatic, ticksPerCycle, IDrawableAnimated.StartDirection.RIGHT, false);
this.progressDown = guiHelper.createAnimatedDrawable(progressDownStatic, ticksPerCycle, IDrawableAnimated.StartDirection.TOP, false);
this.progressRight = guiHelper.createAnimatedDrawable(progressRightStatic, ticksPerCycle, IDrawableAnimated.StartDirection.LEFT, false);
}
@Override
public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
super.drawAnimations(minecraft, recipeWidth, recipeHeight);
progressUp.draw(minecraft, 33, 18);
progressLeft.draw(minecraft, 18, 33);
progressDown.draw(minecraft, 33, 48);
progressRight.draw(minecraft, 48, 33);
}
}