WorldEdit

WorldEdit

43M Downloads

WorldEdit 7.1.0 API schematic Offset

TNTTripper opened this issue ยท 3 comments

commented

WorldEdit version: 7.1.0
Platform version: spigot-1.15.1

I'm using the Worldedit API to loop all schematics inside a folder and load them into a world. Problem is schematics are saved with a x,y,z offset based on the player position the schematic was copied from, when I load the schematic it could be placed anyway.

Code pasting schematic:

										ClipboardFormat format = ClipboardFormats.findByFile(schematicFile);
										try (ClipboardReader reader = format.getReader(new FileInputStream(schematicFile))) {
											Clipboard clipboard = reader.read();
											try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(BukkitAdapter.adapt(Bukkit.getWorld("Build_Helpers")), -1)) {
												Operation operation = new ClipboardHolder(clipboard)
														.createPaste(editSession)

														.maskSource(editSession.getMask())
														.to(BlockVector3.at(10, 10, 10))
														.ignoreAirBlocks(false)
														.build();

												Operations.complete(operation);
											}catch (WorldEditException e){
												e.printStackTrace();
												throw new RuntimeException("Unexpected exception", e);
											}
										}

2020-04-04_21 14 28

On worldedit-bukkit-6.1.7* (around minecraft 1.12) I could use:

CuboidClipboard clipboard = SchematicFormat.MCEDIT.load(fileSchematic);
int offsetX = clipboard.getOffset().getBlockX();
int offsetY = clipboard.getOffset().getBlockY();
int offsetZ = clipboard.getOffset().getBlockZ();

Is there a way to set clipboard offset using WorldEdit 7.1.0 API?

commented

And the answer is yes, there is a way to set/get the offset/origin if you read the clipboard interface at all before making a bug report.

commented
int x1 = 0;
int y1 = 0;
int z1 = 0;

if(clipboard.getRegion().getMinimumPoint().getBlockX() != 0){
x1 = clipboard.getRegion().getMinimumPoint().getBlockX();
}
if(clipboard.getRegion().getMinimumPoint().getBlockY() != 0){
y1 = clipboard.getRegion().getMinimumPoint().getBlockY();
}
if(clipboard.getRegion().getMinimumPoint().getBlockZ() != 0){
z1 = clipboard.getRegion().getMinimumPoint().getBlockZ();
}

clipboard.setOrigin(BlockVector3.at(+x1, +y1, +z1));

2020-04-05_04 02 42

Working!! :) Thanks guys, sorry for the trouble

commented

Confused as to why this is a bug report.