本文整理汇总了Java中cn.nukkit.item.Item.AIR属性的典型用法代码示例。如果您正苦于以下问题:Java Item.AIR属性的具体用法?Java Item.AIR怎么用?Java Item.AIR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类cn.nukkit.item.Item
的用法示例。
在下文中一共展示了Item.AIR属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerShapedRecipe
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);
}
示例2: getSpawnCompound
@Override
public CompoundTag getSpawnCompound() {
if (!this.namedTag.contains("Item")) {
this.setItem(new ItemBlock(new BlockAir()), false);
}
CompoundTag NBTItem = namedTag.getCompound("Item").copy();
NBTItem.setName("Item");
boolean item = NBTItem.getShort("id") == Item.AIR;
return new CompoundTag()
.putString("id", BlockEntity.ITEM_FRAME)
.putInt("x", (int) this.x)
.putInt("y", (int) this.y)
.putInt("z", (int) this.z)
.putCompound("Item", item ? NBTIO.putItemHelper(new ItemBlock(new BlockAir())) : NBTItem)
.putByte("ItemRotation", item ? 0 : this.getItemRotation());
// TODO: This crashes the client, why?
// .putFloat("ItemDropChance", this.getItemDropChance());
}
示例3: onUpdate
@Override
public int onUpdate(int type) {
int[] faces = {
3,
2,
5,
4,
};
if (type == Level.BLOCK_UPDATE_NORMAL) {
if (this.meta >= 2 && this.meta <= 5) {
if (this.getSide(BlockFace.fromIndex(faces[this.meta - 2])).getId() == Item.AIR) {
this.getLevel().useBreakOn(this);
}
return Level.BLOCK_UPDATE_NORMAL;
}
}
return 0;
}
示例4: setItem
@Override
public void setItem(int index, Item item) {
int i = this.getSlotIndex(index);
CompoundTag d = NBTIO.putItemHelper(item, index);
if (item.getId() == Item.AIR || item.getCount() <= 0) {
if (i >= 0) {
this.namedTag.getList("Items").getAll().remove(i);
}
} else if (i < 0) {
(this.namedTag.getList("Items", CompoundTag.class)).add(d);
} else {
(this.namedTag.getList("Items", CompoundTag.class)).add(i, d);
}
}
示例5: canAddItem
@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;
}
示例6: setItem
@Override
public void setItem(int index, Item item) {
int i = this.getSlotIndex(index);
CompoundTag d = NBTIO.putItemHelper(item, index);
// If item is air or count less than 0, remove the item from the "Items" list
if (item.getId() == Item.AIR || item.getCount() <= 0) {
if (i >= 0) {
this.namedTag.getList("Items").remove(i);
}
} else if (i < 0) {
// If it is less than i, then it is a new item, so we are going to add it at the end of the list
(this.namedTag.getList("Items", CompoundTag.class)).add(d);
} else {
// If it is more than i, then it is an update on a slot, so we are going to overwrite the item in the list
(this.namedTag.getList("Items", CompoundTag.class)).add(i, d);
}
}
示例7: onUpdate
@Override
public int onUpdate(int type) {
if (type == Level.BLOCK_UPDATE_NORMAL) {
if (this.down().getId() == Item.AIR) {
this.getLevel().useBreakOn(this);
return Level.BLOCK_UPDATE_NORMAL;
}
}
return 0;
}
示例8: clear
@Override
public boolean clear(int index, boolean send) {
if (this.slots.containsKey(index)) {
Item item = new ItemBlock(new BlockAir(), null, 0);
Item old = this.slots.get(index);
InventoryHolder holder = this.getHolder();
if (holder instanceof Entity) {
EntityInventoryChangeEvent ev = new EntityInventoryChangeEvent((Entity) holder, this, old, item, index);
Server.getInstance().getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
this.sendSlot(index, this.getViewers());
return false;
}
item = ev.getNewItem();
}
if (item.getId() != Item.AIR) {
this.slots.put(index, item.clone());
} else {
this.slots.remove(index);
}
this.onSlotChange(index, old, send);
}
return true;
}
示例9: clear
@Override
public boolean clear(int index) {
if (this.slots.containsKey(index)) {
Item item = new ItemBlock(new BlockAir(), null, 0);
Item old = this.slots.get(index);
InventoryHolder holder = this.getHolder();
if (holder instanceof Entity) {
EntityInventoryChangeEvent ev = new EntityInventoryChangeEvent((Entity) holder, old, item, index);
Server.getInstance().getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
this.sendSlot(index, this.getViewers());
return false;
}
item = ev.getNewItem();
}
if (item.getId() != Item.AIR) {
this.slots.put(index, item.clone());
} else {
this.slots.remove(index);
}
this.onSlotChange(index, old);
}
return true;
}
示例10: firstEmpty
@Override
public int firstEmpty(Item item) {
for (int i = 0; i < this.size; ++i) {
if (this.getItem(i).getId() == Item.AIR) {
return i;
}
}
return -1;
}
示例11: place
@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
Block down = this.down();
if (down.getId() != Item.AIR) {
this.getLevel().setBlock(block, this, true, true);
return true;
}
return false;
}
示例12: onActivate
@Override
public boolean onActivate(Item item, Player player) {
BlockEntity blockEntity = this.getLevel().getBlockEntity(this);
BlockEntityItemFrame itemFrame = (BlockEntityItemFrame) blockEntity;
if (itemFrame.getItem().getId() == Item.AIR) {
// We can't use Item.get(item.getId(), item.getDamage(), 1) because
// we need to keep the item's NBT tags
Item itemOnFrame = item.clone(); // So we clone the item
itemOnFrame.setCount(1); // Change it to only one item (if we keep +1, visual glitches will happen)
itemFrame.setItem(itemOnFrame); // And then we set it on the item frame
// The item will be removed from the player's hand a few lines ahead
this.getLevel().addSound(new ItemFrameItemAddedSound(this));
if (player != null && player.isSurvival()) {
int count = item.getCount();
if (count-- <= 0) {
player.getInventory().setItemInHand(new ItemBlock(new BlockAir(), 0, 0));
return true;
}
item.setCount(count);
player.getInventory().setItemInHand(item);
}
} else {
int itemRot = itemFrame.getItemRotation();
if (itemRot >= 7) {
itemRot = 0;
} else {
itemRot++;
}
itemFrame.setItemRotation(itemRot);
this.getLevel().addSound(new ItemFrameItemRotated(this));
}
return true;
}