|
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 |
| 1 | +--- a/net/minecraft/world/level/levelgen/DensityFunctions.java 2025-12-10 12:13:46.468496065 +0100 |
| 2 | ++++ b/net/minecraft/world/level/levelgen/DensityFunctions.java 2025-12-10 12:13:07.200959142 +0100 |
3 | 3 | @@ -72,6 +72,7 @@ |
4 | 4 | register(registry, "spline", DensityFunctions.Spline.CODEC); |
5 | 5 | register(registry, "constant", DensityFunctions.Constant.CODEC); |
|
12 | 12 | return new DensityFunctions.FindTopSurface(density, upperBound, lowerBound, stepSize); |
13 | 13 | } |
14 | 14 |
|
15 | | -+ public static DensityFunction mazeWall(final int cellSize, final int wallThickness, final int wallHeight) { |
16 | | -+ return new DensityFunctions.MazeWall(cellSize, wallThickness, wallHeight); |
| 15 | ++ public static DensityFunction mazeWall(final int cell, final int thick, final int height) { |
| 16 | ++ return new DensityFunctions.MazeWall(cell, thick, height); |
17 | 17 | + } |
18 | 18 | + |
19 | 19 | private record Ap2( |
20 | 20 | DensityFunctions.TwoArgumentSimpleFunction.Type type, DensityFunction argument1, DensityFunction argument2, double minValue, double maxValue |
21 | 21 | ) implements DensityFunctions.TwoArgumentSimpleFunction { |
22 | | -@@ -1391,6 +1396,85 @@ |
| 22 | +@@ -1391,6 +1396,113 @@ |
23 | 23 | } |
24 | 24 | } |
25 | 25 |
|
26 | | -+ protected record MazeWall(int cellSize, int wallThickness, int wallHeight) implements DensityFunction.SimpleFunction { |
| 26 | ++ protected record MazeWall(int cell, int thick, int height) implements DensityFunction.SimpleFunction { |
27 | 27 | + private static final MapCodec<DensityFunctions.MazeWall> DATA_CODEC = RecordCodecBuilder.mapCodec( |
28 | 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) |
| 29 | ++ Codec.INT.fieldOf("cell_size").forGetter(DensityFunctions.MazeWall::cell), |
| 30 | ++ Codec.INT.fieldOf("wall_thickness").forGetter(DensityFunctions.MazeWall::thick), |
| 31 | ++ Codec.INT.fieldOf("wall_height").forGetter(DensityFunctions.MazeWall::height) |
32 | 32 | + ) |
33 | 33 | + .apply(i, DensityFunctions.MazeWall::new) |
34 | 34 | + ); |
35 | 35 | + public static final KeyDispatchDataCodec<DensityFunctions.MazeWall> CODEC = DensityFunctions.makeCodec(DATA_CODEC); |
| 36 | ++ private static final int HILBERT_N = 4; |
| 37 | ++ private static final int HILBERT_SZ = 1 << HILBERT_N; |
| 38 | ++ private static final int[] DX = {-1, 1, 0, 0}; |
| 39 | ++ private static final int[] DZ = {0, 0, -1, 1}; |
| 40 | ++ |
| 41 | ++ private static int hilbertXy2d(final int n, final int x, final int y) { |
| 42 | ++ int rx, ry, s, d = 0; |
| 43 | ++ int cx = x, cy = y; |
| 44 | ++ for (s = n / 2; s > 0; s /= 2) { |
| 45 | ++ rx = (cx & s) > 0 ? 1 : 0; |
| 46 | ++ ry = (cy & s) > 0 ? 1 : 0; |
| 47 | ++ d += s * s * ((3 * rx) ^ ry); |
| 48 | ++ if (ry == 0) { |
| 49 | ++ if (rx == 1) { |
| 50 | ++ cx = s - 1 - cx; |
| 51 | ++ cy = s - 1 - cy; |
| 52 | ++ } |
| 53 | ++ int temp = cx; |
| 54 | ++ cx = cy; |
| 55 | ++ cy = temp; |
| 56 | ++ } |
| 57 | ++ } |
| 58 | ++ return d; |
| 59 | ++ } |
36 | 60 | + |
37 | | -+ private long hash(final long x, final long z) { |
38 | | -+ long h = x * 3129871L ^ z * 116129781L; |
| 61 | ++ private long hash(final long a, final long b, final long c) { |
| 62 | ++ long h = a * 3129871L ^ b * 116129781L ^ c * 982451653L; |
39 | 63 | + h = h * h * 42317861L + h * 11L; |
40 | 64 | + return h; |
41 | 65 | + } |
42 | 66 | + |
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 | | -+ } |
| 67 | ++ private int getConn(final int cx, final int cz) { |
| 68 | ++ int hx = Math.floorMod(cx, HILBERT_SZ); |
| 69 | ++ int hz = Math.floorMod(cz, HILBERT_SZ); |
| 70 | ++ int qx = Math.floorDiv(cx, HILBERT_SZ); |
| 71 | ++ int qz = Math.floorDiv(cz, HILBERT_SZ); |
| 72 | ++ int d = hilbertXy2d(HILBERT_SZ, hx, hz); |
| 73 | ++ int[] cand = new int[4]; |
| 74 | ++ int n = 0; |
| 75 | ++ for (int dir = 0; dir < 4; dir++) { |
| 76 | ++ int nx = hx + DX[dir]; |
| 77 | ++ int nz = hz + DZ[dir]; |
| 78 | ++ if (nx < 0 || nx >= HILBERT_SZ || nz < 0 || nz >= HILBERT_SZ) continue; |
| 79 | ++ int nd = hilbertXy2d(HILBERT_SZ, nx, nz); |
| 80 | ++ if (nd > d) cand[n++] = dir; |
78 | 81 | + } |
| 82 | ++ if (n == 0) return -1; |
| 83 | ++ long h = hash(cx, cz, qx * 31L + qz); |
| 84 | ++ return cand[(int) ((h & 0x7FFFFFFFL) % n)]; |
| 85 | ++ } |
79 | 86 | + |
80 | | -+ if (onWallZ) { |
81 | | -+ if (localX >= pathMid - openingHalf && localX <= pathMid + openingHalf) { |
82 | | -+ if (hasOpening(cellX, cellZ, 1)) return -1.0; |
83 | | -+ } |
84 | | -+ } |
| 87 | ++ private boolean isOpen(final int cx, final int cz, final int dir) { |
| 88 | ++ int conn = getConn(cx, cz); |
| 89 | ++ if (conn == dir) return true; |
| 90 | ++ int nx = cx + DX[dir]; |
| 91 | ++ int nz = cz + DZ[dir]; |
| 92 | ++ return getConn(nx, nz) == (dir ^ 1); |
| 93 | ++ } |
85 | 94 | + |
| 95 | ++ @Override |
| 96 | ++ public double compute(final DensityFunction.FunctionContext ctx) { |
| 97 | ++ int x = ctx.blockX(); |
| 98 | ++ int y = ctx.blockY(); |
| 99 | ++ int z = ctx.blockZ(); |
| 100 | ++ int floor = 64; |
| 101 | ++ if (y < floor) return 1.0; |
| 102 | ++ if (y >= floor + this.height) return -1.0; |
| 103 | ++ int stride = this.cell + this.thick; |
| 104 | ++ int lx = Math.floorMod(x, stride); |
| 105 | ++ int lz = Math.floorMod(z, stride); |
| 106 | ++ int cx = Math.floorDiv(x, stride); |
| 107 | ++ int cz = Math.floorDiv(z, stride); |
| 108 | ++ boolean wx = lx < this.thick; |
| 109 | ++ boolean wz = lz < this.thick; |
| 110 | ++ if (!wx && !wz) return -1.0; |
| 111 | ++ if (wx && wz) return 1.0; |
| 112 | ++ if (wx && lz >= this.thick && isOpen(cx, cz, 0)) return -1.0; |
| 113 | ++ if (wz && lx >= this.thick && isOpen(cx, cz, 2)) return -1.0; |
86 | 114 | + return 1.0; |
87 | 115 | + } |
88 | 116 | + |
|
105 | 133 | private record YClampedGradient(int fromY, int toY, double fromValue, double toValue) implements DensityFunction.SimpleFunction { |
106 | 134 | private static final MapCodec<DensityFunctions.YClampedGradient> DATA_CODEC = RecordCodecBuilder.mapCodec( |
107 | 135 | 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 |
| 136 | +--- a/net/minecraft/world/level/levelgen/RandomState.java 2025-12-10 12:13:46.467890698 +0100 |
| 137 | ++++ b/net/minecraft/world/level/levelgen/RandomState.java 2025-12-10 12:13:40.929849826 +0100 |
110 | 138 | @@ -94,7 +94,8 @@ |
111 | 139 | } |
112 | 140 | } |
113 | 141 |
|
114 | 142 | - this.router = settings.noiseRouter().mapAll(new NoiseWiringHelper()); |
115 | | -+ NoiseRouter baseRouter = settings.noiseRouter().mapAll(new NoiseWiringHelper()); |
116 | | -+ this.router = wrapMaze(baseRouter); |
| 143 | ++ NoiseRouter base = settings.noiseRouter().mapAll(new NoiseWiringHelper()); |
| 144 | ++ this.router = wrapMaze(base); |
117 | 145 | DensityFunction.Visitor noiseFlattener = new DensityFunction.Visitor() { |
118 | 146 | private final Map<DensityFunction, DensityFunction> wrapped = new HashMap<>(); |
119 | 147 |
|
|
122 | 150 | return this.oreRandom; |
123 | 151 | } |
124 | 152 | + |
125 | | -+ private static NoiseRouter wrapMaze(final NoiseRouter router) { |
126 | | -+ DensityFunction maze = DensityFunctions.mazeWall(32, 2, 20); |
| 153 | ++ private static NoiseRouter wrapMaze(final NoiseRouter r) { |
| 154 | ++ DensityFunction maze = DensityFunctions.mazeWall(8, 4, 100); |
127 | 155 | + 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(), |
| 156 | ++ r.barrierNoise(), |
| 157 | ++ r.fluidLevelFloodednessNoise(), |
| 158 | ++ r.fluidLevelSpreadNoise(), |
| 159 | ++ r.lavaNoise(), |
| 160 | ++ r.temperature(), |
| 161 | ++ r.vegetation(), |
| 162 | ++ r.continents(), |
| 163 | ++ r.erosion(), |
| 164 | ++ r.depth(), |
| 165 | ++ r.ridges(), |
| 166 | ++ r.preliminarySurfaceLevel(), |
139 | 167 | + maze, |
140 | | -+ router.veinToggle(), |
141 | | -+ router.veinRidged(), |
142 | | -+ router.veinGap() |
| 168 | ++ r.veinToggle(), |
| 169 | ++ r.veinRidged(), |
| 170 | ++ r.veinGap() |
143 | 171 | + ); |
144 | 172 | + } |
145 | 173 | } |
0 commit comments