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 00000000..5c51c8dc Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/gui/altar.png differ