2016-01-28 14:56:49 -08:00
|
|
|
package WayofTime.bloodmagic.livingArmour.upgrade;
|
2016-01-05 10:29:50 -05:00
|
|
|
|
2017-08-14 20:53:42 -07:00
|
|
|
import WayofTime.bloodmagic.BloodMagic;
|
2018-02-15 18:49:01 -08:00
|
|
|
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;
|
2016-03-17 13:00:44 -07:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2016-03-24 14:11:05 -04:00
|
|
|
import net.minecraft.init.MobEffects;
|
2016-03-17 13:00:44 -07:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.potion.PotionEffect;
|
2017-05-27 16:04:40 -07:00
|
|
|
import net.minecraft.util.text.TextComponentString;
|
2016-03-17 13:00:44 -07:00
|
|
|
import net.minecraft.world.World;
|
2016-01-05 10:29:50 -05:00
|
|
|
|
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};
|
2016-01-05 10:29:50 -05:00
|
|
|
|
|
|
|
public int poisonCooldown = 0;
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public LivingArmourUpgradePoisonResist(int level) {
|
2016-01-05 10:29:50 -05:00
|
|
|
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);
|
2016-01-05 10:29:50 -05:00
|
|
|
poisonCooldown = poisonCooldownTime[this.level];
|
|
|
|
|
2017-05-27 16:04:40 -07:00
|
|
|
player.sendStatusMessage(new TextComponentString(TextHelper.localize(chatBase + "poisonRemove")), true);
|
2016-01-05 10:29:50 -05:00
|
|
|
}
|
2017-08-15 21:30:48 -07:00
|
|
|
} else if (poisonCooldown > 0) {
|
2016-01-05 10:29:50 -05:00
|
|
|
poisonCooldown--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public String getUniqueIdentifier() {
|
2017-08-14 20:53:42 -07:00
|
|
|
return BloodMagic.MODID + ".upgrade.poisonResist";
|
2016-01-05 10:29:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public int getMaxTier() {
|
2016-01-05 10:29:50 -05:00
|
|
|
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() {
|
2016-01-05 10:29:50 -05:00
|
|
|
return costs[this.level];
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public void writeToNBT(NBTTagCompound tag) {
|
2016-01-05 10:29:50 -05:00
|
|
|
tag.setInteger(Constants.NBT.UPGRADE_POISON_TIMER, poisonCooldown);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public void readFromNBT(NBTTagCompound tag) {
|
2016-01-05 10:29:50 -05:00
|
|
|
poisonCooldown = tag.getInteger(Constants.NBT.UPGRADE_POISON_TIMER);
|
|
|
|
}
|
2016-01-05 11:12:56 -05:00
|
|
|
|
|
|
|
@Override
|
2019-01-31 19:10:37 -08:00
|
|
|
public String getTranslationKey() {
|
2016-01-05 11:12:56 -05:00
|
|
|
return tooltipBase + "poisonResist";
|
|
|
|
}
|
2016-01-05 10:29:50 -05:00
|
|
|
}
|