Scrapbox JEI handler and modified some scrapbox recipes

This is my first JEI handler, kinda just stole it from the compressor. hope I did good?
This commit is contained in:
TheDoctorSoda 2016-03-06 22:23:25 -08:00
parent a379360ef5
commit ca3cd6d4f8
7 changed files with 264 additions and 77 deletions

View file

@ -0,0 +1,20 @@
package techreborn.api.recipe;
import net.minecraft.item.ItemStack;
import techreborn.api.ScrapboxList;
import techreborn.init.ModItems;
import techreborn.lib.Reference;
public class ScrapboxRecipe extends BaseRecipe {
public ScrapboxRecipe(ItemStack output) {
super(Reference.compressorRecipe, 0, 0);
inputs.add(new ItemStack(ModItems.scrapBox));
addOutput(output);
}
@Override
public String getUserFreindlyName() {
return "Scrapbox";
}
}

View file

@ -19,4 +19,5 @@ public class RecipeCategoryUids {
public static final String GRINDER = "TechReborn.Grinder";
public static final String EXTRACTOR = "TechReborn.Extractor";
public static final String COMPRESSOR = "TechReborn.Compressor";
public static final String SCRAPBOX = "TechReborn.Scrapbox";
}

View file

@ -18,40 +18,8 @@ import techreborn.api.reactor.FusionReactorRecipeHelper;
import techreborn.api.recipe.RecipeHandler;
import techreborn.api.recipe.machines.AssemblingMachineRecipe;
import techreborn.api.recipe.machines.ImplosionCompressorRecipe;
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.ContainerChemicalReactor;
import techreborn.client.container.ContainerCompressor;
import techreborn.client.container.ContainerExtractor;
import techreborn.client.container.ContainerFusionReactor;
import techreborn.client.container.ContainerGrinder;
import techreborn.client.container.ContainerImplosionCompressor;
import techreborn.client.container.ContainerIndustrialElectrolyzer;
import techreborn.client.container.ContainerIndustrialGrinder;
import techreborn.client.container.ContainerIndustrialSawmill;
import techreborn.client.container.ContainerRollingMachine;
import techreborn.client.container.ContainerVacuumFreezer;
import techreborn.client.gui.GuiAlloyFurnace;
import techreborn.client.gui.GuiAlloySmelter;
import techreborn.client.gui.GuiAssemblingMachine;
import techreborn.client.gui.GuiBlastFurnace;
import techreborn.client.gui.GuiCentrifuge;
import techreborn.client.gui.GuiChemicalReactor;
import techreborn.client.gui.GuiCompressor;
import techreborn.client.gui.GuiElectricFurnace;
import techreborn.client.gui.GuiExtractor;
import techreborn.client.gui.GuiFusionReactor;
import techreborn.client.gui.GuiGrinder;
import techreborn.client.gui.GuiImplosionCompressor;
import techreborn.client.gui.GuiIndustrialElectrolyzer;
import techreborn.client.gui.GuiIndustrialGrinder;
import techreborn.client.gui.GuiIndustrialSawmill;
import techreborn.client.gui.GuiIronFurnace;
import techreborn.client.gui.GuiRollingMachine;
import techreborn.client.gui.GuiVacuumFreezer;
import techreborn.client.container.*;
import techreborn.client.gui.*;
import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeCategory;
import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeHandler;
import techreborn.compat.jei.assemblingMachine.AssemblingMachineRecipeCategory;
@ -81,6 +49,8 @@ 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.scrapbox.ScrapboxRecipeCategory;
import techreborn.compat.jei.scrapbox.ScrapboxRecipeHandler;
import techreborn.compat.jei.vacuumFreezer.VacuumFreezerRecipeCategory;
import techreborn.compat.jei.vacuumFreezer.VacuumFreezerRecipeHandler;
@ -106,7 +76,8 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
new VacuumFreezerRecipeCategory(guiHelper),
new GrinderRecipeCategory(guiHelper),
new ExtractorRecipeCategory(guiHelper),
new CompressorRecipeCategory(guiHelper)
new CompressorRecipeCategory(guiHelper),
new ScrapboxRecipeCategory(guiHelper)
);
registry.addRecipeHandlers(
@ -124,7 +95,8 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
new VacuumFreezerRecipeHandler(jeiHelpers),
new GrinderRecipeHandler(jeiHelpers),
new ExtractorRecipeHandler(jeiHelpers),
new CompressorRecipeHandler(jeiHelpers)
new CompressorRecipeHandler(jeiHelpers),
new ScrapboxRecipeHandler(jeiHelpers)
);
registry.addRecipes(RecipeHandler.recipeList);

View file

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

View file

