Skip to content

Commit

Permalink
Updated to lotr renewed 4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
CraftedMods committed Sep 1, 2021
1 parent 120bdae commit 775166b
Show file tree
Hide file tree
Showing 11 changed files with 851 additions and 742 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog of JEI LOTR

## 3.0.0-BETA
* Updated to LOTR Renewed-4.5
* Added support for addons

## 2.0.0-BETA
* Updated to 1.16.5 and LOTR Renewed-3.0

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
The plugin adds JEI support for all devices and recipes added by the LOTR Mod.
## Dependencies
JEI LOTR has the following dependencies:
- [The Lord of the Rings Mod Renewed v3.0](https://www.curseforge.com/minecraft/mc-mods/the-lord-of-the-rings-mod-renewed/files)
- [The Lord of the Rings Mod Renewed v4.5](https://www.curseforge.com/minecraft/mc-mods/the-lord-of-the-rings-mod-renewed/files)
- [JEI 1.16.5-7.6.4.86](https://www.curseforge.com/minecraft/mc-mods/jei/files/all)

The plugin was created with the MinecraftForge version "1.16.5-36.1.0".
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: "net.minecrell.licenser"

version = '2.0.0-BETA'
version = '3.0.0-BETA'
group = 'craftedMods.jeiLotr' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'jeilotr'

Expand All @@ -34,7 +34,7 @@ minecraft {
// stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'official', version: '1.16.5'
mappings channel: 'snapshot', version: '20210309-1.16.5'
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
Expand Down Expand Up @@ -107,7 +107,7 @@ dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.16.5-36.1.0'
minecraft 'net.minecraftforge:forge:1.16.5-36.2.2'

compileOnly fg.deobf("mezz.jei:jei-${jei_mc_version}:${jei_version}")

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
jei_mc_version=1.16.5
jei_version=7.6.4.86
lotr_version=3.0
lotr_version=4.5
222 changes: 120 additions & 102 deletions src/main/java/craftedMods/jeiLotr/AlloyForge.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import lotr.common.recipe.AbstractAlloyForgeRecipe;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.drawable.IDrawableAnimated;
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;
Expand All @@ -33,107 +32,126 @@
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.AbstractCookingRecipe;
import net.minecraft.item.crafting.IRecipe;
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.get(forgeIcon.getDescriptionId());
}

@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.getResultItem());
}

@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, MatrixStack matrixStack, double mouseX, double mouseY) {
animatedFlame.draw(matrixStack, 35, 92);
arrow.draw(matrixStack, 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.font;
int stringWidth = fontRenderer.width(experienceString);
fontRenderer.draw(matrixStack, experienceString, background.getWidth() - stringWidth, 43.0f, -8355712);
}
}
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 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, MatrixStack matrixStack, double mouseX, double mouseY)
{
animatedFlame.draw (matrixStack, 35, 92);
arrow.draw (matrixStack, 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 (matrixStack, experienceString, background.getWidth () - stringWidth, 43.0f,
-8355712);
}
}

}
Loading

0 comments on commit 775166b

Please sign in to comment.