Placer

Generate Minecraft worlds by map images!

  1. Basic Placer
  2. Noise Placer
  3. Registering Block Placer Types

Block placer place blocks within the defined Layer. In most cases, you can also replace the Basic Placer codec directly with its block.

Basic Placer

Always places the same Block:

{
    "type": "ctgen:basic_placer",
    "value": "minecraft:grass_block"
}

Or in Java:

BlockPlacer grassPlacer = new BasicPlacer(Blocks.GRASS_BLOCK);

Noise Placer

Places a Block by checking a defined noise and it’s thresholds. A block will be placed if the calculated noise value is higher than the threshold value.

{
  "type": "ctgen:noise_placer",
  "is_2d": false,
  "noise": {
    "octaves": [
      {
        "frequency": 1,
        "amplitude": 1
      }
    ],
    "persistence": 1.0,
    "stretch": 1,
    "stretch_y": 1
  },
  "default": "minecraft:brown_concrete",
  "values": {
    "-0.5": "minecraft:orange_concrete",
    "0.0": "minecraft:red_concrete"
  }
}
  • is_2d - whether a 2D or 3D version of SimplexNoise should be applied
  • noise - a noise codec
    • octaves - the octaves for the SimplexNoise. Will be applied in the specified order
    • persistence - multiplies the amplitude for each octave
    • stretch - stretch the noise in x and z direction
    • stretch_y - stretch the noise in y direction
  • default - block that will be placed if the noise value is not inbound of any threshold
  • values - map where thresholds are mapped to blocks. Each threshold

Or in Java:

BlockPlacer concretePlacer = new NoisePlacer(new Noise(List.of(1f), 1D, 1, 1), Map.of(-0.5D, Blocks.ORANGE_CONCRETE, 0D, Blocks.RED_CONCRETE), false);

Registering Block Placer Types

You can also register a custom block placer using code similar to this one:

public class BasicPlacer extends BlockPlacer {
  @NotNull
  private final Block value;

  public BasicPlacer(@NotNull Block value) {
    this.value = value;
  }

  public @NotNull Block get(SimplexNoise noise, double x, double y, double z, double surfaceHeight, String layer) {
    return value;
  }

  public @NotNull Block getValue() {
    return value;
  }

  public static final Codec<BasicPlacer> CODEC = RecordCodecBuilder.create(instance -> instance.group(
          Codecs.BLOCK.fieldOf("value").forGetter(o -> o.value)
  ).apply(instance, instance.stable(BasicPlacer::new)));

  public static final ResourceLocation ID = new ResourceLocation(YourMod.MODID, "basic_placer");

  @Override
  protected Codec<BasicPlacer> codec() {
    return CODEC;
  }
}

To register the layer, just use this snippet:

CTRegistries.BLOCK_PLACER.register(BasicPlacer.ID, BasicPlacer.CODEC);

Continue with Terrain Height