diff --git a/src/main/java/ru/betterend/config/Configs.java b/src/main/java/ru/betterend/config/Configs.java index 7274b0c5..d6a32724 100644 --- a/src/main/java/ru/betterend/config/Configs.java +++ b/src/main/java/ru/betterend/config/Configs.java @@ -1,11 +1,17 @@ package ru.betterend.config; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import ru.betterend.BetterEnd; + public class Configs { public static final PathConfig ENTITY_CONFIG = new PathConfig("entities"); public static final PathConfig BLOCK_CONFIG = new PathConfig("blocks"); public static final PathConfig ITEM_CONFIG = new PathConfig("items"); public static final IdConfig BIOME_CONFIG = new EntryConfig("biomes"); public static final PathConfig GENERATOR_CONFIG = new PathConfig("generator"); + + @Environment(value = EnvType.CLIENT) public static final PathConfig CLENT_CONFIG = new PathConfig("client"); public static void saveConfigs() { @@ -14,6 +20,9 @@ public class Configs { BIOME_CONFIG.saveChanges(); ITEM_CONFIG.saveChanges(); GENERATOR_CONFIG.saveChanges(); - CLENT_CONFIG.saveChanges(); + + if (BetterEnd.isClient()) { + CLENT_CONFIG.saveChanges(); + } } } diff --git a/src/main/java/ru/betterend/world/generator/BetterEndBiomeSource.java b/src/main/java/ru/betterend/world/generator/BetterEndBiomeSource.java index a99d4c03..441d8ce2 100644 --- a/src/main/java/ru/betterend/world/generator/BetterEndBiomeSource.java +++ b/src/main/java/ru/betterend/world/generator/BetterEndBiomeSource.java @@ -42,8 +42,8 @@ public class BetterEndBiomeSource extends BiomeSource { public BetterEndBiomeSource(Registry biomeRegistry, long seed) { super(getBiomes(biomeRegistry)); - this.mapLand = new BiomeMap(seed, 256, EndBiomes.LAND_BIOMES); - this.mapVoid = new BiomeMap(seed, 256, EndBiomes.VOID_BIOMES); + this.mapLand = new BiomeMap(seed, GeneratorOptions.getBiomeSizeLand(), EndBiomes.LAND_BIOMES); + this.mapVoid = new BiomeMap(seed, GeneratorOptions.getBiomeSizeVoid(), EndBiomes.VOID_BIOMES); this.centerBiome = biomeRegistry.getOrThrow(BiomeKeys.THE_END); this.barrens = biomeRegistry.getOrThrow(BiomeKeys.END_BARRENS); this.biomeRegistry = biomeRegistry; diff --git a/src/main/java/ru/betterend/world/generator/BiomeMap.java b/src/main/java/ru/betterend/world/generator/BiomeMap.java index 450b162e..bcc73d85 100644 --- a/src/main/java/ru/betterend/world/generator/BiomeMap.java +++ b/src/main/java/ru/betterend/world/generator/BiomeMap.java @@ -1,6 +1,8 @@ package ru.betterend.world.generator; -import java.util.HashMap; +import java.util.Map; + +import com.google.common.collect.Maps; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.gen.ChunkRandom; @@ -8,11 +10,10 @@ import ru.betterend.noise.OpenSimplexNoise; import ru.betterend.util.MHelper; import ru.betterend.world.biome.EndBiome; -public class BiomeMap -{ +public class BiomeMap { private static final ChunkRandom RANDOM = new ChunkRandom(); - private final HashMap maps = new HashMap(); + private final Map maps = Maps.newHashMap(); private final int size; private final int sizeXZ; private final int depth; @@ -20,8 +21,7 @@ public class BiomeMap private final OpenSimplexNoise noiseZ; private final BiomePicker picker; - public BiomeMap(long seed, int size, BiomePicker picker) - { + public BiomeMap(long seed, int size, BiomePicker picker) { maps.clear(); RANDOM.setSeed(seed); noiseX = new OpenSimplexNoise(RANDOM.nextLong()); @@ -32,15 +32,13 @@ public class BiomeMap this.picker = picker; } - public void clearCache() - { + public void clearCache() { if (maps.size() > 32) { maps.clear(); } } - private EndBiome getRawBiome(int bx, int bz) - { + private EndBiome getRawBiome(int bx, int bz) { double x = (double) bx * size / sizeXZ; double z = (double) bz * size / sizeXZ; double nx = x; @@ -49,8 +47,7 @@ public class BiomeMap double px = bx * 0.2; double pz = bz * 0.2; - for (int i = 0; i < depth; i++) - { + for (int i = 0; i < depth; i++) { nx = (x + noiseX.eval(px, pz)) / 2F; nz = (z + noiseZ.eval(px, pz)) / 2F; @@ -72,8 +69,7 @@ public class BiomeMap ChunkPos cpos = new ChunkPos(MHelper.floor(x / BiomeChunk.WIDTH), MHelper.floor(z / BiomeChunk.WIDTH)); BiomeChunk chunk = maps.get(cpos); - if (chunk == null) - { + if (chunk == null) { RANDOM.setTerrainSeed(cpos.x, cpos.z); chunk = new BiomeChunk(this, RANDOM, picker); maps.put(cpos, chunk); @@ -82,15 +78,14 @@ public class BiomeMap return chunk.getBiome(MHelper.floor(x), MHelper.floor(z)); } - public EndBiome getBiome(int x, int z) - { + public EndBiome getBiome(int x, int z) { EndBiome biome = getRawBiome(x, z); - if (biome.hasEdge() || (biome.hasParentBiome() && biome.getParentBiome().hasEdge())) - { + if (biome.hasEdge() || (biome.hasParentBiome() && biome.getParentBiome().hasEdge())) { EndBiome search = biome; - if (biome.hasParentBiome()) + if (biome.hasParentBiome()) { search = biome.getParentBiome(); + } int d = (int) Math.ceil(search.getEdgeSize() / 4F) << 2; boolean edge = !search.isSame(getRawBiome(x + d, z)); @@ -102,8 +97,7 @@ public class BiomeMap edge = edge || !search.isSame(getRawBiome(x + 1, z - 1)); edge = edge || !search.isSame(getRawBiome(x + 1, z + 1)); - if (edge) - { + if (edge) { biome = search.getEdge(); } } diff --git a/src/main/java/ru/betterend/world/generator/GeneratorOptions.java b/src/main/java/ru/betterend/world/generator/GeneratorOptions.java new file mode 100644 index 00000000..fd6b1a8f --- /dev/null +++ b/src/main/java/ru/betterend/world/generator/GeneratorOptions.java @@ -0,0 +1,21 @@ +package ru.betterend.world.generator; + +import ru.betterend.config.Configs; + +public class GeneratorOptions { + private static int biomeSizeLand; + private static int biomeSizeVoid; + + public static void init() { + biomeSizeLand = Configs.GENERATOR_CONFIG.getIntRoot("biomeSizeLand", 256); + biomeSizeVoid = Configs.GENERATOR_CONFIG.getIntRoot("biomeSizeVoid", 256); + } + + public static int getBiomeSizeLand() { + return biomeSizeLand; + } + + public static int getBiomeSizeVoid() { + return biomeSizeVoid; + } +} diff --git a/src/main/java/ru/betterend/world/generator/TerrainGenerator.java b/src/main/java/ru/betterend/world/generator/TerrainGenerator.java index abe22eca..4f8c8e9a 100644 --- a/src/main/java/ru/betterend/world/generator/TerrainGenerator.java +++ b/src/main/java/ru/betterend/world/generator/TerrainGenerator.java @@ -22,8 +22,8 @@ public class TerrainGenerator { private static boolean noRingVoid; public static void init() { - newGenerator = Configs.GENERATOR_CONFIG.getBoolean("generator", "useNewGenerator", false); - noRingVoid = Configs.GENERATOR_CONFIG.getBoolean("generator", "noRingVoid", false); + newGenerator = Configs.GENERATOR_CONFIG.getBooleanRoot("useNewGenerator", false); + noRingVoid = Configs.GENERATOR_CONFIG.getBooleanRoot("noRingVoid", false); } public static void initNoise(long seed) {