[Test Framework] Add a check in StructureTemplateBuilder#set to prevent placing block outside template bondaries (#950)

This commit is contained in:
Sirttas 2024-05-11 19:48:09 +02:00 committed by GitHub
parent 2d93ce5e64
commit abc54b7a49
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -79,6 +79,9 @@ public class StructureTemplateBuilder implements TemplateBuilderHelper<Structure
@Override
public StructureTemplateBuilder set(int x, int y, int z, BlockState state, @Nullable CompoundTag nbt) {
if (x < 0 || y < 0 || z < 0 || x >= size.getX() || y >= size.getY() || z >= size.getZ()) {
throw new IllegalArgumentException("Block position is out of template bounds");
}
blocks.put(new BlockPos(x, y, z), new StructureTemplate.StructureBlockInfo(new BlockPos(x, y, z), state, nbt));
return this;
}