当前位置: 首页>>代码示例>>Java>>正文


Java NBTIO.putItemHelper方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:17,代码来源:BlockEntityHopper.java

示例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);
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:20,代码来源:BlockEntityChest.java

示例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);
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:20,代码来源:BlockEntityShulkerBox.java

示例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);
    }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:20,代码来源:BlockEntityChest.java

示例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();
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:35,代码来源:Level.java

示例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();
    }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:36,代码来源:Level.java


注:本文中的cn.nukkit.nbt.NBTIO.putItemHelper方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。