Added altar recipe registry
This commit is contained in:
parent
eb46185dc8
commit
17f63200aa
|
@ -37,6 +37,7 @@ import WayofTime.alchemicalWizardry.common.PotionProjectileProtect;
|
||||||
import WayofTime.alchemicalWizardry.common.PotionReciprocation;
|
import WayofTime.alchemicalWizardry.common.PotionReciprocation;
|
||||||
import WayofTime.alchemicalWizardry.common.alchemy.AlchemicalPotionCreationHandler;
|
import WayofTime.alchemicalWizardry.common.alchemy.AlchemicalPotionCreationHandler;
|
||||||
import WayofTime.alchemicalWizardry.common.alchemy.AlchemyRecipeRegistry;
|
import WayofTime.alchemicalWizardry.common.alchemy.AlchemyRecipeRegistry;
|
||||||
|
import WayofTime.alchemicalWizardry.common.altarRecipeRegistry.AltarRecipeRegistry;
|
||||||
import WayofTime.alchemicalWizardry.common.block.ArmourForge;
|
import WayofTime.alchemicalWizardry.common.block.ArmourForge;
|
||||||
import WayofTime.alchemicalWizardry.common.block.LifeEssenceBlock;
|
import WayofTime.alchemicalWizardry.common.block.LifeEssenceBlock;
|
||||||
import WayofTime.alchemicalWizardry.common.bloodAltarUpgrade.UpgradedAltars;
|
import WayofTime.alchemicalWizardry.common.bloodAltarUpgrade.UpgradedAltars;
|
||||||
|
@ -785,6 +786,7 @@ public class AlchemicalWizardry
|
||||||
ArmourForge.initializeRecipes();
|
ArmourForge.initializeRecipes();
|
||||||
TEPlinth.initialize();
|
TEPlinth.initialize();
|
||||||
AlchemicalPotionCreationHandler.initializePotions();
|
AlchemicalPotionCreationHandler.initializePotions();
|
||||||
|
AltarRecipeRegistry.initRecipes();
|
||||||
MinecraftForge.setToolClass(ModItems.boundPickaxe, "pickaxe", 5);
|
MinecraftForge.setToolClass(ModItems.boundPickaxe, "pickaxe", 5);
|
||||||
MinecraftForge.setToolClass(ModItems.boundAxe, "axe", 5);
|
MinecraftForge.setToolClass(ModItems.boundAxe, "axe", 5);
|
||||||
MinecraftForge.setToolClass(ModItems.boundShovel, "shovel", 5);
|
MinecraftForge.setToolClass(ModItems.boundShovel, "shovel", 5);
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
package WayofTime.alchemicalWizardry.common.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,83 @@
|
||||||
|
package WayofTime.alchemicalWizardry.common.altarRecipeRegistry;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import WayofTime.alchemicalWizardry.ModItems;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
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 void initRecipes()
|
||||||
|
{
|
||||||
|
registerAltarRecipe(new ItemStack(ModItems.weakBloodOrb), new ItemStack(Item.diamond),1,2000,2,1,false);
|
||||||
|
registerAltarRecipe(new ItemStack(ModItems.apprenticeBloodOrb), new ItemStack(Item.emerald),2,5000,5,5,false);
|
||||||
|
registerAltarRecipe(new ItemStack(ModItems.magicianBloodOrb), new ItemStack(Block.blockGold),3,5000,5,5,false);
|
||||||
|
registerAltarRecipe(new ItemStack(ModItems.masterBloodOrb), new ItemStack(ModItems.weakBloodShard),4,40000,30,50,false);
|
||||||
|
registerAltarRecipe(new ItemStack(ModItems.archmageBloodOrb), new ItemStack(ModItems.demonBloodShard),5,50000,5,5,false);
|
||||||
|
|
||||||
|
registerAltarOrbRecipe(new ItemStack(ModItems.weakBloodOrb),1,2);
|
||||||
|
registerAltarOrbRecipe(new ItemStack(ModItems.apprenticeBloodOrb),2,5);
|
||||||
|
registerAltarOrbRecipe(new ItemStack(ModItems.magicianBloodOrb),3,5);
|
||||||
|
registerAltarOrbRecipe(new ItemStack(ModItems.masterBloodOrb),4,25);
|
||||||
|
registerAltarOrbRecipe(new ItemStack(ModItems.archmageBloodOrb),5,50);
|
||||||
|
|
||||||
|
registerAltarRecipe(new ItemStack(ModItems.telepositionFocus), new ItemStack(Item.enderPearl),4,2000,10,10,false);
|
||||||
|
registerAltarRecipe(new ItemStack(ModItems.enhancedTelepositionFocus), new ItemStack(ModItems.telepositionFocus),4,10000,25,15,false);
|
||||||
|
registerAltarRecipe(new ItemStack(ModItems.imbuedSlate), new ItemStack(ModItems.imbuedSlate),4,15000,20,20,false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,8 @@ import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||||
import WayofTime.alchemicalWizardry.ModBlocks;
|
import WayofTime.alchemicalWizardry.ModBlocks;
|
||||||
import WayofTime.alchemicalWizardry.ModItems;
|
import WayofTime.alchemicalWizardry.ModItems;
|
||||||
import WayofTime.alchemicalWizardry.common.*;
|
import WayofTime.alchemicalWizardry.common.*;
|
||||||
|
import WayofTime.alchemicalWizardry.common.altarRecipeRegistry.AltarRecipe;
|
||||||
|
import WayofTime.alchemicalWizardry.common.altarRecipeRegistry.AltarRecipeRegistry;
|
||||||
import WayofTime.alchemicalWizardry.common.bloodAltarUpgrade.AltarUpgradeComponent;
|
import WayofTime.alchemicalWizardry.common.bloodAltarUpgrade.AltarUpgradeComponent;
|
||||||
import WayofTime.alchemicalWizardry.common.bloodAltarUpgrade.UpgradedAltars;
|
import WayofTime.alchemicalWizardry.common.bloodAltarUpgrade.UpgradedAltars;
|
||||||
import WayofTime.alchemicalWizardry.common.items.EnergyBattery;
|
import WayofTime.alchemicalWizardry.common.items.EnergyBattery;
|
||||||
|
@ -535,14 +537,19 @@ public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFlui
|
||||||
if (progress >= liquidRequired * stackSize)
|
if (progress >= liquidRequired * stackSize)
|
||||||
{
|
{
|
||||||
ItemStack result = null;
|
ItemStack result = null;
|
||||||
|
result = AltarRecipeRegistry.getItemForItemAndTier(this.getStackInSlot(0), this.upgradeLevel);
|
||||||
if (!isResultBlock)
|
if(result!=null)
|
||||||
{
|
{
|
||||||
result = new ItemStack(resultID, stackSize, resultDamage);
|
result.stackSize*=stackSize;
|
||||||
} else
|
|
||||||
{
|
|
||||||
result = new ItemStack(Block.blocksList[resultID], stackSize, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (!isResultBlock)
|
||||||
|
// {
|
||||||
|
// result = new ItemStack(resultID, stackSize, resultDamage);
|
||||||
|
// } else
|
||||||
|
// {
|
||||||
|
// result = new ItemStack(Block.blocksList[resultID], stackSize, 0);
|
||||||
|
// }
|
||||||
|
|
||||||
setInventorySlotContents(0, result);
|
setInventorySlotContents(0, result);
|
||||||
progress = 0;
|
progress = 0;
|
||||||
|
@ -765,6 +772,17 @@ public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFlui
|
||||||
{
|
{
|
||||||
progress = 0;
|
progress = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(AltarRecipeRegistry.isRequiredItemValid(getStackInSlot(0), upgradeLevel))
|
||||||
|
{
|
||||||
|
AltarRecipe recipe = AltarRecipeRegistry.getAltarRecipeForItemAndTier(getStackInSlot(0), upgradeLevel);
|
||||||
|
this.isActive = true;
|
||||||
|
this.liquidRequired = recipe.getLiquidRequired();
|
||||||
|
this.canBeFilled = recipe.getCanBeFilled();
|
||||||
|
this.consumptionRate = recipe.getConsumptionRate();
|
||||||
|
this.drainRate = recipe.drainRate;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (getStackInSlot(0).getItem() instanceof ItemBlock)
|
if (getStackInSlot(0).getItem() instanceof ItemBlock)
|
||||||
{
|
{
|
||||||
|
@ -902,83 +920,10 @@ public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFlui
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getStackInSlot(0).itemID == ModItems.archmageBloodOrb.itemID)
|
|
||||||
{
|
|
||||||
ItemStack item = getStackInSlot(0);
|
|
||||||
|
|
||||||
if (item.stackTagCompound == null || item.stackTagCompound.getString("ownerName").equals(""))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
isActive = true;
|
|
||||||
canBeFilled = true;
|
|
||||||
consumptionRate = 50;
|
|
||||||
isResultBlock = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (upgradeLevel >= 4)
|
if (upgradeLevel >= 4)
|
||||||
{
|
{
|
||||||
if (getStackInSlot(0).itemID == ModItems.weakBloodShard.itemID)
|
|
||||||
{
|
|
||||||
isActive = true;
|
|
||||||
liquidRequired = 40000;
|
|
||||||
canBeFilled = false;
|
|
||||||
consumptionRate = 30;
|
|
||||||
drainRate = 50;
|
|
||||||
resultID = ModItems.masterBloodOrb.itemID;
|
|
||||||
resultDamage = 0;
|
|
||||||
isResultBlock = false;
|
|
||||||
//setInventorySlotContents(1, bloodOrb);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getStackInSlot(0).itemID == ModItems.masterBloodOrb.itemID)
|
|
||||||
{
|
|
||||||
ItemStack item = getStackInSlot(0);
|
|
||||||
|
|
||||||
if (item.stackTagCompound == null || item.stackTagCompound.getString("ownerName").equals(""))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
isActive = true;
|
|
||||||
canBeFilled = true;
|
|
||||||
consumptionRate = 25;
|
|
||||||
isResultBlock = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getStackInSlot(0).itemID == Item.enderPearl.itemID)
|
|
||||||
{
|
|
||||||
isActive = true;
|
|
||||||
liquidRequired = 5000;
|
|
||||||
canBeFilled = false;
|
|
||||||
consumptionRate = 10;
|
|
||||||
drainRate = 10;
|
|
||||||
resultID = ModItems.telepositionFocus.itemID;
|
|
||||||
resultDamage = 0;
|
|
||||||
isResultBlock = false;
|
|
||||||
//setInventorySlotContents(1, bloodOrb);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getStackInSlot(0).itemID == ModItems.telepositionFocus.itemID)
|
|
||||||
{
|
|
||||||
isActive = true;
|
|
||||||
liquidRequired = 10000;
|
|
||||||
canBeFilled = false;
|
|
||||||
consumptionRate = 25;
|
|
||||||
drainRate = 15;
|
|
||||||
resultID = ModItems.enhancedTelepositionFocus.itemID;
|
|
||||||
resultDamage = 0;
|
|
||||||
isResultBlock = false;
|
|
||||||
//setInventorySlotContents(1, bloodOrb);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getStackInSlot(0).itemID == ModItems.imbuedSlate.itemID)
|
if (getStackInSlot(0).itemID == ModItems.imbuedSlate.itemID)
|
||||||
{
|
{
|
||||||
isActive = true;
|
isActive = true;
|
||||||
|
@ -987,7 +932,7 @@ public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFlui
|
||||||
consumptionRate = 5;
|
consumptionRate = 5;
|
||||||
drainRate = 5;
|
drainRate = 5;
|
||||||
ItemStack bloodOrb = new ItemStack(ModItems.apprenticeBloodOrb);
|
ItemStack bloodOrb = new ItemStack(ModItems.apprenticeBloodOrb);
|
||||||
resultID = ModItems.demonicSlate.itemID;
|
resultID = ModItems.imbuedSlate.itemID;
|
||||||
resultDamage = 0;
|
resultDamage = 0;
|
||||||
isResultBlock = false;
|
isResultBlock = false;
|
||||||
//setInventorySlotContents(1, bloodOrb);
|
//setInventorySlotContents(1, bloodOrb);
|
||||||
|
@ -1074,36 +1019,9 @@ public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFlui
|
||||||
|
|
||||||
if (upgradeLevel >= 2)
|
if (upgradeLevel >= 2)
|
||||||
{
|
{
|
||||||
if (getStackInSlot(0).itemID == Item.emerald.itemID)
|
|
||||||
{
|
|
||||||
isActive = true;
|
|
||||||
liquidRequired = 5000;
|
|
||||||
canBeFilled = false;
|
|
||||||
consumptionRate = 5;
|
|
||||||
drainRate = 5;
|
|
||||||
ItemStack bloodOrb = new ItemStack(ModItems.apprenticeBloodOrb);
|
|
||||||
resultID = ModItems.apprenticeBloodOrb.itemID;
|
|
||||||
resultDamage = 0;
|
|
||||||
isResultBlock = false;
|
|
||||||
//setInventorySlotContents(1, bloodOrb);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getStackInSlot(0).itemID == ModItems.apprenticeBloodOrb.itemID)
|
|
||||||
{
|
|
||||||
ItemStack item = getStackInSlot(0);
|
|
||||||
|
|
||||||
if (item.stackTagCompound == null || item.stackTagCompound.getString("ownerName").equals(""))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
isActive = true;
|
|
||||||
canBeFilled = true;
|
|
||||||
consumptionRate = 5;
|
|
||||||
isResultBlock = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getStackInSlot(0).itemID == Item.swordIron.itemID)
|
if (getStackInSlot(0).itemID == Item.swordIron.itemID)
|
||||||
{
|
{
|
||||||
|
@ -1149,36 +1067,22 @@ public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFlui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getStackInSlot(0).itemID == Item.diamond.itemID)
|
// if (getStackInSlot(0).itemID == Item.diamond.itemID)
|
||||||
{
|
// {
|
||||||
isActive = true;
|
// isActive = true;
|
||||||
liquidRequired = 2000;
|
// liquidRequired = 2000;
|
||||||
canBeFilled = false;
|
// canBeFilled = false;
|
||||||
consumptionRate = 2;
|
// consumptionRate = 2;
|
||||||
drainRate = 1;
|
// drainRate = 1;
|
||||||
ItemStack bloodOrb = new ItemStack(ModItems.weakBloodOrb);
|
// ItemStack bloodOrb = new ItemStack(ModItems.weakBloodOrb);
|
||||||
resultID = ModItems.weakBloodOrb.itemID;
|
// resultID = ModItems.weakBloodOrb.itemID;
|
||||||
resultDamage = 0;
|
// resultDamage = 0;
|
||||||
isResultBlock = false;
|
// isResultBlock = false;
|
||||||
//setInventorySlotContents(1, bloodOrb);
|
// //setInventorySlotContents(1, bloodOrb);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (getStackInSlot(0).itemID == ModItems.weakBloodOrb.itemID)
|
|
||||||
{
|
|
||||||
ItemStack item = getStackInSlot(0);
|
|
||||||
|
|
||||||
if (item.stackTagCompound == null || item.stackTagCompound.getString("ownerName").equals(""))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
isActive = true;
|
|
||||||
canBeFilled = true;
|
|
||||||
consumptionRate = 2;
|
|
||||||
isResultBlock = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getStackInSlot(0).itemID == Item.bucketEmpty.itemID)
|
if (getStackInSlot(0).itemID == Item.bucketEmpty.itemID)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue