Add chemical reactor recipes
This commit is contained in:
parent
bb82e2cfb2
commit
c187f931ce
6 changed files with 154 additions and 1 deletions
|
@ -10,7 +10,7 @@ import techreborn.tiles.TileChemicalReactor;
|
|||
|
||||
public class GuiChemicalReactor extends GuiContainer {
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/chemical_reactor.png");
|
||||
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/chemical_reactor.png");
|
||||
|
||||
TileChemicalReactor chemicalReactor;
|
||||
ContainerChemicalReactor containerChemicalReactor;
|
||||
|
|
|
@ -8,5 +8,6 @@ public class RecipeCategoryUids {
|
|||
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 CHEMICAL_REACTOR = "TechReborn.ChemicalReactor";
|
||||
public static final String FUSION_REACTOR = "TechReborn.FusionReactor";
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import techreborn.client.container.ContainerAlloySmelter;
|
|||
import techreborn.client.container.ContainerAssemblingMachine;
|
||||
import techreborn.client.container.ContainerBlastFurnace;
|
||||
import techreborn.client.container.ContainerCentrifuge;
|
||||
import techreborn.client.container.ContainerChemicalReactor;
|
||||
import techreborn.client.container.ContainerFusionReactor;
|
||||
import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeCategory;
|
||||
import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeHandler;
|
||||
|
@ -31,6 +32,8 @@ 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.chemicalReactor.ChemicalReactorRecipeCategory;
|
||||
import techreborn.compat.jei.chemicalReactor.ChemicalReactorRecipeHandler;
|
||||
import techreborn.compat.jei.fusionReactor.FusionReactorRecipeCategory;
|
||||
import techreborn.compat.jei.fusionReactor.FusionReactorRecipeHandler;
|
||||
|
||||
|
@ -62,6 +65,7 @@ public class TechRebornJeiPlugin implements IModPlugin {
|
|||
new AssemblingMachineRecipeCategory(guiHelper),
|
||||
new BlastFurnaceRecipeCategory(guiHelper),
|
||||
new CentrifugeRecipeCategory(guiHelper),
|
||||
new ChemicalReactorRecipeCategory(guiHelper),
|
||||
new FusionReactorRecipeCategory(guiHelper)
|
||||
);
|
||||
|
||||
|
@ -70,6 +74,7 @@ public class TechRebornJeiPlugin implements IModPlugin {
|
|||
new AssemblingMachineRecipeHandler(),
|
||||
new BlastFurnaceRecipeHandler(),
|
||||
new CentrifugeRecipeHandler(),
|
||||
new ChemicalReactorRecipeHandler(),
|
||||
new FusionReactorRecipeHandler()
|
||||
);
|
||||
|
||||
|
@ -87,6 +92,7 @@ public class TechRebornJeiPlugin implements IModPlugin {
|
|||
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(ContainerChemicalReactor.class, RecipeCategoryUids.CHEMICAL_REACTOR, 0, 2, 8, 36);
|
||||
recipeTransferRegistry.addRecipeTransferHandler(ContainerFusionReactor.class, RecipeCategoryUids.FUSION_REACTOR, 0, 2, 3, 36);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
package techreborn.compat.jei.chemicalReactor;
|
||||
|
||||
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.GuiChemicalReactor;
|
||||
import techreborn.compat.jei.RecipeCategoryUids;
|
||||
|
||||
public class ChemicalReactorRecipeCategory implements IRecipeCategory {
|
||||
private static final int INPUT_SLOT_0 = 0;
|
||||
private static final int INPUT_SLOT_1 = 1;
|
||||
private static final int OUTPUT_SLOT = 2;
|
||||
|
||||
private final IDrawable background;
|
||||
private final String title;
|
||||
|
||||
public ChemicalReactorRecipeCategory(IGuiHelper guiHelper) {
|
||||
background = guiHelper.createDrawable(GuiChemicalReactor.texture, 69, 20, 38, 48);
|
||||
title = StatCollector.translateToLocal("tile.techreborn.chemicalreactor.name");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUid() {
|
||||
return RecipeCategoryUids.CHEMICAL_REACTOR;
|
||||
}
|
||||
|
||||
@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_0, true, 0, 0);
|
||||
guiItemStacks.init(INPUT_SLOT_1, true, 20, 0);
|
||||
|
||||
guiItemStacks.init(OUTPUT_SLOT, false, 10, 30);
|
||||
|
||||
if (recipeWrapper instanceof ChemicalReactorRecipeWrapper) {
|
||||
ChemicalReactorRecipeWrapper recipe = (ChemicalReactorRecipeWrapper) recipeWrapper;
|
||||
|
||||
List<ItemStack> inputs = recipe.getInputs();
|
||||
guiItemStacks.set(INPUT_SLOT_0, inputs.get(0));
|
||||
if (inputs.size() > 1) {
|
||||
guiItemStacks.set(INPUT_SLOT_1, inputs.get(1));
|
||||
}
|
||||
|
||||
guiItemStacks.set(OUTPUT_SLOT, recipe.getOutputs());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package techreborn.compat.jei.chemicalReactor;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import techreborn.api.recipe.machines.CentrifugeRecipe;
|
||||
import techreborn.api.recipe.machines.ChemicalReactorRecipe;
|
||||
import techreborn.compat.jei.RecipeCategoryUids;
|
||||
|
||||
public class ChemicalReactorRecipeHandler implements IRecipeHandler<ChemicalReactorRecipe> {
|
||||
@Nonnull
|
||||
@Override
|
||||
public Class<ChemicalReactorRecipe> getRecipeClass() {
|
||||
return ChemicalReactorRecipe.class;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getRecipeCategoryUid() {
|
||||
return RecipeCategoryUids.CHEMICAL_REACTOR;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull ChemicalReactorRecipe recipe) {
|
||||
return new ChemicalReactorRecipeWrapper(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(@Nonnull ChemicalReactorRecipe recipe) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package techreborn.compat.jei.chemicalReactor;
|
||||
|
||||
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.ChemicalReactorRecipe;
|
||||
import techreborn.client.gui.GuiChemicalReactor;
|
||||
import techreborn.compat.jei.BaseRecipeWrapper;
|
||||
import techreborn.compat.jei.TechRebornJeiPlugin;
|
||||
|
||||
public class ChemicalReactorRecipeWrapper extends BaseRecipeWrapper {
|
||||
private final IDrawableAnimated progress;
|
||||
|
||||
public ChemicalReactorRecipeWrapper(ChemicalReactorRecipe baseRecipe) {
|
||||
super(baseRecipe);
|
||||
IGuiHelper guiHelper = TechRebornJeiPlugin.jeiHelpers.getGuiHelper();
|
||||
IDrawableStatic progressStatic = guiHelper.createDrawable(GuiChemicalReactor.texture, 176, 14, 32, 12);
|
||||
|
||||
int ticksPerCycle = baseRecipe.tickTime();
|
||||
this.progress = guiHelper.createAnimatedDrawable(progressStatic, ticksPerCycle, IDrawableAnimated.StartDirection.TOP, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
|
||||
super.drawAnimations(minecraft, recipeWidth, recipeHeight);
|
||||
progress.draw(minecraft, 3, 18);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue