本文整理匯總了Java中net.minecraft.entity.EntityLivingBase.getArmorInventoryList方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityLivingBase.getArmorInventoryList方法的具體用法?Java EntityLivingBase.getArmorInventoryList怎麽用?Java EntityLivingBase.getArmorInventoryList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.entity.EntityLivingBase
的用法示例。
在下文中一共展示了EntityLivingBase.getArmorInventoryList方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: damageArmor
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
private void damageArmor(ItemStack stack, int amount, EntityLivingBase entity)
{
int slot = -1;
int x = 0;
for (ItemStack i : entity.getArmorInventoryList())
{
if (i == stack){
slot = x;
break;
}
x++;
}
if (slot == -1 || !(stack.getItem() instanceof net.minecraftforge.common.ISpecialArmor))
{
stack.damageItem(1, entity);
return;
}
net.minecraftforge.common.ISpecialArmor armor = (net.minecraftforge.common.ISpecialArmor)stack.getItem();
armor.damageArmor(entity, stack, DamageSource.causeThornsDamage(entity), amount, slot);
}
示例2: hitEntity
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
super.hitEntity(stack, target, attacker);
for (ItemStack armor : target.getArmorInventoryList()) {
if (armor.isItemStackDamageable() && this.itemRand.nextFloat() < 0.3F) {
armor.damageItem((int) (this.getAttackDamage(stack) / 2) + 1, target);
}
}
return true;
}