Added Sentient Armour - not fully implemented.

This commit is contained in:
WayofTime 2016-01-09 13:01:05 -05:00
parent 61e6cf2a14
commit 4d835257ab
13 changed files with 315 additions and 1 deletions

View file

@ -0,0 +1,265 @@
package WayofTime.bloodmagic.item.armour;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
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.registry.ModItems;
public class ItemSentientArmour extends ItemArmor implements ISpecialArmor
{
public static String[] names = { "helmet", "chest", "legs", "boots" };
public ItemSentientArmour(int armorType)
{
super(ItemArmor.ArmorMaterial.IRON, 0, armorType);
setUnlocalizedName(Constants.Mod.MODID + ".sentientArmour.");
setMaxDamage(250);
setCreativeTab(BloodMagic.tabBloodMagic);
}
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot)
{
double armourReduction = 0.0;
double damageAmount = 0.25;
if (this == ModItems.sentientArmourBoots || this == ModItems.sentientArmourHelmet)
{
damageAmount = 3d / 20d * 0.6;
} else if (this == ModItems.sentientArmourLegs)
{
damageAmount = 6d / 20d * 0.6;
} else if (this == ModItems.sentientArmourChest)
{
damageAmount = 0.64;
}
double armourPenetrationReduction = 0;
int maxAbsorption = 100000;
if (source.equals(DamageSource.drown))
{
return new ArmorProperties(-1, 0, 0);
}
if (source.equals(DamageSource.outOfWorld))
{
return new ArmorProperties(-1, 0, 0);
}
if (this == ModItems.sentientArmourChest)
{
armourReduction = 0.24 / 0.64; // This values puts it at iron level
ItemStack helmet = player.getEquipmentInSlot(4);
ItemStack leggings = player.getEquipmentInSlot(2);
ItemStack boots = player.getEquipmentInSlot(1);
if (helmet == null || leggings == null || boots == null)
{
damageAmount *= (armourReduction);
return new ArmorProperties(-1, damageAmount, maxAbsorption);
}
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
armourReduction = armourReduction + (1 - remainder) * (1 - armourReduction);
damageAmount *= (armourReduction);
if (source.isUnblockable())
{
return new ArmorProperties(-1, damageAmount * armourPenetrationReduction, maxAbsorption);
}
return new ArmorProperties(-1, damageAmount, maxAbsorption);
}
} else
{
if (source.isUnblockable())
{
return new ArmorProperties(-1, damageAmount * armourPenetrationReduction, maxAbsorption);
}
return new ArmorProperties(-1, damageAmount, maxAbsorption);
}
return new ArmorProperties(-1, 0, 0);
}
@Override
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot)
{
if (armor.getItem() == ModItems.sentientArmourHelmet)
{
return 3;
}
if (armor.getItem() == ModItems.sentientArmourChest)
{
return 8;
}
if (armor.getItem() == ModItems.sentientArmourLegs)
{
return 6;
}
if (armor.getItem() == ModItems.sentientArmourBoots)
{
return 3;
}
return 5;
}
@Override
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot)
{
return; // Armour shouldn't get damaged... for now
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced)
{
super.addInformation(stack, player, tooltip, advanced);
}
@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
{
if (this == ModItems.sentientArmourChest || this == ModItems.sentientArmourHelmet || this == ModItems.sentientArmourBoots)
{
return "bloodmagic:models/armor/sentientArmour_layer_1.png";
}
if (this == ModItems.sentientArmourLegs)
{
return "bloodmagic:models/armor/sentientArmour_layer_2.png";
} else
{
return null;
}
}
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack stack)
{
super.onArmorTick(world, player, stack);
if (world.isRemote)
{
return;
}
//TODO: Consume will - if the will drops to 0, return the contained item
}
@Override
public String getUnlocalizedName(ItemStack stack)
{
return super.getUnlocalizedName(stack) + names[armorType];
}
public void revertArmour(EntityPlayer player, ItemStack itemStack)
{
ItemStack stack = this.getContainedArmourStack(itemStack);
player.inventory.armorInventory[3 - this.armorType] = stack;
}
public static void revertAllArmour(EntityPlayer player)
{
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)
{
return;
}
NBTTagCompound tag = new NBTTagCompound();
previousArmour.writeToNBT(tag);
NBTTagCompound omegaTag = newArmour.getTagCompound();
if (omegaTag == null)
{
omegaTag = new NBTTagCompound();
newArmour.setTagCompound(omegaTag);
}
omegaTag.setTag("armour", tag);
}
public ItemStack getContainedArmourStack(ItemStack newArmour)
{
NBTTagCompound omegaTag = newArmour.getTagCompound();
if (omegaTag == null)
{
return null;
}
NBTTagCompound tag = omegaTag.getCompoundTag("armour");
ItemStack armourStack = ItemStack.loadItemStackFromNBT(tag);
return armourStack;
}
public static boolean convertPlayerArmour(EntityPlayer player)
{
ItemStack[] armours = player.inventory.armorInventory;
ItemStack helmetStack = armours[3];
ItemStack chestStack = armours[2];
ItemStack leggingsStack = armours[1];
ItemStack bootsStack = armours[0];
{
ItemStack omegaHelmetStack = ((ItemSentientArmour) ModItems.sentientArmourHelmet).getSubstituteStack(helmetStack);
ItemStack omegaChestStack = ((ItemSentientArmour) ModItems.sentientArmourChest).getSubstituteStack(chestStack);
ItemStack omegaLeggingsStack = ((ItemSentientArmour) ModItems.sentientArmourLegs).getSubstituteStack(leggingsStack);
ItemStack omegaBootsStack = ((ItemSentientArmour) ModItems.sentientArmourBoots).getSubstituteStack(bootsStack);
armours[3] = omegaHelmetStack;
armours[2] = omegaChestStack;
armours[1] = omegaLeggingsStack;
armours[0] = omegaBootsStack;
return true;
}
}
public ItemStack getSubstituteStack(ItemStack previousArmour)
{
ItemStack newArmour = new ItemStack(this);
this.setContainedArmourStack(newArmour, previousArmour);
return newArmour;
}
}

