2016-01-28 14:56:49 -08:00
|
|
|
package WayofTime.bloodmagic.livingArmour.upgrade;
|
2016-01-03 14:12:55 -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.livingArmour.ILivingArmour;
|
|
|
|
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade;
|
2017-08-15 21:30:48 -07:00
|
|
|
import com.google.common.collect.HashMultimap;
|
|
|
|
import com.google.common.collect.Multimap;
|
2016-01-03 14:12:55 -05:00
|
|
|
import net.minecraft.entity.SharedMonsterAttributes;
|
|
|
|
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
2016-01-04 08:55:57 -05:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2016-03-24 14:11:05 -04:00
|
|
|
import net.minecraft.init.MobEffects;
|
2016-01-03 14:12:55 -05:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2016-01-04 08:55:57 -05:00
|
|
|
import net.minecraft.potion.PotionEffect;
|
|
|
|
import net.minecraft.world.World;
|
2017-02-13 19:35:14 -08:00
|
|
|
import org.apache.commons.codec.binary.StringUtils;
|
2016-01-04 08:55:57 -05:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
import java.util.UUID;
|
|
|
|
|
2018-03-30 18:03:31 -04:00
|
|
|
public class LivingArmourUpgradeSpeed extends LivingArmourUpgrade
|
|
|
|
{
|
|
|
|
public static final int[] costs = new int[] { 3, 7, 13, 26, 42, 60, 90, 130, 180, 250 };
|
|
|
|
public static final double[] speedModifier = new double[] { 0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 0.9, 1.1, 1.3, 1.5 };
|
|
|
|
public static final int[] sprintSpeedTime = new int[] { 0, 0, 0, 0, 0, 20, 60, 60, 100, 200 };
|
|
|
|
public static final int[] sprintSpeedLevel = new int[] { 0, 0, 0, 0, 0, 0, 0, 1, 1, 2 };
|
|
|
|
public static final int[] healthModifier = new int[] { 0, 0, 0, 0, 0, 0, 0, 4, 10, 20 };
|
|
|
|
public static final int[] sprintRegenTime = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 25 };
|
|
|
|
|
|
|
|
public LivingArmourUpgradeSpeed(int level)
|
|
|
|
{
|
2016-01-03 14:12:55 -05:00
|
|
|
super(level);
|
|
|
|
}
|
|
|
|
|
2018-03-30 18:03:31 -04:00
|
|
|
public double getSpeedModifier()
|
|
|
|
{
|
2016-02-17 16:31:11 -05:00
|
|
|
return speedModifier[this.level];
|
|
|
|
}
|
|
|
|
|
2016-01-04 08:55:57 -05:00
|
|
|
@Override
|
2018-03-30 18:03:31 -04:00
|
|
|
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour)
|
|
|
|
{
|
|
|
|
if (player.isSprinting())
|
|
|
|
{
|
|
|
|
if (sprintSpeedTime[this.level] > 0)
|
|
|
|
{
|
2016-04-24 10:06:28 -07:00
|
|
|
player.addPotionEffect(new PotionEffect(MobEffects.SPEED, sprintSpeedTime[this.level], sprintSpeedLevel[this.level], false, false));
|
2016-01-04 08:55:57 -05:00
|
|
|
}
|
|
|
|
|
2018-03-30 18:03:31 -04:00
|
|
|
if (sprintRegenTime[this.level] > 0 && !player.isPotionActive(MobEffects.REGENERATION))
|
|
|
|
{
|
2016-04-24 10:06:28 -07:00
|
|
|
player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, sprintRegenTime[this.level], 0, false, false));
|
2016-01-04 08:55:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-03 14:12:55 -05:00
|
|
|
@Override
|
2018-03-30 18:03:31 -04:00
|
|
|
public Multimap<String, AttributeModifier> getAttributeModifiers()
|
|
|
|
{
|
2018-03-01 19:27:38 -08:00
|
|
|
Multimap<String, AttributeModifier> modifierMap = HashMultimap.create();
|
2016-01-03 14:12:55 -05:00
|
|
|
|
2016-02-17 16:31:11 -05:00
|
|
|
// modifierMap.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(895132, 1), "Speed modifier" + 1, speedModifier[this.level], 1));
|
2016-01-04 08:55:57 -05:00
|
|
|
|
2018-03-30 18:03:31 -04:00
|
|
|
// if (healthModifier[this.level] > 0) {
|
|
|
|
// String name = getUniqueIdentifier() + "-HealthModifier1";
|
|
|
|
// modifierMap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(UUID.nameUUIDFromBytes(StringUtils.getBytesUtf8(name)), "HealthModifier1", healthModifier[this.level], 0));
|
|
|
|
// }
|
2016-01-03 14:12:55 -05:00
|
|
|
|
|
|
|
return modifierMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-03-30 18:03:31 -04:00
|
|
|
public String getUniqueIdentifier()
|
|
|
|
{
|
2017-08-14 20:53:42 -07:00
|
|
|
return BloodMagic.MODID + ".upgrade.movement";
|
2016-01-03 14:12:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-03-30 18:03:31 -04:00
|
|
|
public int getMaxTier()
|
|
|
|
{
|
2016-01-03 15:39:59 -05:00
|
|
|
return 10;
|
2016-01-03 14:12:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-03-30 18:03:31 -04:00
|
|
|
public int getCostOfUpgrade()
|
|
|
|
{
|
2016-01-04 08:55:57 -05:00
|
|
|
return costs[this.level];
|
2016-01-03 14:12:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-03-30 18:03:31 -04:00
|
|
|
public void writeToNBT(NBTTagCompound tag)
|
|
|
|
{
|
2016-01-03 14:12:55 -05:00
|
|
|
// EMPTY
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-03-30 18:03:31 -04:00
|
|
|
public void readFromNBT(NBTTagCompound tag)
|
|
|
|
{
|
2016-01-03 14:12:55 -05:00
|
|
|
// EMPTY
|
|
|
|
}
|
2016-01-05 11:12:56 -05:00
|
|
|
|
|
|
|
@Override
|
2018-03-30 18:03:31 -04:00
|
|
|
public String getUnlocalizedName()
|
|
|
|
{
|
2016-01-05 11:12:56 -05:00
|
|
|
return tooltipBase + "speed";
|
|
|
|
}
|
2016-01-03 14:12:55 -05:00
|
|
|
}
|