Skip to content

Commit

Permalink
fix: ensure sizeX|Y|Z is bigger than zero when picking structure usin…
Browse files Browse the repository at this point in the history
…g structure command
  • Loading branch information
smartcmd committed Dec 25, 2024
1 parent 16ccb81 commit 7fa4797
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,18 @@ public void prepareCommandTree(CommandTree tree) {
String fileName = context.getResult(1);
Vector3f start = ((Vector3f) context.getResult(2)).floor();
Vector3f end = ((Vector3f) context.getResult(3)).floor();
var sizeX = (int) (end.x - start.x + 1);
var sizeY = (int) (end.y - start.y + 1);
var sizeZ = (int) (end.z - start.z + 1);
// SizeX|Y|Z should bigger than 0
if (sizeX <= 0 || sizeY <= 0 || sizeZ <= 0) {
context.addError("Invalid size");
return context.fail();
}
var structure = Structure.pickStructure(
player.getDimension(),
(int) start.x, (int) start.y, (int) start.z,
(int) (end.x - start.x), (int) (end.y - start.y), (int) (end.z - start.z),
sizeX, sizeY, sizeZ,
true
);
var filePath = STRUCTURE_DIR.resolve(fileName + STRUCTURE_FILE_EXT);
Expand Down

0 comments on commit 7fa4797

Please sign in to comment.