From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Byteflux Date: Wed, 2 Mar 2016 02:17:54 -0600 Subject: [PATCH] Generator Settings diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { private void perPlayerMobSpawns() { perPlayerMobSpawns = getBoolean("per-player-mob-spawns", false); } + + public boolean generateFlatBedrock; + private void generatorSettings() { + generateFlatBedrock = getBoolean("generator-settings.flat-bedrock", false); + } } diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java @@ -0,0 +0,0 @@ import org.apache.logging.log4j.LogManager; public interface ChunkAccess extends BlockGetter, FeatureAccess { + // Paper start + default boolean generateFlatBedrock() { + if (this instanceof ProtoChunk) { + return ((ProtoChunk)this).world.paperConfig.generateFlatBedrock; + } else if (this instanceof LevelChunk) { + return ((LevelChunk)this).world.paperConfig.generateFlatBedrock; + } else { + return false; + } + } + // Paper end + BlockState getType(final int x, final int y, final int z); // Paper @Nullable BlockState setBlockState(BlockPos pos, BlockState state, boolean moved); diff --git a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java @@ -0,0 +0,0 @@ public class ProtoChunk implements ChunkAccess { private long inhabitedTime; private final Map carvingMasks; private volatile boolean isLightCorrect; - private final Level world; // Paper - Anti-Xray - Add world + final Level world; // Paper - Anti-Xray - Add world // Paper - private -> default // Paper start - Anti-Xray - Add world @Deprecated public ProtoChunk(ChunkPos pos, UpgradeData upgradeData) { this(pos, upgradeData, null); } // Notice for updates: Please make sure this constructor isn't used anywhere diff --git a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java +++ b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java @@ -0,0 +0,0 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { int i = chunk.getPos().getMinBlockX(); int j = chunk.getPos().getMinBlockZ(); NoiseGeneratorSettings generatorsettingbase = (NoiseGeneratorSettings) this.settings.get(); - int k = generatorsettingbase.getBedrockFloorPosition(); - int l = this.height - 1 - generatorsettingbase.getBedrockRoofPosition(); + int k = generatorsettingbase.getBedrockFloorPosition(); final int floorHeight = k; // Paper + int l = this.height - 1 - generatorsettingbase.getBedrockRoofPosition(); final int roofHeight = l; // Paper boolean flag = true; boolean flag1 = l + 4 >= 0 && l < this.height; boolean flag2 = k + 4 >= 0 && k < this.height; @@ -0,0 +0,0 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { if (flag1) { for (i1 = 0; i1 < 5; ++i1) { - if (i1 <= random.nextInt(5)) { + if (i1 <= (chunk.generateFlatBedrock() ? roofHeight : random.nextInt(5))) { // Paper - Configurable flat bedrock roof chunk.setBlockState(blockposition_mutableblockposition.set(blockposition.getX(), l - i1, blockposition.getZ()), Blocks.BEDROCK.defaultBlockState(), false); } } @@ -0,0 +0,0 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { if (flag2) { for (i1 = 4; i1 >= 0; --i1) { - if (i1 <= random.nextInt(5)) { + if (i1 <= (chunk.generateFlatBedrock() ? floorHeight : random.nextInt(5))) { // Paper - Configurable flat bedrock floor chunk.setBlockState(blockposition_mutableblockposition.set(blockposition.getX(), k + i1, blockposition.getZ()), Blocks.BEDROCK.defaultBlockState(), false); } }