本文整理汇总了Java中cn.nukkit.item.ItemBookEnchanted类的典型用法代码示例。如果您正苦于以下问题:Java ItemBookEnchanted类的具体用法?Java ItemBookEnchanted怎么用?Java ItemBookEnchanted使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ItemBookEnchanted类属于cn.nukkit.item包,在下文中一共展示了ItemBookEnchanted类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onEnchant
import cn.nukkit.item.ItemBookEnchanted; //导入依赖的package包/类
public void onEnchant(Player who, Item before, Item after) {
Item result = (before.getId() == Item.BOOK) ? new ItemBookEnchanted() : before;
if (!before.hasEnchantments() && after.hasEnchantments() && after.getId() == result.getId() && this.levels != null && this.entries != null) {
Enchantment[] enchantments = after.getEnchantments();
for (int i = 0; i < 3; i++) {
if (Arrays.equals(enchantments, this.entries[i].getEnchantments())) {
Item lapis = this.getItem(1);
int level = who.getExperienceLevel();
int exp = who.getExperience();
int cost = this.entries[i].getCost();
if (lapis.getId() == Item.DYE && lapis.getDamage() == DyeColor.BLUE.getDyeData() && lapis.getCount() > i && level >= cost) {
result.addEnchantment(enchantments);
this.setItem(0, result);
lapis.setCount(lapis.getCount() - i - 1);
this.setItem(1, lapis);
who.setExperience(exp, level - cost);
break;
}
}
}
}
}
开发者ID:Nukkit,项目名称:Nukkit,代码行数:23,代码来源:EnchantInventory.java
示例2: onEnchant
import cn.nukkit.item.ItemBookEnchanted; //导入依赖的package包/类
public void onEnchant(Player who, Item before, Item after) {
Item result = (before.getId() == Item.BOOK) ? new ItemBookEnchanted() : before;
if (!before.hasEnchantments() && after.hasEnchantments() && after.getId() == result.getId() && this.levels != null && this.entries != null) {
Enchantment[] enchantments = after.getEnchantments();
for (int i = 0; i < 3; i++) {
if (enchantsCheck(enchantments, this.entries[i].getEnchantments())) {
Item lapis = this.getItem(1);
int level = who.getExperienceLevel();
int exp = who.getExperience();
int cost = this.entries[i].getCost();
if (lapis.getId() == Item.DYE && lapis.getDamage() == DyeColor.BLUE.getDyeData() && lapis.getCount() > i && level >= cost) {
result.addEnchantment(enchantments);
this.setItem(0, result);
lapis.setCount(lapis.getCount() - i - 1);
this.setItem(1, lapis);
who.setExperience(exp, level - cost);
break;
}
}
}
}
}
开发者ID:NycuRO,项目名称:Apollo-OLD,代码行数:23,代码来源:EnchantInventory.java
注:本文中的cn.nukkit.item.ItemBookEnchanted类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论