BloodMagic/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradePoisonResist.java

70 lines
2.3 KiB
Java
Raw Normal View History

package WayofTime.bloodmagic.livingArmour.upgrade;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.util.Constants;
import WayofTime.bloodmagic.livingArmour.ILivingArmour;
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade;
2017-08-15 21:30:48 -07:00
import WayofTime.bloodmagic.util.helper.TextHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;
2017-08-15 21:30:48 -07:00
public class LivingArmourUpgradePoisonResist extends LivingArmourUpgrade {
public static final int[] costs = new int[]{2, 6, 14, 25, 40};
public static final int[] poisonCooldownTime = new int[]{1200, 800, 600, 300, 100};
public static final int[] poisonMaxCure = new int[]{0, 1, 2, 2, 3};
public int poisonCooldown = 0;
2017-08-15 21:30:48 -07:00
public LivingArmourUpgradePoisonResist(int level) {
super(level);
}
@Override
2017-08-15 21:30:48 -07:00
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) {
if (player.isPotionActive(MobEffects.POISON) && poisonCooldown <= 0) {
2016-04-24 10:06:28 -07:00
PotionEffect eff = player.getActivePotionEffect(MobEffects.POISON);
2017-08-15 21:30:48 -07:00
if (eff.getAmplifier() <= poisonMaxCure[this.level]) {
2016-04-24 10:06:28 -07:00
player.removePotionEffect(MobEffects.POISON);
poisonCooldown = poisonCooldownTime[this.level];
player.sendStatusMessage(new TextComponentString(TextHelper.localize(chatBase + "poisonRemove")), true);
}
2017-08-15 21:30:48 -07:00
} else if (poisonCooldown > 0) {
poisonCooldown--;
}
}
@Override
2017-08-15 21:30:48 -07:00
public String getUniqueIdentifier() {
return BloodMagic.MODID + ".upgrade.poisonResist";
}
@Override
2017-08-15 21:30:48 -07:00
public int getMaxTier() {
return 5; // Set to here until I can add more upgrades to it.
}
@Override
2017-08-15 21:30:48 -07:00
public int getCostOfUpgrade() {
return costs[this.level];
}
@Override
2017-08-15 21:30:48 -07:00
public void writeToNBT(NBTTagCompound tag) {
tag.setInteger(Constants.NBT.UPGRADE_POISON_TIMER, poisonCooldown);
}
@Override
2017-08-15 21:30:48 -07:00
public void readFromNBT(NBTTagCompound tag) {
poisonCooldown = tag.getInteger(Constants.NBT.UPGRADE_POISON_TIMER);
}
@Override
2019-01-31 19:10:37 -08:00
public String getTranslationKey() {
return tooltipBase + "poisonResist";
}
}