diff --git a/src/main/java/craftedMods/jeiLotr/AlloyForge.java b/src/main/java/craftedMods/jeiLotr/AlloyForge.java index aed89f8..7ac8553 100644 --- a/src/main/java/craftedMods/jeiLotr/AlloyForge.java +++ b/src/main/java/craftedMods/jeiLotr/AlloyForge.java @@ -16,141 +16,142 @@ */ package craftedMods.jeiLotr; - -import lotr.common.recipe.AbstractAlloyForgeRecipe; -import mezz.jei.api.constants.VanillaTypes; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.gui.drawable.*; -import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; -import mezz.jei.api.helpers.IGuiHelper; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.plugins.vanilla.cooking.FurnaceVariantCategory; -import mezz.jei.util.Translator; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.*; -import net.minecraft.util.ResourceLocation; - -public class AlloyForge extends FurnaceVariantCategory> -{ - - private final ResourceLocation uid; - private final ItemStack forgeIcon; - private final IDrawable icon; - private final IDrawable background; - private final IDrawable arrow; - - public static final ResourceLocation ALLOY_FORGE_GUI_LOCATION = new ResourceLocation ( - "lotr:textures/gui/alloy_forge.png"); - - public AlloyForge (ResourceLocation uid, ItemStack forgeIcon, IGuiHelper guiHelper) - { - super (guiHelper); - this.uid = uid; - this.forgeIcon = forgeIcon; - this.icon = guiHelper.createDrawableIngredient (forgeIcon); - this.background = guiHelper.createDrawable (ALLOY_FORGE_GUI_LOCATION, 45, 20, 85, 130); - this.arrow = guiHelper - .drawableBuilder (ALLOY_FORGE_GUI_LOCATION, 176, 14, 16, 30) - .buildAnimated (200, IDrawableAnimated.StartDirection.TOP, false); - } - - @Override - public ResourceLocation getUid () - { - return uid; - } - - @Override - public String getTitle () - { - return I18n.format (forgeIcon.getTranslationKey ()); - } - - @Override - public IDrawable getIcon () - { - return this.icon; - } - - @Override - public IDrawable getBackground () - { - return this.background; - } - - @Override - @SuppressWarnings("unchecked") - public Class> getRecipeClass () - { - return (Class>) (Class) IRecipe.class; - } - - @Override - public void setIngredients (IRecipe recipe, IIngredients ingreds) - { - ingreds.setInputIngredients (recipe.getIngredients ()); - ingreds.setOutput (VanillaTypes.ITEM, recipe.getRecipeOutput ()); - } - - @Override - public void setRecipe (IRecipeLayout layout, IRecipe recipe, IIngredients ingreds) - { - IGuiItemStackGroup guiItemStacks = layout.getItemStacks (); - - for (int i = 0; i < 4; i++) - { - guiItemStacks.init (i, true, 7 + 18 * i, 18); - guiItemStacks.set (i, ingreds.getInputs (VanillaTypes.ITEM).get (0)); - } - - // Alloy items are not required - if (ingreds.getInputs (VanillaTypes.ITEM).size () > 1) - { - for (int i = 0; i < 4; i++) - { - guiItemStacks.init (i + 4, true, 7 + 18 * i, 0); - guiItemStacks.set (i + 4, ingreds.getInputs (VanillaTypes.ITEM).get (1)); - } - } - - for (int i = 0; i < 4; i++) - { - guiItemStacks.init (i + 8, false, 7 + 18 * i, 64); - guiItemStacks.set (i + 8, ingreds.getOutputs (VanillaTypes.ITEM).get (0)); - } - } - - public void draw (IRecipe recipe, double mouseX, double mouseY) - { - this.animatedFlame.draw (35, 92); - this.arrow.draw (35, 38); - - float experience = 0f; - - if (recipe instanceof AbstractCookingRecipe) - { - experience = ((AbstractCookingRecipe) recipe).getExperience (); - } - else if (recipe instanceof AbstractAlloyForgeRecipe) - { - experience = ((AbstractAlloyForgeRecipe) recipe).getExperience (); - } - - if (experience > 0.0f) - { - String experienceString = Translator.translateToLocalFormatted ( - (String) "gui.jei.category.smelting.experience", - (Object[]) new Object[] - {Float.valueOf (experience)}); - Minecraft minecraft = Minecraft.getInstance (); - FontRenderer fontRenderer = minecraft.fontRenderer; - int stringWidth = fontRenderer.getStringWidth (experienceString); - fontRenderer.drawString (experienceString, (float) (this.background.getWidth () - stringWidth), 43.0f, - -8355712); - } - } - -} + +import lotr.common.recipe.AbstractAlloyForgeRecipe; +import mezz.jei.api.constants.VanillaTypes; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.drawable.*; +import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; +import mezz.jei.api.helpers.IGuiHelper; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.plugins.vanilla.cooking.FurnaceVariantCategory; +import mezz.jei.util.Translator; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.*; +import net.minecraft.util.ResourceLocation; + +public class AlloyForge extends FurnaceVariantCategory> +{ + + private final ResourceLocation uid; + private final ItemStack forgeIcon; + private final IDrawable icon; + private final IDrawable background; + private final IDrawable arrow; + + public static final ResourceLocation ALLOY_FORGE_GUI_LOCATION = new ResourceLocation ( + "lotr:textures/gui/alloy_forge.png"); + + public AlloyForge (ResourceLocation uid, ItemStack forgeIcon, IGuiHelper guiHelper) + { + super (guiHelper); + this.uid = uid; + this.forgeIcon = forgeIcon; + icon = guiHelper.createDrawableIngredient (forgeIcon); + background = guiHelper.createDrawable (ALLOY_FORGE_GUI_LOCATION, 45, 20, 85, 130); + arrow = guiHelper + .drawableBuilder (ALLOY_FORGE_GUI_LOCATION, 176, 14, 16, 30) + .buildAnimated (200, IDrawableAnimated.StartDirection.TOP, false); + } + + @Override + public ResourceLocation getUid () + { + return uid; + } + + @Override + public String getTitle () + { + return I18n.format (forgeIcon.getTranslationKey ()); + } + + @Override + public IDrawable getIcon () + { + return icon; + } + + @Override + public IDrawable getBackground () + { + return background; + } + + @Override + @SuppressWarnings("unchecked") + public Class> getRecipeClass () + { + return (Class>) (Class) IRecipe.class; + } + + @Override + public void setIngredients (IRecipe recipe, IIngredients ingreds) + { + ingreds.setInputIngredients (recipe.getIngredients ()); + ingreds.setOutput (VanillaTypes.ITEM, recipe.getRecipeOutput ()); + } + + @Override + public void setRecipe (IRecipeLayout layout, IRecipe recipe, IIngredients ingreds) + { + IGuiItemStackGroup guiItemStacks = layout.getItemStacks (); + + for (int i = 0; i < 4; i++) + { + guiItemStacks.init (i, true, 7 + 18 * i, 18); + guiItemStacks.set (i, ingreds.getInputs (VanillaTypes.ITEM).get (0)); + } + + // Alloy items are not required + if (ingreds.getInputs (VanillaTypes.ITEM).size () > 1) + { + for (int i = 0; i < 4; i++) + { + guiItemStacks.init (i + 4, true, 7 + 18 * i, 0); + guiItemStacks.set (i + 4, ingreds.getInputs (VanillaTypes.ITEM).get (1)); + } + } + + for (int i = 0; i < 4; i++) + { + guiItemStacks.init (i + 8, false, 7 + 18 * i, 64); + guiItemStacks.set (i + 8, ingreds.getOutputs (VanillaTypes.ITEM).get (0)); + } + } + + @Override + public void draw (IRecipe recipe, double mouseX, double mouseY) + { + animatedFlame.draw (35, 92); + arrow.draw (35, 38); + + float experience = 0f; + + if (recipe instanceof AbstractCookingRecipe) + { + experience = ((AbstractCookingRecipe) recipe).getExperience (); + } + else if (recipe instanceof AbstractAlloyForgeRecipe) + { + experience = ((AbstractAlloyForgeRecipe) recipe).getExperience (); + } + + if (experience > 0.0f) + { + String experienceString = Translator.translateToLocalFormatted ( + "gui.jei.category.smelting.experience", + new Object[] + {Float.valueOf (experience)}); + Minecraft minecraft = Minecraft.getInstance (); + FontRenderer fontRenderer = minecraft.fontRenderer; + int stringWidth = fontRenderer.getStringWidth (experienceString); + fontRenderer.drawString (experienceString, background.getWidth () - stringWidth, 43.0f, + -8355712); + } + } + +} diff --git a/src/main/java/craftedMods/jeiLotr/JEIPlugin.java b/src/main/java/craftedMods/jeiLotr/JEIPlugin.java index 1786064..d6cd42e 100644 --- a/src/main/java/craftedMods/jeiLotr/JEIPlugin.java +++ b/src/main/java/craftedMods/jeiLotr/JEIPlugin.java @@ -251,6 +251,7 @@ public void registerGuiHandlers (IGuiHandlerRegistration registration) registration.addGuiContainerHandler (LOTRGuiCrafting.class, new IGuiContainerHandler () { + @Override public Collection getGuiClickableAreas (LOTRGuiCrafting containerScreen, double mouseX, double mouseY) { @@ -269,6 +270,7 @@ public Collection getGuiClickableAreas (LOTRGuiCrafting conta registration.addGuiContainerHandler (AlloyForgeScreen.class, new IGuiContainerHandler () { + @Override public Collection getGuiClickableAreas (AlloyForgeScreen containerScreen, double mouseX, double mouseY) @@ -315,7 +317,7 @@ public LOTRKeg (ResourceLocation uid, ItemStack icon, Collection> @Override public IRecipeCategory createCategoryInstance (IGuiHelper guiHelper, IModIdHelper modIdHelper) { - return new Keg (this.uid, this.icon, guiHelper); + return new Keg (uid, icon, guiHelper); } @Override @@ -324,7 +326,7 @@ public void registerTransferHandlers (IRecipeTransferRegistration registration) super.registerTransferHandlers (registration); registration.addRecipeTransferHandler (KegContainer.class, - this.uid, 0, 9, 10, 36); + uid, 0, 9, 10, 36); } } @@ -346,7 +348,7 @@ public LOTRAlloyForge (ResourceLocation uid, ItemStack icon, Collection createCategoryInstance (IGuiHelper guiHelper, IModIdHelper modIdHelper) { - return new AlloyForge (this.uid, this.icon, guiHelper); + return new AlloyForge (uid, icon, guiHelper); } @Override @@ -404,7 +406,7 @@ public void registerTransferHandlers (IRecipeTransferRegistration registration) { super.registerTransferHandlers (registration); - registration.addRecipeTransferHandler (AlloyForgeContainer.class, this.uid, 0, 8, 13, 36); + registration.addRecipeTransferHandler (AlloyForgeContainer.class, uid, 0, 8, 13, 36); } } @@ -424,7 +426,7 @@ public LOTRCraftingTable (ResourceLocation uid, ItemStack icon, Collection createCategoryInstance (IGuiHelper guiHelper, IModIdHelper modIdHelper) { - return new FactionCraftingTable (this.uid, this.icon, guiHelper, modIdHelper); + return new FactionCraftingTable (uid, icon, guiHelper, modIdHelper); } @SuppressWarnings("resource") @@ -435,7 +437,7 @@ public void registerTransferHandlers (IRecipeTransferRegistration registration) registration.addRecipeTransferHandler ( container.get ().create (0, Minecraft.getInstance ().player.inventory).getClass (), - this.uid, 1, 9, 10, 36); + uid, 1, 9, 10, 36); registration.addRecipeTransferHandler ( container.get ().create (0, Minecraft.getInstance ().player.inventory).getClass (), VanillaRecipeCategoryUid.CRAFTING, 1, 9, 10, 36); diff --git a/src/main/java/craftedMods/jeiLotr/Keg.java b/src/main/java/craftedMods/jeiLotr/Keg.java index 582ec40..e0bab57 100644 --- a/src/main/java/craftedMods/jeiLotr/Keg.java +++ b/src/main/java/craftedMods/jeiLotr/Keg.java @@ -50,8 +50,8 @@ public Keg (ResourceLocation uid, ItemStack forgeIcon, IGuiHelper guiHelper) { this.uid = uid; this.forgeIcon = forgeIcon; - this.icon = guiHelper.createDrawableIngredient (forgeIcon); - this.background = guiHelper.createDrawable (Constants.RECIPE_GUI_VANILLA, 0, 60, 116, 54); + icon = guiHelper.createDrawableIngredient (forgeIcon); + background = guiHelper.createDrawable (Constants.RECIPE_GUI_VANILLA, 0, 60, 116, 54); } @Override @@ -69,13 +69,13 @@ public String getTitle () @Override public IDrawable getIcon () { - return this.icon; + return icon; } @Override public IDrawable getBackground () { - return this.background; + return background; } @Override @@ -129,6 +129,7 @@ public void setRecipe (IRecipeLayout layout, DrinkBrewingRecipe recipe, IIngredi guiItemStacks.set (9, resultItems); } + @Override public void draw (DrinkBrewingRecipe recipe, double mouseX, double mouseY) { Minecraft minecraft = Minecraft.getInstance (); @@ -139,12 +140,12 @@ public void draw (DrinkBrewingRecipe recipe, double mouseX, double mouseY) if (experience > 0.0f) { String experienceString = Translator.translateToLocalFormatted ( - (String) "gui.jei.category.smelting.experience", - (Object[]) new Object[] + "gui.jei.category.smelting.experience", + new Object[] {Float.valueOf (experience)}); int stringWidth = fontRenderer.getStringWidth (experienceString); - fontRenderer.drawString (experienceString, (float) (this.background.getWidth () - stringWidth), 0.0f, + fontRenderer.drawString (experienceString, background.getWidth () - stringWidth, 0.0f, -8355712); } @@ -152,7 +153,7 @@ public void draw (DrinkBrewingRecipe recipe, double mouseX, double mouseY) int stringWidth = fontRenderer.getStringWidth (brewingTimeString); fontRenderer.drawString (brewingTimeString, - (float) (this.background.getWidth () - stringWidth), 45.0f, + background.getWidth () - stringWidth, 45.0f, -8355712); }