use of WayofTime.bloodmagic.item.armour.ItemLivingArmour in project BloodMagic by WayofTime.
the class ItemLivingArmourPointsUpgrade method onItemUseFinish.
@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
if (!(entityLiving instanceof EntityPlayer))
return super.onItemUseFinish(stack, worldIn, entityLiving);
EntityPlayer player = (EntityPlayer) entityLiving;
if (!player.capabilities.isCreativeMode)
stack.shrink(1);
if (!worldIn.isRemote) {
player.addPotionEffect(new PotionEffect(MobEffects.WITHER, 300, 5));
player.addPotionEffect(new PotionEffect(MobEffects.POISON, 300, 5));
player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 400, 1));
if (LivingArmour.hasFullSet(player)) {
ItemStack chestStack = Iterables.toArray(player.getArmorInventoryList(), ItemStack.class)[2];
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null) {
if (armour.maxUpgradePoints < 200) {
armour.maxUpgradePoints = 200;
((ItemLivingArmour) chestStack.getItem()).setLivingArmour(chestStack, armour, true);
ItemLivingArmour.setLivingArmour(chestStack, armour);
}
}
}
}
return stack;
}
Aggregations