Added JEI Integration

This commit is contained in:
Kino 2017-03-11 23:44:00 -05:00
parent 9aa4a97d64
commit b343d4e634
10 changed files with 578 additions and 6 deletions

View file

@ -24,12 +24,12 @@ public class BlockRendering
public static void initialize()
{
register(BlocksAether.aether_grass, "aether_grass");
register(BlocksAether.aether_dirt, "aether_dirt");
register(BlocksAether.holystone, "holystone");
register(BlocksAether.mossy_holystone, "mossy_holystone");
register(BlocksAether.quicksoil, "quicksoil");
register(BlocksAether.ambrosium_ore, "ambrosium_ore");
registerD(BlocksAether.aether_grass, "aether_grass");
registerD(BlocksAether.aether_dirt, "aether_dirt");
registerD(BlocksAether.holystone, "holystone");
registerD(BlocksAether.mossy_holystone, "mossy_holystone");
registerD(BlocksAether.quicksoil, "quicksoil");
registerD(BlocksAether.ambrosium_ore, "ambrosium_ore");
register(BlocksAether.enchanted_aether_grass, "enchanted_aether_grass");
register(BlocksAether.holystone_brick, "holystone_brick");
register(BlocksAether.icestone, "icestone");
@ -139,6 +139,12 @@ public class BlockRendering
AetherEntityRenderingRegistry.registerTileEntities();
}
public static void registerD(Block block, String model)
{
register(block, 0, model);
register(block, 1, model);
}
public static void register(Block block, String model)
{
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(Aether.modAddress() + model, "inventory"));

View file

@ -0,0 +1,21 @@
package com.legacy.aether.universal;
import net.minecraftforge.fml.common.Loader;
public class AetherCompatibility
{
public static void initialization()
{
if (isLoaded("jei"))
{
}
}
public static boolean isLoaded(String modId)
{
return Loader.isModLoaded(modId);
}
}

View file

@ -0,0 +1,55 @@
package com.legacy.aether.universal.jei;
import mezz.jei.api.IJeiRuntime;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.ISubtypeRegistry;
import mezz.jei.api.JEIPlugin;
import mezz.jei.api.ingredients.IModIngredientRegistration;
import net.minecraft.item.ItemStack;
import com.legacy.aether.server.blocks.BlocksAether;
import com.legacy.aether.server.registry.AetherRegistry;
import com.legacy.aether.universal.jei.category.EnchanterRecipeCategory;
import com.legacy.aether.universal.jei.category.FreezerRecipeCategory;
import com.legacy.aether.universal.jei.handler.EnchanterRecipeHandler;
import com.legacy.aether.universal.jei.handler.FreezerRecipeHandler;
@JEIPlugin
public class AetherJEIPlugin implements IModPlugin
{
@Override
public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry)
{
}
@Override
public void registerIngredients(IModIngredientRegistration registry)
{
}
@Override
public void register(IModRegistry registry)
{
registry.addRecipeCategories(new EnchanterRecipeCategory(registry.getJeiHelpers().getGuiHelper()),
new FreezerRecipeCategory(registry.getJeiHelpers().getGuiHelper()));
registry.addRecipeHandlers(new EnchanterRecipeHandler(), new FreezerRecipeHandler());
registry.addRecipeCategoryCraftingItem(new ItemStack(BlocksAether.enchanter), "aether_legacy.enchantment");
registry.addRecipeCategoryCraftingItem(new ItemStack(BlocksAether.freezer), "aether_legacy.freezable");
registry.addRecipes(AetherRegistry.getEnchantables());
registry.addRecipes(AetherRegistry.getFreezables());
}
@Override
public void onRuntimeAvailable(IJeiRuntime jeiRuntime)
{
}
}

View file

