本文整理匯總了Java中org.bukkit.enchantments.Enchantment.getId方法的典型用法代碼示例。如果您正苦於以下問題:Java Enchantment.getId方法的具體用法?Java Enchantment.getId怎麽用?Java Enchantment.getId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.enchantments.Enchantment
的用法示例。
在下文中一共展示了Enchantment.getId方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: removeEnchantment
import org.bukkit.enchantments.Enchantment; //導入方法依賴的package包/類
@Override
public int removeEnchantment(Enchantment ench) {
Validate.notNull(ench, "Cannot remove null enchantment");
net.minecraft.nbt.NBTTagList list = getEnchantmentList(handle), listCopy;
if (list == null) {
return 0;
}
int index = Integer.MIN_VALUE;
int level = Integer.MIN_VALUE;
int size = list.tagCount();
for (int i = 0; i < size; i++) {
net.minecraft.nbt.NBTTagCompound enchantment = (net.minecraft.nbt.NBTTagCompound) list.getCompoundTagAt(i);
int id = 0xffff & enchantment.getShort(ENCHANTMENTS_ID.NBT);
if (id == ench.getId()) {
index = i;
level = 0xffff & enchantment.getShort(ENCHANTMENTS_LVL.NBT);
break;
}
}
if (index == Integer.MIN_VALUE) {
return 0;
}
if (size == 1) {
handle.stackTagCompound.removeTag(ENCHANTMENTS.NBT);
if (handle.stackTagCompound.hasNoTags()) {
handle.stackTagCompound = null;
}
return level;
}
// This is workaround for not having an index removal
listCopy = new net.minecraft.nbt.NBTTagList();
for (int i = 0; i < size; i++) {
if (i != index) {
listCopy.appendTag(list.getCompoundTagAt(i));
}
}
handle.stackTagCompound.setTag(ENCHANTMENTS.NBT, listCopy);
return level;
}
示例2: Enchants
import org.bukkit.enchantments.Enchantment; //導入方法依賴的package包/類
public Enchants(Enchantment ench,int lv){
if(ench != null)
id = ench.getId();
level = lv;
}
示例3: translatableFromEnchantment
import org.bukkit.enchantments.Enchantment; //導入方法依賴的package包/類
public static String translatableFromEnchantment(final Enchantment ench) {
final net.minecraft.server.v1_7_R4.Enchantment nms = net.minecraft.server.v1_7_R4.Enchantment.byId[ench.getId()];
return (nms == null) ? ench.getName() : nms.a();
}