Skip to content

msmp-mc/basic-maze-world-generator

Basic Maze World Generator

Spigot plugin modifying the default Minecraft generation by replacing it by a maze.

Maze generated by this CLI App.

Usage

Put the plugin inside your plugins folder.

Start the server and stop it (it will stop by itself because an error occurs: the config was not set).

Go into config/BasicMazeWorldGenerator and create a new maze with the CLI App.

For example, run the command:

./maze-generator -s 100 -d 1 -o maze.txt -g 1

To generate a maze by 36x36 chunks with the difficulty 1 (hard). This maze will be stored in maze.txt. To understand how it works, just read the README in the repo of this project.

Edit now the config.yaml and change the path to the stored maze.

For example, this config;

maze:
  path: foo/bar/maze.txt
  ...

Is looking for the maze at this path foo/bar/maze.txt inside the config directory of the plugin. The "real" path will be: config/BasicMazeWorldGenerator/foo/bar/maze.txt.

Now, modify the file bukkit.yml at the root of your server. Add these lines at the bottom of the file:

worlds:
  YOUR_WORLD_NAME:
    generator: BasicMazeWorldGenerator

Don't forget to replace the YOUR_WORLD_NAME by the name of your world (by default it's world). Your world's name is the value inside the level-name in the server.properties file.

Docs

Config

The config is located at config/BasicMazeWorldGenerator/config.yml.

Currently, the default config is:

# The maze must be generated by the MazeGeneratorCLI
# Look at this repo for more information: https://github.com/msmp-mc/maze-generator-cli
maze:
  path: maze.txt
  coefficient:
    chest:
      # The coefficient of chest spawn is the number of wall without chest between two chests (on average)
      # For example: if the coefficient is 5, there will be 5 walls without chest between two chests -> C W W W W W C W W W W W C ...
      spawn: 10
      # The coefficient chest dist describes the quality of loot in the chest
      # For example: if the coefficient is 200, only tier-one chest will be generated in the first 200 blocks, the tier-two will be added after these 200 blocks, etc...
      dist: 200

Maze related

  • path: the path to the maze file (relative to the plugin's config directory)
  • coefficient: the coefficient of the maze
    • chest: the coefficient related to the chest placed in the maze
      • spawn: numbers of wall without chest between two chests (on average)
      • dist: describes the quality of loot in the chest

Generate a maze

To generate a maze, you must use the CLI App MazeGeneratorCLI.

This command:

./maze-generator -s 100 -d 1 -o maze.txt -g 1

will generate a maze for starting at (800;800) and ending at (-800;-800) blocks world with the difficulty 1 (hard). It will also have a hole in the external wall: the player will be able to go outside the maze (this is the exit). This maze will be stored in maze.txt and this is this file you must put inside the config folder.

You can also use replace -g 1 by -g x with x > 0 to generate a maze with x hole in the wall (or x exists).

More information about the CLI App in the repo of this project.

How to generate a maze with a specific size (in chunk)?

The size of the maze determines the size of the world.

When we specify a size of 100, it means that the maze will be 800x800 chunks, but why?

Let's go some simple math (never look inside these projects if you don't want to be scared by the math):

  • A cell in the maze is a chunk in the world
  • So, the cell is a square of 16x16 blocks
  • The maze is a grid of cells with walls
  • The maze is centered at (0;0)
  • These walls are included inside the cells' chunk
  • So, the size of the maze is the number of cells in the grid * 16
  • But why 16? Because a chunk is a square of 16x16 blocks
  • Thus, the maze start at (the number of cells in the grid * 16/2;the number of cells in the grid * 16/2) and finish at (-the number of cells in the grid * 16/2;-the number of cells in the grid * 16/2)
  • Why? Because we want the maze to be centered at (0;0), so we must shift it by half of its size, that's all

Okay, let's sum up:

  • To generate a maze starting at (x;x) and ending at (-x;-x), we must generate a maze with a size of x/8 chunks

Example:

  • We want a maze starting at (800;800) and ending at (-800;-800), so we must create a maze with a size of 800/8 = 100
  • We want a maze starting at (1000;1000) and ending at (-1000;-1000), so we must create a maze with a size of 1000/8 = 125

Technologies

  • Kotlin 1.8.21
  • MazeGeneratorCLI's file
  • Spigot for Minecraft 1.19.4