@@ -53,15 +53,15 @@ public CompletableFuture<Chunk> populateNoise(Blender blender, NoiseConfig noise
53
53
set .add (chunkSection );
54
54
}
55
55
56
- boolean var19 = false ;
56
+ boolean updatingChunk = false ;
57
57
58
- Chunk var21 ;
58
+ Chunk newChunk ;
59
59
try {
60
- var19 = true ;
61
- var21 = this .populateNoise (blender , structureAccessor , noiseConfig , chunk , j , k );
62
- var19 = false ;
60
+ updatingChunk = true ;
61
+ newChunk = this .populateNoise (blender , structureAccessor , noiseConfig , chunk , j , k );
62
+ updatingChunk = false ;
63
63
} finally {
64
- if (var19 ) {
64
+ if (updatingChunk ) {
65
65
for (ChunkSection chunkSection3 : set ) {
66
66
chunkSection3 .unlock ();
67
67
}
@@ -72,7 +72,7 @@ public CompletableFuture<Chunk> populateNoise(Blender blender, NoiseConfig noise
72
72
chunkSection2 .unlock ();
73
73
}
74
74
75
- return var21 ;
75
+ return newChunk ;
76
76
}, Util .getMainWorkerExecutor ().named ("wgen_fill_noise" ));
77
77
}
78
78
@@ -83,66 +83,63 @@ private Chunk populateNoise(Blender blender, StructureAccessor structureAccessor
83
83
Heightmap heightmap = chunk .getHeightmap (Heightmap .Type .OCEAN_FLOOR_WG );
84
84
Heightmap heightmap2 = chunk .getHeightmap (Heightmap .Type .WORLD_SURFACE_WG );
85
85
ChunkPos chunkPos = chunk .getPos ();
86
- int i = chunkPos .getStartX ();
87
- int j = chunkPos .getStartZ ();
86
+ int startX = chunkPos .getStartX ();
87
+ int startZ = chunkPos .getStartZ ();
88
88
AquiferSampler aquiferSampler = chunkNoiseSampler .getAquiferSampler ();
89
89
chunkNoiseSampler .sampleStartDensity ();
90
90
BlockPos .Mutable mutable = new BlockPos .Mutable ();
91
- int k = chunkNoiseSampler .getHorizontalCellBlockCount ();
92
- int l = chunkNoiseSampler .getVerticalCellBlockCount ();
93
- int m = 16 / k ;
94
- int n = 16 / k ;
91
+ int horizBlockCount = chunkNoiseSampler .getHorizontalCellBlockCount ();
92
+ int vertBlockCount = chunkNoiseSampler .getVerticalCellBlockCount ();
93
+ int horizontalDensity = 16 / horizBlockCount ;
95
94
96
- for (int o = 0 ; o < m ; o ++) {
97
- chunkNoiseSampler .sampleEndDensity (o );
95
+ for (int horiz1 = 0 ; horiz1 < horizontalDensity ; horiz1 ++) {
96
+ chunkNoiseSampler .sampleEndDensity (horiz1 )0b1 (int horiz2 = 0 ; horiz2 < horizontalDensity ; horiz2 ++) {
97
+ int verticalSectionCount = chunk .countVerticalSections () - 1 ;
98
+ ChunkSection chunkSection = chunk .getSection (verticalSectionCount );
98
99
99
- for (int p = 0 ; p < n ; p ++) {
100
- int q = chunk .countVerticalSections () - 1 ;
101
- ChunkSection chunkSection = chunk .getSection (q );
100
+ for (int height = cellHeight - 1 ; height >= 0 ; height --) {
101
+ chunkNoiseSampler .onSampledCellCorners (height , horiz2 );
102
102
103
- for (int r = cellHeight - 1 ; r >= 0 ; r --) {
104
- chunkNoiseSampler .onSampledCellCorners (r , p );
105
-
106
- for (int s = l - 1 ; s >= 0 ; s --) {
107
- int t = (minimumCellY + r ) * l + s ;
108
- int u = t & 15 ;
103
+ for (int layer = vertBlockCount - 1 ; layer >= 0 ; layer --) {
104
+ int t = (minimumCellY + height ) * vertBlockCount + layer ;
105
+ int u = t & 0b1111;
109
106
int v = chunk .getSectionIndex (t );
110
- if (q != v ) {
111
- q = v ;
107
+ if (verticalSectionCount != v ) {
108
+ verticalSectionCount = v ;
112
109
chunkSection = chunk .getSection (v );
113
110
}
114
111
115
- double d = (double )s / (double )l ;
116
- chunkNoiseSampler .interpolateY (t , d );
112
+ double normalLayer = (double )layer / (double )vertBlockCount ;
113
+ chunkNoiseSampler .interpolateY (t , normalLayer );
117
114
118
- for (int w = 0 ; w < k ; w ++) {
119
- int x = i + o * k + w ;
120
- int y = x & 15 ;
121
- double e = (double )w / (double )k ;
115
+ for (int w = 0 ; w < horizBlockCount ; w ++) {
116
+ int x = startX + horiz1 * horizBlockCount + w ;
117
+ int y = x & 0b1111 ;
118
+ double e = (double )w / (double )horizBlockCount ;
122
119
chunkNoiseSampler .interpolateX (x , e );
123
120
124
- for (int z = 0 ; z < k ; z ++) {
125
- int aa = j + p * k + z ;
126
- int ab = aa & 15 ;
127
- double f = (double )z / (double )k ;
128
- chunkNoiseSampler .interpolateZ (aa , f );
121
+ for (int z = 0 ; z < horizBlockCount ; z ++) {
122
+ int blockZ = startZ + horiz2 * horizBlockCount + z ;
123
+ double normalZ = (double )z / (double )horizBlockCount ;
124
+ chunkNoiseSampler .interpolateZ (blockZ , normalZ );
129
125
BlockState blockState = chunkNoiseSampler .sampleBlockState ();
130
- if (blockState == null ) {
131
- blockState = this .getSettings ().value ().defaultBlock ();
132
- }
133
126
134
- if (aa != -1 && aa != 0 && aa != 1 ) {
135
- blockState = AIR ;
127
+ if (blockZ < -1 || blockZ > 1 ) {
136
128
continue ;
137
129
}
138
130
139
- blockState = super .getBlockState (chunkNoiseSampler , x , t , aa , blockState );
131
+ if (blockState == null ) {
132
+ blockState = this .getSettings ().value ().defaultBlock ();
133
+ }
134
+
135
+ int maskedBlockZ = blockZ & 0b1111;
136
+ blockState = super .getBlockState (chunkNoiseSampler , x , t , blockZ , blockState );
140
137
if (blockState != AIR && !SharedConstants .isOutsideGenerationArea (chunk .getPos ())) {
141
- chunkSection .setBlockState (y , u , ab , blockState , false );
142
- heightmap .trackUpdate (y , t , ab , blockState );
143
- heightmap2 .trackUpdate (y , t , ab , blockState );
138
+ chunkSection .setBlockState (y , u , maskedBlockZ , blockState , false );
139
+ heightmap .trackUpdate (y , t , maskedBlockZ , blockState );
140
+ heightmap2 .trackUpdate (y , t , maskedBlockZ , blockState );
144
141
if (aquiferSampler .needsFluidTick () && !blockState .getFluidState ().isEmpty ()) {
145
- mutable .set (x , t , aa );
142
+ mutable .set (x , t , blockZ );
146
143
chunk .markBlockForPostProcessing (mutable );
147
144
}
148
145
}
0 commit comments