@ -0,0 +1,109 @@
package com.legacy.aether.universal.jei.category;
import java.util.ArrayList;
import java.util.List;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IDrawableAnimated;
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.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import com.legacy.aether.server.Aether;
import com.legacy.aether.server.items.ItemsAether;
import com.legacy.aether.universal.jei.wrapper.EnchanterRecipeWrapper;
public class EnchanterRecipeCategory implements IRecipeCategory<EnchanterRecipeWrapper>
{
private static final ResourceLocation altar = Aether.locate("textures/gui/altar.png");
private IGuiHelper guiHelper;
private IDrawableAnimated flame, arrow;
public EnchanterRecipeCategory(IGuiHelper guiHelper)
{
this.guiHelper = guiHelper;
this.flame = guiHelper.createAnimatedDrawable(guiHelper.createDrawable(altar, 176, 0, 14, 14), 300, IDrawableAnimated.StartDirection.TOP, true);
this.arrow = guiHelper.createAnimatedDrawable(guiHelper.createDrawable(altar, 176, 14, 24, 17), 200, IDrawableAnimated.StartDirection.LEFT, false);
}
@Override
public String getUid()
{
return "aether_legacy.enchantment";
}
@Override
public String getTitle()
{
return "Aether Enchantments";
}
@Override
public IDrawable getBackground()
{
return this.guiHelper.createDrawable(altar, 25, 5, 146, 76);
}
@Override
public IDrawable getIcon()
{
return null;
}
@Override
public void drawExtras(Minecraft minecraft)
{
this.flame.draw(minecraft, 32, 30);
this.arrow.draw(minecraft, 54, 30);
}
@Override
public void drawAnimations(Minecraft minecraft)
{
}
@Override
public List<String> getTooltipStrings(int mouseX, int mouseY)
{
return new ArrayList<String>();
}
@Override
public void setRecipe(IRecipeLayout recipeLayout, EnchanterRecipeWrapper recipeWrapper)
{
IGuiItemStackGroup stacks = recipeLayout.getItemStacks();
stacks.init(0, false, 30, 11);
stacks.init(1, false, 30, 47);
stacks.init(2, true, 90, 29);
stacks.set(0, recipeWrapper.enchantment.getEnchantmentInput());
stacks.set(1, new ItemStack(ItemsAether.ambrosium_shard));
stacks.set(2, recipeWrapper.enchantment.getEnchantedResult());
}
@Override
public void setRecipe(IRecipeLayout recipeLayout, EnchanterRecipeWrapper recipeWrapper, IIngredients ingredients)
{
IGuiItemStackGroup stacks = recipeLayout.getItemStacks();
stacks.init(0, false, 30, 11);
stacks.init(1, false, 30, 47);
stacks.init(2, true, 90, 29);
stacks.set(0, recipeWrapper.enchantment.getEnchantmentInput());
stacks.set(1, new ItemStack(ItemsAether.ambrosium_shard));
stacks.set(2, recipeWrapper.enchantment.getEnchantedResult());
}
}

View file

@ -0,0 +1,109 @@
package com.legacy.aether.universal.jei.category;
import java.util.ArrayList;
import java.util.List;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IDrawableAnimated;
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.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import com.legacy.aether.server.Aether;
import com.legacy.aether.server.blocks.BlocksAether;
import com.legacy.aether.universal.jei.wrapper.FreezerRecipeWrapper;
public class FreezerRecipeCategory implements IRecipeCategory<FreezerRecipeWrapper>
{
private static final ResourceLocation altar = Aether.locate("textures/gui/altar.png");
private IGuiHelper guiHelper;
private IDrawableAnimated flame, arrow;
public FreezerRecipeCategory(IGuiHelper guiHelper)
{
this.guiHelper = guiHelper;
this.flame = guiHelper.createAnimatedDrawable(guiHelper.createDrawable(altar, 176, 0, 14, 14), 300, IDrawableAnimated.StartDirection.TOP, true);
this.arrow = guiHelper.createAnimatedDrawable(guiHelper.createDrawable(altar, 176, 14, 24, 17), 200, IDrawableAnimated.StartDirection.LEFT, false);
}
@Override
public String getUid()
{
return "aether_legacy.freezable";
}
@Override
public String getTitle()
{
return "Aether Freezables";
}
@Override
public IDrawable getBackground()
{
return this.guiHelper.createDrawable(altar, 25, 5, 146, 76);
}
@Override
public IDrawable getIcon()
{
return null;
}
@Override
public void drawExtras(Minecraft minecraft)
{
this.flame.draw(minecraft, 32, 30);
this.arrow.draw(minecraft, 54, 30);
}
@Override
public void drawAnimations(Minecraft minecraft)
{
}
@Override
public List<String> getTooltipStrings(int mouseX, int mouseY)
{
return new ArrayList<String>();
}
@Override
public void setRecipe(IRecipeLayout recipeLayout, FreezerRecipeWrapper recipeWrapper)
{
IGuiItemStackGroup stacks = recipeLayout.getItemStacks();
stacks.init(0, false, 30, 11);
stacks.init(1, false, 30, 47);
stacks.init(2, true, 90, 29);
stacks.set(0, recipeWrapper.freezable.getFreezableInput());
stacks.set(1, new ItemStack(BlocksAether.icestone));
stacks.set(2, recipeWrapper.freezable.getFrozenResult());
}
@Override
public void setRecipe(IRecipeLayout recipeLayout, FreezerRecipeWrapper recipeWrapper, IIngredients ingredients)
{
IGuiItemStackGroup stacks = recipeLayout.getItemStacks();
stacks.init(0, false, 30, 11);
stacks.init(1, false, 30, 47);
stacks.init(2, true, 90, 29);
stacks.set(0, recipeWrapper.freezable.getFreezableInput());
stacks.set(1, new ItemStack(BlocksAether.icestone));
stacks.set(2, recipeWrapper.freezable.getFrozenResult());
}
}

View file

