use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.
the class ItemBoundHoe method onUpdate.
@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int slotIndex, boolean par5) {
if (par3Entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) par3Entity;
if (player.capabilities.isCreativeMode)
return;
ExtendedProperties props = ExtendedProperties.For(player);
if (props.getCurrentMana() + props.getBonusCurrentMana() < this.maintainCost()) {
UnbindItem(par1ItemStack, (EntityPlayer) par3Entity, slotIndex);
return;
} else {
props.deductMana(this.maintainCost());
}
if (par1ItemStack.getItemDamage() > 0)
par1ItemStack.damageItem(-1, (EntityLivingBase) par3Entity);
}
}
use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.
the class ItemBoundPickaxe method onUpdate.
@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int slotIndex, boolean par5) {
if (par3Entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) par3Entity;
if (player.capabilities.isCreativeMode)
return;
ExtendedProperties props = ExtendedProperties.For(player);
if (props.getCurrentMana() + props.getBonusCurrentMana() < this.maintainCost()) {
UnbindItem(par1ItemStack, (EntityPlayer) par3Entity, slotIndex);
return;
} else {
props.deductMana(this.maintainCost());
}
if (par1ItemStack.getItemDamage() > 0)
par1ItemStack.damageItem(-1, (EntityLivingBase) par3Entity);
}
}
use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.
the class ItemBoundShovel method onUpdate.
@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int slotIndex, boolean par5) {
if (par3Entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) par3Entity;
if (player.capabilities.isCreativeMode)
return;
ExtendedProperties props = ExtendedProperties.For(player);
if (props.getCurrentMana() + props.getBonusCurrentMana() < this.maintainCost()) {
UnbindItem(par1ItemStack, (EntityPlayer) par3Entity, slotIndex);
return;
} else {
props.deductMana(this.maintainCost());
}
if (par1ItemStack.getItemDamage() > 0)
par1ItemStack.damageItem(-1, (EntityLivingBase) par3Entity);
}
}
use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.
the class ItemBoundSword method onUpdate.
@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int slotIndex, boolean par5) {
if (par3Entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) par3Entity;
if (player.capabilities.isCreativeMode)
return;
ExtendedProperties props = ExtendedProperties.For(player);
if (props.getCurrentMana() + props.getBonusCurrentMana() < this.maintainCost()) {
UnbindItem(par1ItemStack, (EntityPlayer) par3Entity, slotIndex);
return;
} else {
props.deductMana(this.maintainCost());
}
if (par1ItemStack.getItemDamage() > 0)
par1ItemStack.damageItem(-1, (EntityLivingBase) par3Entity);
}
}
use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.
the class LifeTap method applyEffectEntity.
@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
if (!(target instanceof EntityLivingBase))
return false;
if (!world.isRemote) {
double damage = SpellUtils.instance.getModifiedDouble_Mul(2, stack, caster, target, world, 0, SpellModifiers.DAMAGE);
ExtendedProperties casterProperties = ExtendedProperties.For(caster);
float manaRefunded = (float) (((damage * 0.01)) * casterProperties.getMaxMana());
if ((caster).attackEntityFrom(DamageSource.outOfWorld, (int) Math.floor(damage))) {
casterProperties.setCurrentMana(casterProperties.getCurrentMana() + manaRefunded);
casterProperties.forceSync();
} else {
return false;
}
}
return true;
}
Aggregations