本文整理汇总了Java中org.spongepowered.api.data.manipulator.mutable.item.EnchantmentData类的典型用法代码示例。如果您正苦于以下问题:Java EnchantmentData类的具体用法?Java EnchantmentData怎么用?Java EnchantmentData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EnchantmentData类属于org.spongepowered.api.data.manipulator.mutable.item包,在下文中一共展示了EnchantmentData类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: canBeAppliedToItemStack
import org.spongepowered.api.data.manipulator.mutable.item.EnchantmentData; //导入依赖的package包/类
public static boolean canBeAppliedToItemStack(ItemStack item, Enchantment enchantment) {
if (enchantment.canBeAppliedToStack(item)) {
EnchantmentData enchantment_data = item.getOrCreate(EnchantmentData.class).get();
for (ItemEnchantment enchantment_item : enchantment_data.enchantments()) {
if (!enchantment.isCompatibleWith(enchantment_item.getEnchantment())) {
return false;
}
}
} else {
return false;
}
return true;
}
开发者ID:EverCraft,项目名称:EverAPI,代码行数:15,代码来源:UtilsEnchantment.java
示例2: commandEnchant
import org.spongepowered.api.data.manipulator.mutable.item.EnchantmentData; //导入依赖的package包/类
private CompletableFuture<Boolean> commandEnchant(final EPlayer player, Enchantment enchantment, int level) {
// Le joueur n'a pas d'item dans la main
if (!player.getItemInMainHand().isPresent()) {
EAMessages.EMPTY_ITEM_IN_HAND.sender()
.prefix(EEMessages.PREFIX)
.sendTo(player);
return CompletableFuture.completedFuture(false);
}
ItemStack item = player.getItemInMainHand().get();
// Le level est trop faible
if (level < enchantment.getMinimumLevel()) {
EEMessages.ENCHANT_LEVEL_TOO_LOW.sender()
.replace("{number}", String.valueOf(level))
.sendTo(player);
return CompletableFuture.completedFuture(false);
}
if (level > enchantment.getMaximumLevel()) {
EEMessages.ENCHANT_LEVEL_TOO_HIGHT.sender()
.replace("{number}", String.valueOf(level))
.sendTo(player);
return CompletableFuture.completedFuture(false);
}
EnchantmentData enchantment_data = item.getOrCreate(EnchantmentData.class).get();
// L'enchantement n'est pas applicable sur cet item
if (!UtilsEnchantment.canBeAppliedToItemStack(item, enchantment)) {
EEMessages.ENCHANT_INCOMPATIBLE.sender()
.replace("{enchantment}", () -> enchantment.getId().toLowerCase().replace("minecraft:", "").replaceAll(" ", ""))
.replace("{level}", String.valueOf(level))
.replace("{item}", () -> EChat.getButtomItem(item, EEMessages.ENCHANT_ITEM_COLOR.getColor()))
.sendTo(player);
return CompletableFuture.completedFuture(false);
}
enchantment_data.set(enchantment_data.enchantments().add(new ItemEnchantment(enchantment, level)));
item.offer(enchantment_data);
player.setItemInMainHand(item);
EEMessages.ENCHANT_SUCCESSFULL.sender()
.replace("{enchantment}", enchantment.getTranslation().get())
.replace("{level}", String.valueOf(level))
.replace("{item}", () -> EChat.getButtomItem(item, EEMessages.ENCHANT_ITEM_COLOR.getColor()))
.sendTo(player);
return CompletableFuture.completedFuture(true);
}
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:50,代码来源:EEEnchant.java
示例3: createEnchantmentGlow
import org.spongepowered.api.data.manipulator.mutable.item.EnchantmentData; //导入依赖的package包/类
/**
* https://github.com/SpongePowered/SpongeForge/issues/470
*
* @param itemStack
*/
public static void createEnchantmentGlow(ItemStack itemStack) {
itemStack.offer(Sponge.getDataManager().getManipulatorBuilder(EnchantmentData.class).get().create());
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:9,代码来源:ItemStackUtils.java
注:本文中的org.spongepowered.api.data.manipulator.mutable.item.EnchantmentData类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论