Added the framework for a ritual that grants downgrades (instead of the potion method)

This commit is contained in:
WayofTime 2016-10-08 21:23:16 -04:00
parent 43f86abc58
commit ed8427c04e
13 changed files with 661 additions and 4 deletions

View file

@ -109,7 +109,7 @@ public class LivingArmour implements ILivingArmour
if (nextLevel > currentLevel)
{
int upgradePointDifference = upgrade.getCostOfUpgrade() - upgradeMap.get(key).getCostOfUpgrade();
if (Math.abs(upgradePointDifference) >= 0 && totalUpgradePoints + upgradePointDifference <= maxUpgradePoints)
if (totalUpgradePoints + upgradePointDifference <= maxUpgradePoints)
{
upgradeMap.put(key, upgrade);
totalUpgradePoints += upgradePointDifference;
@ -142,6 +142,36 @@ public class LivingArmour implements ILivingArmour
return false;
}
@Override
public boolean canApplyUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade)
{
String key = upgrade.getUniqueIdentifier();
if (upgradeMap.containsKey(key))
{
//Check if this is a higher level than the previous upgrade
int nextLevel = upgrade.getUpgradeLevel();
int currentLevel = upgradeMap.get(key).getUpgradeLevel();
if (nextLevel > currentLevel)
{
int upgradePointDifference = upgrade.getCostOfUpgrade() - upgradeMap.get(key).getCostOfUpgrade();
if (totalUpgradePoints + upgradePointDifference <= maxUpgradePoints)
{
return true;
}
}
} else
{
int upgradePoints = upgrade.getCostOfUpgrade();
if (totalUpgradePoints + upgradePoints <= maxUpgradePoints)
{
return true;
}
}
return false;
}
@Override
public void notifyPlayerOfUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade)
{

View file

@ -0,0 +1,64 @@
package WayofTime.bloodmagic.livingArmour.downgrade;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.ILivingArmour;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
public class LivingArmourUpgradeStormTrooper extends LivingArmourUpgrade
{
public static final int[] costs = new int[] { -150 };
public static final float[] inaccuracy = new float[] { 0.04f, 0.08f, 0.12f, 0.16f, 0.2f };
public LivingArmourUpgradeStormTrooper(int level)
{
super(level);
}
@Override
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour)
{
}
public float getArrowJiggle(EntityPlayer player)
{
return inaccuracy[this.level];
}
@Override
public String getUniqueIdentifier()
{
return Constants.Mod.MODID + ".upgrade.stormTrooper";
}
@Override
public int getMaxTier()
{
return 1;
}
@Override
public int getCostOfUpgrade()
{
return costs[this.level];
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
}
@Override
public String getUnlocalizedName()
{
return tooltipBase + "stormTrooper";
}
}