Some work on the armour
This commit is contained in:
parent
4d835257ab
commit
3edfc3a8ac
|
@ -15,6 +15,8 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import WayofTime.bloodmagic.BloodMagic;
|
import WayofTime.bloodmagic.BloodMagic;
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
|
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||||
|
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||||
import WayofTime.bloodmagic.registry.ModItems;
|
import WayofTime.bloodmagic.registry.ModItems;
|
||||||
|
|
||||||
public class ItemSentientArmour extends ItemArmor implements ISpecialArmor
|
public class ItemSentientArmour extends ItemArmor implements ISpecialArmor
|
||||||
|
@ -78,6 +80,7 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor
|
||||||
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
|
double remainder = 1; // Multiply this number by the armour upgrades for protection
|
||||||
|
remainder *= (1 - this.getArmourModifier(stack));
|
||||||
|
|
||||||
armourReduction = armourReduction + (1 - remainder) * (1 - armourReduction);
|
armourReduction = armourReduction + (1 - remainder) * (1 - armourReduction);
|
||||||
damageAmount *= (armourReduction);
|
damageAmount *= (armourReduction);
|
||||||
|
@ -131,14 +134,27 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor
|
||||||
@Override
|
@Override
|
||||||
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot)
|
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot)
|
||||||
{
|
{
|
||||||
return; // Armour shouldn't get damaged... for now
|
if (entity instanceof EntityPlayer)
|
||||||
|
{
|
||||||
|
EntityPlayer player = (EntityPlayer) entity;
|
||||||
|
|
||||||
|
double willRequired = this.getCostModifier(stack) * damage;
|
||||||
|
double willLeft = PlayerDemonWillHandler.getTotalDemonWill(player);
|
||||||
|
if (willLeft >= willRequired)
|
||||||
|
{
|
||||||
|
PlayerDemonWillHandler.consumeDemonWill(player, willRequired);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
this.revertArmour(player, stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced)
|
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced)
|
||||||
{
|
{
|
||||||
|
|
||||||
super.addInformation(stack, player, tooltip, advanced);
|
super.addInformation(stack, player, tooltip, advanced);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,8 +184,38 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: Consume will - if the will drops to 0, return the contained item
|
public double getCostModifier(ItemStack stack)
|
||||||
|
{
|
||||||
|
NBTHelper.checkNBT(stack);
|
||||||
|
NBTTagCompound tag = stack.getTagCompound();
|
||||||
|
|
||||||
|
return tag.getDouble("costModifier");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCostModifier(ItemStack stack, double modifier)
|
||||||
|
{
|
||||||
|
NBTHelper.checkNBT(stack);
|
||||||
|
NBTTagCompound tag = stack.getTagCompound();
|
||||||
|
|
||||||
|
tag.setDouble("costModifier", modifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getArmourModifier(ItemStack stack)
|
||||||
|
{
|
||||||
|
NBTHelper.checkNBT(stack);
|
||||||
|
NBTTagCompound tag = stack.getTagCompound();
|
||||||
|
|
||||||
|
return tag.getDouble("armourModifier");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArmourModifier(ItemStack stack, double modifier)
|
||||||
|
{
|
||||||
|
NBTHelper.checkNBT(stack);
|
||||||
|
NBTTagCompound tag = stack.getTagCompound();
|
||||||
|
|
||||||
|
tag.setDouble("armourModifier", modifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -230,7 +276,7 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor
|
||||||
return armourStack;
|
return armourStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean convertPlayerArmour(EntityPlayer player)
|
public static boolean convertPlayerArmour(EntityPlayer player, double recurringCost, double protection)
|
||||||
{
|
{
|
||||||
ItemStack[] armours = player.inventory.armorInventory;
|
ItemStack[] armours = player.inventory.armorInventory;
|
||||||
|
|
||||||
|
@ -240,10 +286,10 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor
|
||||||
ItemStack bootsStack = armours[0];
|
ItemStack bootsStack = armours[0];
|
||||||
|
|
||||||
{
|
{
|
||||||
ItemStack omegaHelmetStack = ((ItemSentientArmour) ModItems.sentientArmourHelmet).getSubstituteStack(helmetStack);
|
ItemStack omegaHelmetStack = ((ItemSentientArmour) ModItems.sentientArmourHelmet).getSubstituteStack(helmetStack, recurringCost, protection);
|
||||||
ItemStack omegaChestStack = ((ItemSentientArmour) ModItems.sentientArmourChest).getSubstituteStack(chestStack);
|
ItemStack omegaChestStack = ((ItemSentientArmour) ModItems.sentientArmourChest).getSubstituteStack(chestStack, recurringCost, protection);
|
||||||
ItemStack omegaLeggingsStack = ((ItemSentientArmour) ModItems.sentientArmourLegs).getSubstituteStack(leggingsStack);
|
ItemStack omegaLeggingsStack = ((ItemSentientArmour) ModItems.sentientArmourLegs).getSubstituteStack(leggingsStack, recurringCost, protection);
|
||||||
ItemStack omegaBootsStack = ((ItemSentientArmour) ModItems.sentientArmourBoots).getSubstituteStack(bootsStack);
|
ItemStack omegaBootsStack = ((ItemSentientArmour) ModItems.sentientArmourBoots).getSubstituteStack(bootsStack, recurringCost, protection);
|
||||||
|
|
||||||
armours[3] = omegaHelmetStack;
|
armours[3] = omegaHelmetStack;
|
||||||
armours[2] = omegaChestStack;
|
armours[2] = omegaChestStack;
|
||||||
|
@ -254,11 +300,13 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getSubstituteStack(ItemStack previousArmour)
|
public ItemStack getSubstituteStack(ItemStack previousArmour, double recurringCost, double protection)
|
||||||
{
|
{
|
||||||
ItemStack newArmour = new ItemStack(this);
|
ItemStack newArmour = new ItemStack(this);
|
||||||
|
|
||||||
this.setContainedArmourStack(newArmour, previousArmour);
|
this.setContainedArmourStack(newArmour, previousArmour);
|
||||||
|
this.setCostModifier(newArmour, recurringCost);
|
||||||
|
this.setArmourModifier(newArmour, protection);
|
||||||
|
|
||||||
return newArmour;
|
return newArmour;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
package WayofTime.bloodmagic.item.soul;
|
||||||
|
|
||||||
|
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
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.soul.PlayerDemonWillHandler;
|
||||||
|
import WayofTime.bloodmagic.item.armour.ItemSentientArmour;
|
||||||
|
|
||||||
|
public class ItemSentientArmourGem extends Item
|
||||||
|
{
|
||||||
|
public static double[] willBracket = new double[] { 30, 200, 600, 1500, 4000, 6000, 8000 };
|
||||||
|
public static double[] consumptionPerHit = new double[] { 0.1, 0.12, 0.15, 0.2, 0.3, 0.35, 0.4 };
|
||||||
|
public static double[] extraProtectionLevel = new double[] { 0, 0.25, 0.5, 0.6, 0.7, 0.75, 0.85 };
|
||||||
|
|
||||||
|
public ItemSentientArmourGem()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.setCreativeTab(BloodMagic.tabBloodMagic);
|
||||||
|
setUnlocalizedName(Constants.Mod.MODID + ".sentientArmourGem");
|
||||||
|
this.setMaxStackSize(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||||
|
{
|
||||||
|
boolean hasSentientArmour = false;
|
||||||
|
ItemStack[] armourInventory = player.inventory.armorInventory;
|
||||||
|
for (ItemStack armourStack : armourInventory)
|
||||||
|
{
|
||||||
|
if (armourStack != null && armourStack.getItem() instanceof ItemSentientArmour)
|
||||||
|
{
|
||||||
|
hasSentientArmour = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasSentientArmour)
|
||||||
|
{
|
||||||
|
ItemSentientArmour.revertAllArmour(player);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
double will = PlayerDemonWillHandler.getTotalDemonWill(player);
|
||||||
|
|
||||||
|
int bracket = getWillBracket(will);
|
||||||
|
|
||||||
|
if (bracket >= 0)
|
||||||
|
{
|
||||||
|
PlayerDemonWillHandler.consumeDemonWill(player, willBracket[bracket]);
|
||||||
|
ItemSentientArmour.convertPlayerArmour(player, consumptionPerHit[bracket], extraProtectionLevel[bracket]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWillBracket(double will)
|
||||||
|
{
|
||||||
|
int bracket = -1;
|
||||||
|
|
||||||
|
for (int i = 0; i < willBracket.length; i++)
|
||||||
|
{
|
||||||
|
if (will >= willBracket[i])
|
||||||
|
{
|
||||||
|
bracket = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bracket;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
|
||||||
|
{
|
||||||
|
boolean hasSentientArmour = false;
|
||||||
|
ItemStack[] armourInventory = player.inventory.armorInventory;
|
||||||
|
for (ItemStack armourStack : armourInventory)
|
||||||
|
{
|
||||||
|
if (armourStack != null && armourStack.getItem() instanceof ItemSentientArmour)
|
||||||
|
{
|
||||||
|
hasSentientArmour = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasSentientArmour)
|
||||||
|
{
|
||||||
|
return new ModelResourceLocation("bloodmagic:ItemSentientArmourGem1", "inventory");
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -48,6 +48,7 @@ import WayofTime.bloodmagic.item.sigil.ItemSigilVoid;
|
||||||
import WayofTime.bloodmagic.item.sigil.ItemSigilWater;
|
import WayofTime.bloodmagic.item.sigil.ItemSigilWater;
|
||||||
import WayofTime.bloodmagic.item.sigil.ItemSigilWhirlwind;
|
import WayofTime.bloodmagic.item.sigil.ItemSigilWhirlwind;
|
||||||
import WayofTime.bloodmagic.item.soul.ItemMonsterSoul;
|
import WayofTime.bloodmagic.item.soul.ItemMonsterSoul;
|
||||||
|
import WayofTime.bloodmagic.item.soul.ItemSentientArmourGem;
|
||||||
import WayofTime.bloodmagic.item.soul.ItemSentientBow;
|
import WayofTime.bloodmagic.item.soul.ItemSentientBow;
|
||||||
import WayofTime.bloodmagic.item.soul.ItemSentientSword;
|
import WayofTime.bloodmagic.item.soul.ItemSentientSword;
|
||||||
import WayofTime.bloodmagic.item.soul.ItemSoulGem;
|
import WayofTime.bloodmagic.item.soul.ItemSoulGem;
|
||||||
|
@ -125,6 +126,7 @@ public class ModItems
|
||||||
|
|
||||||
public static Item sentientSword;
|
public static Item sentientSword;
|
||||||
public static Item sentientBow;
|
public static Item sentientBow;
|
||||||
|
public static Item sentientArmourGem;
|
||||||
|
|
||||||
public static Item.ToolMaterial boundToolMaterial = EnumHelper.addToolMaterial("BoundToolMaterial", 4, 0, 10, 8, 50);
|
public static Item.ToolMaterial boundToolMaterial = EnumHelper.addToolMaterial("BoundToolMaterial", 4, 0, 10, 8, 50);
|
||||||
public static Item.ToolMaterial soulToolMaterial = EnumHelper.addToolMaterial("SoulToolMaterial", 4, 0, 7, 8, 50);
|
public static Item.ToolMaterial soulToolMaterial = EnumHelper.addToolMaterial("SoulToolMaterial", 4, 0, 7, 8, 50);
|
||||||
|
@ -208,6 +210,7 @@ public class ModItems
|
||||||
|
|
||||||
sentientSword = registerItem(new ItemSentientSword());
|
sentientSword = registerItem(new ItemSentientSword());
|
||||||
sentientBow = registerItem(new ItemSentientBow());
|
sentientBow = registerItem(new ItemSentientBow());
|
||||||
|
sentientArmourGem = registerItem(new ItemSentientArmourGem());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initRenders()
|
public static void initRenders()
|
||||||
|
@ -326,6 +329,8 @@ public class ModItems
|
||||||
renderHelper.itemRender(sentientBow, 2, "ItemSentientBow_pulling_1");
|
renderHelper.itemRender(sentientBow, 2, "ItemSentientBow_pulling_1");
|
||||||
renderHelper.itemRender(sentientBow, 3, "ItemSentientBow_pulling_2");
|
renderHelper.itemRender(sentientBow, 3, "ItemSentientBow_pulling_2");
|
||||||
|
|
||||||
|
renderHelper.itemRender(sentientArmourGem, 0, "ItemSentientArmourGem0");
|
||||||
|
renderHelper.itemRender(sentientArmourGem, 1, "ItemSentientArmourGem1");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Item registerItem(Item item, String name)
|
private static Item registerItem(Item item, String name)
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"parent":"bloodmagic:item/ItemModelBase",
|
||||||
|
"textures": {
|
||||||
|
"layer0":"bloodmagic:items/SentientArmourGem_deactivated"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"parent":"bloodmagic:item/ItemModelBase",
|
||||||
|
"textures": {
|
||||||
|
"layer0":"bloodmagic:items/SentientArmourGem_activated"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 475 B |
Binary file not shown.
After Width: | Height: | Size: 472 B |
Loading…
Reference in a new issue