本文整理汇总了Java中com.sk89q.worldedit.blocks.BaseBlock.setNbtData方法的典型用法代码示例。如果您正苦于以下问题:Java BaseBlock.setNbtData方法的具体用法?Java BaseBlock.setNbtData怎么用?Java BaseBlock.setNbtData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sk89q.worldedit.blocks.BaseBlock
的用法示例。
在下文中一共展示了BaseBlock.setNbtData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBlock
import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
public BaseBlock getBlock(Location location)
{
Preconditions.checkNotNull(location);
CraftWorld craftWorld = (CraftWorld)location.getWorld();
int x = location.getBlockX();
int y = location.getBlockY();
int z = location.getBlockZ();
Block bukkitBlock = location.getBlock();
BaseBlock block = new BaseBlock(bukkitBlock.getTypeId(), bukkitBlock.getData());
TileEntity te = craftWorld.getHandle().getTileEntity(new BlockPosition(x, y, z));
if (te != null)
{
NBTTagCompound tag = new NBTTagCompound();
readTileEntityIntoTag(te, tag);
block.setNbtData((CompoundTag)toNative(tag));
}
return block;
}
示例2: applyBlock
import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public void applyBlock(int x, int y, int z, BaseBlock block, MutableLong ignore) {
int id = block.getId();
int data = FaweCache.hasData(id) ? block.getData() : 0;
int combined = FaweCache.getCombined(id, data);
Pattern p = map[combined];
if (p != null) {
BaseBlock newBlock = p.apply(x, y, z);
int currentId = block.getId();
if (FaweCache.hasNBT(currentId)) {
block.setNbtData(null);
}
block.setId(newBlock.getId());
block.setData(newBlock.getData());
}
}
示例3: getBlock
import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public BaseBlock getBlock(Vector position) {
final int state = BlockRegistryModule.get().getStateInternalIdAndData(
getWorld().getBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ()));
final Optional<TileEntity> optTile = getWorld().getTileEntity(position.getBlockX(), position.getBlockY(), position.getBlockZ());
final BaseBlock baseBlock = new BaseBlock(state >> 4, state & 0xf);
if (optTile.isPresent()) {
final TileEntity tile = optTile.get();
final ObjectSerializer serializer = ObjectSerializerRegistry.get().get(tile.getClass()).get();
final DataView dataView = serializer.serialize(tile);
baseBlock.setNbtData(DataViewNbt.to(dataView));
}
return baseBlock;
}
示例4: remap
import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
public BaseBlock remap(BaseBlock block) {
int combined = block.getCombined();
if (remap[combined]) {
char value = remapCombined[combined];
BaseBlock newBlock = FaweCache.CACHE_BLOCK[value];
newBlock.setNbtData(block.getNbtData());
return newBlock;
}
return block;
}
示例5: applyBlock
import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public void applyBlock(int x, int y, int z, BaseBlock block, MutableLong ignore) {
if (matchFrom.apply(block)) {
BaseBlock newBlock = to.apply(x, y, z);
int currentId = block.getId();
if (FaweCache.hasNBT(currentId)) {
block.setNbtData(null);
}
block.setId(newBlock.getId());
block.setData(newBlock.getData());
}
}
示例6: 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;
}