当前位置: 首页>>代码示例>>Java>>正文


Java EnchantmentDurability.negateDamage方法代码示例

本文整理汇总了Java中net.minecraft.enchantment.EnchantmentDurability.negateDamage方法的典型用法代码示例。如果您正苦于以下问题:Java EnchantmentDurability.negateDamage方法的具体用法?Java EnchantmentDurability.negateDamage怎么用?Java EnchantmentDurability.negateDamage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.enchantment.EnchantmentDurability的用法示例。


在下文中一共展示了EnchantmentDurability.negateDamage方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: attemptDamageItem

import net.minecraft.enchantment.EnchantmentDurability; //导入方法依赖的package包/类
/**
 * Attempts to damage the ItemStack with par1 amount of damage, If the
 * ItemStack has the Unbreaking enchantment there is a chance for each point
 * of damage to be negated. Returns true if it takes more damage than
 * getMaxDamage(). Returns false otherwise or if the ItemStack can't be
 * damaged or if all points of damage are negated.
 */
public boolean attemptDamageItem(ItemStack stack, int amount, Random rand) {
	if (amount > 0) {
		int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.UNBREAKING, stack);
		int j = 0;

		for (int k = 0;i > 0 && k < amount;++k) {
			if (EnchantmentDurability.negateDamage(stack, i, rand)) {
				++j;
			}
		}

		amount -= j;

		if (amount <= 0) { return false; }
	}

	setItemDamage(stack, getItemDamage(stack) + amount); // Redirect through
															// Item's
															// callback if
															// applicable.
	return getItemDamage(stack) > getDurability(stack);
}
 
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:30,代码来源:ItemDamagableCrafting.java

示例2: attemptDamageItem

import net.minecraft.enchantment.EnchantmentDurability; //导入方法依赖的package包/类
public static boolean attemptDamageItem(ItemStack stack, int damage, Random rand) {
	if(!isItemStackDamageable(stack)) {
		return false;
	} else {
		if(damage > 0) {
			int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.unbreaking.effectId, stack);
			int k = 0;
			for(int l = 0; j > 0 && l < damage; ++l) {
				if(EnchantmentDurability.negateDamage(stack, j, rand)) {
					k++;
				}
			}
			damage -= k;
			if(damage <= 0) {
				return false;
			}
		}
		stack.setItemDamage(stack.getItemDamage() + damage);
		return stack.getItemDamage() > stack.getMaxDamage();
	}
}
 
开发者ID:AgeCraft,项目名称:AgeCraft-Old,代码行数:22,代码来源:ACUtil.java

示例3: attemptDamageItem

import net.minecraft.enchantment.EnchantmentDurability; //导入方法依赖的package包/类
/**
 * Attempts to damage the ItemStack with par1 amount of damage, If the ItemStack has the Unbreaking enchantment
 * there is a chance for each point of damage to be negated. Returns true if it takes more damage than
 * getMaxDamage(). Returns false otherwise or if the ItemStack can't be damaged or if all points of damage are
 * negated.
 */
