Solved Copying Blocks from World1 to World2

Discussion in 'Plugin Help/Development/Requests' started by curlip, Apr 10, 2015.

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

    curlip

    Curlip, Back Again.

    Currently I am having an issue copying the 64 chunks around the player to a second world. I am trying to take the blocks around the player and place them in World2 then teleport the player to World2.

    My Issue is, first of all the blocks don't copy across so I fall into the void, second it now seams to crash the server.

    Thankyou for any help,
    Curlip

    PS: Please be very descriptive.

    The Code:

    In the Command (open)

    Code:
    Location playerloc = player.getLocation();
                    World currentWorld = playerloc.getWorld();
                    World tempWorld = this.getServer().createWorld(new WorldCreator(player.getName() + "temp").generator(new EmptyGenerator()));
                  
                    for(int x = playerloc.getBlockX() - (4 * 16); x < playerloc.getBlockX() + (4 * 16); x++){
                        for(int y = 0; y < currentWorld.getMaxHeight(); y++){
                            for(int z = playerloc.getBlockZ() - (4 * 16); z < playerloc.getBlockZ() + (4 * 16); z++){
                              
                                Location get = new Location(currentWorld, x, y, z);
                                Location set = new Location(tempWorld, x - playerloc.getX(), y, z - playerloc.getZ());
                              
                                currentWorld.loadChunk(get.getChunk());
                                tempWorld.loadChunk(set.getChunk());
                              
                                set.getBlock().setType(get.getBlock().getType());
                              
                                tempWorld.unloadChunk(set.getChunk());
                                tempWorld.loadChunk(set.getChunk());
                            }
                        }
                    }
                  
                    tempWorld.save();
    Teleport later in command.
     
  2. Offline

    Zombie_Striker

    • Make an Map3 of an Integer and Block (x,y,z)
    • Put into each of those maps the x y zx coards relitive to the player (e.g Starting point is 100 - Playerloc(200) = -100, and Ending point is 300 - Playerloc(200) = 100)
    • Now that it's stored, go to the location and change it from putting stuff in, to taking it out and setting the Block to be that block in the Map.
     
  3. Offline

    curlip

    I'm quite new to Bukkit can you explain this more.

    @Zombie_Striker Can you give me an example
     
    Last edited by a moderator: Apr 12, 2015
  4. Offline

    curlip

    Im receiving this error now. (I was also getting this before)
    And the blocks are still not copying, still open to suggestions from you all.

    Error (open)



    Current Code (open)

    Code:
    Location playerloc = player.getLocation();
                    World currentWorld = playerloc.getWorld();
                    World tempWorld = this.getServer().createWorld(new WorldCreator(player.getName() + "temp").generator(new EmptyGenerator()));
                   
                    Map<Vector, Block> blocks = new HashMap<Vector, Block>();
                   
                    for(int x = playerloc.getBlockX() - (4 * 16); x < playerloc.getBlockX() + (4 * 16); x++){
                        for(int y = 0; y < currentWorld.getMaxHeight(); y++){
                            for(int z = playerloc.getBlockZ() - (4 * 16); z < playerloc.getBlockZ() + (4 * 16); z++){
                                Location get = new Location(currentWorld, x, y, z);
                                Vector set = new Vector(x - playerloc.getX(), y, z - playerloc.getZ());
                               
                                blocks.put(set, get.getBlock());
                            }
                        }   
                    }   
                   
                    for (Map.Entry<Vector, Block> entry : blocks.entrySet())
                    {
                        Vector vec = entry.getKey();
                       
                        Location loc = new Location(tempWorld, vec.getX(), vec.getY(), vec.getZ());
                        loc.getBlock().setType(loc.getBlock().getType());
                    }
    player.teleport(new Location(tempWorld, 0, playerloc.getY() + 3, 0));
     
Thread Status:
Not open for further replies.

Share This Page