While adding new features to World Edit (i.e. copy / paste) I'm trying to find the best and most optimal way to set data in the world. The three methods that currently exist are
- setTerrainDataInArea(int startChunkX, int startChunkY, int startChunkZ, byte startBlockX, byte startBlockY, byte startBlockZ, int endChunkZ, int endChunkY, int endChunkZ, byte endBlockX, byte endBlockY, byte endBlockZ, int terrainId)
- setBlockDataInArea(int startChunkX, int startChunkY, int startChunkZ, byte startBlockX, byte startBlockY, byte startBlockZ, int endChunkZ, int endChunkY, int endChunkZ, byte endBlockX, byte endBlockY, byte endBlockZ, int blockId)
- placeBlock(int chunkX, int chunkY, int chunkZ, int blockX, int blockY, int blockZ, int blockId)
Each of these methods take only a single block or terrain type, set it then broadcast. Well, usually, players will copy and paste more complexe terrain and block organisation and will require some more fine-grained terrain and block manipulations. Calling any of these methods repeatedly (and each time broadcasting) is note quite desirable and will saturate the server.
A solution would be to create modification objects, and then apply and broadcast all modifications all at once.
I'm thinking, something like :