Fixes
This commit is contained in:
parent
f7b1f6baff
commit
20f93cc9a4
7 changed files with 69 additions and 68 deletions
|
@ -61,27 +61,22 @@ public class BiomeDefinition {
|
|||
this.id = BetterEnd.makeID(name);
|
||||
}
|
||||
|
||||
public BiomeDefinition setSurface(Block surfaceBlock) {
|
||||
this.surface = SurfaceBuilder.DEFAULT.withConfig(new TernarySurfaceConfig(
|
||||
surfaceBlock.getDefaultState(),
|
||||
public BiomeDefinition setSurface(Block block) {
|
||||
setSurface(SurfaceBuilder.DEFAULT.withConfig(new TernarySurfaceConfig(
|
||||
block.getDefaultState(),
|
||||
Blocks.END_STONE.getDefaultState(),
|
||||
Blocks.END_STONE.getDefaultState()
|
||||
));
|
||||
)));
|
||||
return this;
|
||||
}
|
||||
|
||||
public BiomeDefinition setSurface(Block surfaceBlock1, Block surfaceBlock2) {
|
||||
this.surface = DoubleBlockSurfaceBuilder.INSTANCE.setConfigUpper(new TernarySurfaceConfig(
|
||||
surfaceBlock1.getDefaultState(),
|
||||
Blocks.END_STONE.getDefaultState(),
|
||||
Blocks.END_STONE.getDefaultState()
|
||||
)).setConfigLower(new TernarySurfaceConfig(
|
||||
surfaceBlock2.getDefaultState(),
|
||||
Blocks.END_STONE.getDefaultState(),
|
||||
Blocks.END_STONE.getDefaultState()
|
||||
)).withConfig(new TernarySurfaceConfig(surfaceBlock1.getDefaultState(),
|
||||
Blocks.END_STONE.getDefaultState(),
|
||||
Blocks.END_STONE.getDefaultState()));
|
||||
public BiomeDefinition setSurface(Block block1, Block block2) {
|
||||
setSurface(DoubleBlockSurfaceBuilder.register("be_" + id.getPath() + "_surface").setBlock1(block1).setBlock2(block2).configured());
|
||||
return this;
|
||||
}
|
||||
|
||||
public BiomeDefinition setSurface(ConfiguredSurfaceBuilder<?> builder) {
|
||||
this.surface = builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import net.minecraft.world.WorldAccess;
|
|||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public class EndBiome {
|
||||
protected List<Subbiome> subbiomes = Lists.newArrayList();
|
||||
protected List<EndBiome> subbiomes = Lists.newArrayList();
|
||||
|
||||
protected final Biome biome;
|
||||
protected final Identifier mcID;
|
||||
|
@ -33,11 +33,11 @@ public class EndBiome {
|
|||
genChanceUnmutable = definition.getGenChance();
|
||||
}
|
||||
|
||||
public EndBiome(Biome biome) {
|
||||
public EndBiome(Biome biome, float genChance) {
|
||||
this.biome = biome;
|
||||
mcID = BuiltinRegistries.BIOME.getId(biome);
|
||||
fogDensity = 1;
|
||||
genChanceUnmutable = 1;
|
||||
genChanceUnmutable = genChance;
|
||||
}
|
||||
|
||||
public void genSurfColumn(WorldAccess world, BlockPos pos, Random random) {
|
||||
|
@ -60,17 +60,17 @@ public class EndBiome {
|
|||
edgeSize = size;
|
||||
}
|
||||
|
||||
public void addSubBiome(EndBiome biome, float chance) {
|
||||
maxSubBiomeChance += chance;
|
||||
public void addSubBiome(EndBiome biome) {
|
||||
maxSubBiomeChance += biome.mutateGenChance(maxSubBiomeChance);
|
||||
biome.biomeParent = this;
|
||||
subbiomes.add(new Subbiome(biome, maxSubBiomeChance));
|
||||
subbiomes.add(biome);
|
||||
}
|
||||
|
||||
public EndBiome getSubBiome(Random random) {
|
||||
float chance = random.nextFloat() * maxSubBiomeChance;
|
||||
for (Subbiome biome : subbiomes)
|
||||
for (EndBiome biome : subbiomes)
|
||||
if (biome.canGenerate(chance))
|
||||
return biome.biome;
|
||||
return biome;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -90,25 +90,11 @@ public class EndBiome {
|
|||
return biome == this || (biome.hasParentBiome() && biome.getParentBiome() == this);
|
||||
}
|
||||
|
||||
protected final class Subbiome {
|
||||
EndBiome biome;
|
||||
float chance;
|
||||
|
||||
Subbiome(EndBiome biome, float chance) {
|
||||
this.biome = biome;
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
public boolean canGenerate(float chance) {
|
||||
return chance < this.chance;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canGenerate(float chance) {
|
||||
return chance <= this.genChance;
|
||||
}
|
||||
|
||||
public float setGenChance(float chance) {
|
||||
public float mutateGenChance(float chance) {
|
||||
genChance = genChanceUnmutable;
|
||||
genChance += chance;
|
||||
return genChance;
|
||||
|
|
|
@ -16,14 +16,14 @@ public class BiomePicker {
|
|||
|
||||
public void addBiome(EndBiome biome) {
|
||||
biomes.add(biome);
|
||||
maxChance = biome.setGenChance(maxChance);
|
||||
maxChance = biome.mutateGenChance(maxChance);
|
||||
biomeCount ++;
|
||||
maxChanceUnmutable = maxChance;
|
||||
}
|
||||
|
||||
public void addBiomeMutable(EndBiome biome) {
|
||||
biomes.add(biome);
|
||||
maxChance = biome.setGenChance(maxChance);
|
||||
maxChance = biome.mutateGenChance(maxChance);
|
||||
}
|
||||
|
||||
public void clearMutables() {
|
||||
|
|
|
@ -2,34 +2,36 @@ package ru.betterend.world.surface;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.surfacebuilder.ConfiguredSurfaceBuilder;
|
||||
import net.minecraft.world.gen.surfacebuilder.SurfaceBuilder;
|
||||
import net.minecraft.world.gen.surfacebuilder.TernarySurfaceConfig;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class DoubleBlockSurfaceBuilder extends SurfaceBuilder<TernarySurfaceConfig> {
|
||||
public static final DoubleBlockSurfaceBuilder INSTANCE = new DoubleBlockSurfaceBuilder(TernarySurfaceConfig.CODEC);
|
||||
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(4141);
|
||||
private TernarySurfaceConfig config1;
|
||||
private TernarySurfaceConfig config2;
|
||||
|
||||
public DoubleBlockSurfaceBuilder(Codec<TernarySurfaceConfig> codec) {
|
||||
super(codec);
|
||||
private DoubleBlockSurfaceBuilder() {
|
||||
super(TernarySurfaceConfig.CODEC);
|
||||
}
|
||||
|
||||
public DoubleBlockSurfaceBuilder setConfigUpper(TernarySurfaceConfig config) {
|
||||
config1 = config;
|
||||
public DoubleBlockSurfaceBuilder setBlock1(Block block) {
|
||||
BlockState stone = Blocks.END_STONE.getDefaultState();
|
||||
config1 = new TernarySurfaceConfig(block.getDefaultState(), stone, stone);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DoubleBlockSurfaceBuilder setConfigLower(TernarySurfaceConfig config) {
|
||||
config2 = config;
|
||||
public DoubleBlockSurfaceBuilder setBlock2(Block block) {
|
||||
BlockState stone = Blocks.END_STONE.getDefaultState();
|
||||
config2 = new TernarySurfaceConfig(block.getDefaultState(), stone, stone);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -39,7 +41,12 @@ public class DoubleBlockSurfaceBuilder extends SurfaceBuilder<TernarySurfaceConf
|
|||
SurfaceBuilder.DEFAULT.generate(random, chunk, biome, x, z, height, noise, defaultBlock, defaultFluid, seaLevel, seed, noise > 0 ? config1 : config2);
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
Registry.register(Registry.SURFACE_BUILDER, "double_block_surface_builder", INSTANCE);
|
||||
public static DoubleBlockSurfaceBuilder register(String name) {
|
||||
return Registry.register(Registry.SURFACE_BUILDER, name, new DoubleBlockSurfaceBuilder());
|
||||
}
|
||||
}
|
||||
|
||||
public ConfiguredSurfaceBuilder<TernarySurfaceConfig> configured() {
|
||||
BlockState stone = Blocks.END_STONE.getDefaultState();
|
||||
return this.withConfig(new TernarySurfaceConfig(config1.getTopMaterial(), stone, stone));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue