Reflection and Chunk Generation.

Discussion in 'Plugin Development' started by tarcseh, Jun 16, 2021.

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

    tarcseh

    Hi. I've come across a problem when developing my cross-version / version-independent plugin. Everything is working, I've used NMS / reflection, but when it comes to the ChunkGenerator, I'm stuck.

    I'm using this chunk generator for the 1.8 base plugin (I want the plugin to be 1.8 and above):

    Code:
    package com.tarcseh;
    
    import org.bukkit.World;
    import org.bukkit.generator.ChunkGenerator;
    import java.util.Random;
    
    public class VoidGenerator extends ChunkGenerator {
    @Override
    public byte[][] generateBlockSections(World world, Random random, int x, int z, BiomeGrid biomes) {
        return new byte[16][];}
    }
    
    This is just a simple void generator, but when I try this in for instance 1.16, it says that I'm missing a required method (generateChunkData).
    Code:
    Caused by: java.lang.UnsupportedOperationException: Custom generator com.tarcseh.VoidGenerator is missing required method generateChunkData
    
    What could I do to make this work, but at the same time, keep the plugin version independent?
     
  2. Online

    timtower Administrator Administrator Moderator

    @tarcseh Somewhere you are returning a new VoidGenerator
    Have multiple versions for that.
     
  3. Offline

    tarcseh

    Thanks for the reply! Yes, I should get the server's version and I should switch the VoidGenerator's class based on the server's version. I'll try, thanks!
     
Thread Status:
Not open for further replies.

Share This Page