mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
JEI Crusher
This commit is contained in:
parent
59d835ed4f
commit
2189dde1a0
5 changed files with 252 additions and 9 deletions
|
@ -15,6 +15,8 @@ import de.ellpeck.actuallyadditions.mod.jei.booklet.BookletRecipeCategory;
|
|||
import de.ellpeck.actuallyadditions.mod.jei.booklet.BookletRecipeHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.coffee.CoffeeMachineRecipeCategory;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.coffee.CoffeeMachineRecipeHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.crusher.CrusherRecipeCategory;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.crusher.CrusherRecipeHandler;
|
||||
import mezz.jei.api.*;
|
||||
|
||||
@JEIPlugin
|
||||
|
@ -36,16 +38,19 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin{
|
|||
public void register(IModRegistry registry){
|
||||
registry.addRecipeCategories(
|
||||
new BookletRecipeCategory(this.helpers.getGuiHelper()),
|
||||
new CoffeeMachineRecipeCategory(this.helpers.getGuiHelper())
|
||||
new CoffeeMachineRecipeCategory(this.helpers.getGuiHelper()),
|
||||
new CrusherRecipeCategory(this.helpers.getGuiHelper())
|
||||
);
|
||||
|
||||
registry.addRecipeHandlers(
|
||||
new BookletRecipeHandler(),
|
||||
new CoffeeMachineRecipeHandler()
|
||||
new CoffeeMachineRecipeHandler(),
|
||||
new CrusherRecipeHandler()
|
||||
);
|
||||
|
||||
registry.addRecipes(ActuallyAdditionsAPI.bookletPagesWithItemStackData);
|
||||
registry.addRecipes(ActuallyAdditionsAPI.coffeeMachineIngredients);
|
||||
registry.addRecipes(ActuallyAdditionsAPI.crusherRecipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -72,19 +72,21 @@ public class CoffeeMachineRecipeWrapper extends RecipeWrapperWithButton implemen
|
|||
|
||||
@Override
|
||||
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight){
|
||||
if(this.theIngredient.getExtraText() != null){
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString(StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".coffee.special")+":", 2, 4, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString(this.theIngredient.getExtraText(), 2, 16, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
}
|
||||
|
||||
if(this.theIngredient.maxAmplifier > 0){
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString(StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".coffee.maxAmount")+": "+this.theIngredient.maxAmplifier, 2, 28, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY){
|
||||
this.updateButton(minecraft, mouseX, mouseY);
|
||||
|
||||
if(this.theIngredient.getExtraText() != null){
|
||||
minecraft.fontRendererObj.drawString(StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".coffee.special")+":", 2, 4, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
minecraft.fontRendererObj.drawString(this.theIngredient.getExtraText(), 2, 16, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
}
|
||||
|
||||
if(this.theIngredient.maxAmplifier > 0){
|
||||
minecraft.fontRendererObj.drawString(StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".coffee.maxAmount")+": "+this.theIngredient.maxAmplifier, 2, 28, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* This file ("CrusherRecipeCategor.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
|
||||
*
|
||||
* © 2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.jei.crusher;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
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.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class CrusherRecipeCategory implements IRecipeCategory{
|
||||
|
||||
public static final String NAME = "actuallyadditions.crushing";
|
||||
|
||||
private IDrawable background;
|
||||
|
||||
public CrusherRecipeCategory(IGuiHelper helper){
|
||||
this.background = helper.createDrawable(AssetUtil.getGuiLocation("guiGrinder"), 60, 13, 56, 79);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUid(){
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle(){
|
||||
return StringUtil.localize("container.nei."+NAME+".name");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground(){
|
||||
return this.background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(Minecraft minecraft){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper){
|
||||
if(recipeWrapper instanceof CrusherRecipeWrapper){
|
||||
CrusherRecipeWrapper wrapper = (CrusherRecipeWrapper)recipeWrapper;
|
||||
|
||||
recipeLayout.getItemStacks().init(0, true, 19, 7);
|
||||
recipeLayout.getItemStacks().set(0, wrapper.theRecipe.getRecipeInputs());
|
||||
|
||||
recipeLayout.getItemStacks().init(1, true, 7, 55);
|
||||
recipeLayout.getItemStacks().set(1, wrapper.theRecipe.getRecipeOutputOnes());
|
||||
|
||||
List<ItemStack> outputTwos = wrapper.theRecipe.getRecipeOutputTwos();
|
||||
if(outputTwos != null && !outputTwos.isEmpty()){
|
||||
recipeLayout.getItemStacks().init(2, true, 31, 55);
|
||||
recipeLayout.getItemStacks().set(2, outputTwos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* This file ("CrusherRecipeHandler.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
|
||||
*
|
||||
* © 2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.jei.crusher;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CrusherRecipeHandler implements IRecipeHandler<CrusherRecipe>{
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Class getRecipeClass(){
|
||||
return CrusherRecipe.class;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getRecipeCategoryUid(){
|
||||
return CrusherRecipeCategory.NAME;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull CrusherRecipe recipe){
|
||||
return new CrusherRecipeWrapper(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(@Nonnull CrusherRecipe recipe){
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* This file ("CrusherRecipeWrapper.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
|
||||
*
|
||||
* © 2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.jei.crusher;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CrusherRecipeWrapper extends RecipeWrapperWithButton implements IRecipeWrapper{
|
||||
|
||||
public CrusherRecipe theRecipe;
|
||||
|
||||
public CrusherRecipeWrapper(CrusherRecipe recipe){
|
||||
this.theRecipe = recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getInputs(){
|
||||
return this.theRecipe.getRecipeInputs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getOutputs(){
|
||||
List list = new ArrayList();
|
||||
list.addAll(this.theRecipe.getRecipeOutputOnes());
|
||||
|
||||
List<ItemStack> outputTwos = this.theRecipe.getRecipeOutputTwos();
|
||||
if(outputTwos != null && !outputTwos.isEmpty()){
|
||||
list.addAll(outputTwos);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getFluidInputs(){
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getFluidOutputs(){
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY){
|
||||
this.updateButton(minecraft, mouseX, mouseY);
|
||||
|
||||
List<ItemStack> outputTwos = this.theRecipe.getRecipeOutputTwos();
|
||||
if(outputTwos != null && !outputTwos.isEmpty()){
|
||||
minecraft.fontRendererObj.drawString(this.theRecipe.outputTwoChance+"%", 60, 60, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight){
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> getTooltipStrings(int mouseX, int mouseY){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleClick(@Nonnull Minecraft minecraft, int mouseX, int mouseY, int mouseButton){
|
||||
return this.handleClick(minecraft, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BookletPage getPage(){
|
||||
return BookletUtils.getFirstPageForStack(new ItemStack(InitBlocks.blockGrinder));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getButtonX(){
|
||||
return -5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getButtonY(){
|
||||
return 26;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue