StructureBlockEntity .java

net.minecraft.world.level.block.entity.StructureBlockEntity (class, 549 lines): members: DEFAULT_SHOW_BOUNDING_BOX, SCAN_CORNER_BLOCKS_RANGE, usedBy.

net.minecraft.world.level.block.entityclass549 linescommonextends BlockEntity17.8 KB

Implements

API Surface (48)

void saveAdditional(final ValueOutput output)
void loadAdditional(final ValueInput input)
ClientboundBlockEntityDataPacket getUpdatePacket()
CompoundTag getUpdateTag(final HolderLookup.Provider registries)
boolean usedBy(final Player player)
String getStructureName()
boolean hasStructureName()
void setStructureName(final @Nullable String structureName)
void setStructureName(final @Nullable Identifier structureName)
void createdBy(final LivingEntity creator)
BlockPos getStructurePos()
void setStructurePos(final BlockPos structurePos)
Vec3i getStructureSize()
void setStructureSize(final Vec3i structureSize)
Mirror getMirror()
void setMirror(final Mirror mirror)
Rotation getRotation()
void setRotation(final Rotation rotation)
String getMetaData()
void setMetaData(final String metaData)
StructureMode getMode()
void setMode(final StructureMode mode)
boolean isIgnoreEntities()
boolean isStrict()
void setIgnoreEntities(final boolean ignoreEntities)
void setStrict(final boolean strict)
float getIntegrity()
void setIntegrity(final float integrity)
long getSeed()
void setSeed(final long seed)
boolean detectSize()
boolean saveStructure()
boolean saveStructure(final boolean saveToDisk)
boolean saveStructure(final ServerLevel level, final Identifier structureName, final BlockPos pos, final Vec3i structureSize, final boolean ignoreEntities, final String author, final boolean saveToDisk, final List<Block> ignoreBlocks)
RandomSource createRandom(final long seed)
boolean placeStructureIfSameSize(final ServerLevel level)
boolean loadStructureInfo(final ServerLevel level)
void placeStructure(final ServerLevel level)
void unloadStructure()
boolean isStructureLoadable()
boolean isPowered()
void setPowered(final boolean powered)
boolean getShowAir()
void setShowAir(final boolean showAir)
boolean getShowBoundingBox()
void setShowBoundingBox(final boolean showBoundingBox)
BoundingBoxRenderable.Mode renderMode()
BoundingBoxRenderable.RenderableBox getRenderableBox()

Fields & Constants (35)

SCAN_CORNER_BLOCKS_RANGE
MAX_OFFSET_PER_AXIS
MAX_SIZE_PER_AXIS
AUTHOR_TAG
DEFAULT_AUTHOR
DEFAULT_METADATA
DEFAULT_POS
DEFAULT_SIZE
DEFAULT_ROTATION
DEFAULT_MIRROR
DEFAULT_IGNORE_ENTITIES
DEFAULT_STRICT
DEFAULT_POWERED
DEFAULT_SHOW_AIR
DEFAULT_SHOW_BOUNDING_BOX
DEFAULT_INTEGRITY
DEFAULT_SEED
structureName
author
metaData
structurePos
structureSize
mirror
rotation
mode
ignoreEntities
strict
powered
showAir
showBoundingBox
integrity
seed
level
pos
saveToDisk

String literals (18)

"author"
"metadata"
"posX"
"posY"
"posZ"
"sizeX"
"sizeY"
"sizeZ"
"rotation"
"mirror"
"mode"
"ignoreEntities"
"strict"
"powered"
"showair"
"showboundingbox"
"integrity"
"seed"

Full Source