@ -0,0 +1,42 @@
package com.legacy.aether.universal.jei.handler;
import com.legacy.aether.server.registry.objects.AetherEnchantment;
import com.legacy.aether.universal.jei.wrapper.EnchanterRecipeWrapper;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
public class EnchanterRecipeHandler implements IRecipeHandler<AetherEnchantment>
{
@Override
public Class<AetherEnchantment> getRecipeClass()
{
return AetherEnchantment.class;
}
@Override
public String getRecipeCategoryUid()
{
return "aether_legacy.enchantment";
}
@Override
public String getRecipeCategoryUid(AetherEnchantment recipe)
{
return this.getRecipeCategoryUid();
}
@Override
public IRecipeWrapper getRecipeWrapper(AetherEnchantment recipe)
{
return new EnchanterRecipeWrapper(recipe);
}
@Override
public boolean isRecipeValid(AetherEnchantment recipe)
{
return true;
}
}

View file

@ -0,0 +1,42 @@
package com.legacy.aether.universal.jei.handler;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import com.legacy.aether.server.registry.objects.AetherFreezable;
import com.legacy.aether.universal.jei.wrapper.FreezerRecipeWrapper;
public class FreezerRecipeHandler implements IRecipeHandler<AetherFreezable>
{
@Override
public Class<AetherFreezable> getRecipeClass()
{
return AetherFreezable.class;
}
@Override
public String getRecipeCategoryUid()
{
return "aether_legacy.freezable";
}
@Override
public String getRecipeCategoryUid(AetherFreezable recipe)
{
return this.getRecipeCategoryUid();
}
@Override
public IRecipeWrapper getRecipeWrapper(AetherFreezable recipe)
{
return new FreezerRecipeWrapper(recipe);
}
@Override
public boolean isRecipeValid(AetherFreezable recipe)
{
return true;
}
}

View file

@ -0,0 +1,94 @@
package com.legacy.aether.universal.jei.wrapper;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.Lists;
import com.legacy.aether.server.registry.AetherRegistry;
import com.legacy.aether.server.registry.objects.AetherEnchantment;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper;
public class EnchanterRecipeWrapper implements IRecipeWrapper
{
private final ArrayList<ItemStack> inputs;
private final ArrayList<ItemStack> outputs;
public AetherEnchantment enchantment;
public EnchanterRecipeWrapper(AetherEnchantment recipe)
{
this.enchantment = recipe;
this.inputs = Lists.newArrayList();
this.outputs = Lists.newArrayList();
for (AetherEnchantment enchantment : AetherRegistry.getEnchantables())
{
this.inputs.add(enchantment.getEnchantmentInput());
this.outputs.add(enchantment.getEnchantedResult());
}
}
@Override
public void getIngredients(IIngredients ingredients)
{
ingredients.setInput(ItemStack.class, this.enchantment.getEnchantmentInput());
ingredients.setOutput(ItemStack.class, this.enchantment.getEnchantedResult());
}
@Override
public List<ItemStack> getInputs()
{
return this.inputs;
}
@Override
public List<ItemStack> getOutputs()
{
return this.outputs;
}
@Override
public List<FluidStack> getFluidInputs()
{
return null;
}
@Override
public List<FluidStack> getFluidOutputs()
{
return null;
}
@Override
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY)
{
}
@Override
public void drawAnimations(Minecraft minecraft, int recipeWidth, int recipeHeight)
{
}
@Override
public List<String> getTooltipStrings(int mouseX, int mouseY)
{
return null;
}
@Override
public boolean handleClick(Minecraft minecraft, int mouseX, int mouseY, int mouseButton)
{
return false;
}
}

View file

@ -0,0 +1,94 @@
package com.legacy.aether.universal.jei.wrapper;
import java.util.ArrayList;
import java.util.List;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import com.google.common.collect.Lists;
import com.legacy.aether.server.registry.AetherRegistry;
import com.legacy.aether.server.registry.objects.AetherFreezable;
public class FreezerRecipeWrapper implements IRecipeWrapper
{
private final ArrayList<ItemStack> inputs;
private final ArrayList<ItemStack> outputs;
public AetherFreezable freezable;
public FreezerRecipeWrapper(AetherFreezable recipe)
{
this.freezable = recipe;
this.inputs = Lists.newArrayList();
this.outputs = Lists.newArrayList();
for (AetherFreezable freezable : AetherRegistry.getFreezables())
{
this.inputs.add(freezable.getFreezableInput());
this.outputs.add(freezable.getFrozenResult());
}
}
@Override
public void getIngredients(IIngredients ingredients)
{
ingredients.setInput(ItemStack.class, this.freezable.getFreezableInput());
ingredients.setOutput(ItemStack.class, this.freezable.getFrozenResult());
}
@Override
public List<ItemStack> getInputs()
{
return this.inputs;
}
@Override
public List<ItemStack> getOutputs()
{
return this.outputs;
}
@Override
public List<FluidStack> getFluidInputs()
{
return null;
}
@Override
public List<FluidStack> getFluidOutputs()
{
return null;
}
@Override
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY)
{
}
@Override
public void drawAnimations(Minecraft minecraft, int recipeWidth, int recipeHeight)
{
}
@Override
public List<String> getTooltipStrings(int mouseX, int mouseY)
{
return null;
}
@Override
public boolean handleClick(Minecraft minecraft, int mouseX, int mouseY, int mouseButton)
{
return false;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB