Skip to content

Commit

Permalink
Applied formatting and cleanup settings
Browse files Browse the repository at this point in the history
  • Loading branch information
CraftedMods committed Aug 23, 2020
1 parent 3b3d948 commit 60b5cf9
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 152 deletions.
277 changes: 139 additions & 138 deletions src/main/java/craftedMods/jeiLotr/AlloyForge.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<IRecipe<?>>
{

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<? extends IRecipe<?>> getRecipeClass ()
{
return (Class<? extends IRecipe<?>>) (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<IRecipe<?>>
{

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<? extends IRecipe<?>> getRecipeClass ()
{
return (Class<? extends IRecipe<?>>) (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);
}
}

}
14 changes: 8 additions & 6 deletions src/main/java/craftedMods/jeiLotr/JEIPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ public void registerGuiHandlers (IGuiHandlerRegistration registration)
registration.addGuiContainerHandler (LOTRGuiCrafting.class, new IGuiContainerHandler<LOTRGuiCrafting> ()
{

@Override
public Collection<IGuiClickableArea> getGuiClickableAreas (LOTRGuiCrafting containerScreen, double mouseX,
double mouseY)
{
Expand All @@ -269,6 +270,7 @@ public Collection<IGuiClickableArea> getGuiClickableAreas (LOTRGuiCrafting conta
registration.addGuiContainerHandler (AlloyForgeScreen.class, new IGuiContainerHandler<AlloyForgeScreen> ()
{

@Override
public Collection<IGuiClickableArea> getGuiClickableAreas (AlloyForgeScreen containerScreen,
double mouseX,
double mouseY)
Expand Down Expand Up @@ -315,7 +317,7 @@ public LOTRKeg (ResourceLocation uid, ItemStack icon, Collection<IRecipeType<?>>
@Override
public IRecipeCategory<?> createCategoryInstance (IGuiHelper guiHelper, IModIdHelper modIdHelper)
{
return new Keg (this.uid, this.icon, guiHelper);
return new Keg (uid, icon, guiHelper);
}

@Override
Expand All @@ -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);
}

}
Expand All @@ -346,7 +348,7 @@ public LOTRAlloyForge (ResourceLocation uid, ItemStack icon, Collection<IRecipeT
@Override
public IRecipeCategory<?> createCategoryInstance (IGuiHelper guiHelper, IModIdHelper modIdHelper)
{
return new AlloyForge (this.uid, this.icon, guiHelper);
return new AlloyForge (uid, icon, guiHelper);
}

@Override
Expand Down Expand Up @@ -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);
}

}
Expand All @@ -424,7 +426,7 @@ public LOTRCraftingTable (ResourceLocation uid, ItemStack icon, Collection<IReci
@Override
public IRecipeCategory<?> createCategoryInstance (IGuiHelper guiHelper, IModIdHelper modIdHelper)
{
return new FactionCraftingTable (this.uid, this.icon, guiHelper, modIdHelper);
return new FactionCraftingTable (uid, icon, guiHelper, modIdHelper);
}

@SuppressWarnings("resource")
Expand All @@ -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);
Expand Down
Loading

0 comments on commit 60b5cf9

Please sign in to comment.