本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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());
}
}