本文整理汇总了Java中cn.nukkit.item.Item.getCompoundTag方法的典型用法代码示例。如果您正苦于以下问题:Java Item.getCompoundTag方法的具体用法?Java Item.getCompoundTag怎么用?Java Item.getCompoundTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.item.Item
的用法示例。
在下文中一共展示了Item.getCompoundTag方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: contains
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public boolean contains(Item item) {
int count = Math.max(1, item.getCount());
boolean checkDamage = item.hasMeta();
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;
}
示例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: 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;
}
示例6: 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());
}
}
}
示例7: first
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public int first(Item item, boolean exact) {
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 || (!exact && entry.getValue().getCount() > count))) {
return entry.getKey();
}
}
return -1;
}
示例8: 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) << 8) | item.getCount();
this.putVarInt(auxValue);
byte[] nbt = item.getCompoundTag();
this.putLShort(nbt.length);
this.put(nbt);
}
示例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: 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;
}