Testing the creation of hell
This commit is contained in:
parent
796e75b1f9
commit
a2b006105e
2587 changed files with 0 additions and 129617 deletions
|
@ -0,0 +1,45 @@
|
|||
package WayofTime.alchemicalWizardry.api;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ColourAndCoords
|
||||
{
|
||||
public int colourRed;
|
||||
public int colourGreen;
|
||||
public int colourBlue;
|
||||
public int colourIntensity;
|
||||
|
||||
public int xCoord;
|
||||
public int yCoord;
|
||||
public int zCoord;
|
||||
|
||||
public ColourAndCoords(int red, int green, int blue, int intensity, int x, int y, int z)
|
||||
{
|
||||
this.colourRed = red;
|
||||
this.colourGreen = green;
|
||||
this.colourBlue = blue;
|
||||
this.colourIntensity = intensity;
|
||||
|
||||
this.xCoord = x;
|
||||
this.yCoord = y;
|
||||
this.zCoord = z;
|
||||
}
|
||||
|
||||
public static ColourAndCoords readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
return new ColourAndCoords(tag.getInteger("colourRed"), tag.getInteger("colourGreen"), tag.getInteger("colourBlue"), tag.getInteger("colourIntensity"), tag.getInteger("xCoord"), tag.getInteger("yCoord"), tag.getInteger("zCoord"));
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
tag.setInteger("colourRed", colourRed);
|
||||
tag.setInteger("colourGreen", colourGreen);
|
||||
tag.setInteger("colourBlue", colourBlue);
|
||||
tag.setInteger("colourIntensity", colourIntensity);
|
||||
tag.setInteger("xCoord", xCoord);
|
||||
tag.setInteger("yCoord", yCoord);
|
||||
tag.setInteger("zCoord", zCoord);
|
||||
|
||||
return tag;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package WayofTime.alchemicalWizardry.api.alchemy;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AlchemicalPotionCreationHandler
|
||||
{
|
||||
public static ArrayList<AlchemyPotionHandlerComponent> registeredPotionEffects = new ArrayList();
|
||||
|
||||
public static void addPotion(ItemStack itemStack, int potionID, int tickDuration)
|
||||
{
|
||||
registeredPotionEffects.add(new AlchemyPotionHandlerComponent(itemStack, potionID, tickDuration));
|
||||
}
|
||||
|
||||
public static int getPotionIDForStack(ItemStack itemStack)
|
||||
{
|
||||
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects)
|
||||
{
|
||||
if (aphc.compareItemStack(itemStack))
|
||||
{
|
||||
return aphc.getPotionID();
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getPotionTickDurationForStack(ItemStack itemStack)
|
||||
{
|
||||
{
|
||||
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects)
|
||||
{
|
||||
if (aphc.compareItemStack(itemStack))
|
||||
{
|
||||
return aphc.getTickDuration();
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean containsRegisteredPotionIngredient(ItemStack[] stackList)
|
||||
{
|
||||
for (ItemStack is : stackList)
|
||||
{
|
||||
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects)
|
||||
{
|
||||
if (aphc.compareItemStack(is))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int getRegisteredPotionIngredientPosition(ItemStack[] stackList)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (ItemStack is : stackList)
|
||||
{
|
||||
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects)
|
||||
{
|
||||
if (aphc.compareItemStack(is))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package WayofTime.alchemicalWizardry.api.alchemy;
|
||||
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class AlchemyPotionHandlerComponent
|
||||
{
|
||||
private ItemStack itemStack;
|
||||
private int potionID;
|
||||
private int tickDuration;
|
||||
|
||||
public AlchemyPotionHandlerComponent(ItemStack itemStack, int potionID, int tickDuration)
|
||||
{
|
||||
this.itemStack = itemStack;
|
||||
this.potionID = potionID;
|
||||
this.tickDuration = tickDuration;
|
||||
}
|
||||
|
||||
public boolean compareItemStack(ItemStack comparedStack)
|
||||
{
|
||||
if (comparedStack != null && itemStack != null)
|
||||
{
|
||||
if (comparedStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
if (itemStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
return comparedStack.getItem().equals(itemStack.getItem()) && comparedStack.getItemDamage() == itemStack.getItemDamage();
|
||||
}
|
||||
} else if (!(itemStack.getItem() instanceof ItemBlock))
|
||||
{
|
||||
return comparedStack.getItem().equals(itemStack.getItem()) && comparedStack.getItemDamage() == itemStack.getItemDamage();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public int getPotionID()
|
||||
{
|
||||
return this.potionID;
|
||||
}
|
||||
|
||||
public int getTickDuration()
|
||||
{
|
||||
return this.tickDuration;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package WayofTime.alchemicalWizardry.api.alchemy;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
|
||||
public class AlchemyPotionHelper
|
||||
{
|
||||
private int potionID;
|
||||
private int tickDuration;
|
||||
private int concentration;
|
||||
private int durationFactor;
|
||||
|
||||
public AlchemyPotionHelper(int potionID, int tickDuration, int concentration, int durationFactor)
|
||||
{
|
||||
this.potionID = potionID;
|
||||
this.tickDuration = tickDuration;
|
||||
this.concentration = concentration;
|
||||
this.durationFactor = durationFactor;
|
||||
}
|
||||
|
||||
public void setConcentration(int concentration)
|
||||
{
|
||||
this.concentration = concentration;
|
||||
}
|
||||
|
||||
public void setDurationFactor(int durationFactor)
|
||||
{
|
||||
this.durationFactor = durationFactor;
|
||||
}
|
||||
|
||||
public int getPotionID()
|
||||
{
|
||||
return this.potionID;
|
||||
}
|
||||
|
||||
public int getTickDuration()
|
||||
{
|
||||
return this.tickDuration;
|
||||
}
|
||||
|
||||
public int getConcentration()
|
||||
{
|
||||
return this.concentration;
|
||||
}
|
||||
|
||||
public int getdurationFactor()
|
||||
{
|
||||
return this.durationFactor;
|
||||
}
|
||||
|
||||
public PotionEffect getPotionEffect()
|
||||
{
|
||||
if (potionID == Potion.heal.id || potionID == Potion.harm.id)
|
||||
{
|
||||
return (new PotionEffect(potionID, 1, concentration));
|
||||
}
|
||||
|
||||
return (new PotionEffect(potionID, (int) (tickDuration * Math.pow(0.5f, concentration) * Math.pow(8.0f / 3.0f, durationFactor)), concentration));
|
||||
}
|
||||
|
||||
public static AlchemyPotionHelper readEffectFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
return new AlchemyPotionHelper(tagCompound.getInteger("potionID"), tagCompound.getInteger("tickDuration"), tagCompound.getInteger("concentration"), tagCompound.getInteger("durationFactor"));
|
||||
}
|
||||
|
||||
public static NBTTagCompound setEffectToNBT(AlchemyPotionHelper aph)
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setInteger("potionID", aph.getPotionID());
|
||||
tagCompound.setInteger("tickDuration", aph.getTickDuration());
|
||||
tagCompound.setInteger("concentration", aph.getConcentration());
|
||||
tagCompound.setInteger("durationFactor", aph.getdurationFactor());
|
||||
return tagCompound;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
package WayofTime.alchemicalWizardry.api.alchemy;
|
||||
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class AlchemyRecipe
|
||||
{
|
||||
private ItemStack output;
|
||||
private ItemStack[] recipe;
|
||||
private int bloodOrbLevel;
|
||||
private int amountNeeded;
|
||||
|
||||
public AlchemyRecipe(ItemStack output, int amountNeeded, ItemStack[] recipe, int bloodOrbLevel)
|
||||
{
|
||||
this.output = output;
|
||||
this.recipe = recipe;
|
||||
this.amountNeeded = amountNeeded;
|
||||
this.bloodOrbLevel = bloodOrbLevel;
|
||||
}
|
||||
|
||||
public boolean doesRecipeMatch(ItemStack[] items, int slottedBloodOrbLevel)
|
||||
{
|
||||
if (slottedBloodOrbLevel < bloodOrbLevel)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack[] recipe = new ItemStack[5];
|
||||
|
||||
if (items.length < 5)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.recipe.length != 5)
|
||||
{
|
||||
ItemStack[] newRecipe = new ItemStack[5];
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (i + 1 > this.recipe.length)
|
||||
{
|
||||
newRecipe[i] = null;
|
||||
} else
|
||||
{
|
||||
newRecipe[i] = this.recipe[i];
|
||||
}
|
||||
}
|
||||
|
||||
recipe = newRecipe;
|
||||
} else
|
||||
{
|
||||
recipe = this.recipe;
|
||||
}
|
||||
|
||||
boolean[] checkList = new boolean[5];
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
checkList[i] = false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
ItemStack recipeItemStack = recipe[i];
|
||||
|
||||
if (recipeItemStack == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean test = false;
|
||||
|
||||
for (int j = 0; j < 5; j++)
|
||||
{
|
||||
if (checkList[j])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack checkedItemStack = items[j];
|
||||
|
||||
if (checkedItemStack == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean quickTest = false;
|
||||
|
||||
if (recipeItemStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
if (checkedItemStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
quickTest = true;
|
||||
}
|
||||
} else if (!(checkedItemStack.getItem() instanceof ItemBlock))
|
||||
{
|
||||
quickTest = true;
|
||||
}
|
||||
|
||||
if (!quickTest)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((checkedItemStack.getItemDamage() == recipeItemStack.getItemDamage() || OreDictionary.WILDCARD_VALUE == recipeItemStack.getItemDamage()) && checkedItemStack.getItem() == recipeItemStack.getItem())
|
||||
{
|
||||
test = true;
|
||||
checkList[j] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!test)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack getResult()
|
||||
{
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
public int getAmountNeeded()
|
||||
{
|
||||
return this.amountNeeded;
|
||||
}
|
||||
|
||||
public ItemStack[] getRecipe()
|
||||
{
|
||||
return this.recipe;
|
||||
}
|
||||
|
||||
public int getOrbLevel()
|
||||
{
|
||||
return this.bloodOrbLevel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package WayofTime.alchemicalWizardry.api.alchemy;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AlchemyRecipeRegistry
|
||||
{
|
||||
public static List<AlchemyRecipe> recipes = new ArrayList();
|
||||
|
||||
public static void registerRecipe(ItemStack output, int amountNeeded, ItemStack[] recipe, int bloodOrbLevel)
|
||||
{
|
||||
recipes.add(new AlchemyRecipe(output, amountNeeded, recipe, bloodOrbLevel));
|
||||
}
|
||||
|
||||
public static ItemStack getResult(ItemStack[] recipe, ItemStack bloodOrb)
|
||||
{
|
||||
if (bloodOrb == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(bloodOrb.getItem() instanceof IBloodOrb))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int bloodOrbLevel = ((IBloodOrb) bloodOrb.getItem()).getOrbLevel();
|
||||
|
||||
for (AlchemyRecipe ar : recipes)
|
||||
{
|
||||
if (ar.doesRecipeMatch(recipe, bloodOrbLevel))
|
||||
{
|
||||
return (ar.getResult());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getAmountNeeded(ItemStack[] recipe, ItemStack bloodOrb)
|
||||
{
|
||||
if (bloodOrb == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(bloodOrb.getItem() instanceof IBloodOrb))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bloodOrbLevel = ((IBloodOrb) bloodOrb.getItem()).getOrbLevel();
|
||||
|
||||
for (AlchemyRecipe ar : recipes)
|
||||
{
|
||||
if (ar.doesRecipeMatch(recipe, bloodOrbLevel))
|
||||
{
|
||||
return (ar.getAmountNeeded());
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static ItemStack[] getRecipeForItemStack(ItemStack itemStack)
|
||||
{
|
||||
for (AlchemyRecipe ar : recipes)
|
||||
{
|
||||
ItemStack result = ar.getResult();
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
if (result.isItemEqual(itemStack))
|
||||
{
|
||||
return ar.getRecipe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IAlchemyGoggles
|
||||
{
|
||||
public boolean showIngameHUD(World world, ItemStack stack, EntityPlayer player);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
public interface IReagentContainer
|
||||
{
|
||||
public ReagentStack getReagent();
|
||||
|
||||
public int getReagentStackAmount();
|
||||
|
||||
public int getCapacity();
|
||||
|
||||
public int fill(ReagentStack resource, boolean doFill);
|
||||
|
||||
public ReagentStack drain(int maxDrain, boolean doDrain);
|
||||
|
||||
public ReagentContainerInfo getInfo();
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IReagentHandler
|
||||
{
|
||||
int fill(ForgeDirection from, ReagentStack resource, boolean doFill);
|
||||
|
||||
ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean doDrain);
|
||||
|
||||
ReagentStack drain(ForgeDirection from, int maxDrain, boolean doDrain);
|
||||
|
||||
boolean canFill(ForgeDirection from, Reagent reagent);
|
||||
|
||||
boolean canDrain(ForgeDirection from, Reagent reagent);
|
||||
|
||||
ReagentContainerInfo[] getContainerInfo(ForgeDirection from);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ISegmentedReagentHandler extends IReagentHandler
|
||||
{
|
||||
public int getNumberOfTanks();
|
||||
|
||||
public int getTanksTunedToReagent(Reagent reagent);
|
||||
|
||||
public void setTanksTunedToReagent(Reagent reagent, int total);
|
||||
|
||||
public Map<Reagent, Integer> getAttunedTankMap();
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
public class Reagent
|
||||
{
|
||||
public final String name;
|
||||
|
||||
public static final int REAGENT_SIZE = 1000;
|
||||
|
||||
private int colourRed = 0;
|
||||
private int colourGreen = 0;
|
||||
private int colourBlue = 0;
|
||||
private int colourIntensity = 255;
|
||||
|
||||
public Reagent(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setColour(int red, int green, int blue, int intensity)
|
||||
{
|
||||
this.colourRed = red;
|
||||
this.colourGreen = green;
|
||||
this.colourBlue = blue;
|
||||
this.colourIntensity = intensity;
|
||||
}
|
||||
|
||||
public int getColourRed()
|
||||
{
|
||||
return colourRed;
|
||||
}
|
||||
|
||||
public int getColourGreen()
|
||||
{
|
||||
return colourGreen;
|
||||
}
|
||||
|
||||
public int getColourBlue()
|
||||
{
|
||||
return colourBlue;
|
||||
}
|
||||
|
||||
public int getColourIntensity()
|
||||
{
|
||||
return colourIntensity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
return o instanceof Reagent ? this == o && name.equals(((Reagent) o).name) : false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ReagentContainer implements IReagentContainer
|
||||
{
|
||||
protected ReagentStack reagentStack;
|
||||
protected int capacity;
|
||||
|
||||
public ReagentContainer(int capacity)
|
||||
{
|
||||
this(null, capacity);
|
||||
}
|
||||
|
||||
public ReagentContainer(ReagentStack stack, int capacity)
|
||||
{
|
||||
this.reagentStack = stack;
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
public ReagentContainer(Reagent reagent, int amount, int capacity)
|
||||
{
|
||||
this(new ReagentStack(reagent, amount), capacity);
|
||||
}
|
||||
|
||||
public static ReagentContainer readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
ReagentStack reagent = ReagentStack.loadReagentStackFromNBT(nbt);
|
||||
int capacity = nbt.getInteger("capacity");
|
||||
|
||||
if (reagent != null)
|
||||
{
|
||||
return new ReagentContainer(reagent, capacity);
|
||||
} else
|
||||
{
|
||||
return new ReagentContainer(null, capacity);
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
if (reagentStack != null)
|
||||
{
|
||||
reagentStack.writeToNBT(nbt);
|
||||
}
|
||||
|
||||
nbt.setInteger("capacity", capacity);
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReagentStack getReagent()
|
||||
{
|
||||
return reagentStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReagentStackAmount()
|
||||
{
|
||||
if (reagentStack == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return reagentStack.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity()
|
||||
{
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ReagentStack resource, boolean doFill)
|
||||
{
|
||||
if (resource == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!doFill)
|
||||
{
|
||||
if (reagentStack == null)
|
||||
{
|
||||
return Math.min(capacity, resource.amount);
|
||||
}
|
||||
|
||||
if (!reagentStack.isReagentEqual(resource))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.min(capacity - reagentStack.amount, resource.amount);
|
||||
}
|
||||
|
||||
if (reagentStack == null)
|
||||
{
|
||||
reagentStack = new ReagentStack(resource, Math.min(capacity, resource.amount));
|
||||
|
||||
return reagentStack.amount;
|
||||
}
|
||||
|
||||
if (!reagentStack.isReagentEqual(resource))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int filled = capacity - reagentStack.amount;
|
||||
|
||||
if (resource.amount < filled)
|
||||
{
|
||||
reagentStack.amount += resource.amount;
|
||||
filled = resource.amount;
|
||||
} else
|
||||
{
|
||||
reagentStack.amount = capacity;
|
||||
}
|
||||
|
||||
return filled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReagentStack drain(int maxDrain, boolean doDrain)
|
||||
{
|
||||
if (reagentStack == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int drained = maxDrain;
|
||||
if (reagentStack.amount < drained)
|
||||
{
|
||||
drained = reagentStack.amount;
|
||||
}
|
||||
|
||||
ReagentStack stack = new ReagentStack(reagentStack, drained);
|
||||
if (doDrain)
|
||||
{
|
||||
reagentStack.amount -= drained;
|
||||
if (reagentStack.amount <= 0)
|
||||
{
|
||||
reagentStack = null;
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReagentContainerInfo getInfo()
|
||||
{
|
||||
return new ReagentContainerInfo(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
public final class ReagentContainerInfo
|
||||
{
|
||||
public final ReagentStack reagent;
|
||||
public final int capacity;
|
||||
|
||||
public ReagentContainerInfo(ReagentStack reagent, int capacity)
|
||||
{
|
||||
this.reagent = reagent;
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
public ReagentContainerInfo(IReagentContainer tank)
|
||||
{
|
||||
this.reagent = tank.getReagent();
|
||||
this.capacity = tank.getCapacity();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ReagentRegistry
|
||||
{
|
||||
public static Map<String, Reagent> reagentList = new HashMap();
|
||||
public static Map<ItemStack, ReagentStack> itemToReagentMap = new HashMap();
|
||||
|
||||
public static Reagent sanctusReagent;
|
||||
public static Reagent incendiumReagent;
|
||||
public static Reagent aquasalusReagent;
|
||||
public static Reagent magicalesReagent;
|
||||
public static Reagent aetherReagent;
|
||||
public static Reagent crepitousReagent;
|
||||
public static Reagent crystallosReagent;
|
||||
public static Reagent terraeReagent;
|
||||
public static Reagent tenebraeReagent;
|
||||
|
||||
public static Reagent offensaReagent;
|
||||
public static Reagent praesidiumReagent;
|
||||
public static Reagent orbisTerraeReagent;
|
||||
public static Reagent virtusReagent;
|
||||
public static Reagent reductusReagent;
|
||||
public static Reagent potentiaReagent;
|
||||
|
||||
public static void initReagents()
|
||||
{
|
||||
sanctusReagent = new Reagent("sanctus");
|
||||
incendiumReagent = new Reagent("incendium");
|
||||
aquasalusReagent = new Reagent("aquasalus");
|
||||
magicalesReagent = new Reagent("magicales");
|
||||
aetherReagent = new Reagent("aether");
|
||||
crepitousReagent = new Reagent("crepitous");
|
||||
crystallosReagent = new Reagent("crystallos");
|
||||
terraeReagent = new Reagent("terrae");
|
||||
tenebraeReagent = new Reagent("tenebrae");
|
||||
offensaReagent = new Reagent("offensa");
|
||||
praesidiumReagent = new Reagent("praesidium");
|
||||
orbisTerraeReagent = new Reagent("orbisTerrae");
|
||||
virtusReagent = new Reagent("virtus");
|
||||
reductusReagent = new Reagent("reductus");
|
||||
potentiaReagent = new Reagent("potentia");
|
||||
|
||||
sanctusReagent.setColour(255, 255, 0, 255);
|
||||
incendiumReagent.setColour(255, 0, 0, 255);
|
||||
aquasalusReagent.setColour(47, 0, 196, 255);
|
||||
magicalesReagent.setColour(150, 0, 146, 255);
|
||||
aetherReagent.setColour(105, 223, 86, 255);
|
||||
crepitousReagent.setColour(145, 145, 145, 255);
|
||||
crystallosReagent.setColour(135, 255, 231, 255);
|
||||
terraeReagent.setColour(147, 48, 13, 255);
|
||||
tenebraeReagent.setColour(86, 86, 86, 255);
|
||||
offensaReagent.setColour(126, 0, 0, 255);
|
||||
praesidiumReagent.setColour(135, 135, 135, 255);
|
||||
orbisTerraeReagent.setColour(32, 94, 14, 255);
|
||||
virtusReagent.setColour(180, 0, 0, 255);
|
||||
reductusReagent.setColour(20, 93, 2, 255);
|
||||
potentiaReagent.setColour(64, 81, 208, 255);
|
||||
|
||||
registerReagent("sanctus", sanctusReagent);
|
||||
registerReagent("incendium", incendiumReagent);
|
||||
registerReagent("aquasalus", aquasalusReagent);
|
||||
registerReagent("magicales", magicalesReagent);
|
||||
registerReagent("aether", aetherReagent);
|
||||
registerReagent("crepitous", crepitousReagent);
|
||||
registerReagent("crystallos", crystallosReagent);
|
||||
registerReagent("terrae", terraeReagent);
|
||||
registerReagent("tenebrae", tenebraeReagent);
|
||||
registerReagent("offensa", offensaReagent);
|
||||
registerReagent("praesidium", praesidiumReagent);
|
||||
registerReagent("orbisTerrae", orbisTerraeReagent);
|
||||
registerReagent("virtus", virtusReagent);
|
||||
registerReagent("reductus", reductusReagent);
|
||||
registerReagent("potentia", potentiaReagent);
|
||||
}
|
||||
|
||||
public static boolean registerReagent(String key, Reagent reagent)
|
||||
{
|
||||
if (reagentList.containsKey(key) || reagent == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
reagentList.put(key, reagent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Reagent getReagentForKey(String key)
|
||||
{
|
||||
if (reagentList.containsKey(key))
|
||||
{
|
||||
return reagentList.get(key);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getKeyForReagent(Reagent reagent)
|
||||
{
|
||||
if (reagentList.containsValue(reagent))
|
||||
{
|
||||
Set<Entry<String, Reagent>> set = reagentList.entrySet();
|
||||
for (Entry<String, Reagent> entry : set)
|
||||
{
|
||||
if (entry.getValue().equals(reagent))
|
||||
{
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void registerItemAndReagent(ItemStack stack, ReagentStack reagentStack)
|
||||
{
|
||||
itemToReagentMap.put(stack, reagentStack);
|
||||
}
|
||||
|
||||
public static ReagentStack getReagentStackForItem(ItemStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for (Entry<ItemStack, ReagentStack> entry : itemToReagentMap.entrySet())
|
||||
{
|
||||
if (entry.getKey() != null && entry.getKey().isItemEqual(stack))
|
||||
{
|
||||
if (entry.getValue() == null)
|
||||
{
|
||||
return null;
|
||||
} else
|
||||
{
|
||||
return entry.getValue().copy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack getItemForReagent(Reagent reagent)
|
||||
{
|
||||
if (reagent == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for (Entry<ItemStack, ReagentStack> entry : itemToReagentMap.entrySet())
|
||||
{
|
||||
if (entry.getValue() != null && entry.getValue().reagent == reagent)
|
||||
{
|
||||
if (entry.getKey() == null)
|
||||
{
|
||||
return null;
|
||||
} else
|
||||
{
|
||||
return entry.getKey().copy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ReagentStack
|
||||
{
|
||||
public Reagent reagent;
|
||||
public int amount;
|
||||
|
||||
public ReagentStack(Reagent reagent, int amount)
|
||||
{
|
||||
this.reagent = reagent;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public ReagentStack(ReagentStack reagentStack, int amount)
|
||||
{
|
||||
this(reagentStack.reagent, amount);
|
||||
}
|
||||
|
||||
public static ReagentStack loadReagentStackFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
Reagent reagent = ReagentRegistry.getReagentForKey(tag.getString("Reagent"));
|
||||
|
||||
if (reagent == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int amount = tag.getInteger("amount");
|
||||
ReagentStack stack = new ReagentStack(reagent, amount);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
tag.setString("Reagent", ReagentRegistry.getKeyForReagent(this.reagent));
|
||||
tag.setInteger("amount", this.amount);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
public ReagentStack splitStack(int amount)
|
||||
{
|
||||
ReagentStack copyStack = this.copy();
|
||||
int splitAmount = Math.min(amount, this.amount);
|
||||
copyStack.amount = splitAmount;
|
||||
this.amount -= splitAmount;
|
||||
|
||||
return copyStack;
|
||||
}
|
||||
|
||||
public ReagentStack copy()
|
||||
{
|
||||
return new ReagentStack(this.reagent, this.amount);
|
||||
}
|
||||
|
||||
public boolean isReagentEqual(ReagentStack other)
|
||||
{
|
||||
return other != null && this.reagent == other.reagent;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
|
||||
package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileReagentHandler extends TileEntity implements IReagentHandler
|
||||
{
|
||||
protected ReagentContainer tank = new ReagentContainer(4000);
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.readFromNBT(tag);
|
||||
tank.readFromNBT(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.writeToNBT(tag);
|
||||
tank.writeToNBT(tag);
|
||||
}
|
||||
|
||||
/* IReagentHandler */
|
||||
@Override
|
||||
public int fill(ForgeDirection from, ReagentStack resource, boolean doFill)
|
||||
{
|
||||
return tank.fill(resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean doDrain)
|
||||
{
|
||||
if (resource == null || !resource.isReagentEqual(tank.getReagent()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return tank.drain(resource.amount, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReagentStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return tank.drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Reagent reagent)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Reagent reagent)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReagentContainerInfo[] getContainerInfo(ForgeDirection from)
|
||||
{
|
||||
return new ReagentContainerInfo[]{tank.getInfo()};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,283 @@
|
|||
|
||||
package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class TileSegmentedReagentHandler extends TileEntity implements ISegmentedReagentHandler
|
||||
{
|
||||
protected ReagentContainer[] tanks;
|
||||
protected Map<Reagent, Integer> attunedTankMap;
|
||||
|
||||
public TileSegmentedReagentHandler()
|
||||
{
|
||||
this(1);
|
||||
}
|
||||
|
||||
public TileSegmentedReagentHandler(int numberOfTanks)
|
||||
{
|
||||
this(numberOfTanks, 1000);
|
||||
}
|
||||
|
||||
public TileSegmentedReagentHandler(int numberOfTanks, int tankSize)
|
||||
{
|
||||
super();
|
||||
|
||||
this.attunedTankMap = new HashMap();
|
||||
this.tanks = new ReagentContainer[numberOfTanks];
|
||||
for (int i = 0; i < numberOfTanks; i++)
|
||||
{
|
||||
this.tanks[i] = new ReagentContainer(tankSize);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.readFromNBT(tag);
|
||||
|
||||
NBTTagList tagList = tag.getTagList("reagentTanks", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
int size = tagList.tagCount();
|
||||
this.tanks = new ReagentContainer[size];
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
NBTTagCompound savedTag = tagList.getCompoundTagAt(i);
|
||||
this.tanks[i] = ReagentContainer.readFromNBT(savedTag);
|
||||
}
|
||||
|
||||
NBTTagList attunedTagList = tag.getTagList("attunedTankMap", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < attunedTagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound savedTag = attunedTagList.getCompoundTagAt(i);
|
||||
Reagent reagent = ReagentRegistry.getReagentForKey(savedTag.getString("reagent"));
|
||||
this.attunedTankMap.put(reagent, savedTag.getInteger("amount"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.writeToNBT(tag);
|
||||
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < this.tanks.length; i++)
|
||||
{
|
||||
NBTTagCompound savedTag = new NBTTagCompound();
|
||||
if (this.tanks[i] != null)
|
||||
{
|
||||
this.tanks[i].writeToNBT(savedTag);
|
||||
}
|
||||
tagList.appendTag(savedTag);
|
||||
}
|
||||
|
||||
tag.setTag("reagentTanks", tagList);
|
||||
|
||||
NBTTagList attunedTagList = new NBTTagList();
|
||||
|
||||
for (Entry<Reagent, Integer> entry : this.attunedTankMap.entrySet())
|
||||
{
|
||||
NBTTagCompound savedTag = new NBTTagCompound();
|
||||
savedTag.setString("reagent", ReagentRegistry.getKeyForReagent(entry.getKey()));
|
||||
savedTag.setInteger("amount", entry.getValue());
|
||||
attunedTagList.appendTag(savedTag);
|
||||
}
|
||||
|
||||
tag.setTag("attunedTankMap", attunedTagList);
|
||||
}
|
||||
|
||||
/* ISegmentedReagentHandler */
|
||||
@Override
|
||||
public int fill(ForgeDirection from, ReagentStack resource, boolean doFill)
|
||||
{
|
||||
int totalFill = 0;
|
||||
|
||||
boolean useTankLimit = !this.attunedTankMap.isEmpty();
|
||||
|
||||
if (resource != null)
|
||||
{
|
||||
int totalTanksFillable = useTankLimit ? this.getTanksTunedToReagent(resource.reagent) : this.tanks.length;
|
||||
int tanksFilled = 0;
|
||||
|
||||
int maxFill = resource.amount;
|
||||
|
||||
for (int i = this.tanks.length - 1; i >= 0; i--)
|
||||
{
|
||||
ReagentStack remainingStack = resource.copy();
|
||||
remainingStack.amount = maxFill - totalFill;
|
||||
|
||||
boolean doesReagentMatch = tanks[i].getReagent() == null ? false : tanks[i].getReagent().isReagentEqual(remainingStack);
|
||||
|
||||
if (doesReagentMatch)
|
||||
{
|
||||
totalFill += tanks[i].fill(remainingStack, doFill);
|
||||
tanksFilled++;
|
||||
} else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (totalFill >= maxFill || tanksFilled >= totalTanksFillable)
|
||||
{
|
||||
return totalFill;
|
||||
}
|
||||
}
|
||||
|
||||
if (tanksFilled >= totalTanksFillable)
|
||||
{
|
||||
return totalFill;
|
||||
}
|
||||
|
||||
for (int i = this.tanks.length - 1; i >= 0; i--)
|
||||
{
|
||||
ReagentStack remainingStack = resource.copy();
|
||||
remainingStack.amount = maxFill - totalFill;
|
||||
|
||||
boolean isTankEmpty = tanks[i].getReagent() == null;
|
||||
|
||||
if (isTankEmpty)
|
||||
{
|
||||
totalFill += tanks[i].fill(remainingStack, doFill);
|
||||
tanksFilled++;
|
||||
} else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (totalFill >= maxFill || tanksFilled >= totalTanksFillable)
|
||||
{
|
||||
return totalFill;
|
||||
}
|
||||
}
|
||||
}
|
||||
return totalFill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean doDrain)
|
||||
{
|
||||
if (resource == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int maxDrain = resource.amount;
|
||||
Reagent reagent = resource.reagent;
|
||||
int drained = 0;
|
||||
|
||||
for (int i = 0; i < tanks.length; i++)
|
||||
{
|
||||
if (drained >= maxDrain)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (resource.isReagentEqual(tanks[i].getReagent()))
|
||||
{
|
||||
ReagentStack drainStack = tanks[i].drain(maxDrain - drained, doDrain);
|
||||
if (drainStack != null)
|
||||
{
|
||||
drained += drainStack.amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ReagentStack(reagent, drained);
|
||||
}
|
||||
|
||||
/* Only returns the amount from the first available tank */
|
||||
@Override
|
||||
public ReagentStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
for (int i = 0; i < tanks.length; i++)
|
||||
{
|
||||
ReagentStack stack = tanks[i].drain(maxDrain, doDrain);
|
||||
if (stack != null)
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Reagent reagent)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Reagent reagent)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReagentContainerInfo[] getContainerInfo(ForgeDirection from)
|
||||
{
|
||||
ReagentContainerInfo[] info = new ReagentContainerInfo[this.getNumberOfTanks()];
|
||||
for (int i = 0; i < this.getNumberOfTanks(); i++)
|
||||
{
|
||||
info[i] = tanks[i].getInfo();
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfTanks()
|
||||
{
|
||||
return tanks.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTanksTunedToReagent(Reagent reagent)
|
||||
{
|
||||
if (this.attunedTankMap.containsKey(reagent) && this.attunedTankMap.get(reagent) != null)
|
||||
{
|
||||
return this.attunedTankMap.get(reagent);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTanksTunedToReagent(Reagent reagent, int total)
|
||||
{
|
||||
if (total == 0 && this.attunedTankMap.containsKey(reagent))
|
||||
{
|
||||
this.attunedTankMap.remove(reagent);
|
||||
return;
|
||||
}
|
||||
|
||||
this.attunedTankMap.put(reagent, new Integer(total));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Reagent, Integer> getAttunedTankMap()
|
||||
{
|
||||
return this.attunedTankMap;
|
||||
}
|
||||
|
||||
public boolean areTanksEmpty()
|
||||
{
|
||||
for (int i = 0; i < this.tanks.length; i++)
|
||||
{
|
||||
if (tanks[i] != null && tanks[i].reagentStack != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package WayofTime.alchemicalWizardry.api.altarRecipeRegistry;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class AltarRecipe
|
||||
{
|
||||
public int minTier;
|
||||
public int liquidRequired;
|
||||
public boolean canBeFilled; //Tells the system that the item is an orb
|
||||
public int consumptionRate;
|
||||
public int drainRate;
|
||||
public ItemStack requiredItem;
|
||||
public ItemStack result;
|
||||
|
||||
public AltarRecipe(ItemStack result, ItemStack requiredItem, int minTier, int liquidRequired, int consumptionRate, int drainRate, boolean canBeFilled)
|
||||
{
|
||||
this.result = result;
|
||||
this.requiredItem = requiredItem;
|
||||
this.minTier = minTier;
|
||||
this.liquidRequired = liquidRequired;
|
||||
this.consumptionRate = consumptionRate;
|
||||
this.drainRate = drainRate;
|
||||
this.canBeFilled = canBeFilled;
|
||||
}
|
||||
|
||||
public ItemStack getResult()
|
||||
{
|
||||
return this.result;
|
||||
}
|
||||
|
||||
public ItemStack getRequiredItem()
|
||||
{
|
||||
return this.requiredItem;
|
||||
}
|
||||
|
||||
public boolean doesRequiredItemMatch(ItemStack comparedStack, int tierCheck)
|
||||
{
|
||||
if (comparedStack == null || this.requiredItem == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return tierCheck >= minTier && this.requiredItem.isItemEqual(comparedStack);
|
||||
}
|
||||
|
||||
public int getMinTier()
|
||||
{
|
||||
return this.minTier;
|
||||
}
|
||||
|
||||
public int getLiquidRequired()
|
||||
{
|
||||
return this.liquidRequired;
|
||||
}
|
||||
|
||||
public int getConsumptionRate()
|
||||
{
|
||||
return this.consumptionRate;
|
||||
}
|
||||
|
||||
public int getDrainRate()
|
||||
{
|
||||
return this.drainRate;
|
||||
}
|
||||
|
||||
public boolean getCanBeFilled()
|
||||
{
|
||||
return this.canBeFilled;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package WayofTime.alchemicalWizardry.api.altarRecipeRegistry;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class AltarRecipeRegistry
|
||||
{
|
||||
public static List<AltarRecipe> altarRecipes = new LinkedList();
|
||||
|
||||
public static void registerAltarRecipe(ItemStack result, ItemStack requiredItem, int minTier, int liquidRequired, int consumptionRate, int drainRate, boolean canBeFilled)
|
||||
{
|
||||
altarRecipes.add(new AltarRecipe(result, requiredItem, minTier, liquidRequired, consumptionRate, drainRate, canBeFilled));
|
||||
}
|
||||
|
||||
public static void registerAltarOrbRecipe(ItemStack orbStack, int minTier, int consumptionRate)
|
||||
{
|
||||
registerAltarRecipe(null, orbStack, minTier, 0, consumptionRate, 0, true);
|
||||
}
|
||||
|
||||
public static boolean isRequiredItemValid(ItemStack testItem, int currentTierAltar)
|
||||
{
|
||||
for (AltarRecipe recipe : altarRecipes)
|
||||
{
|
||||
if (recipe.doesRequiredItemMatch(testItem, currentTierAltar))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemStack getItemForItemAndTier(ItemStack testItem, int currentTierAltar)
|
||||
{
|
||||
for (AltarRecipe recipe : altarRecipes)
|
||||
{
|
||||
if (recipe.doesRequiredItemMatch(testItem, currentTierAltar))
|
||||
{
|
||||
return ItemStack.copyItemStack(recipe.getResult());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static AltarRecipe getAltarRecipeForItemAndTier(ItemStack testItem, int currentTierAltar)
|
||||
{
|
||||
for (AltarRecipe recipe : altarRecipes)
|
||||
{
|
||||
if (recipe.doesRequiredItemMatch(testItem, currentTierAltar))
|
||||
{
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package WayofTime.alchemicalWizardry.api.bindingRegistry;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class BindingRecipe
|
||||
{
|
||||
public ItemStack requiredItem;
|
||||
public ItemStack outputItem;
|
||||
|
||||
public BindingRecipe(ItemStack outputItem, ItemStack requiredItem)
|
||||
{
|
||||
this.requiredItem = requiredItem;
|
||||
this.outputItem = outputItem;
|
||||
}
|
||||
|
||||
public boolean doesRequiredItemMatch(ItemStack testStack)
|
||||
{
|
||||
if (testStack == null || this.requiredItem == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.requiredItem.isItemEqual(testStack);
|
||||
}
|
||||
|
||||
public ItemStack getResult(ItemStack inputItem)
|
||||
{
|
||||
return this.getResult();
|
||||
}
|
||||
|
||||
public ItemStack getResult()
|
||||
{
|
||||
return this.outputItem;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package WayofTime.alchemicalWizardry.api.bindingRegistry;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class BindingRegistry
|
||||
{
|
||||
public static List<BindingRecipe> bindingRecipes = new LinkedList();
|
||||
|
||||
public static void registerRecipe(ItemStack output, ItemStack input)
|
||||
{
|
||||
bindingRecipes.add(new BindingRecipe(output, input));
|
||||
}
|
||||
|
||||
public static boolean isRequiredItemValid(ItemStack testItem)
|
||||
{
|
||||
for (BindingRecipe recipe : bindingRecipes)
|
||||
{
|
||||
if (recipe.doesRequiredItemMatch(testItem))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemStack getItemForItemAndTier(ItemStack testItem)
|
||||
{
|
||||
for (BindingRecipe recipe : bindingRecipes)
|
||||
{
|
||||
if (recipe.doesRequiredItemMatch(testItem))
|
||||
{
|
||||
return recipe.getResult(testItem).copy();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getIndexForItem(ItemStack testItem)
|
||||
{
|
||||
int i = 0;
|
||||
for (BindingRecipe recipe : bindingRecipes)
|
||||
{
|
||||
if (recipe.doesRequiredItemMatch(testItem))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static ItemStack getOutputForIndex(int index)
|
||||
{
|
||||
if (bindingRecipes.size() <= index)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return bindingRecipes.get(index).getResult();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package WayofTime.alchemicalWizardry.api.harvest;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HarvestRegistry
|
||||
{
|
||||
public static List<IHarvestHandler> handlerList = new ArrayList();
|
||||
|
||||
public static void registerHarvestHandler(IHarvestHandler handler)
|
||||
{
|
||||
handlerList.add(handler);
|
||||
}
|
||||
|
||||
public static boolean harvestBlock(World world, int xCoord, int yCoord, int zCoord)
|
||||
{
|
||||
Block block = world.getBlock(xCoord, yCoord, zCoord);
|
||||
int meta = world.getBlockMetadata(xCoord, yCoord, zCoord);
|
||||
|
||||
for (IHarvestHandler handler : handlerList)
|
||||
{
|
||||
if (handler.harvestAndPlant(world, xCoord, yCoord, zCoord, block, meta))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package WayofTime.alchemicalWizardry.api.harvest;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IHarvestHandler
|
||||
{
|
||||
/**
|
||||
* A handler that is used to harvest and replant the block at the specified location
|
||||
*
|
||||
* @param world
|
||||
* @param xCoord
|
||||
* @param yCoord
|
||||
* @param zCoord
|
||||
* @param block block at this given location
|
||||
* @param meta meta at this given location
|
||||
* @return true if successfully harvested, false if not
|
||||
*/
|
||||
public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta);
|
||||
}
|
|
@ -0,0 +1,281 @@
|
|||
package WayofTime.alchemicalWizardry.api.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* 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,174 @@
|
|||
package WayofTime.alchemicalWizardry.api.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* 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,15 @@
|
|||
package WayofTime.alchemicalWizardry.api.items.interfaces;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ArmourUpgrade
|
||||
{
|
||||
//Called when the armour ticks
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack);
|
||||
|
||||
public boolean isUpgrade();
|
||||
|
||||
public int getEnergyForTenSeconds();
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package WayofTime.alchemicalWizardry.api.items.interfaces;
|
||||
|
||||
public interface IBindable
|
||||
{
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package WayofTime.alchemicalWizardry.api.items.interfaces;
|
||||
|
||||
public interface IBloodOrb
|
||||
{
|
||||
public int getMaxEssence();
|
||||
|
||||
public int getOrbLevel();
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package WayofTime.alchemicalWizardry.api.items.interfaces;
|
||||
|
||||
public interface IHolding
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package WayofTime.alchemicalWizardry.api.items.interfaces;
|
||||
|
||||
/**
|
||||
* Implement this interface to have reagent blocks return false on activating them, to allow manipulation of said block
|
||||
*/
|
||||
public interface IReagentManipulator
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.ISegmentedReagentHandler;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IMasterRitualStone extends ISegmentedReagentHandler
|
||||
{
|
||||
public void performRitual(World world, int x, int y, int z, String ritualID);
|
||||
|
||||
public String getOwner();
|
||||
|
||||
public void setCooldown(int newCooldown);
|
||||
|
||||
public int getCooldown();
|
||||
|
||||
public void setVar1(int newVar1);
|
||||
|
||||
public int getVar1();
|
||||
|
||||
public void setActive(boolean active);
|
||||
|
||||
public int getDirection();
|
||||
|
||||
public World getWorld();
|
||||
|
||||
public int getXCoord();
|
||||
|
||||
public int getYCoord();
|
||||
|
||||
public int getZCoord();
|
||||
|
||||
public NBTTagCompound getCustomRitualTag();
|
||||
|
||||
public void setCustomRitualTag(NBTTagCompound tag);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
public interface IRitualStone
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
public class RitualComponent
|
||||
{
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private int stoneType;
|
||||
public static final int BLANK = 0;
|
||||
public static final int WATER = 1;
|
||||
public static final int FIRE = 2;
|
||||
public static final int EARTH = 3;
|
||||
public static final int AIR = 4;
|
||||
public static final int DUSK = 5;
|
||||
|
||||
public RitualComponent(int x, int y, int z, int stoneType)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.stoneType = stoneType;
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getY()
|
||||
{
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public int getZ()
|
||||
{
|
||||
return this.z;
|
||||
}
|
||||
|
||||
public int getStoneType()
|
||||
{
|
||||
return this.stoneType;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class RitualEffect
|
||||
{
|
||||
public abstract void performEffect(IMasterRitualStone ritualStone);
|
||||
|
||||
public boolean startRitual(IMasterRitualStone ritualStone, EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onRitualBroken(IMasterRitualStone ritualStone)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public abstract int getCostPerRefresh();
|
||||
|
||||
public int getInitialCooldown()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public abstract List<RitualComponent> getRitualComponentList();
|
||||
|
||||
public boolean canDrainReagent(IMasterRitualStone ritualStone, Reagent reagent, int amount, boolean doDrain)
|
||||
{
|
||||
if (ritualStone == null || reagent == null || amount == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ReagentStack reagentStack = new ReagentStack(reagent, amount);
|
||||
|
||||
ReagentStack stack = ritualStone.drain(ForgeDirection.UNKNOWN, reagentStack, false);
|
||||
|
||||
if (stack != null && stack.amount >= amount)
|
||||
{
|
||||
if (doDrain)
|
||||
{
|
||||
ritualStone.drain(ForgeDirection.UNKNOWN, reagentStack, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,421 @@
|
|||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
import WayofTime.alchemicalWizardry.common.renderer.MRSRenderer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Rituals
|
||||
{
|
||||
private int crystalLevel;
|
||||
private int actCost;
|
||||
private RitualEffect effect;
|
||||
private String name;
|
||||
|
||||
private MRSRenderer customRenderer;
|
||||
|
||||
public static Map<String, Rituals> ritualMap = new HashMap();
|
||||
public static List<String> keyList = new LinkedList();
|
||||
|
||||
public Rituals(int crystalLevel, int actCost, RitualEffect effect, String name, MRSRenderer renderer)
|
||||
{
|
||||
this.crystalLevel = crystalLevel;
|
||||
this.actCost = actCost;
|
||||
this.effect = effect;
|
||||
this.name = name;
|
||||
keyList.add(name);
|
||||
ritualMap.put(name, this);
|
||||
this.customRenderer = renderer;
|
||||
}
|
||||
|
||||
public Rituals(int crystalLevel, int actCost, RitualEffect effect, String name)
|
||||
{
|
||||
this(crystalLevel, actCost, effect, name, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Static method to register a ritual to the Ritual Registry
|
||||
*
|
||||
* @param key Unique identification key - must be different from all others to properly register
|
||||
* @param crystalLevel Crystal level required to activate
|
||||
* @param actCost LP amount required to activate
|
||||
* @param effect The effect that will be ticked
|
||||
* @param name The name of the ritual
|
||||
* @return Returns true if properly registered, or false if the key is already used
|
||||
*/
|
||||
public static boolean registerRitual(String key, int crystalLevel, int actCost, RitualEffect effect, String name, MRSRenderer renderer)
|
||||
{
|
||||
if (ritualMap.containsKey(key))
|
||||
{
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
Rituals ritual = new Rituals(crystalLevel, actCost, effect, name, renderer);
|
||||
ritual.removeRitualFromList();
|
||||
ritualMap.put(key, ritual);
|
||||
keyList.add(key);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean registerRitual(String key, int crystalLevel, int actCost, RitualEffect effect, String name)
|
||||
{
|
||||
if (ritualMap.containsKey(key))
|
||||
{
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
Rituals ritual = new Rituals(crystalLevel, actCost, effect, name);
|
||||
ritual.removeRitualFromList();
|
||||
ritualMap.put(key, ritual);
|
||||
keyList.add(key);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeRitualFromList()
|
||||
{
|
||||
if (ritualMap.containsValue(this))
|
||||
{
|
||||
ritualMap.remove(ritualMap.remove(this.name));
|
||||
}
|
||||
if (keyList.contains(this.name))
|
||||
{
|
||||
keyList.remove(this.name);
|
||||
}
|
||||
}
|
||||
|
||||
public static String checkValidRitual(World world, int x, int y, int z)
|
||||
{
|
||||
for (String key : ritualMap.keySet())
|
||||
{
|
||||
if (checkRitualIsValid(world, x, y, z, key))
|
||||
{
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static boolean canCrystalActivate(String ritualID, int crystalLevel)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null)
|
||||
{
|
||||
return ritual.getCrystalLevel() <= crystalLevel;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean checkRitualIsValid(World world, int x, int y, int z, String ritualID)
|
||||
{
|
||||
int direction = Rituals.getDirectionOfRitual(world, x, y, z, ritualID);
|
||||
|
||||
if (direction != -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1 - NORTH
|
||||
* 2 - EAST
|
||||
* 3 - SOUTH
|
||||
* 4 - WEST
|
||||
*/
|
||||
public static boolean checkDirectionOfRitualValid(World world, int x, int y, int z, String ritualID, int direction)
|
||||
{
|
||||
List<RitualComponent> ritual = Rituals.getRitualList(ritualID);
|
||||
|
||||
if (ritual == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Block test = null;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case 1:
|
||||
for (RitualComponent rc : ritual)
|
||||
{
|
||||
test = world.getBlock(x + rc.getX(), y + rc.getY(), z + rc.getZ());
|
||||
|
||||
if (!(test instanceof IRitualStone))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world.getBlockMetadata(x + rc.getX(), y + rc.getY(), z + rc.getZ()) != rc.getStoneType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
for (RitualComponent rc : ritual)
|
||||
{
|
||||
test = world.getBlock(x - rc.getZ(), y + rc.getY(), z + rc.getX());
|
||||
|
||||
if (!(test instanceof IRitualStone))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world.getBlockMetadata(x - rc.getZ(), y + rc.getY(), z + rc.getX()) != rc.getStoneType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
for (RitualComponent rc : ritual)
|
||||
{
|
||||
test = world.getBlock(x - rc.getX(), y + rc.getY(), z - rc.getZ());
|
||||
|
||||
if (!(test instanceof IRitualStone))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world.getBlockMetadata(x - rc.getX(), y + rc.getY(), z - rc.getZ()) != rc.getStoneType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 4:
|
||||
for (RitualComponent rc : ritual)
|
||||
{
|
||||
test = world.getBlock(x + rc.getZ(), y + rc.getY(), z - rc.getX());
|
||||
|
||||
if (!(test instanceof IRitualStone))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world.getBlockMetadata(x + rc.getZ(), y + rc.getY(), z - rc.getX()) != rc.getStoneType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int getDirectionOfRitual(World world, int x, int y, int z, String ritualID)
|
||||
{
|
||||
for (int i = 1; i <= 4; i++)
|
||||
{
|
||||
if (Rituals.checkDirectionOfRitualValid(world, x, y, z, ritualID, i))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getCostForActivation(String ritualID)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null)
|
||||
{
|
||||
return ritual.actCost;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int getInitialCooldown(String ritualID)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null && ritual.effect != null)
|
||||
{
|
||||
return ritual.effect.getInitialCooldown();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static List<RitualComponent> getRitualList(String ritualID)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null)
|
||||
{
|
||||
return ritual.obtainComponents();
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private List<RitualComponent> obtainComponents()
|
||||
{
|
||||
return this.effect.getRitualComponentList();
|
||||
}
|
||||
|
||||
private int getCrystalLevel()
|
||||
{
|
||||
return this.crystalLevel;
|
||||
}
|
||||
|
||||
private MRSRenderer getRenderer()
|
||||
{
|
||||
return this.customRenderer;
|
||||
}
|
||||
|
||||
public static void performEffect(IMasterRitualStone ritualStone, String ritualID)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null && ritual.effect != null)
|
||||
{
|
||||
ritual.effect.performEffect(ritualStone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean startRitual(IMasterRitualStone ritualStone, String ritualID, EntityPlayer player)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null && ritual.effect != null)
|
||||
{
|
||||
return ritual.effect.startRitual(ritualStone, player);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void onRitualBroken(IMasterRitualStone ritualStone, String ritualID)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null && ritual.effect != null)
|
||||
{
|
||||
ritual.effect.onRitualBroken(ritualStone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int getNumberOfRituals()
|
||||
{
|
||||
return ritualMap.size();
|
||||
}
|
||||
|
||||
public String getRitualName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public static String getNameOfRitual(String id)
|
||||
{
|
||||
if (ritualMap.containsKey(id))
|
||||
{
|
||||
Rituals ritual = ritualMap.get(id);
|
||||
if (ritual != null)
|
||||
{
|
||||
return ritual.getRitualName();
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getNextRitualKey(String key)
|
||||
{
|
||||
boolean hasSpotted = false;
|
||||
String firstKey = "";
|
||||
|
||||
for (String str : keyList)
|
||||
{
|
||||
if (firstKey.equals(""))
|
||||
{
|
||||
firstKey = str;
|
||||
}
|
||||
if (hasSpotted)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
if (str.equals(key))
|
||||
{
|
||||
hasSpotted = true;
|
||||
}
|
||||
}
|
||||
|
||||
return firstKey;
|
||||
}
|
||||
|
||||
public static String getPreviousRitualKey(String key)
|
||||
{
|
||||
boolean hasSpotted = false;
|
||||
String lastKey = keyList.get(keyList.size() - 1);
|
||||
|
||||
for (String str : keyList)
|
||||
{
|
||||
if (str.equals(key))
|
||||
{
|
||||
hasSpotted = true;
|
||||
}
|
||||
if (hasSpotted)
|
||||
{
|
||||
return lastKey;
|
||||
}
|
||||
lastKey = str;
|
||||
}
|
||||
|
||||
return lastKey;
|
||||
}
|
||||
|
||||
public static MRSRenderer getRendererForKey(String ritualID)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null)
|
||||
{
|
||||
return ritual.getRenderer();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package WayofTime.alchemicalWizardry.api.soulNetwork;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class LifeEssenceNetwork extends net.minecraft.world.WorldSavedData
|
||||
{
|
||||
public int currentEssence;
|
||||
|
||||
public LifeEssenceNetwork(String par1Str)
|
||||
{
|
||||
super(par1Str);
|
||||
currentEssence = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
currentEssence = nbttagcompound.getInteger("currentEssence");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
nbttagcompound.setInteger("currentEssence", currentEssence);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,303 @@
|
|||
package WayofTime.alchemicalWizardry.api.soulNetwork;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class SoulNetworkHandler
|
||||
{
|
||||
public static UUID getUUIDFromPlayer(EntityPlayer player)
|
||||
{
|
||||
return player.getPersistentID();
|
||||
}
|
||||
|
||||
public static EntityPlayer getPlayerFromUUID(UUID uuid)
|
||||
{
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
GameProfile gameProfile;
|
||||
gameProfile = server.func_152358_ax().func_152652_a(uuid);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int syphonFromNetwork(ItemStack ist, int damageToBeDone)
|
||||
{
|
||||
if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals("")))
|
||||
{
|
||||
String ownerName = ist.getTagCompound().getString("ownerName");
|
||||
|
||||
return syphonFromNetwork(ownerName, damageToBeDone);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int syphonFromNetwork(String ownerName, int damageToBeDone)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
|
||||
if (data.currentEssence >= damageToBeDone)
|
||||
{
|
||||
data.currentEssence -= damageToBeDone;
|
||||
data.markDirty();
|
||||
return damageToBeDone;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Master method used to syphon from the player's network, and will damage them accordingly if they do not have enough LP.
|
||||
* Does not drain on the client side.
|
||||
*
|
||||
* @param ist Owned itemStack
|
||||
* @param player Player using the item
|
||||
* @param damageToBeDone
|
||||
* @return True if server-sided, false if client-sided
|
||||
*/
|
||||
public static boolean syphonAndDamageFromNetwork(ItemStack ist, EntityPlayer player, int damageToBeDone)
|
||||
{
|
||||
if (player.worldObj.isRemote)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int amount = SoulNetworkHandler.syphonFromNetwork(ist, damageToBeDone);
|
||||
|
||||
hurtPlayer(player, damageToBeDone - amount);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean syphonAndDamageFromNetwork(String ownerName, EntityPlayer player, int damageToBeDone)
|
||||
{
|
||||
if (player.worldObj.isRemote)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int amount = SoulNetworkHandler.syphonFromNetwork(ownerName, damageToBeDone);
|
||||
|
||||
hurtPlayer(player, damageToBeDone - amount);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean canSyphonFromOnlyNetwork(ItemStack ist, int damageToBeDone)
|
||||
{
|
||||
if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals("")))
|
||||
{
|
||||
String ownerName = ist.getTagCompound().getString("ownerName");
|
||||
|
||||
return canSyphonFromOnlyNetwork(ownerName, damageToBeDone);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canSyphonFromOnlyNetwork(String ownerName, int damageToBeDone)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
|
||||
return data.currentEssence >= damageToBeDone;
|
||||
}
|
||||
|
||||
public static int getCurrentEssence(String ownerName)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
|
||||
return data.currentEssence;
|
||||
}
|
||||
|
||||
public static void setCurrentEssence(String ownerName, int essence)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
|
||||
data.currentEssence = essence;
|
||||
data.markDirty();
|
||||
}
|
||||
|
||||
/**
|
||||
* A method to add to an owner's network up to a maximum value.
|
||||
*
|
||||
* @param ownerName
|
||||
* @param addedEssence
|
||||
* @param maximum
|
||||
* @return amount added to the network
|
||||
*/
|
||||
public static int addCurrentEssenceToMaximum(String ownerName, int addedEssence, int maximum)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
|
||||
int currEss = data.currentEssence;
|
||||
|
||||
if (currEss >= maximum)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int newEss = Math.min(maximum, currEss + addedEssence);
|
||||
data.currentEssence = newEss;
|
||||
|
||||
return newEss - currEss;
|
||||
}
|
||||
|
||||
public static void hurtPlayer(EntityPlayer user, int energySyphoned)
|
||||
{
|
||||
if (energySyphoned < 100 && energySyphoned > 0)
|
||||
{
|
||||
if (!user.capabilities.isCreativeMode)
|
||||
{
|
||||
user.setHealth((user.getHealth() - 1));
|
||||
|
||||
if (user.getHealth() <= 0.0005f)
|
||||
{
|
||||
user.onDeath(DamageSource.generic);
|
||||
}
|
||||
}
|
||||
} else if (energySyphoned >= 100)
|
||||
{
|
||||
if (!user.capabilities.isCreativeMode)
|
||||
{
|
||||
for (int i = 0; i < ((energySyphoned + 99) / 100); i++)
|
||||
{
|
||||
user.setHealth((user.getHealth() - 1));
|
||||
|
||||
if (user.getHealth() <= 0.0005f)
|
||||
{
|
||||
user.onDeath(DamageSource.generic);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkAndSetItemOwner(ItemStack item, EntityPlayer player)
|
||||
{
|
||||
if (item.stackTagCompound == null)
|
||||
{
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (item.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
item.stackTagCompound.setString("ownerName", SoulNetworkHandler.getUsername(player));
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkAndSetItemOwner(ItemStack item, String ownerName)
|
||||
{
|
||||
if (item.stackTagCompound == null)
|
||||
{
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (item.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
item.stackTagCompound.setString("ownerName", ownerName);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getUsername(EntityPlayer player)
|
||||
{
|
||||
return player.getDisplayName();
|
||||
}
|
||||
|
||||
public static EntityPlayer getPlayerForUsername(String str)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return MinecraftServer.getServer().getConfigurationManager().func_152612_a(str);
|
||||
}
|
||||
|
||||
public static void causeNauseaToPlayer(ItemStack stack)
|
||||
{
|
||||
if (stack.getTagCompound() != null && !(stack.getTagCompound().getString("ownerName").equals("")))
|
||||
{
|
||||
String ownerName = stack.getTagCompound().getString("ownerName");
|
||||
|
||||
SoulNetworkHandler.causeNauseaToPlayer(ownerName);
|
||||
}
|
||||
}
|
||||
|
||||
public static void causeNauseaToPlayer(String ownerName)
|
||||
{
|
||||
EntityPlayer entityOwner = SoulNetworkHandler.getPlayerForUsername(ownerName);
|
||||
|
||||
if (entityOwner == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package WayofTime.alchemicalWizardry.api.summoningRegistry;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class SummoningHelper
|
||||
{
|
||||
protected String id;
|
||||
|
||||
public SummoningHelper(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public abstract EntityLivingBase getEntity(World worldObj);
|
||||
|
||||
public String getSummoningHelperID()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package WayofTime.alchemicalWizardry.api.summoningRegistry;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SummoningRegistry
|
||||
{
|
||||
public static List<SummoningRegistryComponent> summoningList = new ArrayList();
|
||||
|
||||
public static void registerSummon(SummoningHelper s, ItemStack[] ring1, ItemStack[] ring2, ItemStack[] ring3, int amountUsed, int bloodOrbLevel)
|
||||
{
|
||||
summoningList.add(new SummoningRegistryComponent(s, ring1, ring2, ring3, amountUsed, bloodOrbLevel));
|
||||
}
|
||||
|
||||
public static boolean isRecipeValid(int bloodOrbLevel, ItemStack[] test1, ItemStack[] test2, ItemStack[] test3)
|
||||
{
|
||||
for (SummoningRegistryComponent src : summoningList)
|
||||
{
|
||||
if (src.getBloodOrbLevel() <= bloodOrbLevel && src.compareRing(1, test1) && src.compareRing(2, test2) && src.compareRing(3, test3))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static SummoningRegistryComponent getRegistryComponent(int bloodOrbLevel, ItemStack[] test1, ItemStack[] test2, ItemStack[] test3)
|
||||
{
|
||||
for (SummoningRegistryComponent src : summoningList)
|
||||
{
|
||||
if (src.getBloodOrbLevel() <= bloodOrbLevel && src.compareRing(1, test1) && src.compareRing(2, test2) && src.compareRing(3, test3))
|
||||
{
|
||||
return src;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EntityLivingBase getEntity(World worldObj, int bloodOrbLevel, ItemStack[] test1, ItemStack[] test2, ItemStack[] test3)
|
||||
{
|
||||
for (SummoningRegistryComponent src : summoningList)
|
||||
{
|
||||
if (src.getBloodOrbLevel() <= bloodOrbLevel && src.compareRing(1, test1) && src.compareRing(2, test2) && src.compareRing(3, test3))
|
||||
{
|
||||
return src.getEntity(worldObj);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EntityLivingBase getEntityWithID(World worldObj, String id)
|
||||
{
|
||||
for (SummoningRegistryComponent src : summoningList)
|
||||
{
|
||||
if (src.getSummoningHelperID().equals(id))
|
||||
{
|
||||
return src.getEntity(worldObj);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,231 @@
|
|||
package WayofTime.alchemicalWizardry.api.summoningRegistry;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class SummoningRegistryComponent
|
||||
{
|
||||
public ItemStack[] ring1 = new ItemStack[6];
|
||||
public ItemStack[] ring2 = new ItemStack[6];
|
||||
public ItemStack[] ring3 = new ItemStack[6];
|
||||
public SummoningHelper summoningHelper;
|
||||
public int summoningCost;
|
||||
public int bloodOrbLevel;
|
||||
|
||||
public SummoningRegistryComponent(SummoningHelper s, ItemStack[] newRing1, ItemStack[] newRing2, ItemStack[] newRing3, int amount, int bloodOrbLevel)
|
||||
{
|
||||
this.summoningHelper = s;
|
||||
this.ring1 = newRing1;
|
||||
this.ring2 = newRing2;
|
||||
this.ring3 = newRing3;
|
||||
this.summoningCost = amount;
|
||||
this.bloodOrbLevel = bloodOrbLevel;
|
||||
|
||||
if (this.ring1.length != 6)
|
||||
{
|
||||
ItemStack[] newRecipe = new ItemStack[6];
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (i + 1 > this.ring1.length)
|
||||
{
|
||||
newRecipe[i] = null;
|
||||
} else
|
||||
{
|
||||
newRecipe[i] = this.ring1[i];
|
||||
}
|
||||
}
|
||||
|
||||
this.ring1 = newRecipe;
|
||||
}
|
||||
|
||||
if (this.ring2.length != 6)
|
||||
{
|
||||
ItemStack[] newRecipe = new ItemStack[6];
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (i + 1 > this.ring2.length)
|
||||
{
|
||||
newRecipe[i] = null;
|
||||
} else
|
||||
{
|
||||
newRecipe[i] = this.ring2[i];
|
||||
}
|
||||
}
|
||||
|
||||
this.ring2 = newRecipe;
|
||||
}
|
||||
|
||||
if (this.ring3.length != 6)
|
||||
{
|
||||
ItemStack[] newRecipe = new ItemStack[6];
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (i + 1 > this.ring3.length)
|
||||
{
|
||||
newRecipe[i] = null;
|
||||
} else
|
||||
{
|
||||
newRecipe[i] = this.ring3[i];
|
||||
}
|
||||
}
|
||||
|
||||
this.ring3 = newRecipe;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean compareRing(int ring, ItemStack[] checkedRingRecipe)
|
||||
{
|
||||
ItemStack[] recipe;
|
||||
|
||||
if (checkedRingRecipe.length < 6)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (ring)
|
||||
{
|
||||
case 1:
|
||||
recipe = ring1;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
recipe = ring2;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
recipe = ring3;
|
||||
break;
|
||||
|
||||
default:
|
||||
recipe = ring1;
|
||||
}
|
||||
|
||||
if (recipe.length != 6)
|
||||
{
|
||||
ItemStack[] newRecipe = new ItemStack[6];
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (i + 1 > recipe.length)
|
||||
{
|
||||
newRecipe[i] = null;
|
||||
} else
|
||||
{
|
||||
newRecipe[i] = recipe[i];
|
||||
}
|
||||
}
|
||||
|
||||
recipe = newRecipe;
|
||||
}
|
||||
|
||||
boolean[] checkList = new boolean[6];
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
checkList[i] = false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ItemStack recipeItemStack = recipe[i];
|
||||
|
||||
if (recipeItemStack == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean test = false;
|
||||
|
||||
for (int j = 0; j < 6; j++)
|
||||
{
|
||||
if (checkList[j])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack checkedItemStack = checkedRingRecipe[j];
|
||||
|
||||
if (checkedItemStack == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean quickTest = false;
|
||||
|
||||
if (recipeItemStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
if (checkedItemStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
quickTest = true;
|
||||
}
|
||||
} else if (!(checkedItemStack.getItem() instanceof ItemBlock))
|
||||
{
|
||||
quickTest = true;
|
||||
}
|
||||
|
||||
if (!quickTest)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((checkedItemStack.getItemDamage() == recipeItemStack.getItemDamage() || OreDictionary.WILDCARD_VALUE == recipeItemStack.getItemDamage()) && checkedItemStack.getItem() == recipeItemStack.getItem())
|
||||
{
|
||||
test = true;
|
||||
checkList[j] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!test)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getSummoningCost()
|
||||
{
|
||||
return summoningCost;
|
||||
}
|
||||
|
||||
public EntityLivingBase getEntity(World world)
|
||||
{
|
||||
return this.summoningHelper.getEntity(world);
|
||||
}
|
||||
|
||||
public int getBloodOrbLevel()
|
||||
{
|
||||
return this.bloodOrbLevel;
|
||||
}
|
||||
|
||||
public ItemStack[] getRingRecipeForRing(int ring)
|
||||
{
|
||||
switch (ring)
|
||||
{
|
||||
case 1:
|
||||
return ring1;
|
||||
|
||||
case 2:
|
||||
return ring2;
|
||||
|
||||
case 3:
|
||||
return ring3;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getSummoningHelperID()
|
||||
{
|
||||
return this.summoningHelper.getSummoningHelperID();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package WayofTime.alchemicalWizardry.api.tile;
|
||||
|
||||
/**
|
||||
* Created by Pokefenn.
|
||||
*/
|
||||
public interface IBloodAltar
|
||||
{
|
||||
|
||||
public int getCapacity();
|
||||
|
||||
public int getCurrentBlood();
|
||||
|
||||
public int getTier();
|
||||
|
||||
public int getProgress();
|
||||
|
||||
public float getSacrificeMultiplier();
|
||||
|
||||
public float getSelfSacrificeMultiplier();
|
||||
|
||||
public float getOrbMultiplier();
|
||||
|
||||
public float getDislocationMultiplier();
|
||||
|
||||
public int getBufferCapacity();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue