Solved Find where a gold block is when placing a schematic and save location.

Discussion in 'Spigot Plugin Development' started by Xemor, Jan 27, 2020.

  1. Hi o/! I'm trying to find where a gold block is when I place a schematic and save the coordinates of it, this is so I can teleport the player there afterwards. I'm not sure how I'd iterate through the clipboard beforehand to find this location (I assume this would be more efficient than doing it afterwards) or if doing it afterwards is acceptable tell me how to do it. I imagine doing it asynchronously might be a good idea in case large schematics are used? Any help would be appreciated :)
     
  2. FrostedSnowman

    Resource Staff

    How are you pasting it?
     
  3. You’d want to do it async of course, what is your question really?
     
  4. I'm pasting it using a WorldEdit API clipboard. It's a hard question because I'm not even sure on how to go about implementing it.
     
  5. Suggestion: Instead of looking for the block when pasting the schematic, save the offset from the start block when saving the schematic and then calculate where the gold block is based on the saved offset.
     
  6. Alright @robertlit , I'll just save the locations I guess?
     
  7. Yes . Let's say you saved the schematic at (x,y,z) and the gold block is at (x+1,y,z). When pasting the schematic, let's say at (a,b,c), the gold block will be at (a+1,b,c). You can use the methods Location#subtract and Location#add