Add rolling machine recipes
This commit is contained in:
parent
090de63608
commit
686dd71caf
7 changed files with 213 additions and 1 deletions
|
@ -11,7 +11,7 @@ import techreborn.tiles.TileRollingMachine;
|
||||||
|
|
||||||
public class GuiRollingMachine extends GuiContainer {
|
public class GuiRollingMachine extends GuiContainer {
|
||||||
|
|
||||||
private static final ResourceLocation texture = new ResourceLocation(
|
public static final ResourceLocation texture = new ResourceLocation(
|
||||||
"techreborn", "textures/gui/rolling_machine.png");
|
"techreborn", "textures/gui/rolling_machine.png");
|
||||||
TileRollingMachine rollingMachine;
|
TileRollingMachine rollingMachine;
|
||||||
ContainerRollingMachine containerRollingMachine;
|
ContainerRollingMachine containerRollingMachine;
|
||||||
|
|
|
@ -14,5 +14,6 @@ public class RecipeCategoryUids {
|
||||||
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 VACUUM_FREEZER = "TechReborn.VacuumFreezer";
|
public static final String VACUUM_FREEZER = "TechReborn.VacuumFreezer";
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import mezz.jei.api.IModRegistry;
|
||||||
import mezz.jei.api.IRecipeRegistry;
|
import mezz.jei.api.IRecipeRegistry;
|
||||||
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
||||||
import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry;
|
import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry;
|
||||||
|
import techreborn.Core;
|
||||||
import techreborn.api.reactor.FusionReactorRecipeHelper;
|
import techreborn.api.reactor.FusionReactorRecipeHelper;
|
||||||
import techreborn.api.recipe.RecipeHandler;
|
import techreborn.api.recipe.RecipeHandler;
|
||||||
import techreborn.api.recipe.machines.AssemblingMachineRecipe;
|
import techreborn.api.recipe.machines.AssemblingMachineRecipe;
|
||||||
|
@ -29,6 +30,7 @@ import techreborn.client.container.ContainerGrinder;
|
||||||
import techreborn.client.container.ContainerImplosionCompressor;
|
import techreborn.client.container.ContainerImplosionCompressor;
|
||||||
import techreborn.client.container.ContainerIndustrialElectrolyzer;
|
import techreborn.client.container.ContainerIndustrialElectrolyzer;
|
||||||
import techreborn.client.container.ContainerIndustrialSawmill;
|
import techreborn.client.container.ContainerIndustrialSawmill;
|
||||||
|
import techreborn.client.container.ContainerRollingMachine;
|
||||||
import techreborn.client.container.ContainerVacuumFreezer;
|
import techreborn.client.container.ContainerVacuumFreezer;
|
||||||
import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeCategory;
|
import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeCategory;
|
||||||
import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeHandler;
|
import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeHandler;
|
||||||
|
@ -50,6 +52,9 @@ import techreborn.compat.jei.industrialElectrolyzer.IndustrialElectrolyzerRecipe
|
||||||
import techreborn.compat.jei.industrialElectrolyzer.IndustrialElectrolyzerRecipeHandler;
|
import techreborn.compat.jei.industrialElectrolyzer.IndustrialElectrolyzerRecipeHandler;
|
||||||
import techreborn.compat.jei.industrialSawmill.IndustrialSawmillRecipeCategory;
|
import techreborn.compat.jei.industrialSawmill.IndustrialSawmillRecipeCategory;
|
||||||
import techreborn.compat.jei.industrialSawmill.IndustrialSawmillRecipeHandler;
|
import techreborn.compat.jei.industrialSawmill.IndustrialSawmillRecipeHandler;
|
||||||
|
import techreborn.compat.jei.rollingMachine.RollingMachineRecipeCategory;
|
||||||
|
import techreborn.compat.jei.rollingMachine.RollingMachineRecipeHandler;
|
||||||
|
import techreborn.compat.jei.rollingMachine.RollingMachineRecipeMaker;
|
||||||
import techreborn.compat.jei.vacuumFreezer.VacuumFreezerRecipeCategory;
|
import techreborn.compat.jei.vacuumFreezer.VacuumFreezerRecipeCategory;
|
||||||
import techreborn.compat.jei.vacuumFreezer.VacuumFreezerRecipeHandler;
|
import techreborn.compat.jei.vacuumFreezer.VacuumFreezerRecipeHandler;
|
||||||
|
|
||||||
|
@ -87,6 +92,7 @@ public class TechRebornJeiPlugin implements IModPlugin {
|
||||||
new ImplosionCompressorRecipeCategory(guiHelper),
|
new ImplosionCompressorRecipeCategory(guiHelper),
|
||||||
new IndustrialElectrolyzerRecipeCategory(guiHelper),
|
new IndustrialElectrolyzerRecipeCategory(guiHelper),
|
||||||
new IndustrialSawmillRecipeCategory(guiHelper),
|
new IndustrialSawmillRecipeCategory(guiHelper),
|
||||||
|
new RollingMachineRecipeCategory(guiHelper),
|
||||||
new VacuumFreezerRecipeCategory(guiHelper)
|
new VacuumFreezerRecipeCategory(guiHelper)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -101,12 +107,20 @@ public class TechRebornJeiPlugin implements IModPlugin {
|
||||||
new ImplosionCompressorRecipeHandler(),
|
new ImplosionCompressorRecipeHandler(),
|
||||||
new IndustrialElectrolyzerRecipeHandler(),
|
new IndustrialElectrolyzerRecipeHandler(),
|
||||||
new IndustrialSawmillRecipeHandler(),
|
new IndustrialSawmillRecipeHandler(),
|
||||||
|
new RollingMachineRecipeHandler(),
|
||||||
new VacuumFreezerRecipeHandler()
|
new VacuumFreezerRecipeHandler()
|
||||||
);
|
);
|
||||||
|
|
||||||
registry.addRecipes(RecipeHandler.recipeList);
|
registry.addRecipes(RecipeHandler.recipeList);
|
||||||
registry.addRecipes(FusionReactorRecipeHelper.reactorRecipes);
|
registry.addRecipes(FusionReactorRecipeHelper.reactorRecipes);
|
||||||
|
|
||||||
|
try {
|
||||||
|
registry.addRecipes(RollingMachineRecipeMaker.getRecipes());
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
Core.logHelper.error("Could not register rolling machine recipes. JEI may have changed its internal recipe wrapper locations.");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
if (mezz.jei.config.Config.isDebugModeEnabled()) {
|
if (mezz.jei.config.Config.isDebugModeEnabled()) {
|
||||||
addDebugRecipes(registry);
|
addDebugRecipes(registry);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
package techreborn.compat.jei.rollingMachine;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
|
|
||||||
|
import mezz.jei.api.IGuiHelper;
|
||||||
|
import mezz.jei.api.gui.ICraftingGridHelper;
|
||||||
|
import mezz.jei.api.gui.IDrawable;
|
||||||
|
import mezz.jei.api.gui.IDrawableAnimated;
|
||||||
|
import mezz.jei.api.gui.IDrawableStatic;
|
||||||
|
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.GuiRollingMachine;
|
||||||
|
import techreborn.compat.jei.RecipeCategoryUids;
|
||||||
|
|
||||||
|
public class RollingMachineRecipeCategory implements IRecipeCategory {
|
||||||
|
private static final int[] INPUT_SLOTS = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||||
|
private static final int[] OUTPUT_SLOTS = {10};
|
||||||
|
|
||||||
|
private final IDrawable background;
|
||||||
|
private final IDrawableAnimated progress;
|
||||||
|
private final ICraftingGridHelper craftingGridHelper;
|
||||||
|
private final String title;
|
||||||
|
|
||||||
|
public RollingMachineRecipeCategory(IGuiHelper guiHelper) {
|
||||||
|
background = guiHelper.createDrawable(GuiRollingMachine.texture, 29, 16, 116, 54);
|
||||||
|
title = StatCollector.translateToLocal("tile.techreborn.rollingmachine.name");
|
||||||
|
|
||||||
|
IDrawableStatic progressStatic = guiHelper.createDrawable(GuiRollingMachine.texture, 176, 14, 20, 18);
|
||||||
|
progress = guiHelper.createAnimatedDrawable(progressStatic, 250, IDrawableAnimated.StartDirection.LEFT, false);
|
||||||
|
|
||||||
|
craftingGridHelper = guiHelper.createCraftingGridHelper(INPUT_SLOTS[0], OUTPUT_SLOTS[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public String getUid() {
|
||||||
|
return RecipeCategoryUids.ROLLING_MACHINE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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) {
|
||||||
|
progress.draw(minecraft, 62, 18);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
|
||||||
|
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||||
|
for (int l = 0; l < 3; l++) {
|
||||||
|
for (int k1 = 0; k1 < 3; k1++) {
|
||||||
|
int i = k1 + l * 3;
|
||||||
|
guiItemStacks.init(INPUT_SLOTS[i], true, k1 * 18, l * 18);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
guiItemStacks.init(OUTPUT_SLOTS[0], false, 94, 18);
|
||||||
|
|
||||||
|
if (recipeWrapper instanceof RollingMachineRecipeWrapper) {
|
||||||
|
RollingMachineRecipeWrapper recipe = (RollingMachineRecipeWrapper) recipeWrapper;
|
||||||
|
craftingGridHelper.setInput(guiItemStacks, recipe.getInputs());
|
||||||
|
craftingGridHelper.setOutput(guiItemStacks, recipe.getOutputs());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package techreborn.compat.jei.rollingMachine;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import mezz.jei.api.recipe.IRecipeHandler;
|
||||||
|
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||||
|
import techreborn.compat.jei.RecipeCategoryUids;
|
||||||
|
|
||||||
|
public class RollingMachineRecipeHandler implements IRecipeHandler<RollingMachineRecipeWrapper> {
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public Class<RollingMachineRecipeWrapper> getRecipeClass() {
|
||||||
|
return RollingMachineRecipeWrapper.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public String getRecipeCategoryUid() {
|
||||||
|
return RecipeCategoryUids.ROLLING_MACHINE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public IRecipeWrapper getRecipeWrapper(@Nonnull RollingMachineRecipeWrapper recipe) {
|
||||||
|
return recipe;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRecipeValid(@Nonnull RollingMachineRecipeWrapper recipe) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package techreborn.compat.jei.rollingMachine;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.item.crafting.IRecipe;
|
||||||
|
|
||||||
|
import techreborn.api.RollingMachineRecipe;
|
||||||
|
|
||||||
|
public class RollingMachineRecipeMaker {
|
||||||
|
private RollingMachineRecipeMaker() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Object> getRecipes() {
|
||||||
|
List<Object> recipes = new ArrayList<>();
|
||||||
|
for (IRecipe recipe : RollingMachineRecipe.instance.getRecipeList()) {
|
||||||
|
RollingMachineRecipeWrapper recipeWrapper = RollingMachineRecipeWrapper.create(recipe);
|
||||||
|
if (recipeWrapper != null) {
|
||||||
|
recipes.add(recipeWrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return recipes;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package techreborn.compat.jei.rollingMachine;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.crafting.IRecipe;
|
||||||
|
import net.minecraft.item.crafting.ShapedRecipes;
|
||||||
|
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||||
|
|
||||||
|
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||||
|
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||||
|
|
||||||
|
import mezz.jei.api.recipe.BlankRecipeWrapper;
|
||||||
|
import mezz.jei.api.recipe.wrapper.ICraftingRecipeWrapper;
|
||||||
|
import mezz.jei.plugins.vanilla.crafting.ShapedOreRecipeWrapper;
|
||||||
|
import mezz.jei.plugins.vanilla.crafting.ShapedRecipesWrapper;
|
||||||
|
import mezz.jei.plugins.vanilla.crafting.ShapelessOreRecipeWrapper;
|
||||||
|
import mezz.jei.plugins.vanilla.crafting.ShapelessRecipesWrapper;
|
||||||
|
|
||||||
|
public class RollingMachineRecipeWrapper extends BlankRecipeWrapper implements ICraftingRecipeWrapper {
|
||||||
|
private final ICraftingRecipeWrapper baseRecipe;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static RollingMachineRecipeWrapper create(IRecipe baseRecipe) {
|
||||||
|
ICraftingRecipeWrapper recipeWrapper;
|
||||||
|
if (baseRecipe instanceof ShapelessRecipes) {
|
||||||
|
recipeWrapper = new ShapelessRecipesWrapper((ShapelessRecipes) baseRecipe);
|
||||||
|
} else if (baseRecipe instanceof ShapedRecipes) {
|
||||||
|
recipeWrapper = new ShapedRecipesWrapper((ShapedRecipes) baseRecipe);
|
||||||
|
} else if (baseRecipe instanceof ShapedOreRecipe) {
|
||||||
|
recipeWrapper = new ShapedOreRecipeWrapper((ShapedOreRecipe) baseRecipe);
|
||||||
|
} else if (baseRecipe instanceof ShapelessOreRecipe) {
|
||||||
|
recipeWrapper = new ShapelessOreRecipeWrapper((ShapelessOreRecipe) baseRecipe);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new RollingMachineRecipeWrapper(recipeWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RollingMachineRecipeWrapper(ICraftingRecipeWrapper baseRecipe) {
|
||||||
|
this.baseRecipe = baseRecipe;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List getInputs() {
|
||||||
|
return baseRecipe.getInputs();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemStack> getOutputs() {
|
||||||
|
return baseRecipe.getOutputs();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue