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


Java ItemStack.getTypeId方法代碼示例

本文整理匯總了Java中org.bukkit.inventory.ItemStack.getTypeId方法的典型用法代碼示例。如果您正苦於以下問題:Java ItemStack.getTypeId方法的具體用法?Java ItemStack.getTypeId怎麽用?Java ItemStack.getTypeId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.inventory.ItemStack的用法示例。


在下文中一共展示了ItemStack.getTypeId方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addToCraftingManager

import org.bukkit.inventory.ItemStack; //導入方法依賴的package包/類
public void addToCraftingManager() {
    Object[] data;
    String[] shape = this.getShape();
    Map<Character, ItemStack> ingred = this.getIngredientMap();
    int datalen = shape.length;
    datalen += ingred.size() * 2;
    int i = 0;
    data = new Object[datalen];
    for (; i < shape.length; i++) {
        data[i] = shape[i];
    }
    for (char c : ingred.keySet()) {
        ItemStack mdata = ingred.get(c);
        if (mdata == null) continue;
        data[i] = c;
        i++;
        int id = mdata.getTypeId();
        short dmg = mdata.getDurability();
        data[i] = new net.minecraft.item.ItemStack(CraftMagicNumbers.getItem(id), 1, dmg);
        i++;
    }
    net.minecraft.item.crafting.CraftingManager.getInstance().addRecipe(CraftItemStack.asNMSCopy(this.getResult()), data);
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:24,代碼來源:CraftShapedRecipe.java

示例2: giveItem

import org.bukkit.inventory.ItemStack; //導入方法依賴的package包/類
public void giveItem(ItemStack i, boolean addToArmor) {
	int id = i.getTypeId();
	Player p = getPlayer();
	if (!addToArmor) {
		p.getInventory().addItem(i);
		return;
	}
	
	if ((id < 298) || (317 < id))
		p.getInventory().addItem(i);
	else if ((id == 298) || (id == 302) || (id == 306) || (id == 310) || (id == 314))
		p.getInventory().setHelmet(new ItemStack(id, 1));
	else if ((id == 299) || (id == 303) || (id == 307) || (id == 311) || (id == 315))
		p.getInventory().setChestplate(new ItemStack(id, 1));
	else if ((id == 300) || (id == 304) || (id == 308) || (id == 312) || (id == 316))
		p.getInventory().setLeggings(new ItemStack(id, 1));
	else if ((id == 301) || (id == 305) || (id == 309) || (id == 313) || (id == 317))
		p.getInventory().setBoots(new ItemStack(id, 1));
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:20,代碼來源:Gamer.java

示例3: setResult

import org.bukkit.inventory.ItemStack; //導入方法依賴的package包/類
public void setResult(ItemStack item) {
    net.minecraft.item.ItemStack[] contents = getResultInventory().getContents();
    if (item == null || item.getTypeId() <= 0) {
        contents[0] = null;
    } else {
        contents[0] = CraftItemStack.asNMSCopy(item);
    }
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:9,代碼來源:CraftInventoryCrafting.java

示例4: setArmorContents

import org.bukkit.inventory.ItemStack; //導入方法依賴的package包/類
public void setArmorContents(ItemStack[] items) {
    int cnt = getSize();

    if (items == null) {
        items = new ItemStack[4];
    }
    for (ItemStack item : items) {
        if (item == null || item.getTypeId() == 0) {
            clear(cnt++);
        } else {
            setItem(cnt++, item);
        }
    }
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:15,代碼來源:CraftInventoryPlayer.java

示例5: contains

import org.bukkit.inventory.ItemStack; //導入方法依賴的package包/類
public boolean contains(int materialId) {
    for (ItemStack item : getContents()) {
        if (item != null && item.getTypeId() == materialId) {
            return true;
        }
    }
    return false;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:9,代碼來源:CraftInventory.java

示例6: all

import org.bukkit.inventory.ItemStack; //導入方法依賴的package包/類
public HashMap<Integer, ItemStack> all(int materialId) {
    HashMap<Integer, ItemStack> slots = new HashMap<Integer, ItemStack>();

    ItemStack[] inventory = getContents();
    for (int i = 0; i < inventory.length; i++) {
        ItemStack item = inventory[i];
        if (item != null && item.getTypeId() == materialId) {
            slots.put(i, item);
        }
    }
    return slots;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:13,代碼來源:CraftInventory.java

示例7: first

import org.bukkit.inventory.ItemStack; //導入方法依賴的package包/類
public int first(int materialId) {
    ItemStack[] inventory = getContents();
    for (int i = 0; i < inventory.length; i++) {
        ItemStack item = inventory[i];
        if (item != null && item.getTypeId() == materialId) {
            return i;
        }
    }
    return -1;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:11,代碼來源:CraftInventory.java

示例8: firstPartial

import org.bukkit.inventory.ItemStack; //導入方法依賴的package包/類
public int firstPartial(int materialId) {
    ItemStack[] inventory = getContents();
    for (int i = 0; i < inventory.length; i++) {
        ItemStack item = inventory[i];
        if (item != null && item.getTypeId() == materialId && item.getAmount() < item.getMaxStackSize()) {
            return i;
        }
    }
    return -1;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:11,代碼來源:CraftInventory.java

示例9: addToCraftingManager

import org.bukkit.inventory.ItemStack; //導入方法依賴的package包/類
public void addToCraftingManager() {
    List<ItemStack> ingred = this.getIngredientList();
    Object[] data = new Object[ingred.size()];
    int i = 0;
    for (ItemStack mdata : ingred) {
        int id = mdata.getTypeId();
        short dmg = mdata.getDurability();
        data[i] = new net.minecraft.item.ItemStack(CraftMagicNumbers.getItem(id), 1, dmg);
        i++;
    }
    net.minecraft.item.crafting.CraftingManager.getInstance().addShapelessRecipe(CraftItemStack.asNMSCopy(this.getResult()), data);
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:13,代碼來源:CraftShapelessRecipe.java

示例10: setItem

import org.bukkit.inventory.ItemStack; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public void setItem(int slot, ItemStack origItem){
	//items[slot] = new ItemStack(itemType);
	if( slot >= 27 )
		return;
	items[slot] = new ItemStack(origItem.getTypeId());
	items[slot].setAmount(origItem.getAmount());
	items[slot].setData(origItem.getData());
	items[slot].setDurability(origItem.getDurability());
}
 
開發者ID:Maximuspayne,項目名稱:NavyCraft2-Lite,代碼行數:11,代碼來源:DataBlock.java

示例11: ItemStacks

import org.bukkit.inventory.ItemStack; //導入方法依賴的package包/類
public ItemStacks(ItemStack sta){
    meta = new DefaultMeta(sta.getItemMeta());
    id = sta.getTypeId();
    durability = sta.getDurability();
    amount = sta.getAmount();
    array = new EnchantArray(sta);

}
 
開發者ID:DevCrafters,項目名稱:SaveableSerializing,代碼行數:9,代碼來源:ItemStacks.java

示例12: ItemStacks

import org.bukkit.inventory.ItemStack; //導入方法依賴的package包/類
public ItemStacks(ItemStack sta){
    meta = new DefaultMeta(sta.getItemMeta());
    id = sta.getTypeId();
    durability = sta.getDurability();
    amount = sta.getAmount();
    array = new EnchantArray(sta);
}
 
開發者ID:DevCrafters,項目名稱:SaveableSerializing,代碼行數:8,代碼來源:ItemStacks.java

示例13: contains

import org.bukkit.inventory.ItemStack; //導入方法依賴的package包/類
@Override
public boolean contains( int i ) {
    for ( ItemStack item : this.items ) {
        if( item != null && item.getTypeId() == i ) {
            return true;
        }
    }
    return false;
}
 
開發者ID:lukas81298,項目名稱:FlexMC,代碼行數:10,代碼來源:FlexInventory.java

示例14: all

import org.bukkit.inventory.ItemStack; //導入方法依賴的package包/類
@Override
public HashMap<Integer, ? extends ItemStack> all( int i ) {
    HashMap<Integer, ItemStack> results = new HashMap<>();
    for ( int index = 0; index < items.length; index++ ) {
        ItemStack itemStack = items[ index ];
        if( itemStack != null && itemStack.getTypeId() == i ) {
            results.put( index, itemStack );
        }
    }
    return results;
}
 
開發者ID:lukas81298,項目名稱:FlexMC,代碼行數:12,代碼來源:FlexInventory.java

示例15: first

import org.bukkit.inventory.ItemStack; //導入方法依賴的package包/類
@Override
public int first( int i ) {
    int j = 0;
    for ( ItemStack item : items ) {
        if( item != null && item.getTypeId() == i ) {
            return j;
        }
        j++;
    }
    return -1;
}
 
開發者ID:lukas81298,項目名稱:FlexMC,代碼行數:12,代碼來源:FlexInventory.java


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