Skip to content

Instantly share code, notes, and snippets.

@Deamon5550
Deamon5550 / WGenDocs.md
Last active July 7, 2022 07:55
Custom World Generation

What this document contains:

  • Overview of the World Generation Process
  • The process of creating a new World Generator
  • A list of not yet implemented features

The Generation Process

As you are probably aware each World is split into a number of Chunks (technically chunk columns) each one of which defines an area of the world which is 16x256x16 blocks (by default see below) and these chunks may be loaded in any order. It is therefore one of the primary requirements of any WorldGenerator that it must generate the world on a chunk-by-chunk basis without any requirement for a specific order.

The assumption as made above that each Chunk has a size of 16x256x16 however this is not always the case as other implementations could theoretically modify the structure and dimensions of chunks. At runtime the size of a chunk may be determined with Chunk.getBlockSize().

@Deamon5550
Deamon5550 / SchematicReader.java
Last active May 8, 2019 20:28
Schematic format analysis
package com.thevoxelbox.stats;
import com.thevoxelbox.stats.StatsGatherer.Schematic;
import org.jnbt.ByteArrayTag;
import org.jnbt.CompoundTag;
import org.jnbt.NBTInputStream;
import org.jnbt.ShortTag;
import org.jnbt.Tag;
import java.io.File;
#!/bin/bash
git log --pretty=format:'%s' --abbrev-commit $1 | sort | uniq > bd-$1-sorted
git log --pretty=format:'%s' --abbrev-commit $2 | sort | uniq > bd-$2-sorted
echo "writing hashes"
git log --pretty=format:'%h %s' --abbrev-commit $1 > bd-hashes
echo "" >> bd-hashes
git log --pretty=format:'%h %s' --abbrev-commit $2 >> bd-hashes
@Deamon5550
Deamon5550 / random_test.cc
Created October 6, 2017 00:15
SIMD Mersenne Twister
#include <chrono>
#include <ctime>
#include <random>
#include <ratio>
#include <cmath>
#include <cinttypes>
#include "boost/random.hpp"
#include <x86intrin.h>
package com.voxelgenesis.test.inject;
import com.voxelgenesis.injector.Inject;
import com.voxelgenesis.injector.Injector;
import com.voxelgenesis.test.TestTarget;
@Injector(TestTarget.class)
public class MixinTestTarget {
// This injection is replacing the value of the local assignment
@Deamon5550
Deamon5550 / goto.kt
Created March 27, 2017 17:00
Kotlin's lack of optimizations of gotos
fun main(args: Array<String>) {
val x = 10
val y = 9
if(x == 6) {
if(y == 6) {
println("a")
} else {
println("b")
}
} else {
@Deamon5550
Deamon5550 / gotos.kt
Created March 27, 2017 19:09
Kotlin Bytecode Issues
fun main(args: Array<String>) {
val x = 10
val y = 9
if(x == 6) {
if(y == 6) {
println("a")
} else {
println("b")
}
} else {
package net.minecraft.block.material;
public class Material {
public static final Material AIR = new MaterialTransparent(MapColor.AIR);
public static final Material GRASS = new Material(MapColor.GRASS);
public static final Material GROUND = new Material(MapColor.DIRT);
public static final Material WOOD = new Material(MapColor.WOOD).setBurning();
public static final Material ROCK = new Material(MapColor.STONE).setRequiresTool();
public static final Material IRON = new Material(MapColor.IRON).setRequiresTool();
import java.util.List;
import java.util.Random;
import javax.annotation.Nullable;
import net.minecraft.block.material.EnumPushReaction;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
Handles structures that are saved to disk. Certain structures
can take up large amounts of disk space for very large maps,
and the data for these structures is only needed while the
world around them is generating. Disabling saving of these structures
can save disk space and time during saves if your world is already
fully generated. Warning: disabling structure saving will break
the vanilla locate command.