jay ee eye for altar

This commit is contained in:
Ellpeck 2018-10-18 18:00:21 +02:00
parent ef8c64c782
commit 2b4bea5e97
6 changed files with 111 additions and 2 deletions

View file

@ -15,6 +15,7 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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) { public static boolean putStackOnTile(EntityPlayer player, EnumHand hand, BlockPos pos, int slot) {
TileEntity tile = player.world.getTileEntity(pos); TileEntity tile = player.world.getTileEntity(pos);
if (tile instanceof TileEntityImpl) { if (tile instanceof TileEntityImpl) {

View file

@ -2,8 +2,11 @@ package de.ellpeck.naturesaura.jei;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.blocks.ModBlocks; 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.TreeRitualCategory;
import de.ellpeck.naturesaura.jei.treeritual.TreeRitualWrapper; import de.ellpeck.naturesaura.jei.treeritual.TreeRitualWrapper;
import de.ellpeck.naturesaura.recipes.AltarRecipe;
import de.ellpeck.naturesaura.recipes.TreeRitualRecipe; import de.ellpeck.naturesaura.recipes.TreeRitualRecipe;
import mezz.jei.api.IGuiHelper; import mezz.jei.api.IGuiHelper;
import mezz.jei.api.IModPlugin; import mezz.jei.api.IModPlugin;
@ -16,22 +19,27 @@ import net.minecraft.item.ItemStack;
public class JEINaturesAuraPlugin implements IModPlugin { public class JEINaturesAuraPlugin implements IModPlugin {
public static final String TREE_RITUAL = NaturesAura.MOD_ID + ".tree_ritual"; public static final String TREE_RITUAL = NaturesAura.MOD_ID + ".tree_ritual";
public static final String ALTAR = NaturesAura.MOD_ID + ".altar";
@Override @Override
public void registerCategories(IRecipeCategoryRegistration registry) { public void registerCategories(IRecipeCategoryRegistration registry) {
IGuiHelper helper = registry.getJeiHelpers().getGuiHelper(); IGuiHelper helper = registry.getJeiHelpers().getGuiHelper();
registry.addRecipeCategories( registry.addRecipeCategories(
new TreeRitualCategory(helper) new TreeRitualCategory(helper),
new AltarCategory(helper)
); );
} }
@Override @Override
public void register(IModRegistry registry) { public void register(IModRegistry registry) {
registry.handleRecipes(TreeRitualRecipe.class, TreeRitualWrapper::new, TREE_RITUAL); registry.handleRecipes(TreeRitualRecipe.class, TreeRitualWrapper::new, TREE_RITUAL);
registry.handleRecipes(AltarRecipe.class, AltarWrapper::new, ALTAR);
registry.addRecipes(TreeRitualRecipe.RECIPES, TREE_RITUAL); 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.GOLD_POWDER), TREE_RITUAL);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.WOOD_STAND), TREE_RITUAL); registry.addRecipeCatalyst(new ItemStack(ModBlocks.WOOD_STAND), TREE_RITUAL);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.NATURE_ALTAR), ALTAR);
} }
} }

View file

@ -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<AltarWrapper> {
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);
}
}

View file

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

View file

@ -16,3 +16,4 @@ item.naturesaura.gold_leaf.name=Gold Leaf
item.naturesaura.infused_iron.name=Infused Iron item.naturesaura.infused_iron.name=Infused Iron
container.naturesaura.tree_ritual.name=Tree Infusion container.naturesaura.tree_ritual.name=Tree Infusion
container.naturesaura.altar.name=Natural Altar

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB