WorldEdit Pasting drops levers, doors, signs etc. ?

Discussion in 'Plugin Development' started by ThunderWaffeMC, Mar 1, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    ThunderWaffeMC

    Hi. I'm having an issue with pasting a schematic from WorldEdit. It seems that all doors, signs, levers, button or anything that needs to be attached to a block drops and isn't pasted. Here's my code:

    Code:java
    1.  
    2. public void pasteVehicleSchematic(String schematicName, Location location, String player) {
    3. String playerName = player;
    4. EditSession session = new EditSession(new BukkitWorld(location.getWorld()), Integer.MAX_VALUE);
    5. try {
    6. try {
    7. File file = new File("plugins/WorldEdit/schematics/" + schematicName + ".schematic");
    8. SchematicFormat schematic = SchematicFormat.getFormat(file);
    9. CuboidClipboard clipboard = schematic.load(file);
    10. clipboard.place(session, BukkitUtil.toVector(location), true);
    11. } catch (NullPointerException ex) {
    12.  
    13. }
    14. } catch (IOException | DataException | MaxChangedBlocksException e) {
    15. ((Throwable)e).printStackTrace();
    16. }
    17. }
    18.  


    I've looked around a bit and someone said there was an enableQueue() option for EditSession which should paste all the doors, signs, levers etc. last. I'm not unsure how to use that or if that works.

    Any help is appreciated, thanks!
     
  2. Offline

    NathanWolf

    Is there a "paste" method in CuboidClipboard? I want to say there is, and that it does what you want, but I could be mistaken.
     
  3. Offline

    ThunderWaffeMC

    My clipboard.place method pastes the schematic but all blocks that need a host block seem to drop (signs, doors, levers, buttons etc.). I read somewhere that I may need to use a method that pastes all the signs, doors, levers last. How can I do something like that or stop them from dropping/breaking ?
     
  4. Offline

    sk89q

    Call session.enableQueue() before you make the changes and then session.flushQueue() after you are done.
     
    NathanWolf and ThunderWaffeMC like this.
  5. Offline

    ThunderWaffeMC

    sk89q
    Thanks! It keeps the blocks now but the items still drop. Any idea?

    Code:java
    1.  
    2. public void pasteVehicleSchematic(String schematicName, Location location, String player) {
    3. String playerName = player;
    4. EditSession session = new EditSession(new BukkitWorld(location.getWorld()), Integer.MAX_VALUE);
    5. session.enableQueue();
    6. try {
    7. try {
    8. File file = new File("plugins/WorldEdit/schematics/" + schematicName + ".schematic");
    9. SchematicFormat schematic = SchematicFormat.getFormat(file);
    10. CuboidClipboard clipboard = schematic.load(file);
    11. clipboard.place(session, BukkitUtil.toVector(location), true);
    12. } catch (NullPointerException ex) {
    13.  
    14. }
    15. } catch (IOException | DataException | MaxChangedBlocksException e) {
    16. ((Throwable)e).printStackTrace();
    17. }
    18. session.flushQueue();
    19. }
    20.  
     
  6. Offline

    NathanWolf

    Wow, you got an answer from the man himself :)

    But really. Try paste instead of place. I think it makes a difference, I just checked the CuboidClipboard code on GitHub. Sk8 or someone can correct me if I'm wrong though.
     
  7. Offline

    ThunderWaffeMC

    I'll give it a try. And yes it is nice to get sk to help out on a random forum post, haha.

    Cheers
     
    NathanWolf likes this.
Thread Status:
Not open for further replies.

Share This Page