Testing
This commit is contained in:
commit
8601e9faff
498 changed files with 45817 additions and 0 deletions
|
@ -0,0 +1,107 @@
|
|||
package WayofTime.alchemicalWizardry.common.alchemy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
|
||||
public class AlchemicalPotionCreationHandler
|
||||
{
|
||||
public static ArrayList<AlchemyPotionHandlerComponent> registeredPotionEffects = new ArrayList();
|
||||
|
||||
public static void initializePotions()
|
||||
{
|
||||
addPotion(new ItemStack(Item.ghastTear), Potion.regeneration.id, 450);
|
||||
addPotion(new ItemStack(Item.goldenCarrot), Potion.nightVision.id, 2 * 60 * 20);
|
||||
addPotion(new ItemStack(Item.magmaCream), Potion.fireResistance.id, 2 * 60 * 20);
|
||||
addPotion(new ItemStack(Item.sugar), Potion.moveSpeed.id, 2 * 60 * 20);
|
||||
addPotion(new ItemStack(Item.speckledMelon), Potion.heal.id, 2 * 60 * 20);
|
||||
addPotion(new ItemStack(Item.spiderEye), Potion.poison.id, 450);
|
||||
addPotion(new ItemStack(Item.fermentedSpiderEye), Potion.weakness.id, 450);
|
||||
addPotion(new ItemStack(Item.blazePowder), Potion.damageBoost.id, 2 * 60 * 20);
|
||||
addPotion(new ItemStack(AlchemicalWizardry.aether), Potion.jump.id, 2 * 60 * 20);
|
||||
addPotion(new ItemStack(Item.clay), Potion.moveSlowdown.id, 450);
|
||||
addPotion(new ItemStack(Item.redstone), Potion.digSpeed.id, 2 * 60 * 20);
|
||||
addPotion(new ItemStack(Item.potion, 1, 0), AlchemicalWizardry.customPotionDrowning.id, 450);
|
||||
//addPotion(new ItemStack(Item.goldenCarrot),Potion.nightVision.id,2*60*20);
|
||||
addPotion(new ItemStack(Item.glassBottle), Potion.invisibility.id, 2 * 60 * 20);
|
||||
addPotion(new ItemStack(Item.diamond), Potion.resistance.id, 2 * 60 * 20);
|
||||
addPotion(new ItemStack(Item.poisonousPotato), Potion.field_76443_y.id, 2); //saturation
|
||||
addPotion(new ItemStack(AlchemicalWizardry.demonBloodShard), Potion.field_76434_w.id, 4 * 60 * 20); //health boost
|
||||
addPotion(new ItemStack(AlchemicalWizardry.weakBloodShard), Potion.field_76444_x.id, 4 * 60 * 20); //Absorption
|
||||
addPotion(new ItemStack(AlchemicalWizardry.terrae), AlchemicalWizardry.customPotionBoost.id, 1 * 60 * 20);
|
||||
addPotion(new ItemStack(Item.feather), AlchemicalWizardry.customPotionFlight.id, 1 * 60 * 20);
|
||||
addPotion(new ItemStack(Item.arrow), AlchemicalWizardry.customPotionReciprocation.id, 1 * 60 * 20);
|
||||
}
|
||||
|
||||
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,53 @@
|
|||
package WayofTime.alchemicalWizardry.common.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.itemID == itemStack.itemID && comparedStack.getItemDamage() == itemStack.getItemDamage();
|
||||
}
|
||||
}
|
||||
else if (!(itemStack.getItem() instanceof ItemBlock))
|
||||
{
|
||||
return comparedStack.itemID == itemStack.itemID && 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.common.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,179 @@
|
|||
package WayofTime.alchemicalWizardry.common.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.itemID == recipeItemStack.itemID)
|
||||
{
|
||||
test = true;
|
||||
checkList[j] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!test)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
// if(slottedBloodOrbLevel<bloodOrbLevel)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// if(items.length<5)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// for(int i=0;i<5;i++)
|
||||
// {
|
||||
// ItemStack itemStackR = this.recipe[i];
|
||||
// ItemStack itemStackC = items[i];
|
||||
//
|
||||
// if(itemStackR==null&&itemStackC==null)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if(itemStackR==null||itemStackC==null)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// Item itemR = itemStackR.getItem();
|
||||
// Item itemC = itemStackC.getItem();
|
||||
//
|
||||
// if(itemR.equals(itemC))
|
||||
// {
|
||||
// continue;
|
||||
// }else
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
}
|
||||
|
||||
public ItemStack getResult()
|
||||
{
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
public int getAmountNeeded()
|
||||
{
|
||||
return this.amountNeeded;
|
||||
}
|
||||
|
||||
public ItemStack[] getRecipe()
|
||||
{
|
||||
return this.recipe;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package WayofTime.alchemicalWizardry.common.alchemy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyBattery;
|
||||
|
||||
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 EnergyBattery))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int bloodOrbLevel = ((EnergyBattery)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 EnergyBattery))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bloodOrbLevel = ((EnergyBattery)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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue