|
| 1 | +--- a/net/minecraft/world/level/levelgen/DensityFunctions.java 2025-12-07 14:45:36.109273548 +0100 |
| 2 | ++++ /home/user/github/minecraft-decomp/client/src/main/java/a/net/minecraft/world/level/levelgen/DensityFunctions.java 2025-12-07 14:40:57.849212137 +0100 |
| 3 | +@@ -72,6 +72,7 @@ |
| 4 | + register(registry, "spline", DensityFunctions.Spline.CODEC); |
| 5 | + register(registry, "constant", DensityFunctions.Constant.CODEC); |
| 6 | + register(registry, "y_clamped_gradient", DensityFunctions.YClampedGradient.CODEC); |
| 7 | ++ register(registry, "maze_wall", DensityFunctions.MazeWall.CODEC); |
| 8 | + return register(registry, "find_top_surface", DensityFunctions.FindTopSurface.CODEC); |
| 9 | + } |
| 10 | + |
| 11 | +@@ -280,6 +281,10 @@ |
| 12 | + return new DensityFunctions.FindTopSurface(density, upperBound, lowerBound, stepSize); |
| 13 | + } |
| 14 | + |
| 15 | ++ public static DensityFunction mazeWall(final int cellSize, final int wallThickness, final int wallHeight) { |
| 16 | ++ return new DensityFunctions.MazeWall(cellSize, wallThickness, wallHeight); |
| 17 | ++ } |
| 18 | ++ |
| 19 | + private record Ap2( |
| 20 | + DensityFunctions.TwoArgumentSimpleFunction.Type type, DensityFunction argument1, DensityFunction argument2, double minValue, double maxValue |
| 21 | + ) implements DensityFunctions.TwoArgumentSimpleFunction { |
| 22 | +@@ -1391,6 +1396,85 @@ |
| 23 | + } |
| 24 | + } |
| 25 | + |
| 26 | ++ protected record MazeWall(int cellSize, int wallThickness, int wallHeight) implements DensityFunction.SimpleFunction { |
| 27 | ++ private static final MapCodec<DensityFunctions.MazeWall> DATA_CODEC = RecordCodecBuilder.mapCodec( |
| 28 | ++ i -> i.group( |
| 29 | ++ Codec.INT.fieldOf("cell_size").forGetter(DensityFunctions.MazeWall::cellSize), |
| 30 | ++ Codec.INT.fieldOf("wall_thickness").forGetter(DensityFunctions.MazeWall::wallThickness), |
| 31 | ++ Codec.INT.fieldOf("wall_height").forGetter(DensityFunctions.MazeWall::wallHeight) |
| 32 | ++ ) |
| 33 | ++ .apply(i, DensityFunctions.MazeWall::new) |
| 34 | ++ ); |
| 35 | ++ public static final KeyDispatchDataCodec<DensityFunctions.MazeWall> CODEC = DensityFunctions.makeCodec(DATA_CODEC); |
| 36 | ++ |
| 37 | ++ private long hash(final long x, final long z) { |
| 38 | ++ long h = x * 3129871L ^ z * 116129781L; |
| 39 | ++ h = h * h * 42317861L + h * 11L; |
| 40 | ++ return h; |
| 41 | ++ } |
| 42 | ++ |
| 43 | ++ private boolean hasOpening(final int cellX, final int cellZ, final int dir) { |
| 44 | ++ long h = hash(cellX, cellZ); |
| 45 | ++ return ((h >> dir) & 1L) == 0L; |
| 46 | ++ } |
| 47 | ++ |
| 48 | ++ @Override |
| 49 | ++ public double compute(final DensityFunction.FunctionContext context) { |
| 50 | ++ int x = context.blockX(); |
| 51 | ++ int y = context.blockY(); |
| 52 | ++ int z = context.blockZ(); |
| 53 | ++ |
| 54 | ++ if (y < 64) return 1.0; |
| 55 | ++ if (y >= 64 + this.wallHeight) return -1.0; |
| 56 | ++ |
| 57 | ++ int localX = Math.floorMod(x, this.cellSize); |
| 58 | ++ int localZ = Math.floorMod(z, this.cellSize); |
| 59 | ++ int cellX = Math.floorDiv(x, this.cellSize); |
| 60 | ++ int cellZ = Math.floorDiv(z, this.cellSize); |
| 61 | ++ |
| 62 | ++ boolean onWallX = localX < this.wallThickness; |
| 63 | ++ boolean onWallZ = localZ < this.wallThickness; |
| 64 | ++ |
| 65 | ++ if (!onWallX && !onWallZ) return -1.0; |
| 66 | ++ |
| 67 | ++ if (onWallX && onWallZ) return 1.0; |
| 68 | ++ |
| 69 | ++ int pathStart = this.wallThickness; |
| 70 | ++ int pathEnd = this.cellSize - this.wallThickness; |
| 71 | ++ int pathMid = (pathStart + pathEnd) / 2; |
| 72 | ++ int openingHalf = (pathEnd - pathStart) / 3; |
| 73 | ++ |
| 74 | ++ if (onWallX) { |
| 75 | ++ if (localZ >= pathMid - openingHalf && localZ <= pathMid + openingHalf) { |
| 76 | ++ if (hasOpening(cellX, cellZ, 0)) return -1.0; |
| 77 | ++ } |
| 78 | ++ } |
| 79 | ++ |
| 80 | ++ if (onWallZ) { |
| 81 | ++ if (localX >= pathMid - openingHalf && localX <= pathMid + openingHalf) { |
| 82 | ++ if (hasOpening(cellX, cellZ, 1)) return -1.0; |
| 83 | ++ } |
| 84 | ++ } |
| 85 | ++ |
| 86 | ++ return 1.0; |
| 87 | ++ } |
| 88 | ++ |
| 89 | ++ @Override |
| 90 | ++ public double minValue() { |
| 91 | ++ return -1.0; |
| 92 | ++ } |
| 93 | ++ |
| 94 | ++ @Override |
| 95 | ++ public double maxValue() { |
| 96 | ++ return 1.0; |
| 97 | ++ } |
| 98 | ++ |
| 99 | ++ @Override |
| 100 | ++ public KeyDispatchDataCodec<? extends DensityFunction> codec() { |
| 101 | ++ return CODEC; |
| 102 | ++ } |
| 103 | ++ } |
| 104 | ++ |
| 105 | + private record YClampedGradient(int fromY, int toY, double fromValue, double toValue) implements DensityFunction.SimpleFunction { |
| 106 | + private static final MapCodec<DensityFunctions.YClampedGradient> DATA_CODEC = RecordCodecBuilder.mapCodec( |
| 107 | + i -> i.group( |
| 108 | +--- a/net/minecraft/world/level/levelgen/RandomState.java 2025-12-07 14:45:36.108581661 +0100 |
| 109 | ++++ /home/user/github/minecraft-decomp/client/src/main/java/a/net/minecraft/world/level/levelgen/RandomState.java 2025-12-07 14:28:09.234229820 +0100 |
| 110 | +@@ -94,7 +94,8 @@ |
| 111 | + } |
| 112 | + } |
| 113 | + |
| 114 | +- this.router = settings.noiseRouter().mapAll(new NoiseWiringHelper()); |
| 115 | ++ NoiseRouter baseRouter = settings.noiseRouter().mapAll(new NoiseWiringHelper()); |
| 116 | ++ this.router = wrapMaze(baseRouter); |
| 117 | + DensityFunction.Visitor noiseFlattener = new DensityFunction.Visitor() { |
| 118 | + private final Map<DensityFunction, DensityFunction> wrapped = new HashMap<>(); |
| 119 | + |
| 120 | +@@ -149,4 +150,25 @@ |
| 121 | + public PositionalRandomFactory oreRandom() { |
| 122 | + return this.oreRandom; |
| 123 | + } |
| 124 | ++ |
| 125 | ++ private static NoiseRouter wrapMaze(final NoiseRouter router) { |
| 126 | ++ DensityFunction maze = DensityFunctions.mazeWall(32, 2, 20); |
| 127 | ++ return new NoiseRouter( |
| 128 | ++ router.barrierNoise(), |
| 129 | ++ router.fluidLevelFloodednessNoise(), |
| 130 | ++ router.fluidLevelSpreadNoise(), |
| 131 | ++ router.lavaNoise(), |
| 132 | ++ router.temperature(), |
| 133 | ++ router.vegetation(), |
| 134 | ++ router.continents(), |
| 135 | ++ router.erosion(), |
| 136 | ++ router.depth(), |
| 137 | ++ router.ridges(), |
| 138 | ++ router.preliminarySurfaceLevel(), |
| 139 | ++ maze, |
| 140 | ++ router.veinToggle(), |
| 141 | ++ router.veinRidged(), |
| 142 | ++ router.veinGap() |
| 143 | ++ ); |
| 144 | ++ } |
| 145 | + } |
0 commit comments