use of net.minecraft.commands.arguments.blocks.ArgumentBlock in project SSB-OneBlock by BG-Software-LLC.
the class NMSAdapter_v1_18_R1 method setBlock.
@Override
public void setBlock(Location location, Material type, byte data, String nbt) {
assert location.getWorld() != null;
WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
worldServer.m(blockPosition);
location.getBlock().setType(type);
if (nbt != null) {
try {
ArgumentBlock argumentBlock = new ArgumentBlock(new StringReader(nbt), false).a(true);
IBlockData blockData = argumentBlock.b();
if (blockData != null) {
ArgumentTileLocation tileLocation = new ArgumentTileLocation(blockData, argumentBlock.a().keySet(), argumentBlock.c());
tileLocation.a(worldServer, blockPosition, 2);
worldServer.a(blockPosition, tileLocation.a().b());
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
use of net.minecraft.commands.arguments.blocks.ArgumentBlock in project SSB-OneBlock by BG-Software-LLC.
the class NMSAdapter_v1_17_R1 method setBlock.
@Override
public void setBlock(Location location, Material type, byte data, String nbt) {
assert location.getWorld() != null;
WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
worldServer.removeTileEntity(blockPosition);
location.getBlock().setType(type);
if (nbt != null) {
try {
ArgumentBlock argumentBlock = new ArgumentBlock(new StringReader(nbt), false).a(true);
ArgumentTileLocation tileLocation = new ArgumentTileLocation(argumentBlock.getBlockData(), argumentBlock.getStateMap().keySet(), argumentBlock.c());
tileLocation.a(worldServer, blockPosition, 2);
worldServer.update(blockPosition, tileLocation.a().getBlock());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Aggregations