StructureBlockEntity.java549 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.block.entity;
2
3
import java.util.List;
4
import java.util.Objects;
5
import java.util.Optional;
6
import java.util.stream.Stream;
7
import net.minecraft.IdentifierException;
8
import net.minecraft.SharedConstants;
9
import net.minecraft.core.BlockPos;
10
import net.minecraft.core.HolderLookup;
11
import net.minecraft.core.Vec3i;
12
import net.minecraft.nbt.CompoundTag;
13
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
14
import net.minecraft.resources.Identifier;
15
import net.minecraft.server.level.ServerLevel;
16
import net.minecraft.util.Mth;
17
import net.minecraft.util.RandomSource;
18
import net.minecraft.util.StringUtil;
19
import net.minecraft.util.Util;
20
import net.minecraft.world.entity.LivingEntity;
21
import net.minecraft.world.entity.player.Player;
22
import net.minecraft.world.level.Level;
23
import net.minecraft.world.level.block.Block;
24
import net.minecraft.world.level.block.Blocks;
25
import net.minecraft.world.level.block.Mirror;
26
import net.minecraft.world.level.block.Rotation;
27
import net.minecraft.world.level.block.StructureBlock;
28
import net.minecraft.world.level.block.state.BlockState;
29
import net.minecraft.world.level.block.state.properties.StructureMode;
30
import net.minecraft.world.level.levelgen.structure.BoundingBox;
31
import net.minecraft.world.level.levelgen.structure.templatesystem.BlockRotProcessor;
32
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
33
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
34
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
35
import net.minecraft.world.level.storage.ValueInput;
36
import net.minecraft.world.level.storage.ValueOutput;
37
import org.apache.commons.lang3.mutable.MutableInt;
38
import org.apache.commons.lang3.mutable.MutableObject;
39
import org.jspecify.annotations.Nullable;
40
41
public class StructureBlockEntity extends BlockEntity implements BoundingBoxRenderable {
42
	private static final int SCAN_CORNER_BLOCKS_RANGE = 80;
43
	public static final int MAX_OFFSET_PER_AXIS = 48;
44
	public static final int MAX_SIZE_PER_AXIS = 48;
45
	public static final String AUTHOR_TAG = "author";
46
	private static final String DEFAULT_AUTHOR = "";
47
	private static final String DEFAULT_METADATA = "";
48
	private static final BlockPos DEFAULT_POS = new BlockPos(0, 1, 0);
49
	private static final Vec3i DEFAULT_SIZE = Vec3i.ZERO;
50
	private static final Rotation DEFAULT_ROTATION = Rotation.NONE;
51
	private static final Mirror DEFAULT_MIRROR = Mirror.NONE;
52
	private static final boolean DEFAULT_IGNORE_ENTITIES = true;
53
	private static final boolean DEFAULT_STRICT = false;
54
	private static final boolean DEFAULT_POWERED = false;
55
	private static final boolean DEFAULT_SHOW_AIR = false;
56
	private static final boolean DEFAULT_SHOW_BOUNDING_BOX = true;
57
	private static final float DEFAULT_INTEGRITY = 1.0F;
58
	private static final long DEFAULT_SEED = 0L;
59
	private @Nullable Identifier structureName;
60
	private String author = "";
61
	private String metaData = "";
62
	private BlockPos structurePos = DEFAULT_POS;
63
	private Vec3i structureSize = DEFAULT_SIZE;
64
	private Mirror mirror = Mirror.NONE;
65
	private Rotation rotation = Rotation.NONE;
66
	private StructureMode mode;
67
	private boolean ignoreEntities = true;
68
	private boolean strict = false;
69
	private boolean powered = false;
70
	private boolean showAir = false;
71
	private boolean showBoundingBox = true;
72
	private float integrity = 1.0F;
73
	private long seed = 0L;
74
75
	public StructureBlockEntity(final BlockPos worldPosition, final BlockState blockState) {
76
		super(BlockEntityTypes.STRUCTURE_BLOCK, worldPosition, blockState);
77
		this.mode = blockState.getValue(StructureBlock.MODE);
78
	}
79
80
	@Override
81
	protected void saveAdditional(final ValueOutput output) {
82
		super.saveAdditional(output);
83
		output.putString("name", this.getStructureName());
84
		output.putString("author", this.author);
85
		output.putString("metadata", this.metaData);
86
		output.putInt("posX", this.structurePos.getX());
87
		output.putInt("posY", this.structurePos.getY());
88
		output.putInt("posZ", this.structurePos.getZ());
89
		output.putInt("sizeX", this.structureSize.getX());
90
		output.putInt("sizeY", this.structureSize.getY());
91
		output.putInt("sizeZ", this.structureSize.getZ());
92
		output.store("rotation", Rotation.LEGACY_CODEC, this.rotation);
93
		output.store("mirror", Mirror.LEGACY_CODEC, this.mirror);
94
		output.store("mode", StructureMode.LEGACY_CODEC, this.mode);
95
		output.putBoolean("ignoreEntities", this.ignoreEntities);
96
		output.putBoolean("strict", this.strict);
97
		output.putBoolean("powered", this.powered);
98
		output.putBoolean("showair", this.showAir);
99
		output.putBoolean("showboundingbox", this.showBoundingBox);
100
		output.putFloat("integrity", this.integrity);
101
		output.putLong("seed", this.seed);
102
	}
103
104
	@Override
105
	protected void loadAdditional(final ValueInput input) {
106
		super.loadAdditional(input);
107
		this.setStructureName(input.getStringOr("name", ""));
108
		this.author = input.getStringOr("author", "");
109
		this.metaData = input.getStringOr("metadata", "");
110
		int xOffset = Mth.clamp(input.getIntOr("posX", DEFAULT_POS.getX()), -48, 48);
111
		int yOffset = Mth.clamp(input.getIntOr("posY", DEFAULT_POS.getY()), -48, 48);
112
		int zOffset = Mth.clamp(input.getIntOr("posZ", DEFAULT_POS.getZ()), -48, 48);
113
		this.structurePos = new BlockPos(xOffset, yOffset, zOffset);
114
		int width = Mth.clamp(input.getIntOr("sizeX", DEFAULT_SIZE.getX()), 0, 48);
115
		int height = Mth.clamp(input.getIntOr("sizeY", DEFAULT_SIZE.getY()), 0, 48);
116
		int depth = Mth.clamp(input.getIntOr("sizeZ", DEFAULT_SIZE.getZ()), 0, 48);
117
		this.structureSize = new Vec3i(width, height, depth);
118
		this.rotation = input.read("rotation", Rotation.LEGACY_CODEC).orElse(DEFAULT_ROTATION);
119
		this.mirror = input.read("mirror", Mirror.LEGACY_CODEC).orElse(DEFAULT_MIRROR);
120
		this.mode = input.read("mode", StructureMode.LEGACY_CODEC).orElse(StructureMode.DATA);
121
		this.ignoreEntities = input.getBooleanOr("ignoreEntities", true);
122
		this.strict = input.getBooleanOr("strict", false);
123
		this.powered = input.getBooleanOr("powered", false);
124
		this.showAir = input.getBooleanOr("showair", false);
125
		this.showBoundingBox = input.getBooleanOr("showboundingbox", true);
126
		this.integrity = input.getFloatOr("integrity", 1.0F);
127
		this.seed = input.getLongOr("seed", 0L);
128
		this.updateBlockState();
129
	}
130
131
	private void updateBlockState() {
132
		if (this.level != null) {
133
			BlockPos pos = this.getBlockPos();
134
			BlockState blockState = this.level.getBlockState(pos);
135
			if (blockState.is(Blocks.STRUCTURE_BLOCK)) {
136
				this.level.setBlock(pos, blockState.setValue(StructureBlock.MODE, this.mode), 2);
137
			}
138
		}
139
	}
140
141
	public ClientboundBlockEntityDataPacket getUpdatePacket() {
142
		return ClientboundBlockEntityDataPacket.create(this);
143
	}
144
145
	@Override
146
	public CompoundTag getUpdateTag(final HolderLookup.Provider registries) {
147
		return this.saveCustomOnly(registries);
148
	}
149
150
	public boolean usedBy(final Player player) {
151
		if (!player.canUseGameMasterBlocks()) {
152
			return false;
153
		}
154
155
		if (player.level().isClientSide()) {
156
			player.openStructureBlock(this);
157
		}
158
159
		return true;
160
	}
161
162
	public String getStructureName() {
163
		return this.structureName == null ? "" : this.structureName.toString();
164
	}
165
166
	public boolean hasStructureName() {
167
		return this.structureName != null;
168
	}
169
170
	public void setStructureName(final @Nullable String structureName) {
171
		this.setStructureName(StringUtil.isNullOrEmpty(structureName) ? null : Identifier.tryParse(structureName));
172
	}
173
174
	public void setStructureName(final @Nullable Identifier structureName) {
175
		this.structureName = structureName;
176
	}
177
178
	public void createdBy(final LivingEntity creator) {
179
		this.author = creator.getPlainTextName();
180
	}
181
182
	public BlockPos getStructurePos() {
183
		return this.structurePos;
184
	}
185
186
	public void setStructurePos(final BlockPos structurePos) {
187
		this.structurePos = structurePos;
188
	}
189
190
	public Vec3i getStructureSize() {
191
		return this.structureSize;
192
	}
193
194
	public void setStructureSize(final Vec3i structureSize) {
195
		this.structureSize = structureSize;
196
	}
197
198
	public Mirror getMirror() {
199
		return this.mirror;
200
	}
201
202
	public void setMirror(final Mirror mirror) {
203
		this.mirror = mirror;
204
	}
205
206
	public Rotation getRotation() {
207
		return this.rotation;
208
	}
209
210
	public void setRotation(final Rotation rotation) {
211
		this.rotation = rotation;
212
	}
213
214
	public String getMetaData() {
215
		return this.metaData;
216
	}
217
218
	public void setMetaData(final String metaData) {
219
		this.metaData = metaData;
220
	}
221
222
	public StructureMode getMode() {
223
		return this.mode;
224
	}
225
226
	public void setMode(final StructureMode mode) {
227
		this.mode = mode;
228
		BlockState state = this.level.getBlockState(this.getBlockPos());
229
		if (state.is(Blocks.STRUCTURE_BLOCK)) {
230
			this.level.setBlock(this.getBlockPos(), state.setValue(StructureBlock.MODE, mode), 2);
231
		}
232
	}
233
234
	public boolean isIgnoreEntities() {
235
		return this.ignoreEntities;
236
	}
237
238
	public boolean isStrict() {
239
		return this.strict;
240
	}
241
242
	public void setIgnoreEntities(final boolean ignoreEntities) {
243
		this.ignoreEntities = ignoreEntities;
244
	}
245
246
	public void setStrict(final boolean strict) {
247
		this.strict = strict;
248
	}
249
250
	public float getIntegrity() {
251
		return this.integrity;
252
	}
253
254
	public void setIntegrity(final float integrity) {
255
		this.integrity = integrity;
256
	}
257
258
	public long getSeed() {
259
		return this.seed;
260
	}
261
262
	public void setSeed(final long seed) {
263
		this.seed = seed;
264
	}
265
266
	public boolean detectSize() {
267
		if (this.mode != StructureMode.SAVE) {
268
			return false;
269
		}
270
271
		BlockPos pos = this.getBlockPos();
272
		return getEnclosingBoundingBox(this.level, pos, this.structureName).filter(bb -> {
273
			int deltaX = bb.maxX() - bb.minX();
274
			int deltaY = bb.maxY() - bb.minY();
275
			int deltaZ = bb.maxZ() - bb.minZ();
276
			if (deltaX > 1 && deltaY > 1 && deltaZ > 1) {
277
				this.structurePos = new BlockPos(bb.minX() - pos.getX() + 1, bb.minY() - pos.getY() + 1, bb.minZ() - pos.getZ() + 1);
278
				this.structureSize = new Vec3i(deltaX - 1, deltaY - 1, deltaZ - 1);
279
				this.setChanged();
280
				BlockState state = this.level.getBlockState(pos);
281
				this.level.sendBlockUpdated(pos, state, state, 3);
282
				return true;
283
			} else {
284
				return false;
285
			}
286
		}).isPresent();
287
	}
288
289
	private static Optional<BoundingBox> getEnclosingBoundingBox(final Level level, final BlockPos selfPos, final Identifier structureName) {
290
		MutableInt cornerCount = new MutableInt();
291
		MutableObject<BoundingBox> result = new MutableObject<>();
292
		BlockPos corner1 = new BlockPos(selfPos.getX() - 80, level.getMinY(), selfPos.getZ() - 80);
293
		BlockPos corner2 = new BlockPos(selfPos.getX() + 80, level.getMaxY(), selfPos.getZ() + 80);
294
		level.findBlocksIn(corner1, corner2)
295
			.filterState(state -> state.is(Blocks.STRUCTURE_BLOCK))
296
			.forEach((pos, var5x) -> level.getBlockEntity(pos, BlockEntityTypes.STRUCTURE_BLOCK).ifPresent(blockEntity -> {
297
				if (blockEntity.mode == StructureMode.CORNER && Objects.equals(structureName, blockEntity.structureName)) {
298
					cornerCount.increment();
299
					BoundingBox boundingBox = result.get();
300
					if (boundingBox == null) {
301
						result.setValue(new BoundingBox(pos));
302
					} else {
303
						boundingBox.encapsulate(pos);
304
					}
305
				}
306
			}));
307
308
		return switch (cornerCount.get().intValue()) {
309
			case 0 -> Optional.empty();
310
			case 1 -> Optional.of(Objects.requireNonNull(result.get()).encapsulate(selfPos));
311
			default -> Optional.of(Objects.requireNonNull(result.get()));
312
		};
313
	}
314
315
	public boolean saveStructure() {
316
		return this.mode != StructureMode.SAVE ? false : this.saveStructure(true);
317
	}
318
319
	public boolean saveStructure(final boolean saveToDisk) {
320
		if (this.structureName != null && this.level instanceof ServerLevel serverLevel) {
321
			BlockPos var4 = this.getBlockPos().offset(this.structurePos);
322
			return saveStructure(serverLevel, this.structureName, var4, this.structureSize, this.ignoreEntities, this.author, saveToDisk, List.of());
323
		} else {
324
			return false;
325
		}
326
	}
327
328
	public static boolean saveStructure(
329
		final ServerLevel level,
330
		final Identifier structureName,
331
		final BlockPos pos,
332
		final Vec3i structureSize,
333
		final boolean ignoreEntities,
334
		final String author,
335
		final boolean saveToDisk,
336
		final List<Block> ignoreBlocks
337
	) {
338
		StructureTemplateManager manager = level.getStructureTemplateManager();
339
340
		StructureTemplate structureTemplate;
341
		try {
342
			structureTemplate = manager.getOrCreate(structureName);
343
		} catch (IdentifierException e) {
344
			return false;
345
		}
346
347
		structureTemplate.fillFromWorld(level, pos, structureSize, !ignoreEntities, Stream.concat(ignoreBlocks.stream(), Stream.of(Blocks.STRUCTURE_VOID)).toList());
348
		structureTemplate.setAuthor(author);
349
		if (saveToDisk) {
350
			try {
351
				return manager.save(structureName);
352
			} catch (IdentifierException e) {
353
				return false;
354
			}
355
		} else {
356
			return true;
357
		}
358
	}
359
360
	public static RandomSource createRandom(final long seed) {
361
		return seed == 0L ? RandomSource.create(Util.getMillis()) : RandomSource.create(seed);
362
	}
363
364
	public boolean placeStructureIfSameSize(final ServerLevel level) {
365
		if (this.mode == StructureMode.LOAD && this.structureName != null) {
366
			StructureTemplate template = level.getStructureTemplateManager().get(this.structureName).orElse(null);
367
			if (template == null) {
368
				return false;
369
			} else if (template.getSize().equals(this.structureSize)) {
370
				this.placeStructure(level, template);
371
				return true;
372
			} else {
373
				this.loadStructureInfo(template);
374
				return false;
375
			}
376
		} else {
377
			return false;
378
		}
379
	}
380
381
	public boolean loadStructureInfo(final ServerLevel level) {
382
		StructureTemplate template = this.getStructureTemplate(level);
383
		if (template == null) {
384
			return false;
385
		}
386
387
		this.loadStructureInfo(template);
388
		return true;
389
	}
390
391
	private void loadStructureInfo(final StructureTemplate structureTemplate) {
392
		this.author = !StringUtil.isNullOrEmpty(structureTemplate.getAuthor()) ? structureTemplate.getAuthor() : "";
393
		this.structureSize = structureTemplate.getSize();
394
		this.setChanged();
395
	}
396
397
	public void placeStructure(final ServerLevel level) {
398
		StructureTemplate template = this.getStructureTemplate(level);
399
		if (template != null) {
400
			this.placeStructure(level, template);
401
		}
402
	}
403
404
	private @Nullable StructureTemplate getStructureTemplate(final ServerLevel level) {
405
		return this.structureName == null ? null : level.getStructureTemplateManager().get(this.structureName).orElse(null);
406
	}
407
408
	private void placeStructure(final ServerLevel level, final StructureTemplate template) {
409
		this.loadStructureInfo(template);
410
		StructurePlaceSettings placeSettings = new StructurePlaceSettings()
411
			.setMirror(this.mirror)
412
			.setRotation(this.rotation)
413
			.setIgnoreEntities(this.ignoreEntities)
414
			.setKnownShape(this.strict);
415
		if (this.integrity < 1.0F) {
416
			placeSettings.clearProcessors().addProcessor(new BlockRotProcessor(Mth.clamp(this.integrity, 0.0F, 1.0F))).setRandom(createRandom(this.seed));
417
		}
418
419
		BlockPos pos = this.getBlockPos().offset(this.structurePos);
420
		if (SharedConstants.DEBUG_STRUCTURE_EDIT_MODE) {
421
			BlockPos.betweenClosed(pos, pos.offset(this.structureSize)).forEach(p -> level.setBlock(p, Blocks.STRUCTURE_VOID.defaultBlockState(), 2));
422
		}
423
424
		template.placeInWorld(level, pos, pos, placeSettings, createRandom(this.seed), 2 | (this.strict ? 816 : 0));
425
	}
426
427
	public void unloadStructure() {
428
		if (this.structureName != null) {
429
			ServerLevel serverLevel = (ServerLevel)this.level;
430
			StructureTemplateManager manager = serverLevel.getStructureTemplateManager();
431
			manager.remove(this.structureName);
432
		}
433
	}
434
435
	public boolean isStructureLoadable() {
436
		if (this.mode == StructureMode.LOAD && !this.level.isClientSide() && this.structureName != null) {
437
			ServerLevel serverLevel = (ServerLevel)this.level;
438
			StructureTemplateManager manager = serverLevel.getStructureTemplateManager();
439
440
			try {
441
				return manager.get(this.structureName).isPresent();
442
			} catch (IdentifierException e) {
443
				return false;
444
			}
445
		} else {
446
			return false;
447
		}
448
	}
449
450
	public boolean isPowered() {
451
		return this.powered;
452
	}
453
454
	public void setPowered(final boolean powered) {
455
		this.powered = powered;
456
	}
457
458
	public boolean getShowAir() {
459
		return this.showAir;
460
	}
461
462
	public void setShowAir(final boolean showAir) {
463
		this.showAir = showAir;
464
	}
465
466
	public boolean getShowBoundingBox() {
467
		return this.showBoundingBox;
468
	}
469
470
	public void setShowBoundingBox(final boolean showBoundingBox) {
471
		this.showBoundingBox = showBoundingBox;
472
	}
473
474
	@Override
475
	public BoundingBoxRenderable.Mode renderMode() {
476
		if (this.mode != StructureMode.SAVE && this.mode != StructureMode.LOAD) {
477
			return BoundingBoxRenderable.Mode.NONE;
478
		} else if (this.mode == StructureMode.SAVE && this.showAir) {
479
			return BoundingBoxRenderable.Mode.BOX_AND_INVISIBLE_BLOCKS;
480
		} else {
481
			return this.mode != StructureMode.SAVE && !this.showBoundingBox ? BoundingBoxRenderable.Mode.NONE : BoundingBoxRenderable.Mode.BOX;
482
		}
483
	}
484
485
	@Override
486
	public BoundingBoxRenderable.RenderableBox getRenderableBox() {
487
		BlockPos pos = this.getStructurePos();
488
		Vec3i size = this.getStructureSize();
489
		int xOrigin = pos.getX();
490
		int zOrigin = pos.getZ();
491
		int y0 = pos.getY();
492
		int y1 = y0 + size.getY();
493
		int xDiff;
494
		int zDiff;
495
		switch (this.mirror) {
496
			case LEFT_RIGHT:
497
				xDiff = size.getX();
498
				zDiff = -size.getZ();
499
				break;
500
			case FRONT_BACK:
501
				xDiff = -size.getX();
502
				zDiff = size.getZ();
503
				break;
504
			default:
505
				xDiff = size.getX();
506
				zDiff = size.getZ();
507
		}
508
509
		int x0;
510
		int z0;
511
		int x1;
512
		int z1;
513
		switch (this.rotation) {
514
			case CLOCKWISE_90:
515
				x0 = zDiff < 0 ? xOrigin : xOrigin + 1;
516
				z0 = xDiff < 0 ? zOrigin + 1 : zOrigin;
517
				x1 = x0 - zDiff;
518
				z1 = z0 + xDiff;
519
				break;
520
			case CLOCKWISE_180:
521
				x0 = xDiff < 0 ? xOrigin : xOrigin + 1;
522
				z0 = zDiff < 0 ? zOrigin : zOrigin + 1;
523
				x1 = x0 - xDiff;
524
				z1 = z0 - zDiff;
525
				break;
526
			case COUNTERCLOCKWISE_90:
527
				x0 = zDiff < 0 ? xOrigin + 1 : xOrigin;
528
				z0 = xDiff < 0 ? zOrigin : zOrigin + 1;
529
				x1 = x0 + zDiff;
530
				z1 = z0 - xDiff;
531
				break;
532
			default:
533
				x0 = xDiff < 0 ? xOrigin + 1 : xOrigin;
534
				z0 = zDiff < 0 ? zOrigin + 1 : zOrigin;
535
				x1 = x0 + xDiff;
536
				z1 = z0 + zDiff;
537
		}
538
539
		return BoundingBoxRenderable.RenderableBox.fromCorners(x0, y0, z0, x1, y1, z1);
540
	}
541
542
	public enum UpdateType {
543
		UPDATE_DATA,
544
		SAVE_AREA,
545
		LOAD_AREA,
546
		SCAN_AREA;
547
	}
548
}
549

Decompiled Minecraft 26.3 source of StructureBlockEntity (net/minecraft/world/level/block/entity/StructureBlockEntity.java) with Mojang official mappings, stored verbatim on the site.