本文整理汇总了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);
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
}
示例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();
}
}
示例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();
}
}