Merge pull request #955 from Artemish/master

Added Compost recipes to JEI (Closes #791)
This commit is contained in:
Brennan Ward 2017-10-31 16:06:56 -04:00 committed by GitHub
commit c09ebe299a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 138 additions and 2 deletions

View file

@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.jei;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe;
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe; import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
@ -27,6 +28,8 @@ import de.ellpeck.actuallyadditions.mod.jei.booklet.BookletRecipeCategory;
import de.ellpeck.actuallyadditions.mod.jei.booklet.BookletRecipeWrapper; import de.ellpeck.actuallyadditions.mod.jei.booklet.BookletRecipeWrapper;
import de.ellpeck.actuallyadditions.mod.jei.coffee.CoffeeMachineRecipeCategory; import de.ellpeck.actuallyadditions.mod.jei.coffee.CoffeeMachineRecipeCategory;
import de.ellpeck.actuallyadditions.mod.jei.coffee.CoffeeMachineRecipeWrapper; import de.ellpeck.actuallyadditions.mod.jei.coffee.CoffeeMachineRecipeWrapper;
import de.ellpeck.actuallyadditions.mod.jei.compost.CompostRecipeCategory;
import de.ellpeck.actuallyadditions.mod.jei.compost.CompostRecipeWrapper;
import de.ellpeck.actuallyadditions.mod.jei.crusher.CrusherRecipeCategory; import de.ellpeck.actuallyadditions.mod.jei.crusher.CrusherRecipeCategory;
import de.ellpeck.actuallyadditions.mod.jei.crusher.CrusherRecipeWrapper; import de.ellpeck.actuallyadditions.mod.jei.crusher.CrusherRecipeWrapper;
import de.ellpeck.actuallyadditions.mod.jei.empowerer.EmpowererRecipeCategory; import de.ellpeck.actuallyadditions.mod.jei.empowerer.EmpowererRecipeCategory;
@ -59,7 +62,8 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin{
public void registerCategories(IRecipeCategoryRegistration registry) { public void registerCategories(IRecipeCategoryRegistration registry) {
IJeiHelpers helpers = registry.getJeiHelpers(); IJeiHelpers helpers = registry.getJeiHelpers();
registry.addRecipeCategories( registry.addRecipeCategories(
new CoffeeMachineRecipeCategory(helpers.getGuiHelper()), new CoffeeMachineRecipeCategory(helpers.getGuiHelper()),
new CompostRecipeCategory(helpers.getGuiHelper()),
new CrusherRecipeCategory(helpers.getGuiHelper()), new CrusherRecipeCategory(helpers.getGuiHelper()),
new ReconstructorRecipeCategory(helpers.getGuiHelper()), new ReconstructorRecipeCategory(helpers.getGuiHelper()),
new EmpowererRecipeCategory(helpers.getGuiHelper()), new EmpowererRecipeCategory(helpers.getGuiHelper()),
@ -75,12 +79,14 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin{
registry.handleRecipes(CrusherRecipe.class, CrusherRecipeWrapper::new, CrusherRecipeCategory.NAME); registry.handleRecipes(CrusherRecipe.class, CrusherRecipeWrapper::new, CrusherRecipeCategory.NAME);
registry.handleRecipes(LensConversionRecipe.class, ReconstructorRecipeWrapper::new, ReconstructorRecipeCategory.NAME); registry.handleRecipes(LensConversionRecipe.class, ReconstructorRecipeWrapper::new, ReconstructorRecipeCategory.NAME);
registry.handleRecipes(EmpowererRecipe.class, EmpowererRecipeWrapper::new, EmpowererRecipeCategory.NAME); registry.handleRecipes(EmpowererRecipe.class, EmpowererRecipeWrapper::new, EmpowererRecipeCategory.NAME);
registry.handleRecipes(CompostRecipe.class, CompostRecipeWrapper::new, CompostRecipeCategory.NAME);
registry.addRecipes(ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA, BookletRecipeCategory.NAME); registry.addRecipes(ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA, BookletRecipeCategory.NAME);
registry.addRecipes(ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS, CoffeeMachineRecipeCategory.NAME); registry.addRecipes(ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS, CoffeeMachineRecipeCategory.NAME);
registry.addRecipes(ActuallyAdditionsAPI.CRUSHER_RECIPES, CrusherRecipeCategory.NAME); registry.addRecipes(ActuallyAdditionsAPI.CRUSHER_RECIPES, CrusherRecipeCategory.NAME);
registry.addRecipes(ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES, ReconstructorRecipeCategory.NAME); registry.addRecipes(ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES, ReconstructorRecipeCategory.NAME);
registry.addRecipes(ActuallyAdditionsAPI.EMPOWERER_RECIPES, EmpowererRecipeCategory.NAME); registry.addRecipes(ActuallyAdditionsAPI.EMPOWERER_RECIPES, EmpowererRecipeCategory.NAME);
registry.addRecipes(ActuallyAdditionsAPI.COMPOST_RECIPES, CompostRecipeCategory.NAME);
registry.addRecipeClickArea(GuiCoffeeMachine.class, 53, 42, 22, 16, CoffeeMachineRecipeCategory.NAME); registry.addRecipeClickArea(GuiCoffeeMachine.class, 53, 42, 22, 16, CoffeeMachineRecipeCategory.NAME);
registry.addRecipeClickArea(GuiGrinder.class, 80, 40, 24, 22, CrusherRecipeCategory.NAME); registry.addRecipeClickArea(GuiGrinder.class, 80, 40, 24, 22, CrusherRecipeCategory.NAME);
@ -107,6 +113,7 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin{
registry.addRecipeCatalyst(new ItemStack(InitBlocks.blockAtomicReconstructor), ReconstructorRecipeCategory.NAME); registry.addRecipeCatalyst(new ItemStack(InitBlocks.blockAtomicReconstructor), ReconstructorRecipeCategory.NAME);
registry.addRecipeCatalyst(new ItemStack(InitBlocks.blockEmpowerer), EmpowererRecipeCategory.NAME); registry.addRecipeCatalyst(new ItemStack(InitBlocks.blockEmpowerer), EmpowererRecipeCategory.NAME);
registry.addRecipeCatalyst(new ItemStack(InitItems.itemBooklet), BookletRecipeCategory.NAME); registry.addRecipeCatalyst(new ItemStack(InitItems.itemBooklet), BookletRecipeCategory.NAME);
registry.addRecipeCatalyst(new ItemStack(InitBlocks.blockCompost), CompostRecipeCategory.NAME);
} }
@Override @Override

View file

@ -0,0 +1,69 @@
/*
* This file ("CompostRecipeCategory.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.jei.compost;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeCategory;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
public class CompostRecipeCategory implements IRecipeCategory<CompostRecipeWrapper>{
public static final String NAME = "actuallyadditions.compost";
private static final ItemStack COMPOST = new ItemStack(InitBlocks.blockCompost);
private final IDrawable background;
public CompostRecipeCategory(IGuiHelper helper){
this.background = helper.createDrawable(AssetUtil.getGuiLocation("gui_nei_simple"), 0, 0, 96, 60);
}
@Override
public String getUid(){
return NAME;
}
@Override
public String getTitle(){
return StringUtil.localize("container.nei."+NAME+".name");
}
@Override
public String getModName(){
return ModUtil.NAME;
}
@Override
public IDrawable getBackground(){
return this.background;
}
@Override
public void drawExtras(Minecraft minecraft){
AssetUtil.renderStackToGui(COMPOST, 1, 35, 1.5F);
}
@Override
public void setRecipe(IRecipeLayout recipeLayout, CompostRecipeWrapper wrapper, IIngredients ingredients){
recipeLayout.getItemStacks().init(0, true, 4, 18);
recipeLayout.getItemStacks().set(0, wrapper.theRecipe.input);
recipeLayout.getItemStacks().init(1, false, 66, 18);
recipeLayout.getItemStacks().set(1, wrapper.theRecipe.output);
}
}

View file

@ -0,0 +1,58 @@
/*
* This file ("CompostRecipeWrapper.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.jei.compost;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCompost;
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
import mezz.jei.api.ingredients.IIngredients;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
public class CompostRecipeWrapper extends RecipeWrapperWithButton{
public final CompostRecipe theRecipe;
public CompostRecipeWrapper(CompostRecipe recipe){
this.theRecipe = recipe;
}
@Override
public void getIngredients(IIngredients ingredients){
ingredients.setInput(ItemStack.class, this.theRecipe.input);
ingredients.setOutput(ItemStack.class, this.theRecipe.output);
}
@Override
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY){
int bake_time = TileEntityCompost.COMPOST_TIME_TICKS / 20;
minecraft.fontRenderer.drawString(bake_time + "s", 28, 3, 0xFFFFFF, true);
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
}
@Override
public int getButtonX(){
return 65;
}
@Override
public int getButtonY(){
return 43;
}
@Override
public IBookletPage getPage(){
return BookletUtils.findFirstPageForStack(new ItemStack(InitBlocks.blockCompost));
}
}

View file

@ -18,6 +18,8 @@ import net.minecraft.nbt.NBTTagCompound;
public class TileEntityCompost extends TileEntityInventoryBase{ public class TileEntityCompost extends TileEntityInventoryBase{
public static final int COMPOST_TIME_TICKS = 3000;
public int conversionTime; public int conversionTime;
public TileEntityCompost(){ public TileEntityCompost(){
@ -66,7 +68,7 @@ public class TileEntityCompost extends TileEntityInventoryBase{
CompostRecipe recipe = getRecipeForInput(this.slots.getStackInSlot(0)); CompostRecipe recipe = getRecipeForInput(this.slots.getStackInSlot(0));
if(recipe != null){ if(recipe != null){
this.conversionTime++; this.conversionTime++;
if(this.conversionTime >= 3000){ if(this.conversionTime >= COMPOST_TIME_TICKS){
ItemStack output = recipe.output.copy(); ItemStack output = recipe.output.copy();
this.slots.setStackInSlot(0, StackUtil.setStackSize(output, StackUtil.getStackSize(this.slots.getStackInSlot(0)))); this.slots.setStackInSlot(0, StackUtil.setStackSize(output, StackUtil.getStackSize(this.slots.getStackInSlot(0))));
this.conversionTime = 0; this.conversionTime = 0;