This commit is contained in:
paulevsGitch 2020-10-24 16:47:30 +03:00
parent f7b1f6baff
commit 20f93cc9a4
7 changed files with 69 additions and 68 deletions

View file

@ -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;
}

View file

@ -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;