Custom Schematic not rotating

Discussion in 'Spigot Plugin Development' started by RayNightStudios, Jul 7, 2019.

  1. So i made a schematic plugin and i want to rotate the placed building relative to the players direction so its rotated correctly but it wont work :/
    Code (Text):

    public void place(Player player) {
        final double yaw = (player.getLocation().getYaw() - 90) % 360;
        final Location relativeCenter = player.getLocation().clone();
        for(String blockString : this.blocks) {
            int x, y, z, blockId, damage;
            x = Integer.valueOf(blockString.split(":")[0]);
            y = Integer.valueOf(blockString.split(":")[1]);
            z = Integer.valueOf(blockString.split(":")[2]);
            blockId = Integer.valueOf(blockString.split(":")[3]);
            damage = Integer.valueOf(blockString.split(":")[4]);

            int relativeX, relativeZ;

            if(yaw >= 0D && yaw < 22.5D) {
                relativeX = x;
                relativeZ = z;
            } else if(yaw >= 67.5D && yaw < 112.5D) {
                relativeX = z;
                relativeZ = x;
            } else if(yaw >= 157.5D && yaw < 202.5D) {
                relativeX = -x;
                relativeZ = -z;
            } else if(yaw >= 247.5D && yaw < 292.5D) {
                relativeX = -z;
                relativeZ = -x;
            } else {
                relativeX = x;
                relativeZ = z;
            }

            relativeCenter.clone().add(relativeX, y, relativeZ).getBlock().setTypeIdAndData(blockId, (byte) damage, true);

        }

    }
     
     
    #1 RayNightStudios, Jul 7, 2019
    Last edited: Jul 7, 2019
  2. hey, i'm not a pro with shematics, i can recommand you to check the source code of worldedit in the command //rotate, it can help you. have a nice day