Generator config
This commit is contained in:
parent
9a41dc8670
commit
078139a26f
5 changed files with 44 additions and 22 deletions
|
@ -27,6 +27,7 @@ import ru.betterend.registry.EndTags;
|
|||
import ru.betterend.util.BonemealUtil;
|
||||
import ru.betterend.util.Logger;
|
||||
import ru.betterend.world.generator.BetterEndBiomeSource;
|
||||
import ru.betterend.world.generator.TerrainGenerator;
|
||||
import ru.betterend.world.surface.SurfaceBuilders;
|
||||
|
||||
public class BetterEnd implements ModInitializer {
|
||||
|
@ -54,6 +55,7 @@ public class BetterEnd implements ModInitializer {
|
|||
EndStructures.register();
|
||||
Integrations.register();
|
||||
BonemealUtil.init();
|
||||
TerrainGenerator.init();
|
||||
|
||||
if (hasGuideBook()) {
|
||||
GuideBook.register();
|
||||
|
|
|
@ -13,11 +13,15 @@ public class Configs {
|
|||
public static final IdConfig ENTITY_CONFIG = new IdConfig("entities", (entityId, category) -> {
|
||||
return new ConfigKey(entityId.getNamespace(), category, entityId.getPath());
|
||||
});
|
||||
public static final IdConfig GENERATOR_CONFIG = new IdConfig("generator", (entityId, category) -> {
|
||||
return new ConfigKey(entityId.getNamespace(), category, entityId.getPath());
|
||||
});
|
||||
|
||||
public static void saveConfigs() {
|
||||
ITEM_CONFIG.saveChanges();
|
||||
BLOCK_CONFIG.saveChanges();
|
||||
BIOME_CONFIG.saveChanges();
|
||||
ENTITY_CONFIG.saveChanges();
|
||||
GENERATOR_CONFIG.saveChanges();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public abstract class NoiseChunkGeneratorMixin {
|
|||
|
||||
@Inject(method = "sampleNoiseColumn([DII)V", at = @At("HEAD"), cancellable = true, allow = 2)
|
||||
private void beSampleNoiseColumn(double[] buffer, int x, int z, CallbackInfo info) {
|
||||
if (settings.get().equals(ChunkGeneratorSettings.END)) {
|
||||
if (TerrainGenerator.useNewGenerator() && settings.get().equals(ChunkGeneratorSettings.END)) {
|
||||
if (TerrainGenerator.canGenerate(x, z)) {
|
||||
TerrainGenerator.fillTerrainDensity(buffer, x, z);
|
||||
info.cancel();
|
||||
|
|
|
@ -13,12 +13,14 @@ import net.minecraft.world.biome.Biome;
|
|||
import net.minecraft.world.biome.Biome.Category;
|
||||
import net.minecraft.world.biome.BiomeKeys;
|
||||
import net.minecraft.world.biome.source.BiomeSource;
|
||||
import net.minecraft.world.biome.source.TheEndBiomeSource;
|
||||
import net.minecraft.world.gen.ChunkRandom;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.EndBiomes;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.FeaturesHelper;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
|
||||
public class BetterEndBiomeSource extends BiomeSource {
|
||||
public static final Codec<BetterEndBiomeSource> CODEC = RecordCodecBuilder.create((instance) -> {
|
||||
|
@ -36,8 +38,6 @@ public class BetterEndBiomeSource extends BiomeSource {
|
|||
private BiomeMap mapLand;
|
||||
private BiomeMap mapVoid;
|
||||
private final long seed;
|
||||
private int preY = -1;
|
||||
boolean preLand = false;
|
||||
|
||||
public BetterEndBiomeSource(Registry<Biome> biomeRegistry, long seed) {
|
||||
super(getBiomes(biomeRegistry));
|
||||
|
@ -70,23 +70,25 @@ public class BetterEndBiomeSource extends BiomeSource {
|
|||
|
||||
@Override
|
||||
public Biome getBiomeForNoiseGen(int biomeX, int biomeY, int biomeZ) {
|
||||
boolean hasVoid = !TerrainGenerator.useNewGenerator() || !TerrainGenerator.noRingVoid();
|
||||
long i = (long) biomeX * (long) biomeX;
|
||||
long j = (long) biomeZ * (long) biomeZ;
|
||||
if (i + j <= 65536L) return this.centerBiome;
|
||||
if (hasVoid && i + j <= 65536L) return this.centerBiome;
|
||||
|
||||
if (biomeX == 0 && biomeZ == 0) {
|
||||
mapLand.clearCache();
|
||||
mapVoid.clearCache();
|
||||
}
|
||||
|
||||
if (TerrainGenerator.useNewGenerator()) {
|
||||
if (TerrainGenerator.isLand(biomeX, biomeZ)) {
|
||||
return mapLand.getBiome(biomeX << 2, biomeZ << 2).getActualBiome();
|
||||
}
|
||||
else {
|
||||
return mapVoid.getBiome(biomeX << 2, biomeZ << 2).getActualBiome();
|
||||
}
|
||||
|
||||
/*
|
||||
}
|
||||
else {
|
||||
float height = TheEndBiomeSource.getNoiseAt(noise, (biomeX >> 1) + 1, (biomeZ >> 1) + 1) + (float) SMALL_NOISE.eval(biomeX, biomeZ) * 5;
|
||||
|
||||
if (height > -20F && height < -5F) {
|
||||
|
@ -94,11 +96,8 @@ public class BetterEndBiomeSource extends BiomeSource {
|
|||
}
|
||||
|
||||
EndBiome endBiome = height < -10F ? mapVoid.getBiome(biomeX << 2, biomeZ << 2) : mapLand.getBiome(biomeX << 2, biomeZ << 2);
|
||||
if (biomeX == 0 && biomeZ == 0) {
|
||||
mapLand.clearCache();
|
||||
mapVoid.clearCache();
|
||||
return endBiome.getActualBiome();
|
||||
}
|
||||
return endBiome.getActualBiome();*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,8 @@ package ru.betterend.world.generator;
|
|||
import java.util.Random;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
import ru.betterend.config.Configs;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
|
@ -17,6 +19,13 @@ public class TerrainGenerator {
|
|||
private static IslandLayer smallIslands;
|
||||
private static OpenSimplexNoise noise1;
|
||||
private static OpenSimplexNoise noise2;
|
||||
private static boolean newGenerator;
|
||||
private static boolean noRingVoid;
|
||||
|
||||
public static void init() {
|
||||
newGenerator = Configs.GENERATOR_CONFIG.getBoolean(new Identifier("generator", "enabled"), "useNewGenerator", true);
|
||||
noRingVoid = Configs.GENERATOR_CONFIG.getBoolean(new Identifier("generator", "enabled"), "noRingVoid", false);
|
||||
}
|
||||
|
||||
public static void initNoise(long seed) {
|
||||
Random random = new Random(seed);
|
||||
|
@ -28,7 +37,15 @@ public class TerrainGenerator {
|
|||
}
|
||||
|
||||
public static boolean canGenerate(int x, int z) {
|
||||
return (long) x + (long) z > CENTER;
|
||||
return noRingVoid || (long) x + (long) z > CENTER;
|
||||
}
|
||||
|
||||
public static boolean noRingVoid() {
|
||||
return noRingVoid;
|
||||
}
|
||||
|
||||
public static boolean useNewGenerator() {
|
||||
return newGenerator;
|
||||
}
|
||||
|
||||
public static void fillTerrainDensity(double[] buffer, int x, int z) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue