本文整理汇总了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);
}
示例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));
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}