TryJump Plugin - Map generation

Discussion in 'Plugin Development' started by felix121felix, Dec 13, 2018.

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

    felix121felix

    Hey guys,
    i want to make a plugin like JumpLeague/Try Jump like it has been on Playminity or now on GommeHD.net
    Before the game starts i have to generate the Jump and Run map. For that i will have pre built parts that will be put together randomly by the plugin. Each part has a checkpoint after it and if you fail 3 times the plugin should load an easier version of the Part. I'm now looking for the best way to load the parts and put them into the map. I have a few Ideas, each with it's own problems:

    1. Use worldedit schematics and paste them in.
    -> Problem: i think i have to store the beginning and the end point of the Jump and Run in order to fit the parts together properly or have the Parts all be the same size and have same start and finish positions.

    2. Build many Maps with the parts already connected.
    -> Problem: I would have to make hundreds of maps if i really want to have all combinations of parts that are possible and if i want to add new parts i would have to do the same thing again.

    3. Make an own schematic like thing that stores all the blocks and begin and end of the part so i can put it together easily.
    -> Problem: This is actually my favorite but it would propably take a lot of time to make a good schematic tool because i have never done something like that and also i dont know how it will perform. All the ways i thought of use much CPU power when pasting the schematics in.

    I hope to hear some great ideas from you guys (especially about making an own schematic tool).
    Thanks in advance.
    - Felix
     
  2. @felix121felix

    Don't do option 2.
    Option 1 should be your back-up if you can't manage option 3.
    Option 3 is also my favorite, so I will give some advice:

    The best tool for creating schematics is probably minecraft itself. I suggest you use a local server for this with worldedit and your plug-in installed.
    In your plug-in, you can create a command that takes minX, minY, minZ, maxX, maxY, maxZ, startX, startY, startZ, finishX, finishY and finishZ as arguments. (That will look a bit ugly, but you should be the only one to use it anyway.)
    When you execute the command, you should iterate over all the blocks and store the data in a file.
    If you need help with encoding all the blocks to a file, just reply and I will give more details.

    In your actual server, you need (another) plug-in that is capable of understanding the files that were written by your 'schematic plug-in' and that can build them on the server. If the map is not big, you can 'paste' the entire map immediately. If the map is big, you can use the Bukkit scheduler to register a task that builds a part of the map every tick. (Alternatively, you could even let the plug-in generate new parts of the map while the player is playing the map to create an endless map.)
    You can also reply if you need more help with this part.
     
  3. Offline

    felix121felix

    Thank you for your help knokko. That's about the thing i was thinking of. Loading the file once i saved it won't be the problem. I think encoding the block data will be a bit trickier as the Block (or Blockstate) class isn't serializable (as far as i remember). I guess the parameters i have to store are something like type, color, rotation(for stairs etc.). I think the color is stored in the float data but i haven't used the rotation of an block before and don't know how to get and set it.

    The next thing to decide is which type of file to use. I guess a binary would be the best solution for performance but pretty bad for readability. Also it would be much easier to save the block types in text.


    P.S.: Someone over at spigot had the idea to use FAWE to use async worldedit schematics and store the needed information about start/finish in a metadata file which would be easier but i still think i'll go with doing it on my own.
     
  4. @felix121felix

    I don't think it will be very hard to save and load blocks.
    You can use net.minecraft.server.v1_12_R1.Block.getCombinedId and getByCombinedId to convert blocks to integers. As long as you don't need tile entities (which I assume), you can simply store the the integers. The combined id will take simple block data like stair rotation into account.
    I suggest you go for binary encoding since reading your files will be no fun anyway. You can simply use DataOutputStream and DataInputStream for this.
     
  5. Offline

    felix121felix

    Hmm i want to maintain compatibility down to 1.8 so i can't use that method and i don't think there was a similar one back in that version. But i could make a method that does the same thing. I'll have a look on the source code of #getCombinedId() for that.
     
Thread Status:
Not open for further replies.

Share This Page