本文整理汇总了Java中cn.nukkit.nbt.NBTIO.putItemHelper方法的典型用法代码示例。如果您正苦于以下问题:Java NBTIO.putItemHelper方法的具体用法?Java NBTIO.putItemHelper怎么用?Java NBTIO.putItemHelper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.nbt.NBTIO
的用法示例。
在下文中一共展示了NBTIO.putItemHelper方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setItem
import cn.nukkit.nbt.NBTIO; //导入方法依赖的package包/类
@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);
}
}
示例2: setItem
import cn.nukkit.nbt.NBTIO; //导入方法依赖的package包/类
@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 inventorySlot, so we are going to overwrite the item in the list
(this.namedTag.getList("Items", CompoundTag.class)).add(i, d);
}
}
示例3: setItem
import cn.nukkit.nbt.NBTIO; //导入方法依赖的package包/类
@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);
}
}
示例4: setItem
import cn.nukkit.nbt.NBTIO; //导入方法依赖的package包/类
@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);
}
}
示例5: dropItem
import cn.nukkit.nbt.NBTIO; //导入方法依赖的package包/类
public void dropItem(Vector3 source, Item item, Vector3 motion, boolean dropAround, int delay) {
if (motion == null) {
if (dropAround) {
float f = this.rand.nextFloat() * 0.5f;
float f1 = this.rand.nextFloat() * ((float) Math.PI * 2);
motion = new Vector3(-MathHelper.sin(f1) * f, 0.20000000298023224, MathHelper.cos(f1) * f);
} else {
motion = new Vector3(new java.util.Random().nextDouble() * 0.2 - 0.1, 0.2,
new java.util.Random().nextDouble() * 0.2 - 0.1);
}
}
CompoundTag itemTag = NBTIO.putItemHelper(item);
itemTag.setName("Item");
if (item.getId() > 0 && item.getCount() > 0) {
EntityItem itemEntity = new EntityItem(
this.getChunk((int) source.getX() >> 4, (int) source.getZ() >> 4, true),
new CompoundTag().putList(new ListTag<DoubleTag>("Pos").add(new DoubleTag("", source.getX()))
.add(new DoubleTag("", source.getY())).add(new DoubleTag("", source.getZ())))
.putList(new ListTag<DoubleTag>("Motion").add(new DoubleTag("", motion.x))
.add(new DoubleTag("", motion.y)).add(new DoubleTag("", motion.z)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", new java.util.Random().nextFloat() * 360))
.add(new FloatTag("", 0)))
.putShort("Health", 5).putCompound("Item", itemTag).putShort("PickupDelay", delay));
itemEntity.spawnToAll();
}
}
示例6: dropItem
import cn.nukkit.nbt.NBTIO; //导入方法依赖的package包/类
public void dropItem(Vector3 source, Item item, Vector3 motion, boolean dropAround, int delay) {
if (motion == null) {
if (dropAround) {
float f = this.rand.nextFloat() * 0.5f;
float f1 = this.rand.nextFloat() * ((float) Math.PI * 2);
motion = new Vector3(-MathHelper.sin(f1) * f, 0.20000000298023224, MathHelper.cos(f1) * f);
} else {
motion = new Vector3(new java.util.Random().nextDouble() * 0.2 - 0.1, 0.2,
new java.util.Random().nextDouble() * 0.2 - 0.1);
}
}
CompoundTag itemTag = NBTIO.putItemHelper(item);
itemTag.setName("Item");
if (item.getId() > 0 && item.getCount() > 0) {
EntityItem itemEntity = new EntityItem(
this.getChunk((int) source.getX() >> 4, (int) source.getZ() >> 4, true),
new CompoundTag().putList(new ListTag<DoubleTag>("Pos").add(new DoubleTag("", source.getX()))
.add(new DoubleTag("", source.getY())).add(new DoubleTag("", source.getZ())))
.putList(new ListTag<DoubleTag>("Motion").add(new DoubleTag("", motion.x))
.add(new DoubleTag("", motion.y)).add(new DoubleTag("", motion.z)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", new java.util.Random().nextFloat() * 360))
.add(new FloatTag("", 0)))
.putShort("Health", 5).putCompound("Item", itemTag).putShort("PickupDelay", delay));
itemEntity.setPickupDelay(delay); //TODO: fix this
itemEntity.spawnToAll();
}
}