mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-29 18:28:34 +01:00
Re-added NEI recipe handlers, added button into nei handlers to show the item in question in the booklet
This commit is contained in:
parent
9f4323bb0d
commit
a92396204a
19 changed files with 1107 additions and 22 deletions
|
@ -546,7 +546,7 @@ public class GuiBooklet extends GuiScreen{
|
|||
}
|
||||
}
|
||||
|
||||
private static class TexturedButton extends GuiButton{
|
||||
public static class TexturedButton extends GuiButton{
|
||||
|
||||
public int texturePosX;
|
||||
public int texturePosY;
|
||||
|
|
|
@ -54,8 +54,7 @@ public enum ConfigBoolValues{
|
|||
CTRL_EXTRA_INFO("Advanced Info", ConfigCategories.OTHER, true, "Show Advanced Item Info when holding Control on every Item"),
|
||||
CTRL_INFO_FOR_EXTRA_INFO("Advanced Info Tooltips", ConfigCategories.OTHER, true, "Show the 'Press Control for more Info'-Text on Item Tooltips"),
|
||||
|
||||
NEED_BOOKLET_FOR_KEYBIND_INFO("Booklet Quick Opening", ConfigCategories.TOOL_VALUES, true, "If the booklet should have to be inside the player's inventory to be able to hover over an item and press a keybind to quickly access the item's page"),
|
||||
SHOW_NEED_BOOKLET_FOR_KEYBIND_INFO("Booklet Quick Opening Info", ConfigCategories.TOOL_VALUES, true, "If the 'Press key for more information'-button should show when the item has a page in the booklet"),
|
||||
SHOW_BOOKLET_INFO("Booklet Quick Opening Info", ConfigCategories.TOOL_VALUES, true, "If the 'Press key for more information'-text should show when the item has a page in the booklet"),
|
||||
GIVE_BOOKLET_ON_FIRST_CRAFT("Give Booklet on First Craft", ConfigCategories.OTHER, true, "If the booklet should be given to the player when he first crafts something from the Mod");
|
||||
|
||||
public final String name;
|
||||
|
|
|
@ -10,8 +10,11 @@
|
|||
|
||||
package ellpeck.actuallyadditions.event;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
|
||||
import ellpeck.actuallyadditions.nei.NeiScreenEvents;
|
||||
import ellpeck.actuallyadditions.update.UpdateCheckerClientNotifier;
|
||||
import ellpeck.actuallyadditions.util.CompatUtil;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.Util;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -36,6 +39,10 @@ public class InitEvents{
|
|||
Util.registerEvent(new TooltipEvent());
|
||||
Util.registerEvent(new RenderPlayerEventAA());
|
||||
|
||||
if(Loader.isModLoaded(CompatUtil.NEI_MOD_ID)){
|
||||
Util.registerEvent(new NeiScreenEvents());
|
||||
}
|
||||
|
||||
if(ConfigBoolValues.DO_UPDATE_CHECK.isEnabled()){
|
||||
Util.registerEvent(new UpdateCheckerClientNotifier());
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
|||
import ellpeck.actuallyadditions.booklet.InitBooklet;
|
||||
import ellpeck.actuallyadditions.booklet.page.BookletPage;
|
||||
import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
|
||||
import ellpeck.actuallyadditions.items.InitItems;
|
||||
import ellpeck.actuallyadditions.util.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
|
@ -38,9 +37,8 @@ public class TooltipEvent{
|
|||
if(event.itemStack != null && !(Minecraft.getMinecraft().currentScreen instanceof GuiBooklet)){
|
||||
for(BookletPage page : InitBooklet.pagesWithItemStackData){
|
||||
if(ItemUtil.contains(page.getItemStacksForPage(), event.itemStack, true)){
|
||||
if(ConfigBoolValues.SHOW_BOOKLET_INFO.isEnabled()){
|
||||
int keyCode = KeyBinds.keybindOpenBooklet.getKeyCode();
|
||||
if(!ConfigBoolValues.NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled() || Minecraft.getMinecraft().thePlayer.inventory.hasItem(InitItems.itemLexicon)){
|
||||
if(ConfigBoolValues.SHOW_NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled()){
|
||||
event.toolTip.add(EnumChatFormatting.GOLD+StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID_LOWER+".keyToSeeRecipe", keyCode > 0 && keyCode < Keyboard.KEYBOARD_SIZE ? "'"+Keyboard.getKeyName(keyCode)+"'" : "[NONE]"));
|
||||
}
|
||||
if(Keyboard.isKeyDown(KeyBinds.keybindOpenBooklet.getKeyCode())){
|
||||
|
@ -50,12 +48,6 @@ public class TooltipEvent{
|
|||
book.openIndexEntry(page.getChapter().entry, InitBooklet.entries.indexOf(page.getChapter().entry)/GuiBooklet.CHAPTER_BUTTONS_AMOUNT+1, true);
|
||||
book.openChapter(page.getChapter(), page);
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(ConfigBoolValues.SHOW_NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled()){
|
||||
event.toolTip.addAll(Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(EnumChatFormatting.ITALIC+StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID_LOWER+".noBookletInInventory"), GuiBooklet.TOOLTIP_SPLIT_LENGTH));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -245,6 +245,10 @@ public class ItemCoffee extends ItemFood implements IActAddItemOrBlock{
|
|||
public boolean effect(ItemStack stack){
|
||||
return ItemCoffee.addEffectToStack(stack, this);
|
||||
}
|
||||
|
||||
public String getExtraText(){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class MilkIngredient extends Ingredient{
|
||||
|
@ -273,5 +277,9 @@ public class ItemCoffee extends ItemFood implements IActAddItemOrBlock{
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExtraText(){
|
||||
return StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".coffee.extra.milk");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
* This file ("CoffeeMachineRecipeHandler.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://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.nei;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.RecipeInfo;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
||||
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||
import ellpeck.actuallyadditions.inventory.gui.GuiCoffeeMachine;
|
||||
import ellpeck.actuallyadditions.items.InitItems;
|
||||
import ellpeck.actuallyadditions.items.ItemCoffee;
|
||||
import ellpeck.actuallyadditions.items.metalists.TheMiscItems;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CoffeeMachineRecipeHandler extends TemplateRecipeHandler implements INeiRecipeHandler{
|
||||
|
||||
public static final String NAME = "actuallyadditions.coffee";
|
||||
|
||||
public CoffeeMachineRecipeHandler(){
|
||||
super();
|
||||
RecipeInfo.setGuiOffset(this.getGuiClass(), 35, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackForInfo(){
|
||||
return new ItemStack(InitBlocks.blockCoffeeMachine);
|
||||
}
|
||||
|
||||
public class CachedCoffee extends CachedRecipe{
|
||||
|
||||
public PositionedStack cup;
|
||||
public PositionedStack coffeeBeans;
|
||||
public PositionedStack result;
|
||||
public PositionedStack ingredientStack;
|
||||
public String extraText;
|
||||
public int maxAmp;
|
||||
|
||||
public CachedCoffee(ItemCoffee.Ingredient ingredient){
|
||||
this.cup = new PositionedStack(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()), 45, 39);
|
||||
this.coffeeBeans = new PositionedStack(new ItemStack(InitItems.itemCoffeeBean, ConfigIntValues.COFFEE_CACHE_USED_PER_ITEM.getValue()), 2, 39);
|
||||
this.ingredientStack = new PositionedStack(ingredient.ingredient.copy(), 90, 21);
|
||||
this.setupResult(ingredient);
|
||||
this.extraText = ingredient.getExtraText();
|
||||
this.maxAmp = ingredient.maxAmplifier;
|
||||
}
|
||||
|
||||
public void setupResult(ItemCoffee.Ingredient ingredient){
|
||||
ItemStack result = new ItemStack(InitItems.itemCoffee);
|
||||
ItemCoffee.addEffectToStack(result, ingredient);
|
||||
this.result = new PositionedStack(result.copy(), 45, 70);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients(){
|
||||
ArrayList<PositionedStack> list = new ArrayList<PositionedStack>();
|
||||
list.add(this.ingredientStack);
|
||||
list.add(this.cup);
|
||||
list.add(this.coffeeBeans);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult(){
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage(){
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects(){
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(20, 39, 20, 16), NAME));
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(64, 42, 23, 10), NAME));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiContainer> getGuiClass(){
|
||||
return GuiCoffeeMachine.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName(){
|
||||
return StringUtil.localize("container.nei."+NAME+".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results){
|
||||
if(outputId.equals(NAME) && getClass() == CoffeeMachineRecipeHandler.class){
|
||||
ArrayList<ItemCoffee.Ingredient> ingredients = ItemCoffee.ingredients;
|
||||
for(ItemCoffee.Ingredient ingredient : ingredients){
|
||||
arecipes.add(new CachedCoffee(ingredient));
|
||||
}
|
||||
}
|
||||
else super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result){
|
||||
ArrayList<ItemCoffee.Ingredient> ingredients = ItemCoffee.ingredients;
|
||||
for(ItemCoffee.Ingredient ingredient : ingredients){
|
||||
if(result.getItem() instanceof ItemCoffee) arecipes.add(new CachedCoffee(ingredient));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient){
|
||||
|
||||
ArrayList<ItemCoffee.Ingredient> ingredients = ItemCoffee.ingredients;
|
||||
for(ItemCoffee.Ingredient ingr : ingredients){
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()), ingredient) || NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(InitItems.itemCoffeeBean), ingredient) || NEIServerUtils.areStacksSameTypeCrafting(ingr.ingredient.copy(), ingredient)){
|
||||
CachedCoffee theRecipe = new CachedCoffee(ingr);
|
||||
theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.ingredientStack), ingredient);
|
||||
arecipes.add(theRecipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture(){
|
||||
return ModUtil.MOD_ID_LOWER + ":textures/gui/guiNEICoffeeMachine.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipeIndex){
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GuiDraw.changeTexture(getGuiTexture());
|
||||
GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 126, 88);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe){
|
||||
drawProgressBar(20, 39, 126, 0, 21, 16, 48, 0);
|
||||
drawProgressBar(63, 42, 125, 16, 24, 12, 48, 2);
|
||||
|
||||
CachedCoffee cache = (CachedCoffee)this.arecipes.get(recipe);
|
||||
if(cache.extraText != null){
|
||||
GuiDraw.drawString(StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".coffee.special") + ":", 2, 4, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
GuiDraw.drawString(cache.extraText, 2, 16, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
}
|
||||
GuiDraw.drawString(StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".coffee.shift"), 1, 75, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
|
||||
if(cache.maxAmp > 0){
|
||||
GuiDraw.drawString(StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".coffee.maxAmount") + ": " + cache.maxAmp, 2, 28, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier(){
|
||||
return NAME;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* This file ("CompostRecipeHandler.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://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.nei;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.RecipeInfo;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
||||
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||
import ellpeck.actuallyadditions.items.InitItems;
|
||||
import ellpeck.actuallyadditions.items.metalists.TheMiscItems;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Collections;
|
||||
|
||||
public class CompostRecipeHandler extends TemplateRecipeHandler implements INeiRecipeHandler{
|
||||
|
||||
public static final String NAME = "actuallyadditions.compost";
|
||||
|
||||
public CompostRecipeHandler(){
|
||||
super();
|
||||
RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackForInfo(){
|
||||
return new ItemStack(InitBlocks.blockCompost);
|
||||
}
|
||||
|
||||
public class CachedCompostRecipe extends CachedRecipe{
|
||||
|
||||
public PositionedStack result;
|
||||
public PositionedStack input;
|
||||
public int chance;
|
||||
|
||||
public CachedCompostRecipe(ItemStack input, ItemStack result){
|
||||
this.result = new PositionedStack(result, 67+32, 19);
|
||||
this.input = new PositionedStack(input, 5+32, 19);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getIngredient(){
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult(){
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiContainer> getGuiClass(){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName(){
|
||||
return StringUtil.localize("container.nei."+NAME+".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects(){
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(31+32, 18, 22, 16), NAME));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results){
|
||||
if(outputId.equals(NAME) && getClass() == CompostRecipeHandler.class){
|
||||
arecipes.add(new CachedCompostRecipe(new ItemStack(InitItems.itemMisc, ConfigIntValues.COMPOST_AMOUNT.getValue(), TheMiscItems.MASHED_FOOD.ordinal()), new ItemStack(InitItems.itemFertilizer, ConfigIntValues.COMPOST_AMOUNT.getValue())));
|
||||
}
|
||||
else super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result){
|
||||
if(NEIServerUtils.areStacksSameType(new ItemStack(InitItems.itemFertilizer), result)) arecipes.add(new CachedCompostRecipe(new ItemStack(InitItems.itemMisc, ConfigIntValues.COMPOST_AMOUNT.getValue(), TheMiscItems.MASHED_FOOD.ordinal()), new ItemStack(InitItems.itemFertilizer, ConfigIntValues.COMPOST_AMOUNT.getValue())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient){
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(InitItems.itemMisc, ConfigIntValues.COMPOST_AMOUNT.getValue(), TheMiscItems.MASHED_FOOD.ordinal()), ingredient)){
|
||||
CachedCompostRecipe theRecipe = new CachedCompostRecipe(new ItemStack(InitItems.itemMisc, ConfigIntValues.COMPOST_AMOUNT.getValue(), TheMiscItems.MASHED_FOOD.ordinal()), new ItemStack(InitItems.itemFertilizer, ConfigIntValues.COMPOST_AMOUNT.getValue()));
|
||||
theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.input), ingredient);
|
||||
arecipes.add(theRecipe);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture(){
|
||||
return ModUtil.MOD_ID_LOWER + ":textures/gui/guiNEISimple.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipeIndex){
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GuiDraw.changeTexture(getGuiTexture());
|
||||
GuiDraw.drawTexturedModalRect(32, 0, 0, 0, 96, 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier(){
|
||||
return NAME;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
/*
|
||||
* 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://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.nei;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.RecipeInfo;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
||||
import ellpeck.actuallyadditions.inventory.gui.GuiGrinder;
|
||||
import ellpeck.actuallyadditions.recipe.CrusherRecipeManualRegistry;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CrusherRecipeHandler extends TemplateRecipeHandler implements INeiRecipeHandler{
|
||||
|
||||
@Override
|
||||
public ItemStack getStackForInfo(){
|
||||
return new ItemStack(InitBlocks.blockGrinder);
|
||||
}
|
||||
|
||||
public static class CrusherDoubleRecipeHandler extends CrusherRecipeHandler{
|
||||
|
||||
@Override
|
||||
public ItemStack getStackForInfo(){
|
||||
return new ItemStack(InitBlocks.blockGrinderDouble);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiContainer> getGuiClass(){
|
||||
return GuiGrinder.GuiGrinderDouble.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects(){
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(51, 40, 24, 22), this.getName()));
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(101, 40, 24, 22), this.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture(){
|
||||
return ModUtil.MOD_ID_LOWER+":textures/gui/guiGrinderDouble.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipeIndex){
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GuiDraw.changeTexture(getGuiTexture());
|
||||
GuiDraw.drawTexturedModalRect(33, 20, 33, 20, 110, 70);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe){
|
||||
drawProgressBar(51, 40, 176, 0, 24, 23, 48, 1);
|
||||
this.drawChanceString(66, 93, recipe);
|
||||
}
|
||||
}
|
||||
|
||||
public CrusherRecipeHandler(){
|
||||
RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0);
|
||||
}
|
||||
|
||||
public class CachedCrush extends CachedRecipe{
|
||||
|
||||
public PositionedStack ingredient;
|
||||
public PositionedStack resultOne;
|
||||
public PositionedStack resultTwo;
|
||||
public int secondChance;
|
||||
|
||||
public CachedCrush(ItemStack in, ItemStack resultOne, ItemStack resultTwo, int secondChance, CrusherRecipeHandler handler){
|
||||
boolean isDouble = handler instanceof CrusherDoubleRecipeHandler;
|
||||
in.stackSize = 1;
|
||||
this.ingredient = new PositionedStack(in, isDouble ? 51 : 80, 21);
|
||||
this.resultOne = new PositionedStack(resultOne, isDouble ? 38 : 66, 69);
|
||||
if(resultTwo != null) this.resultTwo = new PositionedStack(resultTwo, isDouble ? 63 : 94, 69);
|
||||
this.secondChance = secondChance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients(){
|
||||
return getCycledIngredients(cycleticks/48, Collections.singletonList(ingredient));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult(){
|
||||
return resultOne;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getOtherStacks(){
|
||||
ArrayList<PositionedStack> list = new ArrayList<PositionedStack>();
|
||||
if(this.resultTwo != null) list.add(this.resultTwo);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage(){
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects(){
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(80, 40, 24, 22), this.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiContainer> getGuiClass(){
|
||||
return GuiGrinder.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName(){
|
||||
return StringUtil.localize("container.nei."+this.getName()+".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results){
|
||||
if(outputId.equals(this.getName()) && (getClass() == CrusherRecipeHandler.class || getClass() == CrusherDoubleRecipeHandler.class)){
|
||||
ArrayList<CrusherRecipeManualRegistry.CrusherRecipe> recipes = CrusherRecipeManualRegistry.recipes;
|
||||
for(CrusherRecipeManualRegistry.CrusherRecipe recipe : recipes){
|
||||
arecipes.add(new CachedCrush(recipe.input, recipe.firstOutput, recipe.secondOutput, recipe.secondChance, this));
|
||||
}
|
||||
}
|
||||
else super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result){
|
||||
ArrayList<CrusherRecipeManualRegistry.CrusherRecipe> recipes = CrusherRecipeManualRegistry.recipes;
|
||||
for(CrusherRecipeManualRegistry.CrusherRecipe recipe : recipes){
|
||||
if(NEIServerUtils.areStacksSameType(recipe.firstOutput, result) || NEIServerUtils.areStacksSameType(recipe.secondOutput, result))
|
||||
arecipes.add(new CachedCrush(recipe.input, recipe.firstOutput, recipe.secondOutput, recipe.secondChance, this));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient){
|
||||
ArrayList<CrusherRecipeManualRegistry.CrusherRecipe> recipes = CrusherRecipeManualRegistry.recipes;
|
||||
for(CrusherRecipeManualRegistry.CrusherRecipe recipe : recipes){
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting(recipe.input, ingredient)){
|
||||
CachedCrush theRecipe = new CachedCrush(recipe.input, recipe.firstOutput, recipe.secondOutput, recipe.secondChance, this);
|
||||
theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.ingredient), ingredient);
|
||||
arecipes.add(theRecipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture(){
|
||||
return ModUtil.MOD_ID_LOWER+":textures/gui/guiGrinder.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipeIndex){
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GuiDraw.changeTexture(getGuiTexture());
|
||||
GuiDraw.drawTexturedModalRect(60, 13, 60, 13, 56, 79);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe){
|
||||
drawProgressBar(80, 40, 176, 0, 24, 23, 48, 1);
|
||||
this.drawChanceString(118, 73, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier(){
|
||||
return this.getName();
|
||||
}
|
||||
|
||||
protected String getName(){
|
||||
return "actuallyadditions."+(this instanceof CrusherDoubleRecipeHandler ? "crushingDouble" : "crushing");
|
||||
}
|
||||
|
||||
protected void drawChanceString(int x, int y, int recipe){
|
||||
CachedCrush crush = (CachedCrush)this.arecipes.get(recipe);
|
||||
if(crush.resultTwo != null){
|
||||
int secondChance = crush.secondChance;
|
||||
String secondString = secondChance+"%";
|
||||
GuiDraw.drawString(secondString, x, y, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* This file ("FurnaceDoubleRecipeHandler.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://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.nei;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.RecipeInfo;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
||||
import ellpeck.actuallyadditions.inventory.gui.GuiFurnaceDouble;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FurnaceDoubleRecipeHandler extends TemplateRecipeHandler implements INeiRecipeHandler{
|
||||
|
||||
public static final String NAME = "actuallyadditions.furnaceDouble";
|
||||
|
||||
public FurnaceDoubleRecipeHandler(){
|
||||
RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackForInfo(){
|
||||
return new ItemStack(InitBlocks.blockFurnaceDouble);
|
||||
}
|
||||
|
||||
public class CachedFurn extends CachedRecipe{
|
||||
|
||||
public PositionedStack ingredient;
|
||||
public PositionedStack resultOne;
|
||||
|
||||
public CachedFurn(ItemStack in, ItemStack resultOne){
|
||||
in.stackSize = 1;
|
||||
this.ingredient = new PositionedStack(in, 51, 21);
|
||||
this.resultOne = new PositionedStack(resultOne, 50, 69);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients(){
|
||||
return getCycledIngredients(cycleticks/48, Collections.singletonList(ingredient));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult(){
|
||||
return resultOne;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiContainer> getGuiClass(){
|
||||
return GuiFurnaceDouble.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects(){
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(51, 40, 24, 22), NAME));
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(101, 40, 24, 22), NAME));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture(){
|
||||
return ModUtil.MOD_ID_LOWER+":textures/gui/guiFurnaceDouble.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipeIndex){
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GuiDraw.changeTexture(getGuiTexture());
|
||||
GuiDraw.drawTexturedModalRect(46, 20, 46, 20, 84, 70);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe){
|
||||
drawProgressBar(51, 40, 176, 0, 24, 23, 48, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage(){
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName(){
|
||||
return StringUtil.localize("container.nei."+NAME+".name");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results){
|
||||
if(outputId.equals(NAME) && getClass() == FurnaceDoubleRecipeHandler.class){
|
||||
Map<ItemStack, ItemStack> recipes = (Map<ItemStack, ItemStack>)FurnaceRecipes.smelting().getSmeltingList();
|
||||
for(Map.Entry<ItemStack, ItemStack> recipe : recipes.entrySet()){
|
||||
arecipes.add(new CachedFurn(recipe.getKey(), recipe.getValue()));
|
||||
}
|
||||
}
|
||||
else super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result){
|
||||
Map<ItemStack, ItemStack> recipes = (Map<ItemStack, ItemStack>)FurnaceRecipes.smelting().getSmeltingList();
|
||||
for(Map.Entry<ItemStack, ItemStack> recipe : recipes.entrySet()){
|
||||
if(NEIServerUtils.areStacksSameType(recipe.getValue(), result))
|
||||
arecipes.add(new CachedFurn(recipe.getKey(), recipe.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient){
|
||||
Map<ItemStack, ItemStack> recipes = (Map<ItemStack, ItemStack>)FurnaceRecipes.smelting().getSmeltingList();
|
||||
for(Map.Entry<ItemStack, ItemStack> recipe : recipes.entrySet()){
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting(recipe.getKey(), ingredient)){
|
||||
CachedFurn theRecipe = new CachedFurn(recipe.getKey(), recipe.getValue());
|
||||
theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.ingredient), ingredient);
|
||||
arecipes.add(theRecipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier(){
|
||||
return NAME;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* This file ("HairyBallRecipeHandler.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://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.nei;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.RecipeInfo;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import ellpeck.actuallyadditions.items.InitItems;
|
||||
import ellpeck.actuallyadditions.recipe.HairyBallHandler;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
public class HairyBallRecipeHandler extends TemplateRecipeHandler implements INeiRecipeHandler{
|
||||
|
||||
public static final String NAME = "actuallyadditions.ballOfHair";
|
||||
|
||||
public HairyBallRecipeHandler(){
|
||||
super();
|
||||
RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackForInfo(){
|
||||
return new ItemStack(InitItems.itemHairyBall);
|
||||
}
|
||||
|
||||
public class CachedBallRecipe extends CachedRecipe{
|
||||
|
||||
public PositionedStack result;
|
||||
public PositionedStack input;
|
||||
public int chance;
|
||||
|
||||
public CachedBallRecipe(ItemStack input, ItemStack result, int chance){
|
||||
this.result = new PositionedStack(result, 67+32, 19);
|
||||
this.chance = chance;
|
||||
this.input = new PositionedStack(input, 5+32, 19);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getIngredient(){
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult(){
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiContainer> getGuiClass(){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName(){
|
||||
return StringUtil.localize("container.nei."+NAME+".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects(){
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(31+32, 18, 22, 16), NAME));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results){
|
||||
if(outputId.equals(NAME) && getClass() == HairyBallRecipeHandler.class){
|
||||
ArrayList<HairyBallHandler.Return> recipes = HairyBallHandler.returns;
|
||||
for(HairyBallHandler.Return recipe : recipes){
|
||||
arecipes.add(new CachedBallRecipe(recipe.inputItem, recipe.returnItem, recipe.itemWeight));
|
||||
}
|
||||
}
|
||||
else super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result){
|
||||
ArrayList<HairyBallHandler.Return> recipes = HairyBallHandler.returns;
|
||||
for(HairyBallHandler.Return recipe : recipes){
|
||||
if(NEIServerUtils.areStacksSameType(recipe.returnItem, result)) arecipes.add(new CachedBallRecipe(recipe.inputItem, recipe.returnItem, recipe.itemWeight));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient){
|
||||
ArrayList<HairyBallHandler.Return> recipes = HairyBallHandler.returns;
|
||||
for(HairyBallHandler.Return recipe : recipes){
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting(recipe.inputItem, ingredient)){
|
||||
CachedBallRecipe theRecipe = new CachedBallRecipe(recipe.inputItem, recipe.returnItem, recipe.itemWeight);
|
||||
theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.input), ingredient);
|
||||
arecipes.add(theRecipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture(){
|
||||
return ModUtil.MOD_ID_LOWER + ":textures/gui/guiNEISimple.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipeIndex){
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GuiDraw.changeTexture(getGuiTexture());
|
||||
GuiDraw.drawTexturedModalRect(32, 0, 0, 0, 96, 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int rec){
|
||||
CachedBallRecipe recipe = (CachedBallRecipe)this.arecipes.get(rec);
|
||||
if(recipe.result != null){
|
||||
int secondChance = recipe.chance;
|
||||
String secondString = secondChance + "%";
|
||||
GuiDraw.drawString(secondString, 65+32, 45, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier(){
|
||||
return NAME;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* This file ("INeiRecipeHandler.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://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.nei;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface INeiRecipeHandler{
|
||||
|
||||
ItemStack getStackForInfo();
|
||||
}
|
|
@ -28,6 +28,34 @@ public class NEIActuallyAdditionsConfig implements IConfigureNEI{
|
|||
API.registerGuiOverlay(GuiCrafter.class, "crafting");
|
||||
API.registerGuiOverlayHandler(GuiCrafter.class, new DefaultOverlayHandler(), "crafting");
|
||||
|
||||
CrusherRecipeHandler crusherRecipeHandler = new CrusherRecipeHandler();
|
||||
API.registerRecipeHandler(crusherRecipeHandler);
|
||||
API.registerUsageHandler(crusherRecipeHandler);
|
||||
|
||||
CrusherRecipeHandler.CrusherDoubleRecipeHandler crusherDoubleRecipeHandler = new CrusherRecipeHandler.CrusherDoubleRecipeHandler();
|
||||
API.registerRecipeHandler(crusherDoubleRecipeHandler);
|
||||
API.registerUsageHandler(crusherDoubleRecipeHandler);
|
||||
|
||||
FurnaceDoubleRecipeHandler furnaceDoubleRecipeHandler = new FurnaceDoubleRecipeHandler();
|
||||
API.registerRecipeHandler(furnaceDoubleRecipeHandler);
|
||||
API.registerUsageHandler(furnaceDoubleRecipeHandler);
|
||||
|
||||
HairyBallRecipeHandler ballRecipeHandler = new HairyBallRecipeHandler();
|
||||
API.registerRecipeHandler(ballRecipeHandler);
|
||||
API.registerUsageHandler(ballRecipeHandler);
|
||||
|
||||
TreasureChestRecipeHandler treasureRecipeHandler = new TreasureChestRecipeHandler();
|
||||
API.registerRecipeHandler(treasureRecipeHandler);
|
||||
API.registerUsageHandler(treasureRecipeHandler);
|
||||
|
||||
CompostRecipeHandler compostRecipeHandler = new CompostRecipeHandler();
|
||||
API.registerRecipeHandler(compostRecipeHandler);
|
||||
API.registerUsageHandler(compostRecipeHandler);
|
||||
|
||||
CoffeeMachineRecipeHandler coffeeMachineRecipeHandler = new CoffeeMachineRecipeHandler();
|
||||
API.registerRecipeHandler(coffeeMachineRecipeHandler);
|
||||
API.registerUsageHandler(coffeeMachineRecipeHandler);
|
||||
|
||||
API.hideItem(new ItemStack(InitBlocks.blockRice));
|
||||
API.hideItem(new ItemStack(InitBlocks.blockCanola));
|
||||
API.hideItem(new ItemStack(InitBlocks.blockFlax));
|
||||
|
@ -38,11 +66,12 @@ public class NEIActuallyAdditionsConfig implements IConfigureNEI{
|
|||
|
||||
@Override
|
||||
public String getName(){
|
||||
return ModUtil.MOD_ID+" NEI Plugin";
|
||||
return ModUtil.MOD_ID + " NEI Plugin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion(){
|
||||
return ModUtil.VERSION;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* This file ("InitGuiEvent.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://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.nei;
|
||||
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
||||
import ellpeck.actuallyadditions.booklet.InitBooklet;
|
||||
import ellpeck.actuallyadditions.booklet.page.BookletPage;
|
||||
import ellpeck.actuallyadditions.util.CompatUtil;
|
||||
import ellpeck.actuallyadditions.util.ItemUtil;
|
||||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
|
||||
public class NeiScreenEvents{
|
||||
|
||||
private static final int NEI_BUTTON_ID = 123782;
|
||||
private GuiBooklet.TexturedButton neiButton;
|
||||
|
||||
@Optional.Method(modid = CompatUtil.NEI_MOD_ID)
|
||||
@SuppressWarnings("unchecked")
|
||||
@SubscribeEvent
|
||||
public void onInitGuiForNEI(GuiScreenEvent.InitGuiEvent event){
|
||||
if(event.gui instanceof GuiRecipe){
|
||||
GuiRecipe theGui = (GuiRecipe)event.gui;
|
||||
|
||||
int xSize = 176;
|
||||
int ySize = 166;
|
||||
int guiLeft = (event.gui.width-xSize)/2;
|
||||
int guiTop = (event.gui.height-ySize)/2;
|
||||
|
||||
this.neiButton = new GuiBooklet.TexturedButton(NEI_BUTTON_ID, guiLeft+xSize-24, guiTop+ySize/2-20, 146, 154, 20, 20){
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int x, int y){
|
||||
super.drawButton(minecraft, x, y);
|
||||
if(this.visible && this.field_146123_n){
|
||||
this.drawString(Minecraft.getMinecraft().fontRenderer, "View more Information", this.xPosition+this.width+5, this.yPosition+this.height/2-Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT/2, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
event.buttonList.add(this.neiButton);
|
||||
this.neiButton.visible = theGui.getCurrentRecipeHandlers().get(theGui.recipetype) instanceof INeiRecipeHandler;
|
||||
}
|
||||
}
|
||||
|
||||
@Optional.Method(modid = CompatUtil.NEI_MOD_ID)
|
||||
@SubscribeEvent
|
||||
public void guiPostAction(GuiScreenEvent.ActionPerformedEvent.Post event){
|
||||
if(this.neiButton != null && event.gui instanceof GuiRecipe){
|
||||
GuiRecipe theGui = (GuiRecipe)event.gui;
|
||||
|
||||
IRecipeHandler handler = theGui.getCurrentRecipeHandlers().get(theGui.recipetype);
|
||||
boolean isPage = handler instanceof INeiRecipeHandler && ((INeiRecipeHandler)handler).getStackForInfo() != null;
|
||||
this.neiButton.visible = isPage;
|
||||
|
||||
if(isPage && event.button.id == NEI_BUTTON_ID){
|
||||
for(BookletPage page : InitBooklet.pagesWithItemStackData){
|
||||
if(ItemUtil.contains(page.getItemStacksForPage(), ((INeiRecipeHandler)handler).getStackForInfo(), true)){
|
||||
GuiBooklet book = new GuiBooklet(Minecraft.getMinecraft().currentScreen);
|
||||
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
Minecraft.getMinecraft().displayGuiScreen(book);
|
||||
book.openIndexEntry(page.getChapter().entry, InitBooklet.entries.indexOf(page.getChapter().entry)/GuiBooklet.CHAPTER_BUTTONS_AMOUNT+1, true);
|
||||
book.openChapter(page.getChapter(), page);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* This file ("TreasureChestRecipeHandler.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://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.nei;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.RecipeInfo;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
||||
import ellpeck.actuallyadditions.recipe.TreasureChestHandler;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
public class TreasureChestRecipeHandler extends TemplateRecipeHandler implements INeiRecipeHandler{
|
||||
|
||||
public static final String NAME = "actuallyadditions.treasureChest";
|
||||
|
||||
public TreasureChestRecipeHandler(){
|
||||
super();
|
||||
RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackForInfo(){
|
||||
return new ItemStack(InitBlocks.blockTreasureChest);
|
||||
}
|
||||
|
||||
public class CachedTreasure extends CachedRecipe{
|
||||
|
||||
public PositionedStack result;
|
||||
public PositionedStack input;
|
||||
public int chance;
|
||||
public int minAmount;
|
||||
public int maxAmount;
|
||||
|
||||
public CachedTreasure(ItemStack input, ItemStack result, int chance, int minAmount, int maxAmount){
|
||||
this.result = new PositionedStack(result, 67+32, 19);
|
||||
this.chance = chance;
|
||||
this.input = new PositionedStack(input, 5+32, 19);
|
||||
this.minAmount = minAmount;
|
||||
this.maxAmount = maxAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getIngredient(){
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult(){
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiContainer> getGuiClass(){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName(){
|
||||
return StringUtil.localize("container.nei."+NAME+".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects(){
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(31+32, 18, 22, 16), NAME));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results){
|
||||
if(outputId.equals(NAME) && getClass() == TreasureChestRecipeHandler.class){
|
||||
ArrayList<TreasureChestHandler.Return> recipes = TreasureChestHandler.returns;
|
||||
for(TreasureChestHandler.Return recipe : recipes){
|
||||
arecipes.add(new CachedTreasure(recipe.input, recipe.returnItem, recipe.itemWeight, recipe.minAmount, recipe.maxAmount));
|
||||
}
|
||||
}
|
||||
else super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result){
|
||||
ArrayList<TreasureChestHandler.Return> recipes = TreasureChestHandler.returns;
|
||||
for(TreasureChestHandler.Return recipe : recipes){
|
||||
if(NEIServerUtils.areStacksSameType(recipe.returnItem, result)) arecipes.add(new CachedTreasure(recipe.input, recipe.returnItem, recipe.itemWeight, recipe.minAmount, recipe.maxAmount));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient){
|
||||
ArrayList<TreasureChestHandler.Return> recipes = TreasureChestHandler.returns;
|
||||
for(TreasureChestHandler.Return recipe : recipes){
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting(recipe.input, ingredient)){
|
||||
CachedTreasure theRecipe = new CachedTreasure(recipe.input, recipe.returnItem, recipe.itemWeight, recipe.minAmount, recipe.maxAmount);
|
||||
theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.input), ingredient);
|
||||
arecipes.add(theRecipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture(){
|
||||
return ModUtil.MOD_ID_LOWER + ":textures/gui/guiNEISimple.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipeIndex){
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GuiDraw.changeTexture(getGuiTexture());
|
||||
GuiDraw.drawTexturedModalRect(32, 0, 0, 0, 96, 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int rec){
|
||||
CachedTreasure recipe = (CachedTreasure)this.arecipes.get(rec);
|
||||
if(recipe.result != null){
|
||||
GuiDraw.drawString(recipe.minAmount+"-"+recipe.maxAmount+" "+StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".treasureChest.info")+" "+recipe.chance+"%", 55, 45, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier(){
|
||||
return NAME;
|
||||
}
|
||||
}
|
|
@ -19,6 +19,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
|
||||
public class CompatUtil{
|
||||
|
||||
public static final String NEI_MOD_ID = "NotEnoughItems";
|
||||
|
||||
public static void registerMFRPlant(Block block){
|
||||
FMLInterModComms.sendMessage("MineFactoryReloaded", "registerHarvestable_Crop", new ItemStack(block, 1, 7));
|
||||
|
||||
|
|
|
@ -10,6 +10,20 @@ key.actuallyadditions.openBooklet.name=Open Booklet in Inventory
|
|||
fluid.oil=Oil
|
||||
fluid.canolaoil=Canola Oil
|
||||
|
||||
#NEI Integration
|
||||
container.nei.actuallyadditions.crushing.name=Crusher
|
||||
container.nei.actuallyadditions.crushingDouble.name=Double Crusher
|
||||
container.nei.actuallyadditions.ballOfHair.name=Ball Of Hair Usage
|
||||
container.nei.actuallyadditions.compost.name=Compost
|
||||
container.nei.actuallyadditions.furnaceDouble.name=Double Furnace
|
||||
container.nei.actuallyadditions.treasureChest.name=Treasure Chest
|
||||
container.nei.actuallyadditions.treasureChest.info=Items at
|
||||
container.nei.actuallyadditions.coffee.name=Coffee Machine
|
||||
container.nei.actuallyadditions.coffee.special=Special Feature
|
||||
container.nei.actuallyadditions.coffee.maxAmount=Max Amount
|
||||
container.nei.actuallyadditions.coffee.shift=[SHIFT]!
|
||||
container.nei.actuallyadditions.coffee.extra.milk=+01:00, -1 Level
|
||||
|
||||
#Blocks
|
||||
tile.actuallyadditions.blockCompost.name=Compost
|
||||
tile.actuallyadditions.blockMiscOreBlackQuartz.name=Black Quartz Ore
|
||||
|
@ -391,7 +405,6 @@ booklet.actuallyadditions.indexEntry.itemsRF.name=Items that use RF
|
|||
booklet.actuallyadditions.recipeDisabled=The crafting recipe for this item is disabled in the Config File! If you're on a server, ask the server author to enable it in the config. If you're on a client, press the 'Open Config'-Button on the top right and enable the recipe!
|
||||
booklet.actuallyadditions.clickToSeeRecipe=Click to see more Information
|
||||
booklet.actuallyadditions.keyToSeeRecipe=Press %s to see more Information
|
||||
booklet.actuallyadditions.noBookletInInventory=Get an Actually Additions Manual to see more Information!
|
||||
|
||||
#Booklet Chapters
|
||||
booklet.actuallyadditions.chapter.intro.name=An Introduction to ActAdd
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 16 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Loading…
Reference in a new issue