2016-06-18 16:59:56 -04:00
|
|
|
package WayofTime.bloodmagic.livingArmour.upgrade;
|
|
|
|
|
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-06-18 16:59:56 -04:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.init.MobEffects;
|
|
|
|
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-06-18 16:59:56 -04:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public class LivingArmourUpgradeFireResist extends LivingArmourUpgrade {
|
|
|
|
public static final int[] costs = new int[]{2, 6, 14, 25, 40};
|
|
|
|
public static final int[] fireCooldownTime = new int[]{5 * 60 * 20, 5 * 60 * 20, 4 * 60 * 20, 3 * 60 * 20, 2 * 60 * 20};
|
|
|
|
public static final int[] fireResistDuration = new int[]{30 * 20, 30 * 20, 40 * 20, 50 * 20, 60 * 20};
|
2016-06-18 16:59:56 -04:00
|
|
|
|
|
|
|
public int fireCooldown = 0;
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public LivingArmourUpgradeFireResist(int level) {
|
2016-06-18 16:59:56 -04:00
|
|
|
super(level);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) {
|
|
|
|
if (player.isBurning() && fireCooldown <= 0) {
|
2016-06-18 16:59:56 -04:00
|
|
|
|
|
|
|
player.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, fireResistDuration[this.level]));
|
|
|
|
fireCooldown = fireCooldownTime[this.level];
|
|
|
|
|
2017-05-27 16:04:40 -07:00
|
|
|
player.sendStatusMessage(new TextComponentString(TextHelper.localizeEffect(chatBase + "fireRemove")), true);
|
2016-06-18 16:59:56 -04:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
} else if (fireCooldown > 0) {
|
2016-06-18 16:59:56 -04:00
|
|
|
fireCooldown--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public String getUniqueIdentifier() {
|
2017-08-14 20:53:42 -07:00
|
|
|
return BloodMagic.MODID + ".upgrade.fireResist";
|
2016-06-18 16:59:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public int getMaxTier() {
|
2016-06-18 16:59:56 -04: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-06-18 16:59:56 -04:00
|
|
|
return costs[this.level];
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public void writeToNBT(NBTTagCompound tag) {
|
2016-06-18 16:59:56 -04:00
|
|
|
tag.setInteger(Constants.NBT.UPGRADE_FIRE_TIMER, fireCooldown);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public void readFromNBT(NBTTagCompound tag) {
|
2016-06-18 16:59:56 -04:00
|
|
|
fireCooldown = tag.getInteger(Constants.NBT.UPGRADE_FIRE_TIMER);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public String getUnlocalizedName() {
|
2016-06-18 16:59:56 -04:00
|
|
|
return tooltipBase + "fireResist";
|
|
|
|
}
|
|
|
|
}
|