1.14.4 WorldEdit Region Mask

Discussion in 'Spigot Plugin Development' started by 55Navyboy, Jan 19, 2020.

  1. So I have been trying for a while to make a region mask so when I paste a schematic, it will not remove the specific region, but everything around it.

    This is what I had so far, I don't get any errors but it doesn't paste

    Code (Java):
    public void setSchematic(String theme, Player p) {
        World worldf = Bukkit.getWorld("PlayerHousing"); //Gets world name
        BukkitWorld world = new BukkitWorld(worldf); //Make world into BukkitWorld
        File schematic = new File("plugins/PlayerHousing/schematics/" + theme + ".schematic"); // Find the schematic file location
        Clipboard clipboard = null; //Creates Clipboard
        ClipboardFormat format = ClipboardFormats.findByFile(schematic);
        try (ClipboardReader reader = format.getReader(new FileInputStream(schematic))) { //Trys to put schematic in clipboard
            clipboard = reader.read();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        UUID uuid = p.getUniqueId(); //Grabs Player UUID
        File playerIslandFile = new File("plugins/PlayerHousing/Islands/" + uuid + ".yml");
        YamlConfiguration playerIslandCord = YamlConfiguration.loadConfiguration(playerIslandFile);
        double x = (double) playerIslandCord.get("IslandX");
        double y = (double) playerIslandCord.get("IslandX");
        double z = (double) playerIslandCord.get("IslandX");
        BlockVector3 pos1 = BlockVector3.at(x+15, y+19, z+15);
        BlockVector3 pos2 = BlockVector3.at(x-15, y-10, z-15);
        Region region = new CuboidRegion(pos1, pos2);
        RegionMask mask = new RegionMask(region);
        try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1)) {
            editSession.setMask(mask);
            Operation operation = new ClipboardHolder(clipboard)
                    .createPaste(editSession)
                    .to(BlockVector3.at(x, y, z))
                    .build(); //Pastes build
            try {
                Operations.complete(operation); //Tries to complete everything
            } catch (WorldEditException e) {
                e.printStackTrace();
            }
        }
    }
    Any ideas???
     
  2. LukeEff

    LukeEff Previously Thatgangster

    double x = (double) playerIslandCord.get("IslandX");
    double y = (double) playerIslandCord.get("IslandX");
    double z = (double) playerIslandCord.get("IslandX");

    Looks like you’re pulled the same piece of information 3 times by accident