View file

@ -27,6 +27,7 @@ import WayofTime.bloodmagic.item.ItemSacrificialDagger;
import WayofTime.bloodmagic.item.ItemSlate;
import WayofTime.bloodmagic.item.ItemTelepositionFocus;
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
import WayofTime.bloodmagic.item.armour.ItemSentientArmour;
import WayofTime.bloodmagic.item.gear.ItemPackSacrifice;
import WayofTime.bloodmagic.item.gear.ItemPackSelfSacrifice;
import WayofTime.bloodmagic.item.sigil.ItemSigilAir;
@ -110,6 +111,11 @@ public class ModItems
public static Item livingArmourLegs;
public static Item livingArmourBoots;
public static Item sentientArmourHelmet;
public static Item sentientArmourChest;
public static Item sentientArmourLegs;
public static Item sentientArmourBoots;
public static Item altarMaker;
public static Item arcaneAshes;
@ -188,6 +194,11 @@ public class ModItems
livingArmourLegs = registerItem(new ItemLivingArmour(2), "ItemLivingArmourLegs");
livingArmourBoots = registerItem(new ItemLivingArmour(3), "ItemLivingArmourBoots");
sentientArmourHelmet = registerItem(new ItemSentientArmour(0), "ItemSentientArmourHelmet");
sentientArmourChest = registerItem(new ItemSentientArmour(1), "ItemSentientArmourChest");
sentientArmourLegs = registerItem(new ItemSentientArmour(2), "ItemSentientArmourLegs");
sentientArmourBoots = registerItem(new ItemSentientArmour(3), "ItemSentientArmourBoots");
altarMaker = registerItem(new ItemAltarMaker());
arcaneAshes = registerItem(new ItemArcaneAshes());
@ -292,6 +303,11 @@ public class ModItems
renderHelper.itemRender(livingArmourLegs, "ItemLivingArmour2");
renderHelper.itemRender(livingArmourBoots, "ItemLivingArmour3");
renderHelper.itemRender(sentientArmourHelmet, "ItemSentientArmour0");
renderHelper.itemRender(sentientArmourChest, "ItemSentientArmour1");
renderHelper.itemRender(sentientArmourLegs, "ItemSentientArmour2");
renderHelper.itemRender(sentientArmourBoots, "ItemSentientArmour3");
renderHelper.itemRender(altarMaker);
renderHelper.itemRender(arcaneAshes);

View file

@ -283,7 +283,7 @@ chat.BloodMagic.livingArmour.upgrade.poisonRemove=You are starting to feel bette
jei.BloodMagic.recipe.altar=Blood Altar
jei.BloodMagic.recipe.binding=Binding Ritual
jei.BloodMagic.recipe.alchemyArrayCrafting=Alchemy Array
jei.BloodMagic.recipe.soulForge=Soul Forge
jei.BloodMagic.recipe.soulForge=Hellfire Forge
jei.BloodMagic.recipe.requiredLP=LP: %d
jei.BloodMagic.recipe.requiredTier=Tier: %d
jei.BloodMagic.recipe.minimumSouls=Minimum: %d Souls

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View file

@ -0,0 +1,8 @@
{
"parent":"bloodmagic:item/ItemModelBase",
"textures": {
"layer0":"bloodmagic:items/SentientHelmet"
}
}

View file

@ -0,0 +1,9 @@
{
"parent":"bloodmagic:item/ItemModelBase",
"textures": {
"layer0":"bloodmagic:items/SentientPlate"
}
}

View file

@ -0,0 +1,8 @@
{
"parent":"bloodmagic:item/ItemModelBase",
"textures": {
"layer0":"bloodmagic:items/SentientLeggings"
}
}

View file

@ -0,0 +1,8 @@
{
"parent":"bloodmagic:item/ItemModelBase",
"textures": {
"layer0":"bloodmagic:items/SentientBoots"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B