Skip to content

Commit

Permalink
Update VoidChunkGenerator to support not having to pass the registry …
Browse files Browse the repository at this point in the history
…data (#38)

QOL patch, only adds 2 constructors. Tested on 1.20.2
  • Loading branch information
avetharun authored Dec 7, 2023
1 parent 6719e00 commit 686f84d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/xyz/nucleoid/fantasy/util/VoidChunkGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.registry.entry.RegistryEntryList;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.server.MinecraftServer;
import net.minecraft.structure.StructureSet;
import net.minecraft.structure.StructureTemplateManager;
import net.minecraft.util.collection.Pool;
Expand Down Expand Up @@ -85,7 +86,7 @@ public CodecHolder<? extends DensityFunction> getCodecHolder() {
};

public static final MultiNoiseUtil.MultiNoiseSampler EMPTY_SAMPLER = new MultiNoiseUtil.MultiNoiseSampler(ZERO_DENSITY_FUNCTION, ZERO_DENSITY_FUNCTION, ZERO_DENSITY_FUNCTION, ZERO_DENSITY_FUNCTION, ZERO_DENSITY_FUNCTION, ZERO_DENSITY_FUNCTION, Collections.emptyList());

public VoidChunkGenerator(RegistryEntry<Biome> biome) {
super(new FixedBiomeSource(biome));
this.biome = biome;
Expand All @@ -104,10 +105,20 @@ public VoidChunkGenerator(Registry<Biome> biomeRegistry, RegistryKey<Biome> biom
this(biomeRegistry.getEntry(biome).get());
}

// Create an empty (void) world!
public VoidChunkGenerator(MinecraftServer server) {
this(RegistryEntry.of(server.getRegistryManager().get(RegistryKeys.BIOME).getEntry(0).get()));
}
// Create a world with a given Biome (as an ID)
public VoidChunkGenerator(MinecraftServer server, Identifier biome) {
this(RegistryEntry.of(server.getRegistryManager().get(RegistryKeys.BIOME).get(biome)));

}
@Override
protected Codec<? extends ChunkGenerator> getCodec() {
return CODEC;
}


@Override
public void carve(ChunkRegion chunkRegion, long seed, NoiseConfig noiseConfig, BiomeAccess world, StructureAccessor structureAccessor, Chunk chunk, GenerationStep.Carver carverStep) {
Expand Down

0 comments on commit 686f84d

Please sign in to comment.