@ -0,0 +1,41 @@
package techreborn.compat.jei.scrapbox;
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.ScrapboxRecipe;
import techreborn.compat.jei.RecipeCategoryUids;
public class ScrapboxRecipeHandler implements IRecipeHandler<ScrapboxRecipe> {
@Nonnull
private final IJeiHelpers jeiHelpers;
public ScrapboxRecipeHandler(@Nonnull IJeiHelpers jeiHelpers) {
this.jeiHelpers = jeiHelpers;
}
@Nonnull
@Override
public Class<ScrapboxRecipe> getRecipeClass() {
return ScrapboxRecipe.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() {
return RecipeCategoryUids.SCRAPBOX;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull ScrapboxRecipe recipe) {
return new ScrapboxRecipeWrapper(jeiHelpers, recipe);
}
@Override
public boolean isRecipeValid(@Nonnull ScrapboxRecipe recipe) {
return true;
}
}

View file

@ -0,0 +1,31 @@
package techreborn.compat.jei.scrapbox;
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.ScrapboxRecipe;
import techreborn.client.gui.GuiCompressor;
import techreborn.compat.jei.BaseRecipeWrapper;
public class ScrapboxRecipeWrapper extends BaseRecipeWrapper<ScrapboxRecipe> {
private final IDrawableAnimated progress;
public ScrapboxRecipeWrapper(@Nonnull IJeiHelpers jeiHelpers, @Nonnull ScrapboxRecipe baseRecipe) {
super(baseRecipe);
IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
IDrawableStatic progressStatic = guiHelper.createDrawable(GuiCompressor.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

@ -21,33 +21,11 @@ import techreborn.api.TechRebornAPI;
import techreborn.api.reactor.FusionReactorRecipe;
import techreborn.api.reactor.FusionReactorRecipeHelper;
import techreborn.api.recipe.RecipeHandler;
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.CompressorRecipe;
import techreborn.api.recipe.machines.ExtractorRecipe;
import techreborn.api.recipe.machines.GrinderRecipe;
import techreborn.api.recipe.machines.ImplosionCompressorRecipe;
import techreborn.api.recipe.machines.IndustrialElectrolyzerRecipe;
import techreborn.api.recipe.machines.IndustrialGrinderRecipe;
import techreborn.api.recipe.machines.IndustrialSawmillRecipe;
import techreborn.api.recipe.machines.PlateCuttingMachineRecipe;
import techreborn.api.recipe.machines.VacuumFreezerRecipe;
import techreborn.blocks.BlockMachineFrame;
import techreborn.blocks.BlockOre;
import techreborn.blocks.BlockOre2;
import techreborn.blocks.BlockStorage;
import techreborn.blocks.BlockStorage2;
import techreborn.api.recipe.ScrapboxRecipe;
import techreborn.api.recipe.machines.*;
import techreborn.blocks.*;
import techreborn.config.ConfigTechReborn;
import techreborn.items.ItemCells;
import techreborn.items.ItemDusts;
import techreborn.items.ItemDustsSmall;
import techreborn.items.ItemGems;
import techreborn.items.ItemIngots;
import techreborn.items.ItemNuggets;
import techreborn.items.ItemParts;
import techreborn.items.ItemPlates;
import techreborn.items.*;
import techreborn.parts.ItemStandaloneCables;
import techreborn.utils.RecipeUtils;
@ -85,10 +63,12 @@ public class ModRecipes {
static void addScrapBoxloot() {
ScrapboxList.addItemStackToList(new ItemStack(Items.diamond));
ScrapboxList.addItemStackToList(new ItemStack(Items.stick));
ScrapboxList.addItemStackToList(new ItemStack(Items.coal));
ScrapboxList.addItemStackToList(new ItemStack(Items.apple));
ScrapboxList.addItemStackToList(new ItemStack(Items.baked_potato));
ScrapboxList.addItemStackToList(new ItemStack(Items.blaze_powder));
ScrapboxList.addItemStackToList(new ItemStack(Items.wheat));
ScrapboxList.addItemStackToList(new ItemStack(Items.carrot));
ScrapboxList.addItemStackToList(new ItemStack(Items.boat));
ScrapboxList.addItemStackToList(new ItemStack(Items.blaze_rod));
@ -99,31 +79,114 @@ public class ModRecipes {
ScrapboxList.addItemStackToList(new ItemStack(Items.cooked_chicken));
ScrapboxList.addItemStackToList(new ItemStack(Items.paper));
ScrapboxList.addItemStackToList(new ItemStack(Items.book));
ScrapboxList.addItemStackToList(new ItemStack(Items.cake));
ScrapboxList.addItemStackToList(new ItemStack(Items.acacia_door));
ScrapboxList.addItemStackToList(new ItemStack(Items.dark_oak_door));
ScrapboxList.addItemStackToList(new ItemStack(Items.birch_door));
ScrapboxList.addItemStackToList(new ItemStack(Items.jungle_door));
ScrapboxList.addItemStackToList(new ItemStack(Items.oak_door));
ScrapboxList.addItemStackToList(new ItemStack(Items.spruce_door));
ScrapboxList.addItemStackToList(new ItemStack(Items.wooden_axe));
ScrapboxList.addItemStackToList(new ItemStack(Items.wooden_hoe));
ScrapboxList.addItemStackToList(new ItemStack(Items.wooden_pickaxe));
ScrapboxList.addItemStackToList(new ItemStack(Items.wooden_shovel));
ScrapboxList.addItemStackToList(new ItemStack(Items.wooden_sword));
ScrapboxList.addItemStackToList(new ItemStack(Items.bed));
ScrapboxList.addItemStackToList(new ItemStack(Items.skull, 1, 0));
ScrapboxList.addItemStackToList(new ItemStack(Items.skull, 1, 2));
ScrapboxList.addItemStackToList(new ItemStack(Items.skull, 1, 4));
ScrapboxList.addItemStackToList(new ItemStack(Items.dye, 1, 3));
ScrapboxList.addItemStackToList(new ItemStack(Items.glowstone_dust));
ScrapboxList.addItemStackToList(new ItemStack(Items.string));
ScrapboxList.addItemStackToList(new ItemStack(Items.minecart));
ScrapboxList.addItemStackToList(new ItemStack(Items.chest_minecart));
ScrapboxList.addItemStackToList(new ItemStack(Items.hopper_minecart));
ScrapboxList.addItemStackToList(new ItemStack(Items.prismarine_shard));
ScrapboxList.addItemStackToList(new ItemStack(Items.shears));
ScrapboxList.addItemStackToList(new ItemStack(Items.experience_bottle));
ScrapboxList.addItemStackToList(new ItemStack(Items.bone));
ScrapboxList.addItemStackToList(new ItemStack(Items.bowl));
ScrapboxList.addItemStackToList(new ItemStack(Items.brick));
ScrapboxList.addItemStackToList(new ItemStack(Items.fishing_rod));
ScrapboxList.addItemStackToList(new ItemStack(Items.paper));
ScrapboxList.addItemStackToList(new ItemStack(Items.sugar));
ScrapboxList.addItemStackToList(new ItemStack(Items.reeds));
ScrapboxList.addItemStackToList(new ItemStack(Items.spider_eye));
ScrapboxList.addItemStackToList(new ItemStack(Items.slime_ball));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.acacia_door));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.bed));
ScrapboxList.addItemStackToList(ItemGems.getGemByName("ruby"));
ScrapboxList.addItemStackToList(ItemDusts.getDustByName("iron"));
ScrapboxList.addItemStackToList(ItemDusts.getDustByName("gold"));
ScrapboxList.addItemStackToList(ItemDusts.getDustByName("copper"));
ScrapboxList.addItemStackToList(ItemDusts.getDustByName("tin"));
ScrapboxList.addItemStackToList(ItemParts.getPartByName("scrap"));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.trapdoor));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.brick_block));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.cake));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.carpet));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.crafting_table));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.dirt));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.dark_oak_door));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.glass));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.glass_pane));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.dirt, 1, 0));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.dirt, 1, 1));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.sand, 1, 0));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.sand, 1, 1));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.glowstone));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.wooden_slab));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.skull));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.leaves));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.gravel));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.hardened_clay));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.glass));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.glass_pane));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.cactus));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.cocoa));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.tallgrass));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.tallgrass, 1, 0));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.tallgrass, 1, 1));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.deadbush));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.chest));
ScrapboxList.addItemStackToList(ItemGems.getGemByName("ruby"));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.tnt));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.rail));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.detector_rail));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.golden_rail));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.activator_rail));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.yellow_flower));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.red_flower, 1, 0));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.red_flower, 1, 1));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.red_flower, 1, 2));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.red_flower, 1, 3));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.red_flower, 1, 4));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.red_flower, 1, 5));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.red_flower, 1, 6));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.red_flower, 1, 7));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.red_flower, 1, 8));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.brown_mushroom));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.red_mushroom));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.brown_mushroom_block));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.red_mushroom_block));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.sapling, 1, 0));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.sapling, 1, 1));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.sapling, 1, 2));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.sapling, 1, 3));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.sapling, 1, 4));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.sapling, 1, 5));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.leaves, 1, 0));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.leaves, 1, 1));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.leaves, 1, 2));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.leaves, 1, 3));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.leaves2, 1, 0));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.leaves2, 1, 1));
ScrapboxList.addItemStackToList(new ItemStack(ModBlocks.rubberSapling));
registerDyable(Blocks.carpet);
registerDyable(Blocks.stained_glass);
registerDyable(Blocks.stained_glass_pane);
registerDyable(Blocks.stained_hardened_clay);
for (int i = 0; i < ScrapboxList.stacks.size(); i++) {
RecipeHandler.addRecipe(new ScrapboxRecipe(ScrapboxList.stacks.get(i)));
}
}
static void registerDyable(Block block){
for(int i = 0; i < 16; i++)
ScrapboxList.addItemStackToList(new ItemStack(block, 1 , i));
}
static void addWireRecipes() {
CraftingHelper.addShapedOreRecipe(ItemStandaloneCables.getCableByName("copper", 6),
"XXX","CCC", "XXX",