1.7.10 commit of I-still-can't-do-any-branches
This commit is contained in:
parent
6aec0a87ea
commit
cabc296b21
763 changed files with 64290 additions and 0 deletions
|
@ -0,0 +1,227 @@
|
|||
package joshie.alchemicalWizardy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
|
||||
|
||||
/** Shaped Blood Orb Recipe Handler by joshie **/
|
||||
public class ShapedBloodOrbRecipe implements IRecipe {
|
||||
private static final int MAX_CRAFT_GRID_WIDTH = 3;
|
||||
private static final int MAX_CRAFT_GRID_HEIGHT = 3;
|
||||
|
||||
private ItemStack output = null;
|
||||
private Object[] input = null;
|
||||
public int width = 0;
|
||||
public int height = 0;
|
||||
private boolean mirrored = true;
|
||||
|
||||
public ShapedBloodOrbRecipe(Block result, Object... recipe) {
|
||||
this(new ItemStack(result), recipe);
|
||||
}
|
||||
|
||||
public ShapedBloodOrbRecipe(Item result, Object... recipe) {
|
||||
this(new ItemStack(result), recipe);
|
||||
}
|
||||
|
||||
public ShapedBloodOrbRecipe(ItemStack result, Object... recipe) {
|
||||
output = result.copy();
|
||||
|
||||
String shape = "";
|
||||
int idx = 0;
|
||||
|
||||
if (recipe[idx] instanceof Boolean) {
|
||||
mirrored = (Boolean) recipe[idx];
|
||||
if (recipe[idx + 1] instanceof Object[]) {
|
||||
recipe = (Object[]) recipe[idx + 1];
|
||||
} else {
|
||||
idx = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (recipe[idx] instanceof String[]) {
|
||||
String[] parts = ((String[]) recipe[idx++]);
|
||||
|
||||
for (String s : parts) {
|
||||
width = s.length();
|
||||
shape += s;
|
||||
}
|
||||
|
||||
height = parts.length;
|
||||
} else {
|
||||
while (recipe[idx] instanceof String) {
|
||||
String s = (String) recipe[idx++];
|
||||
shape += s;
|
||||
width = s.length();
|
||||
height++;
|
||||
}
|
||||
}
|
||||
|
||||
if (width * height != shape.length()) {
|
||||
String ret = "Invalid shaped ore recipe: ";
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException(ret);
|
||||
}
|
||||
|
||||
HashMap<Character, Object> itemMap = new HashMap<Character, Object>();
|
||||
|
||||
for (; idx < recipe.length; idx += 2) {
|
||||
Character chr = (Character) recipe[idx];
|
||||
Object in = recipe[idx + 1];
|
||||
|
||||
if (in instanceof IBloodOrb || (in instanceof ItemStack && ((ItemStack)in).getItem() instanceof IBloodOrb)) { //If the item is an instanceof IBloodOrb then save the level of the orb
|
||||
if(in instanceof ItemStack) itemMap.put(chr, (Integer)(((IBloodOrb)((ItemStack)in).getItem()).getOrbLevel()));
|
||||
else itemMap.put(chr, (Integer)(((IBloodOrb)in).getOrbLevel()));
|
||||
} else if (in instanceof ItemStack) {
|
||||
itemMap.put(chr, ((ItemStack) in).copy());
|
||||
} else if (in instanceof Item) {
|
||||
itemMap.put(chr, new ItemStack((Item) in));
|
||||
} else if (in instanceof Block) {
|
||||
itemMap.put(chr, new ItemStack((Block) in, 1, OreDictionary.WILDCARD_VALUE));
|
||||
} else if (in instanceof String) {
|
||||
itemMap.put(chr, OreDictionary.getOres((String) in));
|
||||
} else {
|
||||
String ret = "Invalid shaped ore recipe: ";
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException(ret);
|
||||
}
|
||||
}
|
||||
|
||||
input = new Object[width * height];
|
||||
int x = 0;
|
||||
for (char chr : shape.toCharArray()) {
|
||||
input[x++] = itemMap.get(chr);
|
||||
}
|
||||
}
|
||||
|
||||
ShapedBloodOrbRecipe(ShapedRecipes recipe, Map<ItemStack, String> replacements) {
|
||||
output = recipe.getRecipeOutput();
|
||||
width = recipe.recipeWidth;
|
||||
height = recipe.recipeHeight;
|
||||
|
||||
input = new Object[recipe.recipeItems.length];
|
||||
|
||||
for (int i = 0; i < input.length; i++) {
|
||||
ItemStack ingred = recipe.recipeItems[i];
|
||||
|
||||
if (ingred == null)
|
||||
continue;
|
||||
|
||||
input[i] = recipe.recipeItems[i];
|
||||
|
||||
for (Entry<ItemStack, String> replace : replacements.entrySet()) {
|
||||
if (OreDictionary.itemMatches(replace.getKey(), ingred, true)) {
|
||||
input[i] = OreDictionary.getOres(replace.getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting var1) {
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return input.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting inv, World world) {
|
||||
for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++) {
|
||||
for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y) {
|
||||
if (checkMatch(inv, x, y, false)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mirrored && checkMatch(inv, x, y, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror) {
|
||||
for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) {
|
||||
for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) {
|
||||
int subX = x - startX;
|
||||
int subY = y - startY;
|
||||
Object target = null;
|
||||
|
||||
if (subX >= 0 && subY >= 0 && subX < width && subY < height) {
|
||||
if (mirror) {
|
||||
target = input[width - subX - 1 + subY * width];
|
||||
} else {
|
||||
target = input[subX + subY * width];
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack slot = inv.getStackInRowAndColumn(x, y);
|
||||
//If target is integer, then we should be check the blood orb value of the item instead
|
||||
if(target instanceof Integer) {
|
||||
if(slot != null && slot.getItem() instanceof IBloodOrb) {
|
||||
IBloodOrb orb = (IBloodOrb) slot.getItem();
|
||||
if(orb.getOrbLevel() < (Integer)target) {
|
||||
return false;
|
||||
}
|
||||
} else return false;
|
||||
} else if (target instanceof ItemStack) {
|
||||
if (!OreDictionary.itemMatches((ItemStack) target, slot, false)) {
|
||||
return false;
|
||||
}
|
||||
} else if (target instanceof ArrayList) {
|
||||
boolean matched = false;
|
||||
|
||||
Iterator<ItemStack> itr = ((ArrayList<ItemStack>) target).iterator();
|
||||
while (itr.hasNext() && !matched) {
|
||||
matched = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||
}
|
||||
|
||||
if (!matched) {
|
||||
return false;
|
||||
}
|
||||
} else if (target == null && slot != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ShapedBloodOrbRecipe setMirrored(boolean mirror) {
|
||||
mirrored = mirror;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Object[] getInput() {
|
||||
return this.input;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,140 @@
|
|||
package joshie.alchemicalWizardy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
|
||||
|
||||
/** Shapeless Blood Orb Recipe Handler by joshie **/
|
||||
public class ShapelessBloodOrbRecipe implements IRecipe {
|
||||
private ItemStack output = null;
|
||||
private ArrayList<Object> input = new ArrayList<Object>();
|
||||
|
||||
public ShapelessBloodOrbRecipe(Block result, Object... recipe) {
|
||||
this(new ItemStack(result), recipe);
|
||||
}
|
||||
|
||||
public ShapelessBloodOrbRecipe(Item result, Object... recipe) {
|
||||
this(new ItemStack(result), recipe);
|
||||
}
|
||||
|
||||
public ShapelessBloodOrbRecipe(ItemStack result, Object... recipe) {
|
||||
output = result.copy();
|
||||
for (Object in : recipe) {
|
||||
if (in instanceof ItemStack) {
|
||||
input.add(((ItemStack) in).copy());
|
||||
} else if (in instanceof IBloodOrb) { //If the item is an instanceof IBloodOrb then save the level of the orb
|
||||
input.add((Integer)(((IBloodOrb)in).getOrbLevel()));
|
||||
} else if (in instanceof Item) {
|
||||
input.add(new ItemStack((Item) in));
|
||||
} else if (in instanceof Block) {
|
||||
input.add(new ItemStack((Block) in));
|
||||
} else if (in instanceof String) {
|
||||
input.add(OreDictionary.getOres((String) in));
|
||||
} else {
|
||||
String ret = "Invalid shapeless ore recipe: ";
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ShapelessBloodOrbRecipe(ShapelessRecipes recipe, Map<ItemStack, String> replacements) {
|
||||
output = recipe.getRecipeOutput();
|
||||
|
||||
for (ItemStack ingred : ((List<ItemStack>) recipe.recipeItems)) {
|
||||
Object finalObj = ingred;
|
||||
for (Entry<ItemStack, String> replace : replacements.entrySet()) {
|
||||
if (OreDictionary.itemMatches(replace.getKey(), ingred, false)) {
|
||||
finalObj = OreDictionary.getOres(replace.getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
input.add(finalObj);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return input.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting var1) {
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting var1, World world) {
|
||||
ArrayList<Object> required = new ArrayList<Object>(input);
|
||||
|
||||
for (int x = 0; x < var1.getSizeInventory(); x++) {
|
||||
ItemStack slot = var1.getStackInSlot(x);
|
||||
|
||||
if (slot != null) {
|
||||
boolean inRecipe = false;
|
||||
Iterator<Object> req = required.iterator();
|
||||
|
||||
while (req.hasNext()) {
|
||||
boolean match = false;
|
||||
|
||||
Object next = req.next();
|
||||
|
||||
//If target is integer, then we should be check the blood orb value of the item instead
|
||||
if(next instanceof Integer) {
|
||||
if(slot != null && slot.getItem() instanceof IBloodOrb) {
|
||||
IBloodOrb orb = (IBloodOrb) slot.getItem();
|
||||
if(orb.getOrbLevel() < (Integer)next) {
|
||||
return false;
|
||||
}
|
||||
} else return false;
|
||||
} else if (next instanceof ItemStack) {
|
||||
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
|
||||
} else if (next instanceof ArrayList) {
|
||||
Iterator<ItemStack> itr = ((ArrayList<ItemStack>) next).iterator();
|
||||
while (itr.hasNext() && !match) {
|
||||
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
inRecipe = true;
|
||||
required.remove(next);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inRecipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return required.isEmpty();
|
||||
}
|
||||
|
||||
public ArrayList<Object> getInput() {
|
||||
return this.input;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
package joshie.alchemicalWizardy.nei;
|
||||
|
||||
import static joshie.alchemicalWizardy.nei.NEIConfig.bloodOrbs;
|
||||
|
||||
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 net.minecraft.util.StatCollector;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.AlchemyRecipe;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.AlchemyRecipeRegistry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class NEIAlchemyRecipeHandler extends TemplateRecipeHandler {
|
||||
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;
|
||||
PositionedStack output;
|
||||
List<PositionedStack> inputs;
|
||||
int lp;
|
||||
|
||||
public CachedAlchemyRecipe(AlchemyRecipe recipe, ItemStack orb) {
|
||||
this(recipe);
|
||||
this.orbs = new ArrayList<BloodOrbs>();
|
||||
orbs.add(new BloodOrbs(orb));
|
||||
}
|
||||
|
||||
public CachedAlchemyRecipe(AlchemyRecipe 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(Item orb: bloodOrbs) {
|
||||
if(((IBloodOrb)orb).getOrbLevel() >= recipe.getOrbLevel()) {
|
||||
orbs.add(new BloodOrbs(new ItemStack(orb)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getOtherStack() {
|
||||
if(orbs == null || orbs.size() <= 0) return null;
|
||||
return orbs.get((cycleticks/48) % orbs.size()).stack;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TemplateRecipeHandler newInstance() {
|
||||
for(ItemStack item : ItemList.items) {
|
||||
if(item != null && item.getItem() instanceof IBloodOrb) {
|
||||
bloodOrbs.add(item.getItem());
|
||||
}
|
||||
}
|
||||
|
||||
return super.newInstance();
|
||||
}
|
||||
|
||||
@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) {
|
||||
if(ingredient.getItem() instanceof IBloodOrb) {
|
||||
for(AlchemyRecipe recipe: AlchemyRecipeRegistry.recipes) {
|
||||
if(((IBloodOrb)ingredient.getItem()).getOrbLevel() >= recipe.getOrbLevel()) {
|
||||
arecipes.add(new CachedAlchemyRecipe(recipe, ingredient));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(AlchemyRecipe recipe: AlchemyRecipeRegistry.recipes) {
|
||||
ItemStack[] stacks = recipe.getRecipe();
|
||||
for(ItemStack stack: stacks) {
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting(stack, ingredient)) {
|
||||
arecipes.add(new CachedAlchemyRecipe(recipe));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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 StatCollector.translateToLocal("tile.blockWritingTable.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return new ResourceLocation("alchemicalwizardry", "gui/nei/alchemy.png").toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,182 @@
|
|||
package joshie.alchemicalWizardy.nei;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.altarRecipeRegistry.AltarRecipe;
|
||||
import WayofTime.alchemicalWizardry.api.altarRecipeRegistry.AltarRecipeRegistry;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class NEIAltarRecipeHandler extends TemplateRecipeHandler {
|
||||
public class CachedAltarRecipe extends CachedRecipe {
|
||||
PositionedStack input;
|
||||
PositionedStack output;
|
||||
int tier, lp_amount, consumption, drain;
|
||||
|
||||
public CachedAltarRecipe(AltarRecipe recipe) {
|
||||
input = new PositionedStack(recipe.requiredItem, 38, 2, false);
|
||||
output = new PositionedStack(recipe.result, 132, 32, false);
|
||||
tier = recipe.minTier;
|
||||
lp_amount = recipe.liquidRequired;
|
||||
consumption = recipe.consumptionRate;
|
||||
drain = recipe.drainRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getIngredient() {
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results) {
|
||||
if (outputId.equals("altarrecipes") && getClass() == NEIAltarRecipeHandler.class) {
|
||||
for(AltarRecipe recipe: AltarRecipeRegistry.altarRecipes) {
|
||||
if(recipe.result != null) arecipes.add(new CachedAltarRecipe(recipe));
|
||||
}
|
||||
} else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
for(AltarRecipe recipe: AltarRecipeRegistry.altarRecipes) {
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting(recipe.result, result)) {
|
||||
if(recipe.result != null) arecipes.add(new CachedAltarRecipe(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
for(AltarRecipe recipe: AltarRecipeRegistry.altarRecipes) {
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting(recipe.requiredItem, ingredient)) {
|
||||
if(recipe.result != null) arecipes.add(new CachedAltarRecipe(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Mouse Position helper
|
||||
public Point getMouse(int width, int height) {
|
||||
Point mousepos = this.getMousePosition();
|
||||
int guiLeft = (width - 176) / 2;
|
||||
int guiTop = (height - 166) / 2;
|
||||
Point relMouse = new Point(mousepos.x - guiLeft, mousepos.y - guiTop);
|
||||
return relMouse;
|
||||
}
|
||||
|
||||
//width helper, getting width normal way hates me on compile
|
||||
public int getGuiWidth(GuiRecipe gui) {
|
||||
try {
|
||||
Field f = gui.getClass().getField("width");
|
||||
return (Integer) f.get(gui);
|
||||
} catch (NoSuchFieldException e) {
|
||||
try {
|
||||
Field f = gui.getClass().getField("field_146294_l");
|
||||
return (Integer) f.get(gui);
|
||||
} catch (Exception e2) {
|
||||
return 0;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//height helper, getting height normal way hates me on compile
|
||||
public int getGuiHeight(GuiRecipe gui) {
|
||||
try {
|
||||
Field f = gui.getClass().getField("height");
|
||||
return (Integer) f.get(gui);
|
||||
} catch (NoSuchFieldException e) {
|
||||
try {
|
||||
Field f = gui.getClass().getField("field_146295_m");
|
||||
return (Integer) f.get(gui);
|
||||
} catch (Exception e2) {
|
||||
return 0;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int id) {
|
||||
CachedAltarRecipe recipe = (CachedAltarRecipe) arecipes.get(id);
|
||||
Minecraft.getMinecraft().fontRenderer.drawString("\u00a77" + StatCollector.translateToLocal("bm.string.tier") + ": " + recipe.tier, 78, 5, 0);
|
||||
Minecraft.getMinecraft().fontRenderer.drawString("\u00a77" + "LP: " + recipe.lp_amount, 78, 15, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiRecipe gui, List<String> currenttip, int id) {
|
||||
currenttip = super.handleTooltip(gui, currenttip, id);
|
||||
Point mouse = getMouse(getGuiWidth(gui), getGuiHeight(gui));
|
||||
CachedAltarRecipe recipe = (CachedAltarRecipe) arecipes.get(id);
|
||||
int yLow = id % 2 == 0 ? 38 : 102;
|
||||
int yHigh = id % 2 == 0 ? 72 : 136;
|
||||
if(mouse.x >= 19 && mouse.x <= 80 && mouse.y >= yLow && mouse.y <= yHigh) {
|
||||
currenttip.add(StatCollector.translateToLocal("bm.string.consume") + ": " + recipe.consumption + "LP/t");
|
||||
currenttip.add(StatCollector.translateToLocal("bm.string.drain") + ": " + recipe.drain + "LP/t");
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return "altarrecipes";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(90, 32, 22, 16), "altarrecipes"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return " " + StatCollector.translateToLocal("tile.bloodAltar.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return new ResourceLocation("alchemicalwizardry", "gui/nei/altar.png").toString();
|
||||
}
|
||||
|
||||
public static Point getMousePosition() {
|
||||
Dimension size = displaySize();
|
||||
Dimension res = displayRes();
|
||||
return new Point(Mouse.getX() * size.width / res.width, size.height - Mouse.getY() * size.height / res.height - 1);
|
||||
}
|
||||
|
||||
public static Dimension displaySize() {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
return new Dimension(res.getScaledWidth(), res.getScaledHeight());
|
||||
}
|
||||
|
||||
public static Dimension displayRes() {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
return new Dimension(mc.displayWidth, mc.displayHeight);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
package joshie.alchemicalWizardy.nei;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import joshie.alchemicalWizardy.ShapedBloodOrbRecipe;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
|
||||
import codechicken.core.ReflectionManager;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.ShapedRecipeHandler;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect;
|
||||
|
||||
/** Extended from the default recipe handler **/
|
||||
public class NEIBloodOrbShapedHandler extends ShapedRecipeHandler {
|
||||
public class CachedBloodOrbRecipe extends CachedShapedRecipe {
|
||||
public CachedBloodOrbRecipe(int width, int height, Object[] items, ItemStack out) {
|
||||
super(width, height, items, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(int width, int height, Object[] items) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
if (items[y * width + x] == null)
|
||||
continue;
|
||||
|
||||
Object o = items[y * width + x];
|
||||
if (o instanceof ItemStack) {
|
||||
PositionedStack stack = new PositionedStack(items[y * width + x], 25 + x * 18, 6 + y * 18, false);
|
||||
stack.setMaxSize(1);
|
||||
ingredients.add(stack);
|
||||
} else if (o instanceof Integer) {
|
||||
ArrayList<ItemStack> orbs = new ArrayList();
|
||||
for (Item item : NEIConfig.bloodOrbs) {
|
||||
if (((IBloodOrb) item).getOrbLevel() >= (Integer) o) {
|
||||
orbs.add(new ItemStack(item));
|
||||
}
|
||||
}
|
||||
|
||||
PositionedStack stack = new PositionedStack(orbs, 25 + x * 18, 6 + y * 18, false);
|
||||
stack.setMaxSize(1);
|
||||
ingredients.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results) {
|
||||
if (outputId.equals("orbCrafting") && getClass() == NEIBloodOrbShapedHandler.class) {
|
||||
for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
|
||||
if (irecipe instanceof ShapedBloodOrbRecipe) {
|
||||
CachedBloodOrbRecipe recipe = forgeShapedRecipe((ShapedBloodOrbRecipe) irecipe);
|
||||
if (recipe == null)
|
||||
continue;
|
||||
|
||||
recipe.computeVisuals();
|
||||
arecipes.add(recipe);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
|
||||
if (irecipe instanceof ShapedBloodOrbRecipe) {
|
||||
CachedBloodOrbRecipe recipe = forgeShapedRecipe((ShapedBloodOrbRecipe) irecipe);
|
||||
if (recipe == null || !NEIServerUtils.areStacksSameTypeCrafting(recipe.result.item, result))
|
||||
continue;
|
||||
|
||||
recipe.computeVisuals();
|
||||
arecipes.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
|
||||
CachedShapedRecipe recipe = null;
|
||||
if (irecipe instanceof ShapedBloodOrbRecipe)
|
||||
recipe = forgeShapedRecipe((ShapedBloodOrbRecipe) irecipe);
|
||||
|
||||
if (recipe == null || !recipe.contains(recipe.ingredients, ingredient.getItem()))
|
||||
continue;
|
||||
|
||||
recipe.computeVisuals();
|
||||
if (recipe.contains(recipe.ingredients, ingredient)) {
|
||||
recipe.setIngredientPermutation(recipe.ingredients, ingredient);
|
||||
arecipes.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private CachedBloodOrbRecipe forgeShapedRecipe(ShapedBloodOrbRecipe recipe) {
|
||||
int width;
|
||||
int height;
|
||||
try {
|
||||
width = recipe.width;
|
||||
height = recipe.height;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
Object[] items = recipe.getInput();
|
||||
for (Object item : items)
|
||||
if (item instanceof List && ((List<?>) item).isEmpty())// ore
|
||||
// handler,
|
||||
// no ores
|
||||
return null;
|
||||
|
||||
return new CachedBloodOrbRecipe(width, height, items, recipe.getRecipeOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), "orbCrafting"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return "orbCrafting";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("bm.string.crafting.orb.shaped");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
package joshie.alchemicalWizardy.nei;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import joshie.alchemicalWizardy.ShapelessBloodOrbRecipe;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.ShapelessRecipeHandler;
|
||||
import codechicken.nei.recipe.ShapelessRecipeHandler.CachedShapelessRecipe;
|
||||
|
||||
public class NEIBloodOrbShapelessHandler extends ShapelessRecipeHandler {
|
||||
public class CachedBloodOrbRecipe extends CachedShapelessRecipe {
|
||||
public CachedBloodOrbRecipe(ArrayList<Object> items, ItemStack recipeOutput) {
|
||||
super(items, recipeOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(List<?> items) {
|
||||
ingredients.clear();
|
||||
for (int ingred = 0; ingred < items.size(); ingred++) {
|
||||
Object o = items.get(ingred);
|
||||
if (o instanceof ItemStack) {
|
||||
PositionedStack stack = new PositionedStack(items.get(ingred), 25 + stackorder[ingred][0] * 18, 6 + stackorder[ingred][1] * 18);
|
||||
stack.setMaxSize(1);
|
||||
ingredients.add(stack);
|
||||
} else if (o instanceof Integer) {
|
||||
ArrayList<ItemStack> orbs = new ArrayList();
|
||||
for (Item item : NEIConfig.bloodOrbs) {
|
||||
if (((IBloodOrb) item).getOrbLevel() >= (Integer) o) {
|
||||
orbs.add(new ItemStack(item));
|
||||
}
|
||||
}
|
||||
|
||||
PositionedStack stack = new PositionedStack(orbs, 25 + stackorder[ingred][0] * 18, 6 + stackorder[ingred][1] * 18);
|
||||
stack.setMaxSize(1);
|
||||
ingredients.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results) {
|
||||
if (outputId.equals("orbCrafting") && getClass() == NEIBloodOrbShapelessHandler.class) {
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe irecipe : allrecipes) {
|
||||
CachedBloodOrbRecipe recipe = null;
|
||||
if (irecipe instanceof ShapelessBloodOrbRecipe)
|
||||
recipe = forgeShapelessRecipe((ShapelessBloodOrbRecipe) irecipe);
|
||||
|
||||
if (recipe == null)
|
||||
continue;
|
||||
|
||||
arecipes.add(recipe);
|
||||
}
|
||||
} else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe irecipe : allrecipes) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
|
||||
CachedBloodOrbRecipe recipe = null;
|
||||
if (irecipe instanceof ShapelessBloodOrbRecipe)
|
||||
recipe = forgeShapelessRecipe((ShapelessBloodOrbRecipe) irecipe);
|
||||
|
||||
if (recipe == null)
|
||||
continue;
|
||||
|
||||
arecipes.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe irecipe : allrecipes) {
|
||||
CachedBloodOrbRecipe recipe = null;
|
||||
if (irecipe instanceof ShapelessBloodOrbRecipe)
|
||||
recipe = forgeShapelessRecipe((ShapelessBloodOrbRecipe) irecipe);
|
||||
|
||||
if (recipe == null)
|
||||
continue;
|
||||
|
||||
if (recipe.contains(recipe.ingredients, ingredient)) {
|
||||
recipe.setIngredientPermutation(recipe.ingredients, ingredient);
|
||||
arecipes.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CachedBloodOrbRecipe forgeShapelessRecipe(ShapelessBloodOrbRecipe recipe) {
|
||||
ArrayList<Object> items = recipe.getInput();
|
||||
|
||||
for (Object item : items)
|
||||
if (item instanceof List && ((List<?>) item).isEmpty())//ore handler, no ores
|
||||
return null;
|
||||
|
||||
return new CachedBloodOrbRecipe(items, recipe.getRecipeOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), "orbCrafting"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return "orbCrafting";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("bm.string.crafting.orb.shapeless");
|
||||
}
|
||||
}
|
33
1.7.10/main/java/joshie/alchemicalWizardy/nei/NEIConfig.java
Normal file
33
1.7.10/main/java/joshie/alchemicalWizardy/nei/NEIConfig.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package joshie.alchemicalWizardy.nei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
|
||||
public class NEIConfig implements IConfigureNEI {
|
||||
public static ArrayList<Item> bloodOrbs = new ArrayList<Item>();
|
||||
|
||||
@Override
|
||||
public void loadConfig() {
|
||||
API.registerRecipeHandler(new NEIAlchemyRecipeHandler());
|
||||
API.registerUsageHandler(new NEIAlchemyRecipeHandler());
|
||||
API.registerRecipeHandler(new NEIAltarRecipeHandler());
|
||||
API.registerUsageHandler(new NEIAltarRecipeHandler());
|
||||
API.registerRecipeHandler(new NEIBloodOrbShapedHandler());
|
||||
API.registerUsageHandler(new NEIBloodOrbShapedHandler());
|
||||
API.registerRecipeHandler(new NEIBloodOrbShapelessHandler());
|
||||
API.registerUsageHandler(new NEIBloodOrbShapelessHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Blood Magic NEI";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "1.2";
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue