Skip to content

PaperMC plugin to generate trees or structures using L-systems.

Notifications You must be signed in to change notification settings

fishydarwin/LSysTree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LSysTree

A PaperMC plugin for generating L-system fractal trees in Minecraft.
How does this work?

Example

The plugin uses custom .tree files and a 3D turtle graphics implementation, alongside instructions, to generate Lindenmayer system trees from a set of axioms, rules, and reiteration.

.tree files

Here's an example .tree file for a Japanese Maple tree.

atoms:
    M:
    - material(stripped_dark_oak_wood)
    A:
    - translate(0, sub($n, $sd), 0)
    B:
    - translate(mul(sub(add($n, 6), $sd), random(-1, 1)), sub(add($n, 1), $sd), mul(sub(add($n, 6), $sd), random(-1, 1)))
    - rotate_xz($lx, $ly, $lz, random(0, 360))
    X:
    - line_width(add(div($n, mul(add($sd, 1), 2.5)), 0.5))
    Y:
    - line_width(add(div($n, mul(add($sd, 1), 2)), 0.5))
    L:
    - translate(0, 1.15, 0)
    - cylinder(add(sub(add($n, 3), $sd), 3), sub($sd, 2), 5%pink_stained_glass;30%red_stained_glass;65%air)
    - translate(0, 1, 0)
    - cylinder(add(sub(add($n, 3), $sd), 3), sub($sd, 2), 5%pink_stained_glass;30%red_stained_glass;65%air)
    - translate(0, -1, 0)
    S:
    - line_width(add(div($n, mul(add($sd, 1), 1.5)), 0.5))
    - translate(0, add($n, 5), 0)
    - translate(0, -2, 0)

predicates:
    A: XALYBL[XALYBL][XALYBL]YBBL
    B: YBLX[AL[AL]YBLX][YBLXAL]
    M: M
    X: X
    Y: Y
    L: ''
    S: S

axiom: 'MSY[A][A]'

The language is parsed using YAML configuration structure. It requires 3 sections:

  • Atoms - what each letter in the axiom and predicates mean (e.g. M stands for the instruction material(stripped_dark_oak_wood)
  • Predicates - what to replace each letter with in every new iteration (e.g. every A we encounter, we replace with XALYBL[XALYBL][XALYBL]YBBL
  • Axiom - the initial rule (iteration n = 0)

Installation

Build the plugin first using mvn clean install.
Then, the resulting .jar in target should be placed inside your server's files.

To add more trees, add them in the folder path /plugins/LSysTree.

Usage

Use a bone item in-game to access the tree tool.
First, you must load a .tree file using /lsysload (filename).

Next, you left-click a block to set the position of the tree.
Every time you press right-click, the next iteration is executed.

You can sneak + click to undo & reset the tree.

About

PaperMC plugin to generate trees or structures using L-systems.

Resources

Stars

Watchers

Forks

Languages