Copying 64 Chunks (FAST)

Discussion in 'Plugin Development' started by curlip, Apr 16, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    curlip

    Hello Curlip Here,

    I am having more trouble copying a large area (8x8 chunks (4,194,304 blocks if my math is right)). I have been using the CuboidUtil and Block.setType() method which currently isn't cutting it. (Lag, Slow, and Crashes the server)

    Can you help me fix/speed this up, because its a command for the general user.

    CuboidsUtil
    My Other Thread

    And my Code:

    Code:
    Location playerloc = player.getLocation();
                    World currentWorld = playerloc.getWorld();
                    World tempWorld = this.getServer().createWorld(new WorldCreator(player.getName() + "temp").environment(currentWorld.getEnvironment()).generator(new EmptyGenerator()));
                    
                    Cuboid cube = new Cuboid(new Location(currentWorld, playerloc.getBlockX() - (16 * 4), 0, playerloc.getBlockZ() - (16 * 4)), 
                            new Location(currentWorld, playerloc.getBlockX() + (16 * 4), currentWorld.getMaxHeight(), playerloc.getBlockZ() + (16 * 4)));
                    
                    for(Block block : cube){
                        
                        Location getloc = block.getLocation();
                        Location setloc = new Location(
                                tempWorld,
                                (double) getloc.getBlockX() - playerloc.getBlockX(),
                                (double) getloc.getBlockY(),
                                (double) getloc.getBlockZ() - playerloc.getBlockZ());
                        
                        setloc.getBlock().setType(getloc.getBlock().getType());
                    }
                    
                    player.teleport(new Location(tempWorld, 0, playerloc.getY() + 3, 0));
                    player.setGameMode(GameMode.CREATIVE);
    Thanks Curlip.
     
  2. Offline

    mine-care

    @curlip Please wait At least 24 hours before bumping.
    If i understand correctly, you want to get a 8x8 area based on a center point? if so it wont be perfectly aligned since mid point of 8 is 3.5 so... it will be 4 to one side and 3 to the other.... (Note: i am thinking based on X,Y,Z axis) the thing changes if you want to select a region starting from point N ending to point Ω so it would be in the concepts of WorldEdit, a nested loop that will loop through the dismentions :p
     
  3. Offline

    curlip

    @mine-care I need to copy an area of 8x8 chunks in which case it is a very large area and simply looping through the area is insufficient.
     
    Last edited: Apr 17, 2015
  4. Offline

    mythbusterma

    @curlip

    Why do you need to copy so many blocks? There's likely a much faster way to do this.
     
  5. Offline

    curlip

    @mythbusterma I need to copy this many blocks so the user can edit an area undisturbed.
    This are would be copied to an empty world.

    What are you recommendations, I could probably go back to 5 or six chunks in each direction.
     
  6. Offline

    Lolmewn

    I know WorldEdit uses a form of "fast edit" where lighting isn't done until all blocks are copied, I suggest you take a look at that.
     
  7. Offline

    curlip

    @Lolmewn I'm trying to use WorldEdit but is seaming very complicated and difficult to understand. I also don't know where to find the Source code, I do have it loaded into eclipse.
     
  8. Offline

    Lolmewn

    @curlip You can find it here: <Edit by Moderator: Redacted bit url>
     
    Last edited by a moderator: Feb 10, 2017
    RawCode likes this.
  9. Offline

    curlip

    @Lolmewn Thank you (I think... )

    I couldn't find anything on the subject blocks with WorldEdit so I began searching through the code, I also cannot find the code WorldEdit uses to copy blocks.

    Any ideas anyone?
     
  10. Offline

    JUSTCAMH

    @curlip possibly you could just log all the changes made by a user and undo them individually at the end, so your not undoing the whole 8x8 chunks and just the number of blocks the player editted
     
  11. Offline

    curlip

    @JUSTCAMH I am not undoing the changes, this will be the area the original player builds in.
     
  12. Offline

    mythbusterma

    @curlip

    Well then spread the changes over multiple ticks, so as not to bog down the server.
     
  13. Offline

    RawCode

    dont copy "chunks" copy internal blockdata arrays
     
  14. Offline

    mythbusterma

    @RawCode

    Because that won't have disastrous side effects....
     
  15. Offline

    bohafr

    Why no copy the world? Simply copy and paste and you have the copy of this world
     
  16. Offline

    curlip

    @bohafr Then the user would be able to edit the entire world.
     
Thread Status:
Not open for further replies.

Share This Page