當前位置: 首頁>>代碼示例>>Java>>正文


Java Enchantment.getId方法代碼示例

本文整理匯總了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;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:45,代碼來源:CraftItemStack.java

示例2: Enchants

import org.bukkit.enchantments.Enchantment; //導入方法依賴的package包/類
public Enchants(Enchantment ench,int lv){
    if(ench != null)
        id = ench.getId();
    level = lv;
}
 
開發者ID:DevCrafters,項目名稱:SaveableSerializing,代碼行數:6,代碼來源:Enchants.java

示例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();
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:5,代碼來源:Lang.java


注:本文中的org.bukkit.enchantments.Enchantment.getId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。