Run formatter
This commit is contained in:
parent
61c44a831b
commit
08258fd6ef
606 changed files with 13464 additions and 22975 deletions
|
@ -1,13 +1,24 @@
|
|||
package WayofTime.bloodmagic.item.armour;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.api.livingArmour.StatTracker;
|
||||
import WayofTime.bloodmagic.api.saving.SoulNetwork;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.item.ItemComponent;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerRepairing;
|
||||
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeElytra;
|
||||
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
|
||||
import WayofTime.bloodmagic.network.PlayerFallDistancePacketProcessor;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
|
@ -29,46 +40,22 @@ import net.minecraftforge.common.ISpecialArmor;
|
|||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.api.livingArmour.StatTracker;
|
||||
import WayofTime.bloodmagic.api.saving.SoulNetwork;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.item.ItemComponent;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerRepairing;
|
||||
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeElytra;
|
||||
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
|
||||
import WayofTime.bloodmagic.network.PlayerFallDistancePacketProcessor;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshProvider
|
||||
{
|
||||
private static Field _FLAGS = ReflectionHelper.findField(Entity.class, "FLAGS", "field_184240_ax");
|
||||
|
||||
private static DataParameter<Byte> FLAGS = null;
|
||||
public static String[] names = { "helmet", "chest", "legs", "boots" };
|
||||
|
||||
public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshProvider {
|
||||
public static final boolean useSpecialArmourCalculation = true;
|
||||
|
||||
public static String[] names = {"helmet", "chest", "legs", "boots"};
|
||||
//TODO: Save/delete cache periodically.
|
||||
public static Map<UUID, LivingArmour> armourMap = new HashMap<UUID, LivingArmour>();
|
||||
private static Field _FLAGS = ReflectionHelper.findField(Entity.class, "FLAGS", "field_184240_ax");
|
||||
private static DataParameter<Byte> FLAGS = null;
|
||||
|
||||
public ItemLivingArmour(EntityEquipmentSlot armorType)
|
||||
{
|
||||
public ItemLivingArmour(EntityEquipmentSlot armorType) {
|
||||
super(ItemArmor.ArmorMaterial.IRON, 0, armorType);
|
||||
setUnlocalizedName(BloodMagic.MODID + ".livingArmour.");
|
||||
// setMaxDamage(250);
|
||||
|
@ -77,27 +64,21 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (stack != null && !world.isRemote && stack.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST)
|
||||
{
|
||||
public void onCreated(ItemStack stack, World world, EntityPlayer player) {
|
||||
if (stack != null && !world.isRemote && stack.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
|
||||
Utils.setUUID(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST || this == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET || this == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS)
|
||||
{
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) {
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST || this == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET || this == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS) {
|
||||
return "bloodmagic:models/armor/livingArmour_layer_1.png";
|
||||
}
|
||||
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS) {
|
||||
return "bloodmagic:models/armor/livingArmour_layer_2.png";
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -115,25 +96,20 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
// }
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
|
||||
{
|
||||
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
|
||||
return ItemStack.areItemsEqual(repair, ItemComponent.getStack(ItemComponent.REAGENT_BINDING));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot)
|
||||
{
|
||||
public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot) {
|
||||
double armourReduction = 0.0;
|
||||
double damageAmount = 0.25;
|
||||
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS || this == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS || this == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET) {
|
||||
damageAmount = 3d / 20d * 0.6;
|
||||
} else if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS)
|
||||
{
|
||||
} else if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS) {
|
||||
damageAmount = 6d / 20d * 0.6;
|
||||
} else if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST)
|
||||
{
|
||||
} else if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
|
||||
damageAmount = 0.64;
|
||||
}
|
||||
|
||||
|
@ -141,42 +117,34 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
|
||||
int maxAbsorption = 100000;
|
||||
|
||||
if (source.equals(DamageSource.DROWN))
|
||||
{
|
||||
if (source.equals(DamageSource.DROWN)) {
|
||||
return new ArmorProperties(-1, 0, 0);
|
||||
}
|
||||
|
||||
if (source.equals(DamageSource.OUT_OF_WORLD))
|
||||
{
|
||||
if (source.equals(DamageSource.OUT_OF_WORLD)) {
|
||||
return new ArmorProperties(-1, 0, 0);
|
||||
}
|
||||
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
|
||||
armourReduction = 0.24 / 0.64; // This values puts it at iron level
|
||||
|
||||
ItemStack helmet = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
|
||||
ItemStack leggings = player.getItemStackFromSlot(EntityEquipmentSlot.LEGS);
|
||||
ItemStack boots = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
|
||||
|
||||
if (helmet.isEmpty() || leggings.isEmpty() || boots.isEmpty())
|
||||
{
|
||||
if (helmet.isEmpty() || leggings.isEmpty() || boots.isEmpty()) {
|
||||
damageAmount *= (armourReduction);
|
||||
|
||||
return new ArmorProperties(-1, damageAmount, maxAbsorption);
|
||||
}
|
||||
|
||||
if (helmet.getItem() instanceof ItemLivingArmour && leggings.getItem() instanceof ItemLivingArmour && boots.getItem() instanceof ItemLivingArmour)
|
||||
{
|
||||
if (helmet.getItem() instanceof ItemLivingArmour && leggings.getItem() instanceof ItemLivingArmour && boots.getItem() instanceof ItemLivingArmour) {
|
||||
double remainder = 1; // Multiply this number by the armour upgrades for protection
|
||||
|
||||
if (hasLivingArmour(stack))
|
||||
{
|
||||
if (hasLivingArmour(stack)) {
|
||||
LivingArmour armour = getLivingArmour(stack);
|
||||
if (armour != null && isEnabled(stack))
|
||||
{
|
||||
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet())
|
||||
{
|
||||
if (armour != null && isEnabled(stack)) {
|
||||
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet()) {
|
||||
LivingArmourUpgrade upgrade = entry.getValue();
|
||||
remainder *= (1 - upgrade.getArmourProtection(player, source));
|
||||
}
|
||||
|
@ -193,10 +161,8 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
|
||||
return new ArmorProperties(-1, source.isUnblockable() ? 1 - remainder : damageAmount, maxAbsorption);
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (source.isUnblockable())
|
||||
{
|
||||
} else {
|
||||
if (source.isUnblockable()) {
|
||||
return new ArmorProperties(-1, damageAmount * armourPenetrationReduction, maxAbsorption);
|
||||
}
|
||||
|
||||
|
@ -207,25 +173,20 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot)
|
||||
{
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET)
|
||||
{
|
||||
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST)
|
||||
{
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS)
|
||||
{
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS) {
|
||||
return 6;
|
||||
}
|
||||
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS)
|
||||
{
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -233,21 +194,16 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST)
|
||||
{
|
||||
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
|
||||
int preDamage = stack.getItemDamage();
|
||||
if (source.isUnblockable())
|
||||
{
|
||||
if (source.isUnblockable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (damage > this.getMaxDamage(stack) - this.getDamage(stack))
|
||||
{
|
||||
if (damage > this.getMaxDamage(stack) - this.getDamage(stack)) {
|
||||
//TODO: Syphon a load of LP.
|
||||
if (entity.getEntityWorld().isRemote && entity instanceof EntityPlayer)
|
||||
{
|
||||
if (entity.getEntityWorld().isRemote && entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
SoulNetwork network = NetworkHelper.getSoulNetwork(player);
|
||||
network.syphonAndDamage(player, damage * 100);
|
||||
|
@ -259,21 +215,17 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
stack.damageItem(damage, entity);
|
||||
|
||||
int receivedDamage = stack.getItemDamage() - preDamage;
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
if (entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(stack);
|
||||
if (armour != null)
|
||||
{
|
||||
if (armour != null) {
|
||||
StatTrackerRepairing.incrementCounter(armour, receivedDamage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
stack.damageItem(damage, entity);
|
||||
}
|
||||
|
||||
|
@ -282,46 +234,36 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
|
||||
LivingArmour armour = getLivingArmourFromStack(stack);
|
||||
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet())
|
||||
{
|
||||
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet()) {
|
||||
LivingArmourUpgrade upgrade = entry.getValue();
|
||||
if (upgrade != null)
|
||||
{
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_M))
|
||||
{
|
||||
if (upgrade != null) {
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_M)) {
|
||||
StatTracker tracker = null;
|
||||
for (StatTracker searchTracker : armour.trackerMap.values())
|
||||
{
|
||||
if (searchTracker != null && searchTracker.providesUpgrade(upgrade.getUniqueIdentifier()))
|
||||
{
|
||||
for (StatTracker searchTracker : armour.trackerMap.values()) {
|
||||
if (searchTracker != null && searchTracker.providesUpgrade(upgrade.getUniqueIdentifier())) {
|
||||
tracker = searchTracker;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tracker != null)
|
||||
{
|
||||
if (tracker != null) {
|
||||
double progress = tracker.getProgress(armour, upgrade.getUpgradeLevel());
|
||||
tooltip.add(TextHelper.localize("tooltip.bloodmagic.livingArmour.upgrade.progress", TextHelper.localize(upgrade.getUnlocalizedName()), MathHelper.clamp((int) (progress * 100D), 0, 100)));
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
tooltip.add(TextHelper.localize("tooltip.bloodmagic.livingArmour.upgrade.level", TextHelper.localize(upgrade.getUnlocalizedName()), upgrade.getUpgradeLevel() + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.livingArmour.upgrade.points", armour.totalUpgradePoints, armour.maxUpgradePoints));
|
||||
if (!(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_M)))
|
||||
{
|
||||
if (!(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_M))) {
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.livingArmour.extraExtraInfo"));
|
||||
}
|
||||
}
|
||||
|
@ -330,52 +272,39 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack stack)
|
||||
{
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
|
||||
super.onArmorTick(world, player, stack);
|
||||
|
||||
if (world.isRemote && this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST)
|
||||
{
|
||||
if (world.isRemote && this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
|
||||
if (player instanceof EntityPlayerSP) //Sanity check
|
||||
{
|
||||
EntityPlayerSP spPlayer = (EntityPlayerSP) player;
|
||||
|
||||
if (FLAGS == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (FLAGS == null) {
|
||||
try {
|
||||
FLAGS = (DataParameter<Byte>) _FLAGS.get(null);
|
||||
} catch (IllegalArgumentException e)
|
||||
{
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e)
|
||||
{
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (FLAGS != null)
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (FLAGS != null) {
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgradeFromNBT(BloodMagic.MODID + ".upgrade.elytra", chestStack);
|
||||
if (upgrade instanceof LivingArmourUpgradeElytra)
|
||||
{
|
||||
if (spPlayer.movementInput.jump && !spPlayer.onGround && spPlayer.motionY < 0.0D && !spPlayer.capabilities.isFlying)
|
||||
{
|
||||
if (spPlayer.motionY > -0.5D)
|
||||
{
|
||||
if (upgrade instanceof LivingArmourUpgradeElytra) {
|
||||
if (spPlayer.movementInput.jump && !spPlayer.onGround && spPlayer.motionY < 0.0D && !spPlayer.capabilities.isFlying) {
|
||||
if (spPlayer.motionY > -0.5D) {
|
||||
BloodMagicPacketHandler.INSTANCE.sendToServer(new PlayerFallDistancePacketProcessor(1));
|
||||
}
|
||||
|
||||
if (!spPlayer.isElytraFlying())
|
||||
{
|
||||
if (!spPlayer.isElytraFlying()) {
|
||||
byte b0 = player.getDataManager().get(FLAGS);
|
||||
player.getDataManager().set(FLAGS, (byte) (b0 | 1 << 7));
|
||||
}
|
||||
} else if (spPlayer.isElytraFlying() && !spPlayer.movementInput.jump && !spPlayer.onGround)
|
||||
{
|
||||
} else if (spPlayer.isElytraFlying() && !spPlayer.movementInput.jump && !spPlayer.onGround) {
|
||||
byte b0 = player.getDataManager().get(FLAGS);
|
||||
player.getDataManager().set(FLAGS, (byte) (b0 & ~(1 << 7)));
|
||||
}
|
||||
|
@ -385,16 +314,13 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
}
|
||||
}
|
||||
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST)
|
||||
{
|
||||
if (!hasLivingArmour(stack))
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
|
||||
if (!hasLivingArmour(stack)) {
|
||||
setLivingArmour(stack, getLivingArmourFromStack(stack));
|
||||
}
|
||||
|
||||
LivingArmour armour = getLivingArmour(stack);
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
this.setIsEnabled(stack, true);
|
||||
armour.onTick(world, player);
|
||||
}
|
||||
|
@ -404,10 +330,8 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST && isEnabled(stack) && slot == EntityEquipmentSlot.CHEST)
|
||||
{
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST && isEnabled(stack) && slot == EntityEquipmentSlot.CHEST) {
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(stack);
|
||||
|
||||
return armour.getAttributeModifiers();
|
||||
|
@ -417,20 +341,16 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + names[3 - armorType.getIndex()];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
return new ItemMeshDefinition()
|
||||
{
|
||||
public ItemMeshDefinition getMeshDefinition() {
|
||||
return new ItemMeshDefinition() {
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack)
|
||||
{
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack) {
|
||||
assert getCustomLocation() != null;
|
||||
if (stack.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET)
|
||||
return new ModelResourceLocation(getCustomLocation(), "armour=head");
|
||||
|
@ -445,14 +365,12 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
public ResourceLocation getCustomLocation() {
|
||||
return new ResourceLocation(BloodMagic.MODID, "item/ItemLivingArmour");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
public List<String> getVariants() {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
ret.add("armour=head");
|
||||
ret.add("armour=body");
|
||||
|
@ -461,48 +379,21 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
return ret;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static LivingArmour getLivingArmourFromStack(ItemStack stack)
|
||||
{
|
||||
NBTTagCompound livingTag = getArmourTag(stack);
|
||||
|
||||
LivingArmour livingArmour = new LivingArmour();
|
||||
livingArmour.readFromNBT(livingTag);
|
||||
|
||||
return livingArmour;
|
||||
}
|
||||
|
||||
public void setLivingArmour(ItemStack stack, LivingArmour armour, boolean forceWrite)
|
||||
{
|
||||
public void setLivingArmour(ItemStack stack, LivingArmour armour, boolean forceWrite) {
|
||||
NBTTagCompound livingTag = new NBTTagCompound();
|
||||
|
||||
if (!forceWrite)
|
||||
{
|
||||
if (!forceWrite) {
|
||||
livingTag = getArmourTag(stack);
|
||||
armour.writeDirtyToNBT(livingTag);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
armour.writeToNBT(livingTag);
|
||||
}
|
||||
|
||||
setArmourTag(stack, livingTag);
|
||||
}
|
||||
|
||||
public static NBTTagCompound getArmourTag(ItemStack stack)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getCompoundTag(Constants.NBT.LIVING_ARMOUR);
|
||||
}
|
||||
|
||||
public void setArmourTag(ItemStack stack, NBTTagCompound livingTag)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
public void setArmourTag(ItemStack stack, NBTTagCompound livingTag) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
|
@ -511,20 +402,59 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
tag.setTag(Constants.NBT.LIVING_ARMOUR, livingTag);
|
||||
}
|
||||
|
||||
public void setIsEnabled(ItemStack stack, boolean bool) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
tag.setBoolean("enabled", bool);
|
||||
}
|
||||
|
||||
public boolean isEnabled(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getBoolean("enabled");
|
||||
}
|
||||
|
||||
public void setIsElytra(ItemStack stack, boolean bool) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
tag.setBoolean("elytra", bool);
|
||||
}
|
||||
|
||||
public boolean isElytra(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getBoolean("elytra");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static LivingArmour getLivingArmourFromStack(ItemStack stack) {
|
||||
NBTTagCompound livingTag = getArmourTag(stack);
|
||||
|
||||
LivingArmour livingArmour = new LivingArmour();
|
||||
livingArmour.readFromNBT(livingTag);
|
||||
|
||||
return livingArmour;
|
||||
}
|
||||
|
||||
public static NBTTagCompound getArmourTag(ItemStack stack) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getCompoundTag(Constants.NBT.LIVING_ARMOUR);
|
||||
}
|
||||
|
||||
//TODO: Add the ability to have the armour give an upgrade with a higher level
|
||||
public static LivingArmourUpgrade getUpgrade(String uniqueIdentifier, ItemStack stack)
|
||||
{
|
||||
if (!hasLivingArmour(stack))
|
||||
{
|
||||
public static LivingArmourUpgrade getUpgrade(String uniqueIdentifier, ItemStack stack) {
|
||||
if (!hasLivingArmour(stack)) {
|
||||
setLivingArmour(stack, getLivingArmourFromStack(stack));
|
||||
}
|
||||
|
||||
LivingArmour armour = getLivingArmour(stack);
|
||||
|
||||
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet())
|
||||
{
|
||||
if (entry.getKey().equals(uniqueIdentifier))
|
||||
{
|
||||
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet()) {
|
||||
if (entry.getKey().equals(uniqueIdentifier)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
@ -532,14 +462,11 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
return null;
|
||||
}
|
||||
|
||||
public static LivingArmourUpgrade getUpgradeFromNBT(String uniqueIdentifier, ItemStack stack)
|
||||
{
|
||||
public static LivingArmourUpgrade getUpgradeFromNBT(String uniqueIdentifier, ItemStack stack) {
|
||||
LivingArmour armour = getLivingArmourFromStack(stack);
|
||||
|
||||
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet())
|
||||
{
|
||||
if (entry.getKey().equals(uniqueIdentifier))
|
||||
{
|
||||
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet()) {
|
||||
if (entry.getKey().equals(uniqueIdentifier)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
@ -547,24 +474,20 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
return null;
|
||||
}
|
||||
|
||||
public static boolean hasLivingArmour(ItemStack stack)
|
||||
{
|
||||
public static boolean hasLivingArmour(ItemStack stack) {
|
||||
UUID uuid = Utils.getUUID(stack);
|
||||
return uuid != null && armourMap.containsKey(uuid);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static LivingArmour getLivingArmour(ItemStack stack)
|
||||
{
|
||||
public static LivingArmour getLivingArmour(ItemStack stack) {
|
||||
UUID uuid = Utils.getUUID(stack);
|
||||
|
||||
return armourMap.get(uuid);
|
||||
}
|
||||
|
||||
public static void setLivingArmour(ItemStack stack, LivingArmour armour)
|
||||
{
|
||||
if (!Utils.hasUUID(stack))
|
||||
{
|
||||
public static void setLivingArmour(ItemStack stack, LivingArmour armour) {
|
||||
if (!Utils.hasUUID(stack)) {
|
||||
Utils.setUUID(stack);
|
||||
}
|
||||
|
||||
|
@ -573,10 +496,8 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
armourMap.put(uuid, armour);
|
||||
}
|
||||
|
||||
public static boolean hasUpgrade(String id, ItemStack stack)
|
||||
{
|
||||
if (!hasLivingArmour(stack))
|
||||
{
|
||||
public static boolean hasUpgrade(String id, ItemStack stack) {
|
||||
if (!hasLivingArmour(stack)) {
|
||||
setLivingArmour(stack, getLivingArmourFromStack(stack));
|
||||
}
|
||||
|
||||
|
@ -584,32 +505,4 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
|
||||
return armour.upgradeMap.containsKey(id);
|
||||
}
|
||||
|
||||
public void setIsEnabled(ItemStack stack, boolean bool)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
tag.setBoolean("enabled", bool);
|
||||
}
|
||||
|
||||
public boolean isEnabled(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getBoolean("enabled");
|
||||
}
|
||||
|
||||
public void setIsElytra(ItemStack stack, boolean bool)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
tag.setBoolean("elytra", bool);
|
||||
}
|
||||
|
||||
public boolean isElytra(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getBoolean("elytra");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
package WayofTime.bloodmagic.item.armour;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IMultiWillTool;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
|
@ -24,37 +32,26 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.common.ISpecialArmor;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IMultiWillTool;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import java.util.*;
|
||||
|
||||
public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMeshProvider, IMultiWillTool
|
||||
{
|
||||
public static String[] names = { "helmet", "chest", "legs", "boots" };
|
||||
public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMeshProvider, IMultiWillTool {
|
||||
public static String[] names = {"helmet", "chest", "legs", "boots"};
|
||||
|
||||
public static double[] willBracket = new double[] { 30, 200, 600, 1500, 4000, 6000, 8000, 16000 };
|
||||
public static double[] consumptionPerHit = new double[] { 0.1, 0.12, 0.15, 0.2, 0.3, 0.35, 0.4, 0.5 };
|
||||
public static double[] extraProtectionLevel = new double[] { 0, 0.25, 0.5, 0.6, 0.7, 0.75, 0.85, 0.9 };
|
||||
public static double[] steadfastProtectionLevel = new double[] { 0.25, 0.5, 0.6, 0.7, 0.75, 0.85, 0.9, 0.95 };
|
||||
public static double[] willBracket = new double[]{30, 200, 600, 1500, 4000, 6000, 8000, 16000};
|
||||
public static double[] consumptionPerHit = new double[]{0.1, 0.12, 0.15, 0.2, 0.3, 0.35, 0.4, 0.5};
|
||||
public static double[] extraProtectionLevel = new double[]{0, 0.25, 0.5, 0.6, 0.7, 0.75, 0.85, 0.9};
|
||||
public static double[] steadfastProtectionLevel = new double[]{0.25, 0.5, 0.6, 0.7, 0.75, 0.85, 0.9, 0.95};
|
||||
|
||||
//public static double[] healthBonus = new double[] { 3, 6, 9, 12, 15, 20, 25, 30 };
|
||||
public static double[] knockbackBonus = new double[] { 0.2, 0.4, 0.6, 0.8, 1, 1, 1, 1 };
|
||||
public static double[] knockbackBonus = new double[]{0.2, 0.4, 0.6, 0.8, 1, 1, 1, 1};
|
||||
|
||||
public static double[] damageBoost = new double[] { 0.03, 0.06, 0.09, 0.12, 0.15, 0.18, 0.22, 0.25 };
|
||||
public static double[] attackSpeed = new double[] { -0.02, -0.04, -0.06, -0.08, -0.1, -0.12, -0.14, -0.16 };
|
||||
public static double[] damageBoost = new double[]{0.03, 0.06, 0.09, 0.12, 0.15, 0.18, 0.22, 0.25};
|
||||
public static double[] attackSpeed = new double[]{-0.02, -0.04, -0.06, -0.08, -0.1, -0.12, -0.14, -0.16};
|
||||
|
||||
public static double[] speedBonus = new double[] { 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4 };
|
||||
public static double[] speedBonus = new double[]{0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4};
|
||||
|
||||
public ItemSentientArmour(EntityEquipmentSlot armorType)
|
||||
{
|
||||
public ItemSentientArmour(EntityEquipmentSlot armorType) {
|
||||
super(ItemArmor.ArmorMaterial.IRON, 0, armorType);
|
||||
setUnlocalizedName(BloodMagic.MODID + ".sentientArmour.");
|
||||
setMaxDamage(250);
|
||||
|
@ -62,111 +59,92 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST || this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET || this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_BOOTS)
|
||||
{
|
||||
switch (this.getCurrentType(stack))
|
||||
{
|
||||
case DEFAULT:
|
||||
return "bloodmagic:models/armor/sentientArmour_layer_1.png";
|
||||
case CORROSIVE:
|
||||
return "bloodmagic:models/armor/sentientArmour_corrosive_layer_1.png";
|
||||
case VENGEFUL:
|
||||
return "bloodmagic:models/armor/sentientArmour_vengeful_layer_1.png";
|
||||
case DESTRUCTIVE:
|
||||
return "bloodmagic:models/armor/sentientArmour_destructive_layer_1.png";
|
||||
case STEADFAST:
|
||||
return "bloodmagic:models/armor/sentientArmour_steadfast_layer_1.png";
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) {
|
||||
if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST || this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET || this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_BOOTS) {
|
||||
switch (this.getCurrentType(stack)) {
|
||||
case DEFAULT:
|
||||
return "bloodmagic:models/armor/sentientArmour_layer_1.png";
|
||||
case CORROSIVE:
|
||||
return "bloodmagic:models/armor/sentientArmour_corrosive_layer_1.png";
|
||||
case VENGEFUL:
|
||||
return "bloodmagic:models/armor/sentientArmour_vengeful_layer_1.png";
|
||||
case DESTRUCTIVE:
|
||||
return "bloodmagic:models/armor/sentientArmour_destructive_layer_1.png";
|
||||
case STEADFAST:
|
||||
return "bloodmagic:models/armor/sentientArmour_steadfast_layer_1.png";
|
||||
}
|
||||
return "bloodmagic:models/armor/sentientArmour_layer_1.png";
|
||||
}
|
||||
|
||||
if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_LEGS)
|
||||
{
|
||||
switch (this.getCurrentType(stack))
|
||||
{
|
||||
case DEFAULT:
|
||||
return "bloodmagic:models/armor/sentientArmour_layer_2.png";
|
||||
case CORROSIVE:
|
||||
return "bloodmagic:models/armor/sentientArmour_corrosive_layer_2.png";
|
||||
case VENGEFUL:
|
||||
return "bloodmagic:models/armor/sentientArmour_vengeful_layer_2.png";
|
||||
case DESTRUCTIVE:
|
||||
return "bloodmagic:models/armor/sentientArmour_destructive_layer_2.png";
|
||||
case STEADFAST:
|
||||
return "bloodmagic:models/armor/sentientArmour_steadfast_layer_2.png";
|
||||
if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_LEGS) {
|
||||
switch (this.getCurrentType(stack)) {
|
||||
case DEFAULT:
|
||||
return "bloodmagic:models/armor/sentientArmour_layer_2.png";
|
||||
case CORROSIVE:
|
||||
return "bloodmagic:models/armor/sentientArmour_corrosive_layer_2.png";
|
||||
case VENGEFUL:
|
||||
return "bloodmagic:models/armor/sentientArmour_vengeful_layer_2.png";
|
||||
case DESTRUCTIVE:
|
||||
return "bloodmagic:models/armor/sentientArmour_destructive_layer_2.png";
|
||||
case STEADFAST:
|
||||
return "bloodmagic:models/armor/sentientArmour_steadfast_layer_2.png";
|
||||
}
|
||||
return "bloodmagic:models/armor/sentientArmour_layer_1.png";
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack stack)
|
||||
{
|
||||
if (this.armorType == EntityEquipmentSlot.CHEST)
|
||||
{
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
|
||||
if (this.armorType == EntityEquipmentSlot.CHEST) {
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
switch (type)
|
||||
{
|
||||
case CORROSIVE:
|
||||
if (player.isPotionActive(MobEffects.POISON))
|
||||
{
|
||||
player.removeActivePotionEffect(MobEffects.POISON);
|
||||
}
|
||||
if (player.isPotionActive(MobEffects.WITHER))
|
||||
{
|
||||
player.removeActivePotionEffect(MobEffects.WITHER);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
switch (type) {
|
||||
case CORROSIVE:
|
||||
if (player.isPotionActive(MobEffects.POISON)) {
|
||||
player.removeActivePotionEffect(MobEffects.POISON);
|
||||
}
|
||||
if (player.isPotionActive(MobEffects.WITHER)) {
|
||||
player.removeActivePotionEffect(MobEffects.WITHER);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerAttacked(ItemStack stack, DamageSource source, EntityPlayer attackedPlayer)
|
||||
{
|
||||
if (source.getTrueSource() instanceof EntityLivingBase)
|
||||
{
|
||||
public void onPlayerAttacked(ItemStack stack, DamageSource source, EntityPlayer attackedPlayer) {
|
||||
if (source.getTrueSource() instanceof EntityLivingBase) {
|
||||
EntityLivingBase attacker = (EntityLivingBase) source.getTrueSource();
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
switch (type)
|
||||
{
|
||||
case CORROSIVE:
|
||||
if (!source.isProjectile())
|
||||
{
|
||||
attacker.addPotionEffect(new PotionEffect(MobEffects.POISON, 100)); //TODO: customize duration
|
||||
}
|
||||
break;
|
||||
case DEFAULT:
|
||||
break;
|
||||
case DESTRUCTIVE:
|
||||
break;
|
||||
case STEADFAST:
|
||||
break;
|
||||
case VENGEFUL:
|
||||
break;
|
||||
switch (type) {
|
||||
case CORROSIVE:
|
||||
if (!source.isProjectile()) {
|
||||
attacker.addPotionEffect(new PotionEffect(MobEffects.POISON, 100)); //TODO: customize duration
|
||||
}
|
||||
break;
|
||||
case DEFAULT:
|
||||
break;
|
||||
case DESTRUCTIVE:
|
||||
break;
|
||||
case STEADFAST:
|
||||
break;
|
||||
case VENGEFUL:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot)
|
||||
{
|
||||
public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot) {
|
||||
double armourReduction = 0.0;
|
||||
double damageAmount = 0.25;
|
||||
|
||||
if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_BOOTS || this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_BOOTS || this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET) {
|
||||
damageAmount = 3d / 20d * 0.6;
|
||||
} else if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_LEGS)
|
||||
{
|
||||
} else if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_LEGS) {
|
||||
damageAmount = 6d / 20d * 0.6;
|
||||
} else if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST)
|
||||
{
|
||||
} else if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST) {
|
||||
damageAmount = 0.64;
|
||||
}
|
||||
|
||||
|
@ -174,50 +152,42 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
|
||||
int maxAbsorption = 100000;
|
||||
|
||||
if (source.equals(DamageSource.DROWN))
|
||||
{
|
||||
if (source.equals(DamageSource.DROWN)) {
|
||||
return new ArmorProperties(-1, 0, 0);
|
||||
}
|
||||
|
||||
if (source.equals(DamageSource.OUT_OF_WORLD))
|
||||
{
|
||||
if (source.equals(DamageSource.OUT_OF_WORLD)) {
|
||||
return new ArmorProperties(-1, 0, 0);
|
||||
}
|
||||
|
||||
if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST) {
|
||||
armourReduction = 0.24 / 0.64; // This values puts it at iron level
|
||||
|
||||
ItemStack helmet = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
|
||||
ItemStack leggings = player.getItemStackFromSlot(EntityEquipmentSlot.LEGS);
|
||||
ItemStack boots = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
|
||||
|
||||
if (helmet.isEmpty() || leggings.isEmpty() || boots.isEmpty())
|
||||
{
|
||||
if (helmet.isEmpty() || leggings.isEmpty() || boots.isEmpty()) {
|
||||
damageAmount *= (armourReduction);
|
||||
|
||||
return new ArmorProperties(-1, damageAmount, maxAbsorption);
|
||||
}
|
||||
|
||||
if (helmet.getItem() instanceof ItemSentientArmour && leggings.getItem() instanceof ItemSentientArmour && boots.getItem() instanceof ItemSentientArmour)
|
||||
{
|
||||
if (helmet.getItem() instanceof ItemSentientArmour && leggings.getItem() instanceof ItemSentientArmour && boots.getItem() instanceof ItemSentientArmour) {
|
||||
double remainder = 1; // Multiply this number by the armour upgrades for protection
|
||||
remainder *= (1 - this.getArmourModifier(stack));
|
||||
|
||||
armourReduction = armourReduction + (1 - remainder) * (1 - armourReduction);
|
||||
damageAmount *= (armourReduction);
|
||||
|
||||
if (source.isUnblockable())
|
||||
{
|
||||
if (source.isUnblockable()) {
|
||||
return new ArmorProperties(-1, damageAmount * armourPenetrationReduction, maxAbsorption);
|
||||
}
|
||||
|
||||
return new ArmorProperties(-1, damageAmount, maxAbsorption);
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (source.isUnblockable())
|
||||
{
|
||||
} else {
|
||||
if (source.isUnblockable()) {
|
||||
return new ArmorProperties(-1, damageAmount * armourPenetrationReduction, maxAbsorption);
|
||||
}
|
||||
|
||||
|
@ -228,25 +198,20 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot)
|
||||
{
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET)
|
||||
{
|
||||
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST)
|
||||
{
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_LEGS)
|
||||
{
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_LEGS) {
|
||||
return 6;
|
||||
}
|
||||
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_BOOTS)
|
||||
{
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_BOOTS) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -254,53 +219,45 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
}
|
||||
|
||||
@Override
|
||||
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot)
|
||||
{
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
|
||||
EnumDemonWillType type = getCurrentType(stack);
|
||||
|
||||
double willRequired = this.getCostModifier(stack) * damage;
|
||||
double willLeft = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
if (willLeft >= willRequired && canSustainArmour(type, willLeft))
|
||||
{
|
||||
if (willLeft >= willRequired && canSustainArmour(type, willLeft)) {
|
||||
this.setAbilitiesOfArmour(type, willLeft - willRequired, stack);
|
||||
PlayerDemonWillHandler.consumeDemonWill(type, player, willRequired);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.revertArmour(player, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getCostModifier(ItemStack stack)
|
||||
{
|
||||
public double getCostModifier(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
return tag.getDouble("costModifier");
|
||||
}
|
||||
|
||||
public void setCostModifier(ItemStack stack, double modifier)
|
||||
{
|
||||
public void setCostModifier(ItemStack stack, double modifier) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble("costModifier", modifier);
|
||||
}
|
||||
|
||||
public double getArmourModifier(ItemStack stack)
|
||||
{
|
||||
public double getArmourModifier(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
return tag.getDouble("armourModifier");
|
||||
}
|
||||
|
||||
public void setArmourModifier(ItemStack stack, double modifier)
|
||||
{
|
||||
public void setArmourModifier(ItemStack stack, double modifier) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
|
@ -308,26 +265,21 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + names[3 - armorType.getIndex()];
|
||||
}
|
||||
|
||||
public void revertArmour(EntityPlayer player, ItemStack itemStack)
|
||||
{
|
||||
public void revertArmour(EntityPlayer player, ItemStack itemStack) {
|
||||
ItemStack stack = this.getContainedArmourStack(itemStack);
|
||||
player.setItemStackToSlot(armorType, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
return new ItemMeshDefinition()
|
||||
{
|
||||
public ItemMeshDefinition getMeshDefinition() {
|
||||
return new ItemMeshDefinition() {
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack)
|
||||
{
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack) {
|
||||
assert getCustomLocation() != null;
|
||||
EnumDemonWillType type = ((ItemSentientArmour) RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET).getCurrentType(stack);
|
||||
String additional = "_" + type.getName().toLowerCase();
|
||||
|
@ -344,17 +296,14 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
public ResourceLocation getCustomLocation() {
|
||||
return new ResourceLocation(BloodMagic.MODID, "item/ItemSentientArmour");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
public List<String> getVariants() {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||
{
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values()) {
|
||||
String additional = "_" + type.getName().toLowerCase();
|
||||
|
||||
ret.add("armour=head" + additional);
|
||||
|
@ -367,11 +316,9 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
}
|
||||
|
||||
@Override
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
|
||||
{
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
|
||||
Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();
|
||||
if (slot == EntityEquipmentSlot.CHEST)
|
||||
{
|
||||
if (slot == EntityEquipmentSlot.CHEST) {
|
||||
multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(0, 318145), "Armor modifier", this.getHealthBonus(stack), 0));
|
||||
multimap.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(), new AttributeModifier(new UUID(0, 8145), "Armor modifier", this.getKnockbackResistance(stack), 0));
|
||||
multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getName(), new AttributeModifier(new UUID(0, 94021), "Armor modifier", this.getSpeedBoost(stack), 2));
|
||||
|
@ -381,22 +328,8 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
return multimap;
|
||||
}
|
||||
|
||||
public static void revertAllArmour(EntityPlayer player)
|
||||
{
|
||||
NonNullList<ItemStack> armourInventory = player.inventory.armorInventory;
|
||||
for (ItemStack stack : armourInventory)
|
||||
{
|
||||
if (stack != null && stack.getItem() instanceof ItemSentientArmour)
|
||||
{
|
||||
((ItemSentientArmour) stack.getItem()).revertArmour(player, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setContainedArmourStack(ItemStack newArmour, ItemStack previousArmour)
|
||||
{
|
||||
if (newArmour == null || previousArmour == null)
|
||||
{
|
||||
public void setContainedArmourStack(ItemStack newArmour, ItemStack previousArmour) {
|
||||
if (newArmour == null || previousArmour == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -404,8 +337,7 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
previousArmour.writeToNBT(tag);
|
||||
|
||||
NBTTagCompound omegaTag = newArmour.getTagCompound();
|
||||
if (omegaTag == null)
|
||||
{
|
||||
if (omegaTag == null) {
|
||||
omegaTag = new NBTTagCompound();
|
||||
newArmour.setTagCompound(omegaTag);
|
||||
}
|
||||
|
@ -415,11 +347,9 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
EnchantmentHelper.setEnchantments(enchantmentMap, newArmour);
|
||||
}
|
||||
|
||||
public ItemStack getContainedArmourStack(ItemStack newArmour)
|
||||
{
|
||||
public ItemStack getContainedArmourStack(ItemStack newArmour) {
|
||||
NBTTagCompound omegaTag = newArmour.getTagCompound();
|
||||
if (omegaTag == null)
|
||||
{
|
||||
if (omegaTag == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -427,10 +357,195 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
return new ItemStack(tag);
|
||||
}
|
||||
|
||||
public static boolean convertPlayerArmour(EnumDemonWillType type, double will, EntityPlayer player)
|
||||
{
|
||||
if (!canSustainArmour(type, will))
|
||||
{
|
||||
public ItemStack getSubstituteStack(EnumDemonWillType type, double will, ItemStack previousArmour) {
|
||||
ItemStack newArmour = new ItemStack(this);
|
||||
|
||||
this.setContainedArmourStack(newArmour, previousArmour);
|
||||
this.setAbilitiesOfArmour(type, will, newArmour);
|
||||
|
||||
return newArmour;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumDemonWillType getCurrentType(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE)) {
|
||||
return EnumDemonWillType.DEFAULT;
|
||||
}
|
||||
|
||||
return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public void setCurrentType(EnumDemonWillType type, ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setString(Constants.NBT.WILL_TYPE, type.toString());
|
||||
}
|
||||
|
||||
public void setAbilitiesOfArmour(EnumDemonWillType type, double willValue, ItemStack armourStack) {
|
||||
int willBracket = getWillBracket(willValue);
|
||||
if (willBracket >= 0) {
|
||||
double recurringCost = consumptionPerHit[willBracket];
|
||||
|
||||
this.setCostModifier(armourStack, recurringCost);
|
||||
this.setCurrentType(type, armourStack);
|
||||
|
||||
if (this.armorType == EntityEquipmentSlot.CHEST) {
|
||||
this.setArmourModifier(armourStack, getArmourModifier(type, willBracket));
|
||||
this.setHealthBonus(armourStack, this.getHealthModifier(type, willBracket));
|
||||
this.setKnockbackResistance(armourStack, getKnockbackModifier(type, willBracket));
|
||||
this.setSpeedBoost(armourStack, getSpeedModifier(type, willBracket));
|
||||
this.setDamageBoost(armourStack, getDamageModifier(type, willBracket));
|
||||
this.setAttackSpeedBoost(armourStack, getAttackSpeedModifier(type, willBracket));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getArmourModifier(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case STEADFAST:
|
||||
return steadfastProtectionLevel[willBracket];
|
||||
default:
|
||||
return extraProtectionLevel[willBracket];
|
||||
}
|
||||
}
|
||||
|
||||
public double getHealthModifier(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case STEADFAST:
|
||||
//return healthBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getKnockbackModifier(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case STEADFAST:
|
||||
return knockbackBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getSpeedModifier(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case VENGEFUL:
|
||||
return speedBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getDamageModifier(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case DESTRUCTIVE:
|
||||
return damageBoost[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getAttackSpeedModifier(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case DESTRUCTIVE:
|
||||
return attackSpeed[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getHealthBonus(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_HEALTH);
|
||||
}
|
||||
|
||||
public void setHealthBonus(ItemStack stack, double hp) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble(Constants.NBT.SOUL_SWORD_HEALTH, hp);
|
||||
}
|
||||
|
||||
public double getKnockbackResistance(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble("knockback");
|
||||
}
|
||||
|
||||
public void setKnockbackResistance(ItemStack stack, double kb) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble("knockback", kb);
|
||||
}
|
||||
|
||||
public double getSpeedBoost(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble("speed");
|
||||
}
|
||||
|
||||
public void setSpeedBoost(ItemStack stack, double speed) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble("speed", speed);
|
||||
}
|
||||
|
||||
public double getDamageBoost(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble("damage");
|
||||
}
|
||||
|
||||
public void setDamageBoost(ItemStack stack, double damage) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble("damage", damage);
|
||||
}
|
||||
|
||||
public double getAttackSpeedBoost(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble("attackSpeed");
|
||||
}
|
||||
|
||||
public void setAttackSpeedBoost(ItemStack stack, double attackSpeed) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble("attackSpeed", attackSpeed);
|
||||
}
|
||||
|
||||
public static void revertAllArmour(EntityPlayer player) {
|
||||
NonNullList<ItemStack> armourInventory = player.inventory.armorInventory;
|
||||
for (ItemStack stack : armourInventory) {
|
||||
if (stack != null && stack.getItem() instanceof ItemSentientArmour) {
|
||||
((ItemSentientArmour) stack.getItem()).revertArmour(player, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean convertPlayerArmour(EnumDemonWillType type, double will, EntityPlayer player) {
|
||||
if (!canSustainArmour(type, will)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -454,230 +569,19 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
}
|
||||
}
|
||||
|
||||
public ItemStack getSubstituteStack(EnumDemonWillType type, double will, ItemStack previousArmour)
|
||||
{
|
||||
ItemStack newArmour = new ItemStack(this);
|
||||
|
||||
this.setContainedArmourStack(newArmour, previousArmour);
|
||||
this.setAbilitiesOfArmour(type, will, newArmour);
|
||||
|
||||
return newArmour;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumDemonWillType getCurrentType(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE))
|
||||
{
|
||||
return EnumDemonWillType.DEFAULT;
|
||||
}
|
||||
|
||||
return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public void setCurrentType(EnumDemonWillType type, ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setString(Constants.NBT.WILL_TYPE, type.toString());
|
||||
}
|
||||
|
||||
public void setAbilitiesOfArmour(EnumDemonWillType type, double willValue, ItemStack armourStack)
|
||||
{
|
||||
int willBracket = getWillBracket(willValue);
|
||||
if (willBracket >= 0)
|
||||
{
|
||||
double recurringCost = consumptionPerHit[willBracket];
|
||||
|
||||
this.setCostModifier(armourStack, recurringCost);
|
||||
this.setCurrentType(type, armourStack);
|
||||
|
||||
if (this.armorType == EntityEquipmentSlot.CHEST)
|
||||
{
|
||||
this.setArmourModifier(armourStack, getArmourModifier(type, willBracket));
|
||||
this.setHealthBonus(armourStack, this.getHealthModifier(type, willBracket));
|
||||
this.setKnockbackResistance(armourStack, getKnockbackModifier(type, willBracket));
|
||||
this.setSpeedBoost(armourStack, getSpeedModifier(type, willBracket));
|
||||
this.setDamageBoost(armourStack, getDamageModifier(type, willBracket));
|
||||
this.setAttackSpeedBoost(armourStack, getAttackSpeedModifier(type, willBracket));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getArmourModifier(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case STEADFAST:
|
||||
return steadfastProtectionLevel[willBracket];
|
||||
default:
|
||||
return extraProtectionLevel[willBracket];
|
||||
}
|
||||
}
|
||||
|
||||
public double getHealthModifier(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case STEADFAST:
|
||||
//return healthBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getKnockbackModifier(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case STEADFAST:
|
||||
return knockbackBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getSpeedModifier(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VENGEFUL:
|
||||
return speedBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getDamageModifier(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DESTRUCTIVE:
|
||||
return damageBoost[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getAttackSpeedModifier(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DESTRUCTIVE:
|
||||
return attackSpeed[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canSustainArmour(EnumDemonWillType type, double willValue)
|
||||
{
|
||||
public static boolean canSustainArmour(EnumDemonWillType type, double willValue) {
|
||||
return getWillBracket(willValue) >= 0;
|
||||
}
|
||||
|
||||
public static int getWillBracket(double will)
|
||||
{
|
||||
public static int getWillBracket(double will) {
|
||||
int bracket = -1;
|
||||
|
||||
for (int i = 0; i < willBracket.length; i++)
|
||||
{
|
||||
if (will >= willBracket[i])
|
||||
{
|
||||
for (int i = 0; i < willBracket.length; i++) {
|
||||
if (will >= willBracket[i]) {
|
||||
bracket = i;
|
||||
}
|
||||
}
|
||||
|
||||
return bracket;
|
||||
}
|
||||
|
||||
public double getHealthBonus(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_HEALTH);
|
||||
}
|
||||
|
||||
public void setHealthBonus(ItemStack stack, double hp)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble(Constants.NBT.SOUL_SWORD_HEALTH, hp);
|
||||
}
|
||||
|
||||
public double getKnockbackResistance(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble("knockback");
|
||||
}
|
||||
|
||||
public void setKnockbackResistance(ItemStack stack, double kb)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble("knockback", kb);
|
||||
}
|
||||
|
||||
public double getSpeedBoost(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble("speed");
|
||||
}
|
||||
|
||||
public void setSpeedBoost(ItemStack stack, double speed)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble("speed", speed);
|
||||
}
|
||||
|
||||
public double getDamageBoost(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble("damage");
|
||||
}
|
||||
|
||||
public void setDamageBoost(ItemStack stack, double damage)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble("damage", damage);
|
||||
}
|
||||
|
||||
public double getAttackSpeedBoost(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble("attackSpeed");
|
||||
}
|
||||
|
||||
public void setAttackSpeedBoost(ItemStack stack, double attackSpeed)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble("attackSpeed", attackSpeed);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue