Changing the biome of all Chunks and reload it

Discussion in 'Plugin Development' started by Skyost, Aug 24, 2013.

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

    Skyost

    Hi,
    All is in the title, I have tried this code :
    Code:java
    1. World w = e.getPlayer().getWorld();
    2. Chunk[] c = w.getLoadedChunks();
    3. for(int i = 0; i < c.length; i++) {
    4. w.setBiome(c[I].getX(), c[I].getX(), Biome.ICE_MOUNTAINS);[/I][/I]
    5. w.refreshChunk(c.getX(), c.getZ());
    6. }


    But it don't work :/
    How to do this ?
    Thanks :)
     
  2. Offline

    KingNyuels

    Premièrement : Vous ne changez pas tous les morceaux d'un monde, mais seulement ceux qui sont actuellement chargés.
    Essayez un relog ou ensemble, au lieu de la "RefreshChunk" derrière elle :
    Code:java
    1. ((CraftPlayer) p).getHandle().playerConnection
    2. .sendPacket(new Packet51MapChunk(
    3. ((CraftChunk) p.getLocation()
    4. .getChunk()).getHandle(),
    5. true, 65535));


    KingNyuels (Hopefullycorrectly:AmGerman)

    PS: "p" is the player!
     
  3. Offline

    Skyost

    KingNyuels Et comment tous les obtenir, même ceux qui ne sont pas chargés ?

    EN: How can obtain all Chunks, with those which aren't loaded ?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  4. Offline

    KingNyuels

    Maybe with a loop:
    Code:java
    1. public static List<Chunk> getAllChunks(double xmin, double xmax,
    2. World world, double zmin, double zmax) {
    3. world.getLoadedChunks();
    4.  
    5. List<Chunk> chunks = new ArrayList<Chunk>();
    6. int x = (int) xmin;
    7. int z = (int) zmin;
    8. while (x <= xmax) {
    9. while (z <= zmax) {
    10. chunks.add(world.getChunkAt((x / 16), (z / 16)));
    11. z += 16;
    12. }
    13. x += 16;
    14. }
    15. return chunks;
    16. }
     
  5. Offline

    Skyost

    Yes but how to obtain the Max X and the Max Z of a world ?
     
  6. Offline

    KingNyuels

    It is not possible.Make a config in the plugin, in which users can specify maximum and minimum values.Otherwise you're taking xmin= -1000, xmax= 1000, zmin = -1000 and zmax= 1000.

    French:
    Il n'est pas possible. Faire une config chez les utilisatrices de plugin qui spécifient des valeurs maximales. Dans le cas contraire, vous prenez xmin = -1000, xmax = 1000 , zmin = -1000 et zmax = 1000.
     
  7. Offline

    Skyost

    Okay :/
    Thanks anyway ;)
     
Thread Status:
Not open for further replies.

Share This Page