Java Code Examples for com.sk89q.worldedit.blocks.BaseBlock#setNbtData()

The following examples show how to use com.sk89q.worldedit.blocks.BaseBlock#setNbtData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FaweAdapter_1_10.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: FaweAdapter_1_12.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: FaweAdapter_1_9.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: FaweAdapter_1_11.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 5
Source File: MappedReplacePatternFilter.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@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());
    }
}
 
Example 6
Source File: ClipboardRemapper.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example 7
Source File: SetPatternFilter.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void applyBlock(int x, int y, int z, BaseBlock block, MutableLong count) {
    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());
    count.increment();
}
 
Example 8
Source File: ReplacePatternFilter.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@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());
    }
}
 
Example 9
Source File: EditSession.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@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;
}