From 2b4bea5e9794832e7c1443d36295ca68c80dd3f7 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 18 Oct 2018 18:00:21 +0200 Subject: [PATCH] jay ee eye for altar --- .../java/de/ellpeck/naturesaura/Helper.java | 17 +++++ .../naturesaura/jei/JEINaturesAuraPlugin.java | 10 ++- .../naturesaura/jei/altar/AltarCategory.java | 62 ++++++++++++++++++ .../naturesaura/jei/altar/AltarWrapper.java | 21 ++++++ .../assets/naturesaura/lang/en_US.lang | 3 +- .../assets/naturesaura/textures/gui/altar.png | Bin 0 -> 2040 bytes 6 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 src/main/java/de/ellpeck/naturesaura/jei/altar/AltarCategory.java create mode 100644 src/main/java/de/ellpeck/naturesaura/jei/altar/AltarWrapper.java create mode 100644 src/main/resources/assets/naturesaura/textures/gui/altar.png diff --git a/src/main/java/de/ellpeck/naturesaura/Helper.java b/src/main/java/de/ellpeck/naturesaura/Helper.java index 130f3d1f..17abd30d 100644 --- a/src/main/java/de/ellpeck/naturesaura/Helper.java +++ b/src/main/java/de/ellpeck/naturesaura/Helper.java @@ -15,6 +15,7 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.IItemHandlerModifiable; +import org.lwjgl.opengl.GL11; import java.util.ArrayList; import java.util.List; @@ -78,6 +79,22 @@ public final class Helper { } } + @SideOnly(Side.CLIENT) + public static void renderItemInGui(ItemStack stack, int x, int y, float scale) { + GlStateManager.pushMatrix(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + RenderHelper.enableGUIStandardItemLighting(); + GlStateManager.enableDepth(); + GlStateManager.enableRescaleNormal(); + GlStateManager.translate(x, y, 0); + GlStateManager.scale(scale, scale, scale); + Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(stack, 0, 0); + Minecraft.getMinecraft().getRenderItem().renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRenderer, stack, 0, 0, null); + RenderHelper.disableStandardItemLighting(); + GlStateManager.popMatrix(); + } + public static boolean putStackOnTile(EntityPlayer player, EnumHand hand, BlockPos pos, int slot) { TileEntity tile = player.world.getTileEntity(pos); if (tile instanceof TileEntityImpl) { diff --git a/src/main/java/de/ellpeck/naturesaura/jei/JEINaturesAuraPlugin.java b/src/main/java/de/ellpeck/naturesaura/jei/JEINaturesAuraPlugin.java index 8dfffeae..4935929a 100644 --- a/src/main/java/de/ellpeck/naturesaura/jei/JEINaturesAuraPlugin.java +++ b/src/main/java/de/ellpeck/naturesaura/jei/JEINaturesAuraPlugin.java @@ -2,8 +2,11 @@ package de.ellpeck.naturesaura.jei; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.blocks.ModBlocks; +import de.ellpeck.naturesaura.jei.altar.AltarCategory; +import de.ellpeck.naturesaura.jei.altar.AltarWrapper; import de.ellpeck.naturesaura.jei.treeritual.TreeRitualCategory; import de.ellpeck.naturesaura.jei.treeritual.TreeRitualWrapper; +import de.ellpeck.naturesaura.recipes.AltarRecipe; import de.ellpeck.naturesaura.recipes.TreeRitualRecipe; import mezz.jei.api.IGuiHelper; import mezz.jei.api.IModPlugin; @@ -16,22 +19,27 @@ import net.minecraft.item.ItemStack; public class JEINaturesAuraPlugin implements IModPlugin { public static final String TREE_RITUAL = NaturesAura.MOD_ID + ".tree_ritual"; + public static final String ALTAR = NaturesAura.MOD_ID + ".altar"; @Override public void registerCategories(IRecipeCategoryRegistration registry) { IGuiHelper helper = registry.getJeiHelpers().getGuiHelper(); registry.addRecipeCategories( - new TreeRitualCategory(helper) + new TreeRitualCategory(helper), + new AltarCategory(helper) ); } @Override public void register(IModRegistry registry) { registry.handleRecipes(TreeRitualRecipe.class, TreeRitualWrapper::new, TREE_RITUAL); + registry.handleRecipes(AltarRecipe.class, AltarWrapper::new, ALTAR); registry.addRecipes(TreeRitualRecipe.RECIPES, TREE_RITUAL); + registry.addRecipes(AltarRecipe.RECIPES, ALTAR); registry.addRecipeCatalyst(new ItemStack(ModBlocks.GOLD_POWDER), TREE_RITUAL); registry.addRecipeCatalyst(new ItemStack(ModBlocks.WOOD_STAND), TREE_RITUAL); + registry.addRecipeCatalyst(new ItemStack(ModBlocks.NATURE_ALTAR), ALTAR); } } diff --git a/src/main/java/de/ellpeck/naturesaura/jei/altar/AltarCategory.java b/src/main/java/de/ellpeck/naturesaura/jei/altar/AltarCategory.java new file mode 100644 index 00000000..35a2ec85 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/jei/altar/AltarCategory.java @@ -0,0 +1,62 @@ +package de.ellpeck.naturesaura.jei.altar; + +import de.ellpeck.naturesaura.Helper; +import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.blocks.ModBlocks; +import de.ellpeck.naturesaura.jei.JEINaturesAuraPlugin; +import de.ellpeck.naturesaura.recipes.AltarRecipe; +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IGuiItemStackGroup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IRecipeCategory; +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +public class AltarCategory implements IRecipeCategory { + + private final IDrawable background; + private final ItemStack altar = new ItemStack(ModBlocks.NATURE_ALTAR); + + public AltarCategory(IGuiHelper helper) { + this.background = helper.createDrawable(new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/altar.png"), 0, 0, 78, 57); + } + + @Override + public String getUid() { + return JEINaturesAuraPlugin.ALTAR; + } + + @Override + public String getTitle() { + return I18n.format("container." + JEINaturesAuraPlugin.ALTAR + ".name"); + } + + @Override + public String getModName() { + return NaturesAura.MOD_NAME; + } + + @Override + public IDrawable getBackground() { + return this.background; + } + + @Override + public void drawExtras(Minecraft minecraft) { + Helper.renderItemInGui(this.altar, 26, 19, 1F); + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, AltarWrapper recipeWrapper, IIngredients ingredients) { + IGuiItemStackGroup group = recipeLayout.getItemStacks(); + AltarRecipe recipe = recipeWrapper.recipe; + group.init(0, true, 0, 18); + group.set(0, recipe.input); + group.init(1, false, 56, 18); + group.set(1, recipe.output); + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/jei/altar/AltarWrapper.java b/src/main/java/de/ellpeck/naturesaura/jei/altar/AltarWrapper.java new file mode 100644 index 00000000..257c45ac --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/jei/altar/AltarWrapper.java @@ -0,0 +1,21 @@ +package de.ellpeck.naturesaura.jei.altar; + +import de.ellpeck.naturesaura.recipes.AltarRecipe; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; +import mezz.jei.api.recipe.IRecipeWrapper; + +public class AltarWrapper implements IRecipeWrapper { + + public final AltarRecipe recipe; + + public AltarWrapper(AltarRecipe recipe) { + this.recipe = recipe; + } + + @Override + public void getIngredients(IIngredients ingredients) { + ingredients.setInput(VanillaTypes.ITEM, this.recipe.input); + ingredients.setOutput(VanillaTypes.ITEM, this.recipe.output); + } +} diff --git a/src/main/resources/assets/naturesaura/lang/en_US.lang b/src/main/resources/assets/naturesaura/lang/en_US.lang index 1428de36..4fa6ad62 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -15,4 +15,5 @@ item.naturesaura.gold_fiber.name=Brilliant Fiber item.naturesaura.gold_leaf.name=Gold Leaf item.naturesaura.infused_iron.name=Infused Iron -container.naturesaura.tree_ritual.name=Tree Infusion \ No newline at end of file +container.naturesaura.tree_ritual.name=Tree Infusion +container.naturesaura.altar.name=Natural Altar \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/textures/gui/altar.png b/src/main/resources/assets/naturesaura/textures/gui/altar.png new file mode 100644 index 0000000000000000000000000000000000000000..5c51c8dcec557548dda997957c3a873ba6cc59a4 GIT binary patch literal 2040 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G$6&2?&#~tz_78O`%fY(kk47* z5n0T@z_%ZS87)|YRe*vLC9V-A!TD(=<%vb93~dWL$2$y#%~85r2h zJY5_^D&pQ=Pwcz1LaOcJ8?Ej$`!=n;BfZjV(+u-g-)89#l}kP^KbE)Ve1dP?pMQUU z^I!kFU*6`r+0wJVu{#wjrsaCg{{8m)`uOeM=M5JZIe*Z(J;m&MwAF&eOP|jOgelOK zy>RhT@tGBO1Z++Nb^a~8esE9r+QUym@K0`-?a$m;CZNhN?>W3lrmxiXVwNb;)%89NoLtK=Tx% zX7V$*BMf>eu=Wgl!{SXPXVufazxQ3(`+a}*{zvZ@dbEGE-ZMXaN%%)r!|4cFIreAy zFAeJ0GuhCpLSPX)MJ2?14qHJi862W;>;NUJE&sRKi<(C@WUDNmkOP_it`Wa81x8C*orDywYf2?1B zxqg1&&!8EXeU?7YzPNSE&iCK$$~R0aJw5%<9EfX{o~_;f{tv^Jb+P+Io|%B1q?`M0 z_g1+>>#f#Rm;U{<)L=QpDVfFh*FI&ayIOcQXxF|F6xFe|HSwh}?}6#m9n}R>o4k?qCrn(+@W61&9N(jfR1yTdg(%f_^K&wY`X)NnwZ>Z)mpmnpk9b3FK^jG zugr`MLr$sa%7rE#5fi1nnp;R=UR|-##3!Ox%KLE3pl7OhPNF|r^8efO^YRZCKI%VU zd_=x6y~CdAyg)t6JjH(;HqL(pE82c2f8hD({y>r}1qbKL|7T8}CC$B{jQI?(mS*sD L^>bP0l+XkK?b_so literal 0 HcmV?d00001