Solved Vector origin

Discussion in 'Plugin Development' started by Fl1pzta, Jul 16, 2013.

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

    Fl1pzta

    I'm having an issue and I think it has something to do with the origin when I'm rotating the loaded schematic. When rotated, the schematic places about two blocks too far back or to the right or left from origin. How can I make this follow exactly how //rotate works and how it doesn't move the origin one bit. Also, loc is an unaltered player's location if that has anything to do with it. Any help would be greatly appreciated. Been up for about 15 hours now, lol.


    Code:java
    1. private void loadArea(String name, String pname,Location loc,BlockFace direction)
    2. throws DataException, IOException, MaxChangedBlocksException
    3. {
    4.  
    5. File file = new File(main.we.getDataFolder()+"/schematics/"+name+".schematic");
    6. EditSession es = new EditSession(new BukkitWorld(main.getWorld()), Integer.MAX_VALUE);
    7. CuboidClipboard cc = SchematicFormat.MCEDIT.load(file);
    8.  
    9. Vector origin = BukkitUtil.toVector(loc);
    10. //cc.setOrigin(origin);
    11. int height = cc.getHeight();
    12. int x1,x2,y1,y2,z1,z2;
    13.  
    14. y1 = (int)loc.getY();
    15. y2 =(int)loc.getY()+height;
    16. x1 = (int)loc.getX();
    17. z1 = (int)loc.getZ();
    18. if(direction ==BlockFace.NORTH){
    19. cc.rotate2D(90);
    20. x2 = x1-cc.getWidth();
    21. z2 = z1+cc.getLength();
    22. }
    23. if(direction ==BlockFace.SOUTH){
    24. cc.rotate2D(270);
    25. x2 = x1+cc.getWidth();
    26. z2 = z1-cc.getLength();
    27. }
    28. if(direction ==BlockFace.EAST){
    29. cc.rotate2D(90);
    30. x2=x1-cc.getLength();
    31. z2=z1-cc.getWidth();
    32. }else{
    33. cc.rotate2D(270);
    34. x2=x1+cc.getLength();
    35. z2=z1+cc.getWidth();
    36. }
    37. cc.paste(es, origin, true, true);
    38. Player player = Bukkit.getPlayer(pname);
    39. if(player.isOnline()){
    40. player.sendMessage(ChatColor.GREEN + "Your " + name + " building has been placed.");
    41. }
    42. }


    I just feel like the origin isn't centered or something if that makes any sense.

    bump

    Fixed, don't convert player location to a wedit vector. get block loc

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
Thread Status:
Not open for further replies.

Share This Page