Working on The Architect book - working out well~
This commit is contained in:
parent
1c806c4328
commit
f87da36775
13 changed files with 499 additions and 298 deletions
|
@ -1,13 +1,16 @@
|
|||
package WayofTime.alchemicalWizardry.api.altarRecipeRegistry;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class AltarRecipeRegistry
|
||||
{
|
||||
public static List<AltarRecipe> altarRecipes = new LinkedList();
|
||||
public static Map<Integer, ItemStack> orbMap = new HashMap();
|
||||
|
||||
public static void registerAltarRecipe(ItemStack result, ItemStack requiredItem, int minTier, int liquidRequired, int consumptionRate, int drainRate, boolean canBeFilled)
|
||||
{
|
||||
|
@ -21,6 +24,10 @@ public class AltarRecipeRegistry
|
|||
|
||||
public static void registerAltarOrbRecipe(ItemStack orbStack, int minTier, int consumptionRate)
|
||||
{
|
||||
if(!orbMap.containsKey(minTier))
|
||||
{
|
||||
orbMap.put(minTier, orbStack);
|
||||
}
|
||||
registerAltarRecipe(null, orbStack, minTier, 0, consumptionRate, 0, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,10 @@ import net.minecraft.entity.Entity;
|
|||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
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.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
|
@ -16,6 +19,7 @@ import net.minecraft.util.Vec3;
|
|||
import net.minecraft.world.World;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class APISpellHelper
|
||||
{
|
||||
|
@ -247,4 +251,75 @@ public class APISpellHelper
|
|||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static Block getBlockForString(String str)
|
||||
{
|
||||
String[] parts = str.split(":");
|
||||
String modId = parts[0];
|
||||
String name = parts[1];
|
||||
return GameRegistry.findBlock(modId, name);
|
||||
}
|
||||
|
||||
public static Item getItemForString(String str)
|
||||
{
|
||||
String[] parts = str.split(":");
|
||||
String modId = parts[0];
|
||||
String name = parts[1];
|
||||
return GameRegistry.findItem(modId, name);
|
||||
}
|
||||
|
||||
public static ItemStack getItemStackForString(String str)
|
||||
{
|
||||
String[] parts = str.split(":");
|
||||
int meta = 0;
|
||||
if(parts.length >= 3)
|
||||
{
|
||||
meta = Integer.decode(parts[2]);
|
||||
}else if(parts.length < 2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String modId = parts[0];
|
||||
String name = parts[1];
|
||||
|
||||
String itemString = modId + ":" + name;
|
||||
Item item = APISpellHelper.getItemForString(itemString);
|
||||
if(item != null)
|
||||
{
|
||||
return new ItemStack(item, 1, meta);
|
||||
}
|
||||
|
||||
Block block = APISpellHelper.getBlockForString(itemString);
|
||||
if(block != null)
|
||||
{
|
||||
return new ItemStack(block, 1, meta);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IRecipe getRecipeForItemStack(ItemStack reqStack) //Does not match NBT. Durrr! -smack-
|
||||
{
|
||||
if(reqStack == null)
|
||||
{
|
||||
return null; //Why are you even doing this to yourself!? You know this can't be healthy!
|
||||
}
|
||||
List craftingList = CraftingManager.getInstance().getRecipeList();
|
||||
for(Object posRecipe : craftingList)
|
||||
{
|
||||
if(posRecipe instanceof IRecipe)
|
||||
{
|
||||
ItemStack outputStack = ((IRecipe) posRecipe).getRecipeOutput();
|
||||
if(outputStack != null)
|
||||
{
|
||||
if(outputStack.getItem() == reqStack.getItem() && (outputStack.getItem().getHasSubtypes() ? outputStack.getItemDamage() == reqStack.getItemDamage() : true))
|
||||
{
|
||||
return (IRecipe)posRecipe;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue