JigsawPlacement .java

net.minecraft.world.level.levelgen.structure.pools.JigsawPlacement (class, 474 lines): members: doExpansionHack, poolAliasLookup, generateJigsaw, Placer.

net.minecraft.world.level.levelgen.structure.poolsclass474 linescommon20.2 KB

API Surface (2)

Optional<Structure.GenerationStub> addPieces(final Structure.GenerationContext context, final Holder<StructureTemplatePool> startPool, final Optional<Identifier> startJigsaw, final int maxDepth, final BlockPos position, final boolean doExpansionHack, final Optional<Heightmap.Types> projectStartToHeightmap, final JigsawStructure.MaxDistance maxDistanceFromCenter, final PoolAliasLookup poolAliasLookup, final DimensionPadding dimensionPadding, final LiquidSettings liquidSettings)
boolean generateJigsaw(final ServerLevel level, final Holder<StructureTemplatePool> pool, final Identifier target, final int maxDepth, final BlockPos position, final boolean keepJigsaws)

Fields & Constants (27)

LOGGER
UNSET_HEIGHT
context
startPool
startJigsaw
maxDepth
position
doExpansionHack
projectStartToHeightmap
maxDistanceFromCenter
poolAliasLookup
dimensionPadding
element
targetJigsawId
rotation
structureTemplateManager
randomState
chunkGenerator
heightAccessor
random
pools
centerPiece
pieces
shape
level
pool

…and 1 more (see full source).

String literals (1)

"<unregistered>"

Full Source

JigsawPlacement.java474 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.structure.pools;
2
3
import com.google.common.collect.Lists;
4
import com.mojang.logging.LogUtils;
5
import java.util.List;
6
import java.util.Optional;
7
import net.minecraft.core.BlockPos;
8
import net.minecraft.core.Direction;
9
import net.minecraft.core.Holder;
10
import net.minecraft.core.Registry;
11
import net.minecraft.core.RegistryAccess;
12
import net.minecraft.core.Vec3i;
13
import net.minecraft.core.registries.Registries;
14
import net.minecraft.data.worldgen.Pools;
15
import net.minecraft.resources.Identifier;
16
import net.minecraft.resources.ResourceKey;
17
import net.minecraft.server.level.ServerLevel;
18
import net.minecraft.util.RandomSource;
19
import net.minecraft.util.SequencedPriorityIterator;
20
import net.minecraft.world.level.ChunkPos;
21
import net.minecraft.world.level.LevelHeightAccessor;
22
import net.minecraft.world.level.StructureManager;
23
import net.minecraft.world.level.block.JigsawBlock;
24
import net.minecraft.world.level.block.Rotation;
25
import net.minecraft.world.level.chunk.ChunkGenerator;
26
import net.minecraft.world.level.levelgen.Heightmap;
27
import net.minecraft.world.level.levelgen.RandomState;
28
import net.minecraft.world.level.levelgen.WorldgenRandom;
29
import net.minecraft.world.level.levelgen.densityfunction.SamplerContext;
30
import net.minecraft.world.level.levelgen.structure.BoundingBox;
31
import net.minecraft.world.level.levelgen.structure.PoolElementStructurePiece;
32
import net.minecraft.world.level.levelgen.structure.Structure;
33
import net.minecraft.world.level.levelgen.structure.StructurePiece;
34
import net.minecraft.world.level.levelgen.structure.pieces.StructurePiecesBuilder;
35
import net.minecraft.world.level.levelgen.structure.pools.alias.PoolAliasLookup;
36
import net.minecraft.world.level.levelgen.structure.structures.JigsawStructure;
37
import net.minecraft.world.level.levelgen.structure.templatesystem.LiquidSettings;
38
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
39
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
40
import net.minecraft.world.phys.AABB;
41
import net.minecraft.world.phys.shapes.BooleanOp;
42
import net.minecraft.world.phys.shapes.Shapes;
43
import net.minecraft.world.phys.shapes.VoxelShape;
44
import org.apache.commons.lang3.mutable.MutableObject;
45
import org.slf4j.Logger;
46
47
public class JigsawPlacement {
48
	private static final Logger LOGGER = LogUtils.getLogger();
49
	private static final int UNSET_HEIGHT = Integer.MIN_VALUE;
50
51
	public static Optional<Structure.GenerationStub> addPieces(
52
		final Structure.GenerationContext context,
53
		final Holder<StructureTemplatePool> startPool,
54
		final Optional<Identifier> startJigsaw,
55
		final int maxDepth,
56
		final BlockPos position,
57
		final boolean doExpansionHack,
58
		final Optional<Heightmap.Types> projectStartToHeightmap,
59
		final JigsawStructure.MaxDistance maxDistanceFromCenter,
60
		final PoolAliasLookup poolAliasLookup,
61
		final DimensionPadding dimensionPadding,
62
		final LiquidSettings liquidSettings
63
	) {
64
		RegistryAccess registryAccess = context.registryAccess();
65
		ChunkGenerator chunkGenerator = context.chunkGenerator();
66
		StructureTemplateManager structureTemplateManager = context.structureTemplateManager();
67
		LevelHeightAccessor heightAccessor = context.heightAccessor();
68
		WorldgenRandom random = context.random();
69
		Registry<StructureTemplatePool> pools = registryAccess.lookupOrThrow(Registries.TEMPLATE_POOL);
70
		Rotation centerRotation = Rotation.getRandom(random);
71
		StructureTemplatePool centerPool = startPool.unwrapKey()
72
			.flatMap(key -> pools.getOptional(poolAliasLookup.lookup((ResourceKey<StructureTemplatePool>)key)))
73
			.orElse(startPool.value());
74
		StructurePoolElement centerElement = centerPool.getRandomTemplate(random);
75
		if (centerElement == EmptyPoolElement.INSTANCE) {
76
			return Optional.empty();
77
		}
78
79
		BlockPos anchoredPosition;
80
		if (startJigsaw.isPresent()) {
81
			Identifier targetJigsawId = startJigsaw.get();
82
			Optional<BlockPos> anchor = getRandomNamedJigsaw(centerElement, targetJigsawId, position, centerRotation, structureTemplateManager, random);
83
			if (anchor.isEmpty()) {
84
				LOGGER.error(
85
					"No starting jigsaw {} found in start pool {}", targetJigsawId, startPool.unwrapKey().map(key -> key.identifier().toString()).orElse("<unregistered>")
86
				);
87
				return Optional.empty();
88
			}
89
90
			anchoredPosition = anchor.get();
91
		} else {
92
			anchoredPosition = position;
93
		}
94
95
		Vec3i localAnchorPosition = anchoredPosition.subtract(position);
96
		BlockPos adjustedPosition = position.subtract(localAnchorPosition);
97
		PoolElementStructurePiece centerPiece = new PoolElementStructurePiece(
98
			structureTemplateManager,
99
			centerElement,
100
			adjustedPosition,
101
			centerElement.getGroundLevelDelta(),
102
			centerRotation,
103
			centerElement.getBoundingBox(structureTemplateManager, adjustedPosition, centerRotation),
104
			liquidSettings
105
		);
106
		BoundingBox box = centerPiece.getBoundingBox();
107
		int centerX = (box.maxX() + box.minX()) / 2;
108
		int centerZ = (box.maxZ() + box.minZ()) / 2;
109
		int bottomY;
110
		if (projectStartToHeightmap.isEmpty()) {
111
			bottomY = adjustedPosition.getY();
112
		} else {
113
			if (!context.couldStructureExistInColumn(centerX, centerZ, heightAccessor.getMinY(), heightAccessor.getMaxY())) {
114
				return Optional.empty();
115
			}
116
117
			bottomY = position.getY() + chunkGenerator.getFirstFreeHeight(centerX, centerZ, projectStartToHeightmap.get(), heightAccessor, context.randomState());
118
		}
119
120
		int oldAbsoluteGroundY = box.minY() + centerPiece.getGroundLevelDelta();
121
		centerPiece.move(0, bottomY - oldAbsoluteGroundY, 0);
122
		if (isStartTooCloseToWorldHeightLimits(heightAccessor, dimensionPadding, centerPiece.getBoundingBox())) {
123
			LOGGER.debug("Center piece {} with bounding box {} does not fit dimension padding {}", centerElement, centerPiece.getBoundingBox(), dimensionPadding);
124
			return Optional.empty();
125
		} else {
126
			int centerY = bottomY + localAnchorPosition.getY();
127
			return Optional.of(
128
				new Structure.GenerationStub(
129
					new BlockPos(centerX, centerY, centerZ),
130
					builder -> {
131
						List<PoolElementStructurePiece> pieces = Lists.newArrayList();
132
						pieces.add(centerPiece);
133
						if (maxDepth > 0) {
134
							AABB aabb = new AABB(
135
								centerX - maxDistanceFromCenter.horizontal(),
136
								Math.max(centerY - maxDistanceFromCenter.vertical(), heightAccessor.getMinY() + dimensionPadding.bottom()),
137
								centerZ - maxDistanceFromCenter.horizontal(),
138
								centerX + maxDistanceFromCenter.horizontal() + 1,
139
								Math.min(centerY + maxDistanceFromCenter.vertical() + 1, heightAccessor.getMaxY() + 1 - dimensionPadding.top()),
140
								centerZ + maxDistanceFromCenter.horizontal() + 1
141
							);
142
							VoxelShape shape = Shapes.join(Shapes.create(aabb), Shapes.create(AABB.of(box)), BooleanOp.ONLY_FIRST);
143
							addPieces(
144
								context.randomState(),
145
								maxDepth,
146
								doExpansionHack,
147
								chunkGenerator,
148
								structureTemplateManager,
149
								heightAccessor,
150
								random,
151
								pools,
152
								centerPiece,
153
								pieces,
154
								shape,
155
								poolAliasLookup,
156
								liquidSettings
157
							);
158
							pieces.forEach(builder::addPiece);
159
						}
160
					}
161
				)
162
			);
163
		}
164
	}
165
166
	private static boolean isStartTooCloseToWorldHeightLimits(
167
		final LevelHeightAccessor heightAccessor, final DimensionPadding dimensionPadding, final BoundingBox centerPieceBb
168
	) {
169
		if (dimensionPadding == DimensionPadding.ZERO) {
170
			return false;
171
		}
172
173
		int minYWithPadding = heightAccessor.getMinY() + dimensionPadding.bottom();
174
		int maxYWithPadding = heightAccessor.getMaxY() - dimensionPadding.top();
175
		return centerPieceBb.minY() < minYWithPadding || centerPieceBb.maxY() > maxYWithPadding;
176
	}
177
178
	private static Optional<BlockPos> getRandomNamedJigsaw(
179
		final StructurePoolElement element,
180
		final Identifier targetJigsawId,
181
		final BlockPos position,
182
		final Rotation rotation,
183
		final StructureTemplateManager structureTemplateManager,
184
		final WorldgenRandom random
185
	) {
186
		for (StructureTemplate.JigsawBlockInfo jigsaw : element.getShuffledJigsawBlocks(structureTemplateManager, position, rotation, random)) {
187
			if (targetJigsawId.equals(jigsaw.name())) {
188
				return Optional.of(jigsaw.pos());
189
			}
190
		}
191
192
		return Optional.empty();
193
	}
194
195
	private static void addPieces(
196
		final RandomState randomState,
197
		final int maxDepth,
198
		final boolean doExpansionHack,
199
		final ChunkGenerator chunkGenerator,
200
		final StructureTemplateManager structureTemplateManager,
201
		final LevelHeightAccessor heightAccessor,
202
		final RandomSource random,
203
		final Registry<StructureTemplatePool> pools,
204
		final PoolElementStructurePiece centerPiece,
205
		final List<PoolElementStructurePiece> pieces,
206
		final VoxelShape shape,
207
		final PoolAliasLookup poolAliasLookup,
208
		final LiquidSettings liquidSettings
209
	) {
210
		JigsawPlacement.Placer placer = new JigsawPlacement.Placer(pools, maxDepth, chunkGenerator, structureTemplateManager, pieces, random);
211
		placer.tryPlacingChildren(centerPiece, new MutableObject<>(shape), 0, doExpansionHack, heightAccessor, randomState, poolAliasLookup, liquidSettings);
212
213
		while (placer.placing.hasNext()) {
214
			JigsawPlacement.PieceState state = placer.placing.next();
215
			placer.tryPlacingChildren(state.piece, state.free, state.depth, doExpansionHack, heightAccessor, randomState, poolAliasLookup, liquidSettings);
216
		}
217
	}
218
219
	public static boolean generateJigsaw(
220
		final ServerLevel level,
221
		final Holder<StructureTemplatePool> pool,
222
		final Identifier target,
223
		final int maxDepth,
224
		final BlockPos position,
225
		final boolean keepJigsaws
226
	) {
227
		ChunkGenerator generator = level.getChunkSource().getGenerator();
228
		StructureTemplateManager structureTemplateManager = level.getStructureTemplateManager();
229
		StructureManager structureManager = level.structureManager();
230
		RandomSource random = level.getRandom();
231
		RandomState randomState = level.getChunkSource().randomState();
232
		Structure.GenerationContext generationContext = new Structure.GenerationContext(
233
			level.registryAccess(),
234
			generator,
235
			generator.getBiomeSource(),
236
			randomState.createClimateSampler(SamplerContext.EMPTY_UNCACHED),
237
			randomState,
238
			structureTemplateManager,
239
			level.getSeed(),
240
			ChunkPos.containing(position),
241
			level,
242
			b -> true
243
		);
244
		Optional<Structure.GenerationStub> stub = addPieces(
245
			generationContext,
246
			pool,
247
			Optional.of(target),
248
			maxDepth,
249
			position,
250
			false,
251
			Optional.empty(),
252
			new JigsawStructure.MaxDistance(128),
253
			PoolAliasLookup.EMPTY,
254
			JigsawStructure.DEFAULT_DIMENSION_PADDING,
255
			JigsawStructure.DEFAULT_LIQUID_SETTINGS
256
		);
257
		if (stub.isPresent()) {
258
			StructurePiecesBuilder builder = stub.get().getPiecesBuilder();
259
260
			for (StructurePiece piece : builder.build().pieces()) {
261
				if (piece instanceof PoolElementStructurePiece poolPiece) {
262
					poolPiece.place(level, structureManager, generator, random, BoundingBox.infinite(), position, keepJigsaws);
263
				}
264
			}
265
266
			return true;
267
		} else {
268
			return false;
269
		}
270
	}
271
272
	private record PieceState(PoolElementStructurePiece piece, MutableObject<VoxelShape> free, int depth) {
273
	}
274
275
	private static final class Placer {
276
		private final Registry<StructureTemplatePool> pools;
277
		private final int maxDepth;
278
		private final ChunkGenerator chunkGenerator;
279
		private final StructureTemplateManager structureTemplateManager;
280
		private final List<? super PoolElementStructurePiece> pieces;
281
		private final RandomSource random;
282
		private final SequencedPriorityIterator<JigsawPlacement.PieceState> placing = new SequencedPriorityIterator<>();
283
284
		private Placer(
285
			final Registry<StructureTemplatePool> pools,
286
			final int maxDepth,
287
			final ChunkGenerator chunkGenerator,
288
			final StructureTemplateManager structureTemplateManager,
289
			final List<? super PoolElementStructurePiece> pieces,
290
			final RandomSource random
291
		) {
292
			this.pools = pools;
293
			this.maxDepth = maxDepth;
294
			this.chunkGenerator = chunkGenerator;
295
			this.structureTemplateManager = structureTemplateManager;
296
			this.pieces = pieces;
297
			this.random = random;
298
		}
299
300
		private void tryPlacingChildren(
301
			final PoolElementStructurePiece sourcePiece,
302
			final MutableObject<VoxelShape> contextFree,
303
			final int depth,
304
			final boolean doExpansionHack,
305
			final LevelHeightAccessor heightAccessor,
306
			final RandomState randomState,
307
			final PoolAliasLookup poolAliasLookup,
308
			final LiquidSettings liquidSettings
309
		) {
310
			StructurePoolElement sourceElement = sourcePiece.getElement();
311
			BlockPos sourceBoxPosition = sourcePiece.getPosition();
312
			Rotation sourceRotation = sourcePiece.getRotation();
313
			StructureTemplatePool.Projection sourceProjection = sourceElement.getProjection();
314
			boolean sourceRigid = sourceProjection == StructureTemplatePool.Projection.RIGID;
315
			MutableObject<VoxelShape> sourceFree = new MutableObject<>();
316
			BoundingBox sourceBB = sourcePiece.getBoundingBox();
317
			int sourceBoxY = sourceBB.minY();
318
319
			label129:
320
			for (StructureTemplate.JigsawBlockInfo sourceJigsaw : sourceElement.getShuffledJigsawBlocks(
321
				this.structureTemplateManager, sourceBoxPosition, sourceRotation, this.random
322
			)) {
323
				Direction sourceDirection = JigsawBlock.getFrontFacing(sourceJigsaw.state());
324
				BlockPos sourceJigsawPos = sourceJigsaw.pos();
325
				BlockPos targetJigsawPos = sourceJigsawPos.relative(sourceDirection);
326
				int sourceJigsawLocalY = sourceJigsawPos.getY() - sourceBoxY;
327
				int sourceJigsawBaseHeight = Integer.MIN_VALUE;
328
				ResourceKey<StructureTemplatePool> poolName = poolAliasLookup.lookup(sourceJigsaw.pool());
329
				Optional<? extends Holder<StructureTemplatePool>> maybeTargetPool = this.pools.get(poolName);
330
				if (maybeTargetPool.isEmpty()) {
331
					JigsawPlacement.LOGGER.warn("Empty or non-existent pool: {}", poolName.identifier());
332
				} else {
333
					Holder<StructureTemplatePool> targetPool = (Holder<StructureTemplatePool>)maybeTargetPool.get();
334
					if (targetPool.value().size() == 0 && !targetPool.is(Pools.EMPTY)) {
335
						JigsawPlacement.LOGGER.warn("Empty or non-existent pool: {}", poolName.identifier());
336
					} else {
337
						Holder<StructureTemplatePool> fallback = targetPool.value().getFallback();
338
						if (fallback.value().size() == 0 && !fallback.is(Pools.EMPTY)) {
339
							JigsawPlacement.LOGGER
340
								.warn("Empty or non-existent fallback pool: {}", fallback.unwrapKey().map(e -> e.identifier().toString()).orElse("<unregistered>"));
341
						} else {
342
							boolean attachInsideSource = sourceBB.isInside(targetJigsawPos);
343
							MutableObject<VoxelShape> childrenFree;
344
							if (attachInsideSource) {
345
								childrenFree = sourceFree;
346
								if (sourceFree.get() == null) {
347
									sourceFree.setValue(Shapes.create(AABB.of(sourceBB)));
348
								}
349
							} else {
350
								childrenFree = contextFree;
351
							}
352
353
							List<StructurePoolElement> targetPieces = Lists.newArrayList();
354
							if (depth != this.maxDepth) {
355
								targetPieces.addAll(targetPool.value().getShuffledTemplates(this.random));
356
							}
357
358
							targetPieces.addAll(fallback.value().getShuffledTemplates(this.random));
359
							int placementPriority = sourceJigsaw.placementPriority();
360
361
							for (StructurePoolElement targetElement : targetPieces) {
362
								if (targetElement == EmptyPoolElement.INSTANCE) {
363
									break;
364
								}
365
366
								for (Rotation targetRotation : Rotation.getShuffled(this.random)) {
367
									List<StructureTemplate.JigsawBlockInfo> targetJigsaws = targetElement.getShuffledJigsawBlocks(
368
										this.structureTemplateManager, BlockPos.ZERO, targetRotation, this.random
369
									);
370
									BoundingBox hackBox = targetElement.getBoundingBox(this.structureTemplateManager, BlockPos.ZERO, targetRotation);
371
									int expandTo;
372
									if (doExpansionHack && hackBox.getYSpan() <= 16) {
373
										expandTo = targetJigsaws.stream().mapToInt(targetJigsawx -> {
374
											if (!hackBox.isInside(targetJigsawx.pos().relative(JigsawBlock.getFrontFacing(targetJigsawx.state())))) {
375
												return 0;
376
											}
377
378
											ResourceKey<StructureTemplatePool> childPoolName = poolAliasLookup.lookup(targetJigsawx.pool());
379
											Optional<? extends Holder<StructureTemplatePool>> childPool = this.pools.get(childPoolName);
380
											Optional<Holder<StructureTemplatePool>> childFallbackPool = childPool.map(p -> p.value().getFallback());
381
											int childPoolSize = childPool.<Integer>map(p -> p.value().getMaxSize(this.structureTemplateManager)).orElse(0);
382
											int childFallbackSize = childFallbackPool.<Integer>map(p -> p.value().getMaxSize(this.structureTemplateManager)).orElse(0);
383
											return Math.max(childPoolSize, childFallbackSize);
384
										}).max().orElse(0);
385
									} else {
386
										expandTo = 0;
387
									}
388
389
									for (StructureTemplate.JigsawBlockInfo targetJigsaw : targetJigsaws) {
390
										if (JigsawBlock.canAttach(sourceJigsaw, targetJigsaw)) {
391
											BlockPos targetJigsawLocalPos = targetJigsaw.pos();
392
											BlockPos rawTargetBoxPos = targetJigsawPos.subtract(targetJigsawLocalPos);
393
											BoundingBox rawTargetBB = targetElement.getBoundingBox(this.structureTemplateManager, rawTargetBoxPos, targetRotation);
394
											int rawTargetY = rawTargetBB.minY();
395
											StructureTemplatePool.Projection targetProjection = targetElement.getProjection();
396
											boolean targetRigid = targetProjection == StructureTemplatePool.Projection.RIGID;
397
											int targetJigsawLocalY = targetJigsawLocalPos.getY();
398
											int deltaY = sourceJigsawLocalY - targetJigsawLocalY + JigsawBlock.getFrontFacing(sourceJigsaw.state()).getStepY();
399
											int targetBoxY;
400
											if (sourceRigid && targetRigid) {
401
												targetBoxY = sourceBoxY + deltaY;
402
											} else {
403
												if (sourceJigsawBaseHeight == Integer.MIN_VALUE) {
404
													sourceJigsawBaseHeight = this.chunkGenerator
405
														.getFirstFreeHeight(sourceJigsawPos.getX(), sourceJigsawPos.getZ(), Heightmap.Types.WORLD_SURFACE_WG, heightAccessor, randomState);
406
												}
407
408
												targetBoxY = sourceJigsawBaseHeight - targetJigsawLocalY;
409
											}
410
411
											int yOffset = targetBoxY - rawTargetY;
412
											BoundingBox targetBB = rawTargetBB.moved(0, yOffset, 0);
413
											BlockPos targetBoxPosition = rawTargetBoxPos.offset(0, yOffset, 0);
414
											if (expandTo > 0) {
415
												int newSize = Math.max(expandTo + 1, targetBB.maxY() - targetBB.minY());
416
												targetBB.encapsulate(new BlockPos(targetBB.minX(), targetBB.minY() + newSize, targetBB.minZ()));
417
											}
418
419
											if (!Shapes.joinIsNotEmpty(childrenFree.get(), Shapes.create(AABB.of(targetBB).deflate(0.25)), BooleanOp.ONLY_SECOND)) {
420
												childrenFree.setValue(Shapes.joinUnoptimized(childrenFree.get(), Shapes.create(AABB.of(targetBB)), BooleanOp.ONLY_FIRST));
421
												int sourceGroundLevelDelta = sourcePiece.getGroundLevelDelta();
422
												int targetGroundLevelDelta;
423
												if (targetRigid) {
424
													targetGroundLevelDelta = sourceGroundLevelDelta - deltaY;
425
												} else {
426
													targetGroundLevelDelta = targetElement.getGroundLevelDelta();
427
												}
428
429
												PoolElementStructurePiece targetPiece = new PoolElementStructurePiece(
430
													this.structureTemplateManager, targetElement, targetBoxPosition, targetGroundLevelDelta, targetRotation, targetBB, liquidSettings
431
												);
432
												int junctionY;
433
												if (sourceRigid) {
434
													junctionY = sourceBoxY + sourceJigsawLocalY;
435
												} else if (targetRigid) {
436
													junctionY = targetBoxY + targetJigsawLocalY;
437
												} else {
438
													if (sourceJigsawBaseHeight == Integer.MIN_VALUE) {
439
														sourceJigsawBaseHeight = this.chunkGenerator
440
															.getFirstFreeHeight(sourceJigsawPos.getX(), sourceJigsawPos.getZ(), Heightmap.Types.WORLD_SURFACE_WG, heightAccessor, randomState);
441
													}
442
443
													junctionY = sourceJigsawBaseHeight + deltaY / 2;
444
												}
445
446
												sourcePiece.addJunction(
447
													new JigsawJunction(
448
														targetJigsawPos.getX(), junctionY - sourceJigsawLocalY + sourceGroundLevelDelta, targetJigsawPos.getZ(), deltaY, targetProjection
449
													)
450
												);
451
												targetPiece.addJunction(
452
													new JigsawJunction(
453
														sourceJigsawPos.getX(), junctionY - targetJigsawLocalY + targetGroundLevelDelta, sourceJigsawPos.getZ(), -deltaY, sourceProjection
454
													)
455
												);
456
												this.pieces.add(targetPiece);
457
												if (depth + 1 <= this.maxDepth) {
458
													JigsawPlacement.PieceState state = new JigsawPlacement.PieceState(targetPiece, childrenFree, depth + 1);
459
													this.placing.add(state, placementPriority);
460
												}
461
												continue label129;
462
											}
463
										}
464
									}
465
								}
466
							}
467
						}
468
					}
469
				}
470
			}
471
		}
472
	}
473
}
474

Decompiled Minecraft 26.3 source of JigsawPlacement (net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement.java) with Mojang official mappings, stored verbatim on the site.