[1.14.4] NMS Worldgeneration

Discussion in 'Plugin Development' started by DasBabyPixel, Dec 31, 2019.

Thread Status:
Not open for further replies.
  1. I recently found out about the org.bukkit.generator.ChunkGenerator, I created my own world with a few hills and I was happy. I created a structure serializing and deserializing system to save and load custom Structures.Worked perfectly. My commands to save edit and paste worked wonderful and I could paste more than 500 blocks in about 10ms. (I got the value with System#currentTimeMillis). I startet to add generation chances to my Structure class so I could use a BlockPoulator to spawn custom trees. It worked, my trees spawned. But as I was flying in creative with the max normal flyspeed (NOT speed 10, i flew with speed 1),I started to get flagged and I bugged backwards. I was confused and buildt a nether portal and went to nether. I flew around, but there were no lags, i did not get flagged, etc even with the more complicated nether generation algorythm. So i looked around the (craft)bukkit source code how the world was generated, and I got completly lost. I tried next in the net.minecraft.server packages and I found somewhat a few things, but I did not figure out how they worked. I am on my cellphone and don't quite remember the class names, but I believe something like WorldGeneratorNether / End / General / Flat etc. And what I'm finally asking for is if somebody who knows something about the topic could help me out with minecraft's chunk generation and it would be appreciated if it was detailed (I always say: You should use code that you dont understand only if theres no other way), or the basics and how to start reverse-eng. that, so I can figure out the rest by myself.

    I also heard, there would be a workaround and that async chunk generation was possible by first generating all the chunksections, replacing sending the replaced ones to the main thread where a timed scheduler would replace them in the WorldServer instance, but I have no clue if that is possible.

    What the goal is that i want to reach is a totally lag-friendly worldgeneration, I don't care how it is finally done, even if I have to learn a totally different section of craftbukkit / net.minecraft.server, I just really want to publish a good worldgenerator that, as the most others i have seen, does not lag or flag people backwards, slow down tick time and after the spike a creeper is behind you and you are dead.

    Thanks for every single bit of help!

    Bump. (430 views no reply.. probably a hard one ._.)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jan 1, 2020
  2. Offline

    timtower Administrator Administrator Moderator

    @DasBabyPixel It is a specialized piece of plugin making.
    Most developers just ignore it.
    But lag free and world generation don't go together.
    You will always notice it, best way to avoid lag is by pre-generating a large part of the world chunk by chunk delayed by ... ticks each.
     
  3. @timtower
    Of course it is laggy, but as far as I can tell, the minecraft server does it asynchr0nously and the players dont get any lag to feel. That's why I want it with the NMS chunkgenerator and I'm currently testing and testing how that chunk gen could work. I just cant stay with the bad method if there is a better one. And a plugin that does not care of lag is, sorry to say, a bad programmed plugin

    Maybe we could find out where the bukkit calls the minecraft normal world generation, I think I'm gonna look for that rn
     
    Last edited by a moderator: Jan 1, 2020
  4. Offline

    timtower Administrator Administrator Moderator

    @DasBabyPixel Minecraft does not run multiple threads as far as I know.
    The plugin that generates the chunks is only responsible for the chunks.
    How often the chunk generation is called is outside that scope though.
     
  5. @timtower Minecraft 1.14.4 does, i think, run multiple threads, because of the max-tick-time or stuff like that (As i said, think not know). But that off point minecraft does manage to create chunks lag-friendly and probably async, because if the server does not lag by itself if it is a good server and you can fly smoothly through the world generating new chunks.
    What I mean, you dont get lagged back, if the chunk isn't yet generated, you are in a "chunkhole", as i like to call it and after a few moments the chunk get's sent. If I use my chunkgenerator (I followed a tutorial on bukkit.gamepedia) it works but is laggy. If i fly in a "chunkhole" the chunk gets generated after a few moments BUT i get flagged back and eg player with elytra in nether gets flagged back, almost every time dead. I dont care if the chunk generation is async or not, but I really have to stop the server slowing down tick time and flagging players.
     
  6. Offline

    timtower Administrator Administrator Moderator

    @DasBabyPixel Then I suggest pre-generation and a border to limit movement.
    If Minecraft is using multiple threads then normal world generation (with your plugin) would use the same methods.
     
Thread Status:
Not open for further replies.

Share This Page