Paste schematic in front of the player

Discussion in 'Plugin Development' started by zDubsCrazy, Jan 14, 2016.

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

    zDubsCrazy

    Hello,

    I'm trying paste a schematic in front of player. E.g: if the player is looking to NORTH, paste in front, if looking to SOUTH, paste in front, etc. But always, this is pasted in side. How change this?

    PS: I'm using WorldEdit API.

    Thanks in advance.
     
  2. Offline

    teej107

    @zDubsCrazy You need to get the direction the player is facing and then paste in the right location based on that.
     
  3. Offline

    zDubsCrazy

    @teej107 Yes, i was using a method of sk85q used in WorldEdit to get the cardinal location, but i not know how to get the relative location based on this.
     
  4. Offline

    teej107

    Can you show us your current code?
     
  5. Offline

    zDubsCrazy

    @teej107
    To paste schematic:
    Code:
    EditSession es = new EditSession(new BukkitWorld(toPaste.getWorld()), Integer.MAX_VALUE);
    SchematicFormat  format = SchematicFormat.getFormat(f);
    CuboidClipboard cc = format.load(f);
    cc.paste(es, BukkitUtil.toVector(toPaste), true, true);
    To get direction of player is looking:
    Code:
        public static String getCardinalDirection(Player player) {
                double rotation = (player.getLocation().getYaw() - 90) % 360;
                if (rotation < 0) {
                    rotation += 360.0;
                }
                 if (0 <= rotation && rotation < 22.5) {
                    return "N";
                } else if (22.5 <= rotation && rotation < 67.5) {
                    return "NE";
                } else if (67.5 <= rotation && rotation < 112.5) {
                    return "E";
                } else if (112.5 <= rotation && rotation < 157.5) {
                    return "SE";
                } else if (157.5 <= rotation && rotation < 202.5) {
                    return "S";
                } else if (202.5 <= rotation && rotation < 247.5) {
                    return "SW";
                } else if (247.5 <= rotation && rotation < 292.5) {
                    return "W";
                } else if (292.5 <= rotation && rotation < 337.5) {
                    return "NW";
                } else if (337.5 <= rotation && rotation < 360.0) {
                    return "N";
                } else {
                    return null;
                }
            }
    BUMP

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

Share This Page