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


Java BaseBlock.getNbtData方法代码示例

本文整理汇总了Java中com.sk89q.worldedit.blocks.BaseBlock.getNbtData方法的典型用法代码示例。如果您正苦于以下问题:Java BaseBlock.getNbtData方法的具体用法?Java BaseBlock.getNbtData怎么用?Java BaseBlock.getNbtData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sk89q.worldedit.blocks.BaseBlock的用法示例。


在下文中一共展示了BaseBlock.getNbtData方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setBlock

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException {
    CompoundTag nbt = block.getNbtData();
    if (nbt != null) {
        if (!limit.MAX_BLOCKSTATES()) {
            WEManager.IMP.cancelEdit(this, BBC.WORLDEDIT_CANCEL_REASON_MAX_TILES);
            return false;
        } else {
            if (!limit.MAX_CHANGES()) {
                WEManager.IMP.cancelEdit(this, BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
                return false;
            }
            return extent.setBlock(x, y, z, block);
        }
    }
    if (!limit.MAX_CHANGES()) {
        WEManager.IMP.cancelEdit(this, BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
        return false;
    } else {
        return extent.setBlock(x, y, z, block);
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:23,代码来源:ProcessedWEExtent.java

示例2: setBlock

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public boolean setBlock(int x, int y, int z, BaseBlock block) {
    try {
        int index = (HEADER_SIZE) + (getIndex(x, y, z) << 1);
        final int id = block.getId();
        final int data = block.getData();
        int combined = (id << 4) + data;
        mbb.putChar(index, (char) combined);
        CompoundTag tile = block.getNbtData();
        if (tile != null) {
            setTile(x, y, z, tile);
        }
        return true;
    } catch (Exception e) {
        MainUtil.handleError(e);
    }
    return false;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:19,代码来源:DiskOptimizedClipboard.java

示例3: applyTileEntityData

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void applyTileEntityData(TileEntity tileEntity, BaseBlock baseBlock) {
    final ObjectStore store = ObjectStoreRegistry.get().get(tileEntity.getClass())
            .orElseThrow(() -> new IllegalStateException("Missing object store for tile " + tileEntity.getType()));
    final CompoundTag tag = baseBlock.getNbtData();
    final DataView dataView = tag == null ? DataContainer.createNew(DataView.SafetyMode.NO_DATA_CLONED) : DataViewNbt.from(tag);
    store.deserialize(tileEntity, dataView);
}
 
开发者ID:LanternPowered,项目名称:LanternWorldEdit,代码行数:10,代码来源:LanternWEWorld.java

示例4: setBlock

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
public boolean setBlock(Location location, BaseBlock block, boolean notifyAndLight)
{
    Preconditions.checkNotNull(location);
    Preconditions.checkNotNull(block);

    CraftWorld craftWorld = (CraftWorld)location.getWorld();
    int x = location.getBlockX();
    int y = location.getBlockY();
    int z = location.getBlockZ();

    boolean changed = location.getBlock().setTypeIdAndData(block.getId(), (byte)block.getData(), notifyAndLight);

    CompoundTag nativeTag = block.getNbtData();
    if (nativeTag != null)
    {
        TileEntity tileEntity = craftWorld.getHandle().getTileEntity(new BlockPosition(x, y, z));
        if (tileEntity != null)
        {
            NBTTagCompound tag = (NBTTagCompound)fromNative(nativeTag);
            tag.set("x", new NBTTagInt(x));
            tag.set("y", new NBTTagInt(y));
            tag.set("z", new NBTTagInt(z));
            readTagIntoTileEntity(tag, tileEntity);
        }
    }
    return changed;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:28,代码来源:FaweAdapter_1_10.java

示例5: getTileEntity

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public CompoundTag getTileEntity(ChunkSnapshot chunk, int x, int y, int z) {
    if (getAdapter() == null) {
        return null;
    }
    Location loc = new Location(getWorld(), x, y, z);
    BaseBlock block = getAdapter().getBlock(loc);
    return block != null ? block.getNbtData() : null;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:10,代码来源:BukkitQueue_All.java

示例6: setBlock

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public boolean setBlock(Location location, BaseBlock block, boolean notifyAndLight) {
    World craftWorld = location.getWorld();
    int x = location.getBlockX();
    int y = location.getBlockY();
    int z = location.getBlockZ();

    boolean changed = location.getBlock().setTypeIdAndData(block.getId(), (byte) block.getData(), notifyAndLight);

    CompoundTag nativeTag = block.getNbtData();
    if (nativeTag != null) {
        try {
            Object nmsWorld = getHandleWorld.invoke(craftWorld);
            Object tileEntity = getTileEntity(nmsWorld, x, y, z);
            if (tileEntity != null) {
                Object tag = fromNative(nativeTag);

                setNBTTagCompound.invoke(tag, "x", newNBTTagInt.newInstance(x));
                setNBTTagCompound.invoke(tag, "y", newNBTTagInt.newInstance(y));
                setNBTTagCompound.invoke(tag, "z", newNBTTagInt.newInstance(z));
                readTagIntoTileEntity.invoke(tileEntity, tag); // Load data
            }
        } catch (Throwable e) {
            throw new RuntimeException(e);
        }
    }

    return changed;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:30,代码来源:FaweAdapter_All.java

示例7: add

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
public void add(int x, int y, int z, int combinedFrom, BaseBlock to) {
    try {
        if (to.hasNbtData()) {
            CompoundTag nbt = to.getNbtData();
            MainUtil.setPosition(nbt, x, y, z);
            addTileCreate(nbt);
        }
        int combinedTo = (to.getId() << 4) + to.getData();
        add(x, y, z, combinedFrom, combinedTo);

    } catch (Exception e) {
        MainUtil.handleError(e);
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:15,代码来源:FaweChangeSet.java

示例8: setBlock

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
public boolean setBlock(int index, BaseBlock block) {
    int id = block.getId();
    setId(index, id);
    setData(index, block.getData());
    if (id >= 256) {
        setAdd(index, (id >> 8));
    }
    CompoundTag tile = block.getNbtData();
    if (tile != null) {
        setTile(index, tile);
    }
    return true;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:14,代码来源:CPUOptimizedClipboard.java

示例9: setBlock

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
public boolean setBlock(int index, BaseBlock block) {
    int id = block.getId();
    setId(index, id);
    if (id >= 256) {
        setAdd(index, (id >> 8));
    }
    setData(index, block.getData());
    CompoundTag tile = block.getNbtData();
    if (tile != null) {
        setTile(index, tile);
    }
    return true;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:14,代码来源:MemoryOptimizedClipboard.java

示例10: transformNbtData

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
/**
 * Transform NBT data in the given block state and return a new instance
 * if the NBT data needs to be transformed.
 *
 * @param state the existing state
 * @return a new state or the existing one
 */
private BaseBlock transformNbtData(BaseBlock state) {
    CompoundTag tag = state.getNbtData();
    if (tag != null) {
        // Handle blocks which store their rotation in NBT
        if (tag.containsKey("Rot")) {
            int rot = tag.asInt("Rot");

            Direction direction = MCDirections.fromRotation(rot);

            if (direction != null) {
                Vector applyAbsolute = transform.apply(direction.toVector());
                Vector applyOrigin = transform.apply(Vector.ZERO);
                applyAbsolute.mutX(applyAbsolute.getX() - applyOrigin.getX());
                applyAbsolute.mutY(applyAbsolute.getY() - applyOrigin.getY());
                applyAbsolute.mutZ(applyAbsolute.getZ() - applyOrigin.getZ());

                Direction newDirection = Direction.findClosest(applyAbsolute, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL);

                if (newDirection != null) {
                    Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue());
                    values.put("Rot", new ByteTag((byte) MCDirections.toRotation(newDirection)));
                }
            }
        }
    }
    return state;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:35,代码来源:ExtentBlockCopy.java

示例11: clearContainerBlockContents

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public boolean clearContainerBlockContents(Vector pos) {
    BaseBlock block = getBlock(pos);
    CompoundTag nbt = block.getNbtData();
    if (nbt != null) {
        if (nbt.containsKey("items")) {
            block.setNbtData(null);
            return setBlock(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), block);
        }
    }
    return false;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:13,代码来源:EditSession.java

示例12: run

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public void run(int x, int y, int z, BaseBlock block) {
    if (this.x == x - 1 && this.y == y && this.z == z) {
        this.x++;
        index++;
    } else {
        index = yarea[this.y = y] + zwidth[this.z = z] + (this.x = x);
    }
    int id = block.getId();
    blocks[index] = (byte) id;
    if (FaweCache.hasData(id)) {
        blockData[index] = (byte) block.getData();
        if (id > 255) {
            if (addBlocks == null) { // Lazily create section
                addBlocks = new byte[((blocks.length + 1) >> 1)];
            }
            addBlocks[index >> 1] = (byte) (((index & 1) == 0) ? addBlocks[index >> 1] & 0xF0 | (id >> 8) & 0xF : addBlocks[index >> 1] & 0xF | ((id >> 8) & 0xF) << 4);
        }
    }
    CompoundTag rawTag = block.getNbtData();
    if (rawTag != null) {
        Map<String, Tag> values = ReflectionUtils.getMap(rawTag.getValue());
        values.put("id", new StringTag(block.getNbtId()));
        values.put("x", new IntTag(x));
        values.put("y", new IntTag(y));
        values.put("z", new IntTag(z));
        tileEntities.add(rawTag);
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:30,代码来源:SchematicWriter.java


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