public boolean attemptDamageItem(int amount, Random rand)
{
    if (!this.isItemStackDamageable())
    {
        return false;
    }
    else
    {
        if (amount > 0)
        {
            int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.unbreaking.effectId, this);
            int j = 0;

            for (int k = 0; i > 0 && k < amount; ++k)
            {
                if (EnchantmentDurability.negateDamage(this, i, rand))
                {
                    ++j;
                }
            }

            amount -= j;

            if (amount <= 0)
            {
                return false;
            }
        }

        this.itemDamage += amount;
        return this.itemDamage > this.getMaxDamage();
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:40,代码来源:ItemStack.java

示例4: attemptDamageItem

import net.minecraft.enchantment.EnchantmentDurability; //导入方法依赖的package包/类
/**
 * Attempts to damage the ItemStack with par1 amount of damage, If the ItemStack has the Unbreaking enchantment
 * there is a chance for each point of damage to be negated. Returns true if it takes more damage than
 * getMaxDamage(). Returns false otherwise or if the ItemStack can't be damaged or if all points of damage are
 * negated.
 */
public boolean attemptDamageItem(int amount, Random rand)
{
    if (!this.isItemStackDamageable())
    {
        return false;
    }
    else
    {
        if (amount > 0)
        {
            int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.UNBREAKING, this);
            int j = 0;

            for (int k = 0; i > 0 && k < amount; ++k)
            {
                if (EnchantmentDurability.negateDamage(this, i, rand))
                {
                    ++j;
                }
            }

            amount -= j;

            if (amount <= 0)
            {
                return false;
            }
        }

        this.itemDamage += amount;
        return this.itemDamage > this.getMaxDamage();
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:40,代码来源:ItemStack.java

示例5: attemptDamageItem

import net.minecraft.enchantment.EnchantmentDurability; //导入方法依赖的package包/类
/**
 * Attempts to damage the ItemStack with par1 amount of damage, If the ItemStack has the Unbreaking enchantment
 * there is a chance for each point of damage to be negated. Returns true if it takes more damage than
 * getMaxDamage(). Returns false otherwise or if the ItemStack can't be damaged or if all points of damage are
 * negated.
 */
public boolean attemptDamageItem(int amount, Random rand)
{
    if (!this.isItemStackDamageable())
    {
        return false;
    }
    else
    {
        if (amount > 0)
        {
            int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.UNBREAKING, this);
            int j = 0;

            for (int k = 0; i > 0 && k < amount; ++k)
            {
                if (EnchantmentDurability.negateDamage(this, i, rand))
                {
                    ++j;
                }
            }

            amount -= j;

            if (amount <= 0)
            {
                return false;
            }
        }

        setItemDamage(getItemDamage() + amount); //Redirect through Item's callback if applicable.
        return getItemDamage() > getMaxDamage();
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:40,代码来源:ItemStack.java

示例6: attemptDamageItem

import net.minecraft.enchantment.EnchantmentDurability; //导入方法依赖的package包/类
/**
 * Attempts to damage the ItemStack with par1 amount of damage, If the ItemStack has the Unbreaking enchantment
 * there is a chance for each point of damage to be negated. Returns true if it takes more damage than
 * getMaxDamage(). Returns false otherwise or if the ItemStack can't be damaged or if all points of damage are
 * negated.
 */
public boolean attemptDamageItem(int par1, Random par2Random)
{
    if (!this.isItemStackDamageable())
    {
        return false;
    }
    else
    {
        if (par1 > 0)
        {
            int var3 = EnchantmentHelper.getEnchantmentLevel(Enchantment.unbreaking.effectId, this);
            int var4 = 0;

            for (int var5 = 0; var3 > 0 && var5 < par1; ++var5)
            {
                if (EnchantmentDurability.negateDamage(this, var3, par2Random))
                {
                    ++var4;
                }
            }

            par1 -= var4;

            if (par1 <= 0)
            {
                return false;
            }
        }

        this.itemDamage += par1;
        return this.itemDamage > this.getMaxDamage();
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:40,代码来源:ItemStack.java

示例7: attemptDamageItem

import net.minecraft.enchantment.EnchantmentDurability; //导入方法依赖的package包/类
public boolean attemptDamageItem(int p_96631_1_, Random p_96631_2_)
{
    if (!this.isItemStackDamageable())
    {
        return false;
    }
    else
    {
        if (p_96631_1_ > 0)
        {
            int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.unbreaking.effectId, this);
            int k = 0;

            for (int l = 0; j > 0 && l < p_96631_1_; ++l)
            {
                if (EnchantmentDurability.negateDamage(this, j, p_96631_2_))
                {
                    ++k;
                }
            }

            p_96631_1_ -= k;

            if (p_96631_1_ <= 0)
            {
                return false;
            }
        }

        setItemDamage(getItemDamage() + p_96631_1_); //Redirect through Item's callback if applicable.
        return getItemDamage() > getMaxDamage();
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:34,代码来源:ItemStack.java

示例8: attemptNBTDamage

import net.minecraft.enchantment.EnchantmentDurability; //导入方法依赖的package包/类
private boolean attemptNBTDamage(ItemStack stack, int damage, Random rand) {
	if (!this.isItemStackNBTDamageable(stack))
       {
           return false;
       }
       else
       {
           if (damage > 0)
           {
               int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.unbreaking.effectId, stack);
               int k = 0;

               for (int l = 0; j > 0 && l < damage; ++l)
               {
                   if (EnchantmentDurability.negateDamage(stack, j, rand))
                   {
                       ++k;
                   }
               }

               damage -= k;

               if (damage <= 0)
               {
                   return false;
               }
           }

           setNBTDamage(stack, getNBTDamage(stack) + damage);

           return getNBTDamage(stack) > getNBTMaxDamage(stack);
       }
}
 
开发者ID:TTFTCUTS,项目名称:ShadowsOfPhysis,代码行数:34,代码来源:ItemPhysisNBTDamage.java

示例9: attemptDamageItem

import net.minecraft.enchantment.EnchantmentDurability; //导入方法依赖的package包/类
/**
 * Attempts to damage the ItemStack with par1 amount of damage, If the ItemStack has the Unbreaking enchantment
 * there is a chance for each point of damage to be negated. Returns true if it takes more damage than
 * getMaxDamage(). Returns false otherwise or if the ItemStack can't be damaged or if all points of damage are
 * negated.
 */
public boolean attemptDamageItem(int par1, Random par2Random)
{
    if (!this.isItemStackDamageable())
    {
        return false;
    }
    else
    {
        if (par1 > 0)
        {
            int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.unbreaking.effectId, this);
            int k = 0;

            for (int l = 0; j > 0 && l < par1; ++l)
            {
                if (EnchantmentDurability.negateDamage(this, j, par2Random))
                {
                    ++k;
                }
            }

            par1 -= k;

            if (par1 <= 0)
            {
                return false;
            }
        }

        setItemDamage(getItemDamage() + par1); //Redirect through Item's callback if applicable.
        return getItemDamage() > getMaxDamage();
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:40,代码来源:ItemStack.java

示例10: isDamaged

import net.minecraft.enchantment.EnchantmentDurability; //导入方法依赖的package包/类
public boolean isDamaged(int p_96631_1_, Random p_96631_2_, EntityLivingBase entitylivingbase)
{
    // Spigot end
    if (!this.isItemStackDamageable())
    {
        return false;
    }
    else
    {
        if (p_96631_1_ > 0)
        {
            int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.unbreaking.effectId, this);
            int k = 0;

            for (int l = 0; j > 0 && l < p_96631_1_; ++l)
            {
                if (EnchantmentDurability.negateDamage(this, j, p_96631_2_))
                {
                    ++k;
                }
            }

            p_96631_1_ -= k;

            // Spigot start
            if (entitylivingbase instanceof EntityPlayerMP)
            {
                org.bukkit.craftbukkit.inventory.CraftItemStack item = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this);
                org.bukkit.event.player.PlayerItemDamageEvent event = new org.bukkit.event.player.PlayerItemDamageEvent((org.bukkit.entity.Player) entitylivingbase.getBukkitEntity(), item, p_96631_1_);
                org.bukkit.Bukkit.getServer().getPluginManager().callEvent(event);

                if (event.isCancelled())
                {
                    return false;
                }

                p_96631_1_ = event.getDamage();
            }

            // Spigot end

            if (p_96631_1_ <= 0)
            {
                return false;
            }
        }

        setItemDamage(getItemDamage() + p_96631_1_); //Redirect through Item's callback if applicable.
        return getItemDamage() > getMaxDamage();
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:52,代码来源:ItemStack.java


注:本文中的net.minecraft.enchantment.EnchantmentDurability.negateDamage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。