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


Java BaseBlock.hasNbtData方法代码示例

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


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

示例1: clearContainerBlockContents

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public boolean clearContainerBlockContents(Vector position) {
    BaseBlock block = extent.getLazyBlock(position);
    if (block.hasNbtData()) {
        Map<String, Tag> nbt = ReflectionUtils.getMap(block.getNbtData().getValue());
        if (nbt.containsKey("Items")) {
            nbt.put("Items", new ListTag(CompoundTag.class, new ArrayList<CompoundTag>()));
            try {
                extent.setBlock(position, block);
            } catch (WorldEditException e) {
                e.printStackTrace();
            }
        }
    }
    return true;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:17,代码来源:MCAWorld.java

示例2: setBlocks

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
/**
 * Sets all the blocks inside a region to a given block type.
 *
 * @param region the region
 * @param block  the block
 * @return number of blocks affected
 * @throws MaxChangedBlocksException thrown if too many blocks are changed
 */
@SuppressWarnings("deprecation")
public int setBlocks(final Region region, final BaseBlock block) {
    checkNotNull(region);
    checkNotNull(block);
    if (canBypassAll(region, false, true) && !block.hasNbtData()) {
        return changes = queue.setBlocks((CuboidRegion) region, block.getId(), block.getData());
    }
    try {
        if (hasExtraExtents()) {
            RegionVisitor visitor = new RegionVisitor(region, new BlockReplace(extent, (block)), this);
            Operations.completeBlindly(visitor);
            this.changes += visitor.getAffected();
        } else {
            Iterator<BlockVector> iter = region.iterator();
            while (iter.hasNext()) {
                if (this.extent.setBlock(iter.next(), block)) {
                    changes++;
                }
            }
        }
    } catch (final WorldEditException e) {
        throw new RuntimeException("Unexpected exception", e);
    }
    return changes;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:34,代码来源:EditSession.java

示例3: 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

示例4: setBlock

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException {
    int combined = queue.getCombinedId4DataDebug(x, y, z, 0, session);
    int id = (combined >> 4);
    if (id == block.getId()) {
        if (!FaweCache.hasData(id)) {
            if (!block.hasNbtData()) {
                return false;
            }
        } else if (!block.hasNbtData()) {
            int data = combined & 0xF;
            if (data == block.getData()) {
                return false;
            }
        }
    }
    try {
        if (!FaweCache.hasNBT(id)) {
            if (block.canStoreNBTData()) {
                this.changeSet.add(x, y, z, combined, block);
            } else {
                this.changeSet.add(x, y, z, combined, (block.getId() << 4) + block.getData());
            }
        } else {
            try {
                CompoundTag tag = queue.getTileEntity(x, y, z);
                this.changeSet.add(x, y, z, new BaseBlock(id, combined & 0xF, tag), block);
            } catch (Throwable e) {
                e.printStackTrace();
                this.changeSet.add(x, y, z, combined, block);
            }
        }
    } catch (FaweException ignore) {
        return false;
    }
    return getExtent().setBlock(x, y, z, block);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:38,代码来源:HistoryExtent.java

示例5: setBlock

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
public void setBlock(int x, int y, int z, BaseBlock block) {
    setBlock(x, y, z, block.getId(), block.getData());
    if (block.hasNbtData()) {
        setTile(x & 15, y, z & 15, block.getNbtData());
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:7,代码来源:FaweChunk.java


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