Added Alchemy Recipe Handler for NEI

This commit is contained in:
joshiejack 2014-01-19 01:55:08 +00:00
parent e116b021c9
commit 43fda5138e
3 changed files with 170 additions and 0 deletions

View file

@ -0,0 +1,137 @@
package joshie.alchemicalWizardy.nei;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import WayofTime.alchemicalWizardry.common.alchemy.AlchemyRecipe;
import WayofTime.alchemicalWizardry.common.alchemy.AlchemyRecipeRegistry;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
public class NEIAlchemyRecipeHandler extends TemplateRecipeHandler {
public static ArrayList<Item> bloodOrbs;
public class CachedAlchemyRecipe extends CachedRecipe {
public class BloodOrbs {
public PositionedStack stack;
public BloodOrbs(ItemStack orb) {
this.stack = new PositionedStack(orb, 136, 47, false);
}
}
ArrayList<BloodOrbs> orbs;
AlchemyRecipe recipe;
PositionedStack output;
List<PositionedStack> inputs;
int lp;
public CachedAlchemyRecipe(AlchemyRecipe recipe) {
this.recipe = recipe;
List<PositionedStack> inputs = new ArrayList<PositionedStack>();
ItemStack[] stacks = recipe.getRecipe();
if(stacks.length > 0)
inputs.add(new PositionedStack(stacks[0], 76, 3));
if(stacks.length > 1)
inputs.add(new PositionedStack(stacks[1], 51, 19));
if(stacks.length > 2)
inputs.add(new PositionedStack(stacks[2], 101, 19));
if(stacks.length > 3)
inputs.add(new PositionedStack(stacks[3], 64, 47));
if(stacks.length > 4)
inputs.add(new PositionedStack(stacks[4], 88, 47));
this.inputs = inputs;
this.output = new PositionedStack(recipe.getResult(), 76, 25);
this.lp = recipe.getAmountNeeded() * 100;
this.orbs = new ArrayList<BloodOrbs>();
for(int i = recipe.getOrbLevel(); i < bloodOrbs.size(); i++) {
ItemStack orb = new ItemStack(bloodOrbs.get(i - 1));
orbs.add(new BloodOrbs(orb));
}
}
@Override
public List<PositionedStack> getIngredients() {
return inputs;
}
@Override
public PositionedStack getResult() {
return output;
}
@Override
public PositionedStack getOtherStack() {
return orbs.get((cycleticks/48) % orbs.size()).stack;
}
}
@Override
public void loadCraftingRecipes(ItemStack result) {
for(AlchemyRecipe recipe: AlchemyRecipeRegistry.recipes) {
ItemStack output = recipe.getResult();
if(NEIServerUtils.areStacksSameTypeCrafting(result, recipe.getResult())) {
arecipes.add(new CachedAlchemyRecipe(recipe));
}
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
for(AlchemyRecipe recipe: AlchemyRecipeRegistry.recipes) {
ItemStack[] stacks = recipe.getRecipe();
for(ItemStack stack: stacks) {
if(NEIServerUtils.areStacksSameTypeCrafting(stack, ingredient)) {
arecipes.add(new CachedAlchemyRecipe(recipe));
}
}
ArrayList<ItemStack> orbs = new ArrayList<ItemStack>();
for(int i = recipe.getOrbLevel(); i < bloodOrbs.size(); i++) {
ItemStack orb = new ItemStack(bloodOrbs.get(i - 1));
if(NEIServerUtils.areStacksSameTypeCrafting(orb, ingredient)) {
arecipes.add(new CachedAlchemyRecipe(recipe));
}
}
}
}
@Override
public void drawExtras(int id) {
CachedAlchemyRecipe cache = (CachedAlchemyRecipe) arecipes.get(id);
Minecraft.getMinecraft().fontRenderer.drawString("\u00a77" + cache.lp + "LP", getLPX(cache.lp), 34, 0);
}
public int getLPX(int lp) {
if(lp < 10)
return 122;
else if (lp < 100)
return 122;
else if (lp < 1000)
return 130;
else if (lp < 10000)
return 127;
else if (lp < 100000)
return 124;
return 122;
}
@Override
public String getRecipeName() {
return "Alchemic Chemistry Set";
}
@Override
public String getOverlayIdentifier() {
return "bmalchemy";
}
@Override
public String getGuiTexture() {
return new ResourceLocation("alchemicalwizardry", "gui/nei/alchemy.png").toString();
}
}

View file

@ -0,0 +1,33 @@
package joshie.alchemicalWizardy.nei;
import java.util.ArrayList;
import net.minecraft.item.Item;
import WayofTime.alchemicalWizardry.ModItems;
import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;
public class NEIConfig implements IConfigureNEI {
@Override
public void loadConfig() {
API.registerRecipeHandler(new NEIAlchemyRecipeHandler());
API.registerUsageHandler(new NEIAlchemyRecipeHandler());
NEIAlchemyRecipeHandler.bloodOrbs = new ArrayList<Item>();
NEIAlchemyRecipeHandler.bloodOrbs.add(ModItems.weakBloodOrb);
NEIAlchemyRecipeHandler.bloodOrbs.add(ModItems.apprenticeBloodOrb);
NEIAlchemyRecipeHandler.bloodOrbs.add(ModItems.magicianBloodOrb);
NEIAlchemyRecipeHandler.bloodOrbs.add(ModItems.masterBloodOrb);
NEIAlchemyRecipeHandler.bloodOrbs.add(ModItems.archmageBloodOrb);
}
@Override
public String getName() {
return "Blood Magic NEI";
}
@Override
public String getVersion() {
return "1.0";
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB