try {
final IWorldEditLocation pasteLoc = new IWorldEditLocation(location);
final ClipboardHolder holder = new ClipboardHolder(clipboard);
transform = transform.rotateY(angle);
holder.setTransform(transform);
final int pasteLocX = pasteLoc.getX();
final int pasteLocY = pasteLoc.getY();
final int pasteLocZ = pasteLoc.getZ();
final BlockVector3 to = BlockVector3.at(pasteLocX, pasteLocY, pasteLocZ);
final Region region = clipboard.getRegion();
final BlockVector3 origin = clipboard.getOrigin();
final BlockVector3 clipboardOffset = region.getMinimumPoint().subtract(origin);
final Vector3 realTo = to.toVector3().add(holder.getTransform().apply(clipboardOffset.toVector3()));
final Vector3 max = realTo.add(holder.getTransform().apply(region.getMaximumPoint().subtract(region.getMinimumPoint()).toVector3()));
final CuboidRegionSelector selector = new CuboidRegionSelector(bukkitWorld, realTo.toBlockPoint(), max.toBlockPoint());
final CuboidRegion cuboidRegion = selector.getRegion();
final BlockVector3 maxPoint = cuboidRegion.getMaximumPoint();
final BlockVector3 minPoint = cuboidRegion.getMinimumPoint();
final HashMap<Vector3i, List<EncodedBlock>> chunkBlocksHashMap = new HashMap<>();
for (int x = minPoint.getBlockX(); x <= maxPoint.getBlockX(); x++)
for (int y = minPoint.getBlockY(); y <= maxPoint.getBlockY(); y++)
for (int z = minPoint.getBlockZ(); z <= maxPoint.getBlockZ(); z++) {
if (pasteLocX == x && pasteLocY == y && pasteLocZ == z)
continue;
final BlockVector3 at = BlockVector3.at(x, y, z).add(origin);
final BlockVector3 subtract = BlockVector3.at(x, y, z).subtract(origin);
final BlockState block = clipboard.getBlock(at);
final BlockState block2 = clipboard.getBlock(subtract);
holder.getTransform()
if (block == null) continue;
final BlockType blockType = block.getBlockType();
System.
out.
println(blockType
);
System.
out.
println("BLOCK 2: " + block2.
getBlockType());
if (blockType == null || blockType == BlockTypes.AIR) continue;
final Material material = BukkitAdapter.adapt(blockType);
if (material == null) continue;
final Location blockLocati Location(world, x, y, z);
final Chunk chunk = blockLocation.getChunk();
final WrappedBlockState blockState = SpigotConversionUtil.fromBukkitBlockData(material.createBlockData());
final EncodedBlock encodedBlock = new EncodedBlock(blockState, x, y, z);
final Vector3i vector3i = new Vector3i(chunk.getX(), 0, chunk.getZ());
if (chunkBlocksHashMap.containsKey(vector3i))
chunkBlocksHashMap.get(vector3i).add(encodedBlock);
else
chunkBlocksHashMap.
put(vector3i,
new ArrayList
<>(List.
of(encodedBlock
)));
}
chunkBlocksHashMap.forEach((vector3i, encodedBlocks) -> {
final WrapperPlayServerMultiBlockChange multiBlockChange = new WrapperPlayServerMultiBlockChange(vector3i, true, encodedBlocks.toArray(new EncodedBlock[0]));
StructureBoxes.getPacketEventsAPI().getPlayerManager().sendPacket(player, multiBlockChange);
});
}