Skip to content

Commit

Permalink
Switch Luminous Grove surface generation to a surface builder.
Browse files Browse the repository at this point in the history
- Fix Luminous Grove surface generation when TerraBlender is present
  • Loading branch information
gniftygnome committed Sep 3, 2022
1 parent ed3a487 commit e781033
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 89 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public static void init() {
Blocks.MAGMA_BLOCK.getDefaultState(),
Blocks.LAVA.getDefaultState()
).setBiomeKey(CinderscapesBiomes.ASHY_SHOALS));

builders.add(new LuminousGroveSurfaceBuilder(
CinderscapesBlocks.UMBRAL_NYLIUM.getDefaultState(),
CinderscapesBlocks.UMBRAL_WART_BLOCK.getDefaultState(),
Blocks.NETHERRACK.getDefaultState()
).setBiomeKey(CinderscapesBiomes.LUMINOUS_GROVE));
}

public static ArrayList<CinderscapesSurfaceBuilder> getBuilders() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.terraformersmc.cinderscapes.surfacebuilders;

import net.minecraft.block.BlockState;
import net.minecraft.tag.BiomeTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.source.BiomeAccess;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.chunk.BlockColumn;
import net.minecraft.world.gen.random.AbstractRandom;

public class LuminousGroveSurfaceBuilder extends CinderscapesSurfaceBuilder {
private final BlockState topMaterial;
private final BlockState midMaterial;
private final BlockState lowMaterial;

public LuminousGroveSurfaceBuilder(BlockState topMaterial, BlockState midMaterial, BlockState lowMaterial) {
this.topMaterial = topMaterial;
this.midMaterial = midMaterial;
this.lowMaterial = lowMaterial;
}

@Override
public void generate(BiomeAccess biomeAccess, BlockColumn column, AbstractRandom rand, Chunk chunk, Biome biome, int x, int z, int vHeight, int seaLevel) {
BlockPos pos = new BlockPos(x, -128, z);
boolean inAir = false;

// Set in-biome netherrack
for (int y = chunk.getTopY() - 6; y >= seaLevel - 1; --y) {
BlockState state = column.getState(y);
if (state.isAir()) {
inAir = true;
} else {
if (inAir && state.isOf(lowMaterial.getBlock()) && biomeAccess.getBiome(pos.withY(y)).matchesKey(biomeKey)) {
column.setState(y, rand.nextFloat() < 0.99f ? topMaterial : midMaterial);
}
inAir = false;
}
}
}

@Override
public boolean filterBiome(RegistryEntry<Biome> biome) {
return biome.isIn(BiomeTags.IS_NETHER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class CinderscapesSurfaceRules {
MaterialRules.block(CinderscapesBlocks.UMBRAL_WART_BLOCK.getDefaultState())),
MaterialRules.block(CinderscapesBlocks.UMBRAL_NYLIUM.getDefaultState())))))));

// TODO: Actually ATM there are no active Cinderscapes surface rules. TerraBlender when present overwrites them.
// When we migrate to TerraBlender, consider whether to migrate back from surface builders to surface rules...
// At the moment, there's just Luminous Grove. To add another, wrap them in MaterialRules.sequence()
public static final MaterialRules.MaterialRule CINDERSCAPES_NETHER_RULES = LUMINOUS_GROVE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@ accessWidener v1 named

accessible class net/minecraft/world/gen/surfacebuilder/MaterialRules$BlockStateRule
accessible class net/minecraft/world/gen/surfacebuilder/MaterialRules$MaterialRuleContext
accessible class net/minecraft/world/gen/surfacebuilder/MaterialRules$BooleanSupplier
accessible method net/minecraft/world/gen/surfacebuilder/MaterialRules$MaterialRuleContext initVerticalContext (IIIIII)V
accessible field net/minecraft/world/gen/surfacebuilder/MaterialRules$MaterialRuleContext surfaceBuilder Lnet/minecraft/world/gen/surfacebuilder/SurfaceBuilder;
accessible method net/minecraft/world/gen/surfacebuilder/MaterialRules$MaterialRuleContext method_39551 ()I
accessible method net/minecraft/world/gen/surfacebuilder/SurfaceBuilder getNoiseSampler (Lnet/minecraft/util/registry/RegistryKey;)Lnet/minecraft/util/math/noise/DoublePerlinNoiseSampler;
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
"package": "com.terraformersmc.cinderscapes.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"ChunkGeneratorSettingsAccessor",
"MaterialRuleContextAccessor",
"MixinMinecraftServer",
"MixinNetherCaveCarver",
"MixinSurfaceBuilder",
"NoiseChunkGeneratorAccessor"
"MixinSurfaceBuilder"
],
"client": [
],
Expand Down

0 comments on commit e781033

Please sign in to comment.