Fixes
This commit is contained in:
parent
f7b1f6baff
commit
20f93cc9a4
7 changed files with 69 additions and 68 deletions
|
@ -23,7 +23,6 @@ import ru.betterend.registry.SoundRegistry;
|
|||
import ru.betterend.registry.StructureRegistry;
|
||||
import ru.betterend.util.Logger;
|
||||
import ru.betterend.world.generator.BetterEndBiomeSource;
|
||||
import ru.betterend.world.surface.DoubleBlockSurfaceBuilder;
|
||||
|
||||
public class BetterEnd implements ModInitializer {
|
||||
public static final String MOD_ID = "betterend";
|
||||
|
@ -33,7 +32,6 @@ public class BetterEnd implements ModInitializer {
|
|||
@Override
|
||||
public void onInitialize() {
|
||||
SoundRegistry.register();
|
||||
DoubleBlockSurfaceBuilder.register();
|
||||
ItemRegistry.register();
|
||||
BlockRegistry.register();
|
||||
BlockEntityRegistry.register();
|
||||
|
|
|
@ -32,12 +32,16 @@ public class BiomeRegistry {
|
|||
|
||||
private static Registry<Biome> biomeRegistry;
|
||||
|
||||
public static final EndBiome END = registerBiome(BiomeKeys.THE_END, BiomeType.LAND, true);
|
||||
public static final EndBiome END_BARRENS = registerBiome(BiomeKeys.END_BARRENS, BiomeType.VOID, true);
|
||||
public static final EndBiome END_HIGHLANDS = registerBiome(BiomeKeys.END_HIGHLANDS, BiomeType.LAND, false);
|
||||
public static final EndBiome END_MIDLANDS = registerBiome(BiomeKeys.END_MIDLANDS, BiomeType.LAND, false);
|
||||
public static final EndBiome SMALL_END_ISLANDS = registerBiome(BiomeKeys.SMALL_END_ISLANDS, BiomeType.VOID, true);
|
||||
// Vanilla Land
|
||||
public static final EndBiome END = registerBiome(BiomeKeys.THE_END, BiomeType.LAND, 1F);
|
||||
public static final EndBiome END_MIDLANDS = registerSubBiome(BiomeKeys.END_MIDLANDS, END, 0.5F);
|
||||
public static final EndBiome END_HIGHLANDS = registerSubBiome(BiomeKeys.END_HIGHLANDS, END, 0.5F);
|
||||
|
||||
// Vanilla Void
|
||||
public static final EndBiome END_BARRENS = registerBiome(BiomeKeys.END_BARRENS, BiomeType.VOID, 1F);
|
||||
public static final EndBiome SMALL_END_ISLANDS = registerBiome(BiomeKeys.SMALL_END_ISLANDS, BiomeType.VOID, 1);
|
||||
|
||||
// Better End Land
|
||||
public static final EndBiome FOGGY_MUSHROOMLAND = registerBiome(new BiomeFoggyMushroomland(), BiomeType.LAND);
|
||||
public static final EndBiome CHORUS_FOREST = registerBiome(new BiomeChorusForest(), BiomeType.LAND);
|
||||
public static final EndBiome DUST_WASTELANDS = registerBiome(new BiomeDustWastelands(), BiomeType.LAND);
|
||||
|
@ -60,7 +64,7 @@ public class BiomeRegistry {
|
|||
biomeRegistry.forEach((biome) -> {
|
||||
if (biome.getCategory() == Category.THEEND) {
|
||||
if (!MUTABLE.containsKey(biome) && !biomeRegistry.getId(biome).getNamespace().equals("minecraft")) {
|
||||
EndBiome endBiome = new EndBiome(biome);
|
||||
EndBiome endBiome = new EndBiome(biome, 1);
|
||||
LAND_BIOMES.addBiomeMutable(endBiome);
|
||||
KEYS.put(endBiome, biomeRegistry.getKey(biome).get());
|
||||
}
|
||||
|
@ -68,16 +72,24 @@ public class BiomeRegistry {
|
|||
});
|
||||
}
|
||||
|
||||
public static EndBiome registerBiome(RegistryKey<Biome> key, BiomeType type, boolean addToGen) {
|
||||
EndBiome endBiome = new EndBiome(BuiltinRegistries.BIOME.get(key));
|
||||
if (addToGen) addToPicker(endBiome, type);
|
||||
public static EndBiome registerBiome(RegistryKey<Biome> key, BiomeType type, float genChance) {
|
||||
return registerBiome(BuiltinRegistries.BIOME.get(key), type, genChance);
|
||||
}
|
||||
|
||||
public static EndBiome registerBiome(Biome biome, BiomeType type, float genChance) {
|
||||
EndBiome endBiome = new EndBiome(biome, genChance);
|
||||
addToPicker(endBiome, type);
|
||||
makeLink(endBiome);
|
||||
return endBiome;
|
||||
}
|
||||
|
||||
public static EndBiome registerBiome(Biome biome, BiomeType type) {
|
||||
EndBiome endBiome = new EndBiome(biome);
|
||||
addToPicker(endBiome, type);
|
||||
public static EndBiome registerSubBiome(RegistryKey<Biome> key, EndBiome parent, float genChance) {
|
||||
return registerSubBiome(BuiltinRegistries.BIOME.get(key), parent, genChance);
|
||||
}
|
||||
|
||||
public static EndBiome registerSubBiome(Biome biome, EndBiome parent, float genChance) {
|
||||
EndBiome endBiome = new EndBiome(biome, genChance);
|
||||
parent.addSubBiome(endBiome);
|
||||
makeLink(endBiome);
|
||||
return endBiome;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,10 @@ public class FeatureRegistry {
|
|||
if (id.getNamespace().equals("minecraft")) {
|
||||
String path = id.getPath();
|
||||
if (path.equals("end_highlands") || path.equals("end_midlands") || path.equals("small_end_islands")) {
|
||||
features.get(GenerationStep.Feature.VEGETAL_DECORATION.ordinal()).clear();
|
||||
int pos = GenerationStep.Feature.VEGETAL_DECORATION.ordinal();
|
||||
if (pos < features.size()) {
|
||||
features.get(pos).clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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