本文整理汇总了Java中cn.nukkit.item.Item.hasMeta方法的典型用法代码示例。如果您正苦于以下问题:Java Item.hasMeta方法的具体用法?Java Item.hasMeta怎么用?Java Item.hasMeta使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.item.Item
的用法示例。
在下文中一共展示了Item.hasMeta方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: contains
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public boolean contains(Item item) {
int count = Math.max(1, item.getCount());
boolean checkDamage = item.hasMeta() && item.getDamage() >= 0;
boolean checkTag = item.getCompoundTag() != null;
for (Item i : this.getContents().values()) {
if (item.equals(i, checkDamage, checkTag)) {
count -= i.getCount();
if (count <= 0) {
return true;
}
}
}
return false;
}
示例2: canAddItem
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public boolean canAddItem(Item item) {
item = item.clone();
boolean checkDamage = item.hasMeta();
boolean checkTag = item.getCompoundTag() != null;
for (int i = 0; i < this.getSize(); ++i) {
Item slot = this.getItem(i);
if (item.equals(slot, checkDamage, checkTag)) {
int diff;
if ((diff = slot.getMaxStackSize() - slot.getCount()) > 0) {
item.setCount(item.getCount() - diff);
}
} else if (slot.getId() == Item.AIR) {
item.setCount(item.getCount() - this.getMaxStackSize());
}
if (item.getCount() <= 0) {
return true;
}
}
return false;
}
示例3: registerShapedRecipe
import cn.nukkit.item.Item; //导入方法依赖的package包/类
public void registerShapedRecipe(ShapedRecipe recipe) {
Item result = recipe.getResult();
this.recipes.put(recipe.getId(), recipe);
Map<Integer, Map<Integer, Item>> ingredients = recipe.getIngredientMap();
String hash = "";
for (Map<Integer, Item> v : ingredients.values()) {
for (Item item : v.values()) {
if (item != null && item.getId() != Item.AIR) {
hash += item.getId() + ":" + (!item.hasMeta() ? "?" : item.getDamage()) + "x" + item.getCount() + ",";
}
}
hash += ";";
}
String index = result.getId() + ":" + (result.hasMeta() ? result.getDamage() : "");
if (!this.recipeLookup.containsKey(index)) {
this.recipeLookup.put(index, new HashMap<>());
}
this.recipeLookup.get(index).put(hash, recipe);
}
示例4: putSlot
import cn.nukkit.item.Item; //导入方法依赖的package包/类
public void putSlot(Item item) {
if (item == null || item.getId() == 0) {
this.putVarInt(0);
return;
}
this.putVarInt(item.getId());
int auxValue = (((item.hasMeta() ? item.getDamage() : -1) & 0x7fff) << 8) | item.getCount();
this.putVarInt(auxValue);
byte[] nbt = item.getCompoundTag();
this.putLShort(nbt.length);
this.put(nbt);
this.putVarInt(0); //TODO CanPlaceOn entry count
this.putVarInt(0); //TODO CanDestroy entry count
}
示例5: first
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public int first(Item item) {
int count = Math.max(1, item.getCount());
boolean checkDamage = item.hasMeta();
boolean checkTag = item.getCompoundTag() != null;
for (Map.Entry<Integer, Item> entry : this.getContents().entrySet()) {
if (item.equals(entry.getValue(), checkDamage, checkTag) && entry.getValue().getCount() >= count) {
return entry.getKey();
}
}
return -1;
}
示例6: registerShapelessRecipe
import cn.nukkit.item.Item; //导入方法依赖的package包/类
public void registerShapelessRecipe(ShapelessRecipe recipe) {
Item result = recipe.getResult();
this.recipes.put(recipe.getId(), recipe);
String hash = "";
List<Item> ingredients = recipe.getIngredientList();
ingredients.sort(this.comparator);
for (Item item : ingredients) {
hash += item.getId() + ":" + (!item.hasMeta() ? "?" : item.getDamage()) + "x" + item.getCount() + ",";
}
if (!this.recipeLookup.containsKey(result.getId() + ":" + result.getDamage())) {
this.recipeLookup.put(result.getId() + ":" + result.getDamage(), new HashMap<>());
}
this.recipeLookup.get(result.getId() + ":" + result.getDamage()).put(hash, recipe);
}
示例7: all
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public Map<Integer, Item> all(Item item) {
Map<Integer, Item> slots = new HashMap<>();
boolean checkDamage = item.hasMeta() && item.getDamage() >= 0;
boolean checkTag = item.getCompoundTag() != null;
for (Map.Entry<Integer, Item> entry : this.getContents().entrySet()) {
if (item.equals(entry.getValue(), checkDamage, checkTag)) {
slots.put(entry.getKey(), entry.getValue());
}
}
return slots;
}
示例8: remove
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public void remove(Item item) {
boolean checkDamage = item.hasMeta();
boolean checkTag = item.getCompoundTag() != null;
for (Map.Entry<Integer, Item> entry : this.getContents().entrySet()) {
if (item.equals(entry.getValue(), checkDamage, checkTag)) {
this.clear(entry.getKey());
}
}
}
示例9: all
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public Map<Integer, Item> all(Item item) {
Map<Integer, Item> slots = new HashMap<>();
boolean checkDamage = item.hasMeta();
boolean checkTag = item.getCompoundTag() != null;
for (Map.Entry<Integer, Item> entry : this.getContents().entrySet()) {
if (item.equals(entry.getValue(), checkDamage, checkTag)) {
slots.put(entry.getKey(), entry.getValue());
}
}
return slots;
}
示例10: SlotEntityData
import cn.nukkit.item.Item; //导入方法依赖的package包/类
public SlotEntityData(int id, Item item) {
this(id, item.getId(), (byte) (item.hasMeta() ? item.getDamage() : 0), item.getCount());
}
示例11: setData
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public void setData(Item data) {
this.blockId = data.getId();
this.meta = (data.hasMeta() ? data.getDamage() : 0);
this.count = data.getCount();
}