本文整理汇总了Java中cn.nukkit.item.Item.getEnchantment方法的典型用法代码示例。如果您正苦于以下问题:Java Item.getEnchantment方法的具体用法?Java Item.getEnchantment怎么用?Java Item.getEnchantment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.item.Item
的用法示例。
在下文中一共展示了Item.getEnchantment方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setOnFire
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public void setOnFire(int seconds) {
int level = 0;
for (Item armor : this.inventory.getArmorContents()) {
Enchantment fireProtection = armor.getEnchantment(Enchantment.ID_PROTECTION_FIRE);
if (fireProtection != null && fireProtection.getLevel() > 0) {
level = Math.max(level, fireProtection.getLevel());
}
}
seconds = (int) (seconds * (1 - level * 0.15));
super.setOnFire(seconds);
}
示例2: getDrops
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public Item[] getDrops(Item item) {
if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) {
int count = 1;
Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
if (fortune != null && fortune.getLevel() >= 1) {
int i = ThreadLocalRandom.current().nextInt(fortune.getLevel() + 2) - 1;
if (i < 0) {
i = 0;
}
count = i + 1;
}
return new Item[]{
new ItemCoal(0, count)
};
} else {
return new Item[0];
}
}
示例3: getDrops
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public Item[] getDrops(Item item) {
if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_IRON) {
int count = new Random().nextInt(2) + 4;
Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
if (fortune != null && fortune.getLevel() >= 1) {
count += new Random().nextInt(fortune.getLevel() + 1);
}
return new Item[]{
new ItemRedstone(0, count)
};
} else {
return new Item[0];
}
}
示例4: getDrops
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public Item[] getDrops(Item item) {
if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_IRON) {
int count = 1;
Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
if (fortune != null && fortune.getLevel() >= 1) {
int i = ThreadLocalRandom.current().nextInt(fortune.getLevel() + 2) - 1;
if (i < 0) {
i = 0;
}
count = i + 1;
}
return new Item[]{
new ItemEmerald(0, count)
};
} else {
return new Item[0];
}
}
示例5: getDrops
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public Item[] getDrops(Item item) {
if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_IRON) {
int count = 1;
Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
if (fortune != null && fortune.getLevel() >= 1) {
int i = ThreadLocalRandom.current().nextInt(fortune.getLevel() + 2) - 1;
if (i < 0) {
i = 0;
}
count = i + 1;
}
return new Item[]{
new ItemDiamond(0, count)
};
} else {
return new Item[0];
}
}
示例6: getDrops
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public Item[] getDrops(Item item) {
if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_STONE) {
int count = 4 + ThreadLocalRandom.current().nextInt(5);
Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
if (fortune != null && fortune.getLevel() >= 1) {
int i = ThreadLocalRandom.current().nextInt(fortune.getLevel() + 2) - 1;
if (i < 0) {
i = 0;
}
count *= (i + 1);
}
return new Item[]{
new ItemDye(4, new Random().nextInt(4) + 4)
};
} else {
return new Item[0];
}
}
示例7: getDrops
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public Item[] getDrops(Item item) {
if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) {
int count = 1;
Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
if (fortune != null && fortune.getLevel() >= 1) {
int i = ThreadLocalRandom.current().nextInt(fortune.getLevel() + 2) - 1;
if (i < 0) {
i = 0;
}
count = i + 1;
}
return new Item[]{
new ItemQuartz(0, count)
};
} else {
return new Item[0];
}
}
示例8: doPostAttack
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public void doPostAttack(Entity attacker, Entity entity) {
if (!(entity instanceof EntityHumanType)) {
return;
}
EntityHumanType human = (EntityHumanType) entity;
int thornsDamage = 0;
Random rnd = new Random();
for (Item armor : human.getInventory().getArmorContents()) {
Enchantment thorns = armor.getEnchantment(Enchantment.ID_THORNS);
if (thorns != null && thorns.getLevel() > 0) {
int chance = thorns.getLevel() * 15;
if (chance > 90) {
chance = 90;
}
if (rnd.nextInt(100) + 1 <= chance) {
thornsDamage += rnd.nextInt(4) + 1;
}
}
}
if (thornsDamage > 0) {
attacker.attack(new EntityDamageEvent(attacker, DamageCause.MAGIC, rnd.nextInt(4) + 1));
}
}
示例9: getDrops
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public Item[] getDrops(Item item) {
Random random = new Random();
int count = 2 + random.nextInt(3);
Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
if (fortune != null && fortune.getLevel() >= 1) {
count += random.nextInt(fortune.getLevel() + 1);
}
return new Item[]{
new ItemGlowstoneDust(0, MathHelper.clamp(count, 1, 4))
};
}
示例10: getDrops
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public Item[] getDrops(Item item) {
Random random = new Random();
int count = 3 + random.nextInt(5);
Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
if (fortune != null && fortune.getLevel() >= 1) {
count += random.nextInt(fortune.getLevel() + 1);
}
return new Item[]{
new ItemMelon(0, Math.min(9, count))
};
}