BlockPopulator can't use Block functions

Discussion in 'Plugin Development' started by BruhMachine, Jun 26, 2019.

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

    BruhMachine

    I am making a custom world gen plugin, but don't know how to add to it if I can't even use BlockPopulator successfully. I am running spigot 1.14.3, not sure if that effects anything. It's not like it doesn't work, I just can't load the world outright. Without the blockpopulator it does fine.
    maingeneratorcode (open)

    Code:
    public class MainGenerator extends ChunkGenerator{
        int currentHeight = 60;
        @Override
        public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biome) {
            SimplexOctaveGenerator generator = new SimplexOctaveGenerator(new Random(world.getSeed()), 8);
            ChunkData chunk = createChunkData(world);
            generator.setScale(0.005D);
    
            for (int X = 0; X < 16; X++)
                for (int Z = 0; Z < 16; Z++) {
                    currentHeight = (int) (generator.noise(chunkX*16+X, chunkZ*16+Z, 0.5D, 0.5D)*15D+50D);
                    chunk.setBlock(X, currentHeight, Z, Material.SAND);
                    chunk.setBlock(X, currentHeight-1, Z, Material.SANDSTONE);
                    for (int i = currentHeight-2; i > 0; i--)
                        chunk.setBlock(X, i, Z, Material.STONE);
                    chunk.setBlock(X, 0, Z, Material.BEDROCK);
                }
            return chunk;
        }
        @Override
        public List<BlockPopulator> getDefaultPopulators(World world) {
            return Arrays.asList(new DeadBushPopulator());
        }
    }
    

    And before you ask, I do have getDefaultWorldGenerator set in Main
    blockpopulatorcode (open)

    Code:
    public class DeadBushPopulator extends BlockPopulator {
        @Override
        public void populate(World world, Random random, Chunk chunk) {
            int cX = chunk.getX() * 16;
            int cY = chunk.getZ() * 16;
            int cZOff = cX + random.nextInt(15);
            int cXOff = cY + random.nextInt(15);
            new Location(world, cXOff, world.getHighestBlockYAt(cXOff, cZOff)+1, cZOff).getBlock().setType(Material.DEAD_BUSH);
        }
    }
     
Thread Status:
Not open for further replies.

Share This Page