Hey, I’m looking for a method that can simply regenerate a chunk. (like World#regenerateChunk from bukkit)/ I know there was one in Sponge but now it’s not there. So even if the API doesn’t support it, I want to know an NMS method. Thanks.
Lignium
December 30, 2019, 6:00am
2
This feature will appear in API 7.2.0.
/** * Regenerates a chunk at the given chunk coordinates. * * @param cx The chunk x coordinate * @param cy The chunk y coordinate * @param cz The chunk z coordinate * @param flag The chunk regenerate flag to use * @return The regenerated chunk, if available */ Optional<Chunk> regenerateChunk(int cx, int cy, int cz, ChunkRegenerateFlag flag);
Oh cool. Is this thing available as an implementation already? So i can see the forge/nms code
Here you go. The chunk method calls this.
} final WorldServer worldserver = (WorldServer) (Object) this; // If we aren't generating, return the chunk if (!shouldGenerate) { return Optional.ofNullable((Chunk) worldserver.getChunkProvider().loadChunk(x, z)); } return Optional.ofNullable((Chunk) worldserver.getChunkProvider().provideChunk(x, z)); } @Override public Optional<Chunk> regenerateChunk(int cx, int cy, int cz, ChunkRegenerateFlag flag) { // Before unloading the chunk, we copy its entities then clear. // This ensures that they don't get unloaded when we unload the chunk, // since we want to keep them. // // We explicitly do *not* clear any tileentity-related things - we // want those to be saved and unloaded, since the new chunk // will have completely different blocks List<EntityPlayerMP> playerList = new ArrayList<>(); List<net.minecraft.entity.Entity> entityList = new ArrayList<>(); Chunk spongeChunk = this.loadChunk(cx, cy, cz, false).orElse(null);
1 Like
Thank you so much! Nice help.