Search in sources :

Example 1 with CompoundTagBuilder

use of com.denizenscript.denizen.nms.util.jnbt.CompoundTagBuilder in project Denizen-For-Bukkit by DenizenScript.

the class BlockHelperImpl method setNbtData.

@Override
public void setNbtData(Block block, CompoundTag ctag) {
    CompoundTagBuilder builder = ctag.createBuilder();
    builder.putInt("x", block.getX());
    builder.putInt("y", block.getY());
    builder.putInt("z", block.getZ());
    ctag = builder.build();
    BlockPos blockPos = new BlockPos(block.getX(), block.getY(), block.getZ());
    BlockEntity te = ((CraftWorld) block.getWorld()).getHandle().getBlockEntity(blockPos, true);
    te.load(((CompoundTagImpl) ctag).toNMSTag());
}
Also used : BlockPos(net.minecraft.core.BlockPos) CompoundTagBuilder(com.denizenscript.denizen.nms.util.jnbt.CompoundTagBuilder) SpawnerBlockEntity(net.minecraft.world.level.block.entity.SpawnerBlockEntity) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Example 2 with CompoundTagBuilder

use of com.denizenscript.denizen.nms.util.jnbt.CompoundTagBuilder in project Denizen-For-Bukkit by DenizenScript.

the class BlockHelperImpl method setNbtData.

@Override
public void setNbtData(Block block, CompoundTag ctag) {
    CompoundTagBuilder builder = ctag.createBuilder();
    builder.putInt("x", block.getX());
    builder.putInt("y", block.getY());
    builder.putInt("z", block.getZ());
    ctag = builder.build();
    BlockPos blockPos = new BlockPos(block.getX(), block.getY(), block.getZ());
    BlockEntity te = ((CraftWorld) block.getWorld()).getHandle().getTileEntity(blockPos, true);
    te.load(((CompoundTagImpl) ctag).toNMSTag());
}
Also used : BlockPos(net.minecraft.core.BlockPos) CompoundTagBuilder(com.denizenscript.denizen.nms.util.jnbt.CompoundTagBuilder) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Example 3 with CompoundTagBuilder

use of com.denizenscript.denizen.nms.util.jnbt.CompoundTagBuilder in project Denizen-For-Bukkit by DenizenScript.

the class BlockHelperImpl method setNbtData.

@Override
public void setNbtData(Block block, CompoundTag ctag) {
    CompoundTagBuilder builder = ctag.createBuilder();
    builder.putInt("x", block.getX());
    builder.putInt("y", block.getY());
    builder.putInt("z", block.getZ());
    ctag = builder.build();
    BlockPosition blockPos = new BlockPosition(block.getX(), block.getY(), block.getZ());
    TileEntity te = ((CraftWorld) block.getWorld()).getHandle().getTileEntity(blockPos);
    te.load(((CraftBlockData) block.getBlockData()).getState(), ((CompoundTagImpl) ctag).toNMSTag());
}
Also used : CompoundTagBuilder(com.denizenscript.denizen.nms.util.jnbt.CompoundTagBuilder)

Aggregations

CompoundTagBuilder (com.denizenscript.denizen.nms.util.jnbt.CompoundTagBuilder)3 BlockPos (net.minecraft.core.BlockPos)2 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)2 SpawnerBlockEntity (net.minecraft.world.level.block.entity.SpawnerBlockEntity)1