Solved Problem with for looping

Discussion in 'Spigot Plugin Development' started by Videosambo, Sep 16, 2018 at 12:16 PM.

Thread Status:
Not open for further replies.
  1. Hello, I'm making portal plugin where player can build a portal and then use it to travel another world, like nether portal. I'm now at point where code builds portal middle a.k.a portal frame for the portal. This loop only run the second for loop of 2 for loops. And that's why builds only half of the portal frames. So, this method takes portal opposite corners coordinates and portal directional way and world name. Here is code and sry for my bad English:

    Code (Text):

    public void makePortal(int x1, int y1, int z1, int x2, int y2, int z2, String s, String world) {
            if (s.equals("x")) {
                x1 = x1 + 1;
                y1 = y1 + 1;
                x2 = x2 - 1;
                y2 = y2 - 1;
                int i = 0;
                Bukkit.getServer().getConsoleSender().sendMessage("Portal high: " + y1 + " and " + y2);
                Bukkit.getServer().getConsoleSender().sendMessage("Portal lenght: " + x1 + " and " + x2);
                for (; x1 <= x2; x1++, i++) {
                    for (; y1 <= y2; y1++, i++) {
                        Bukkit.getServer().getWorld(world).getBlockAt(x1, y1, z1).setType(Material.GLASS_PANE);
                        Bukkit.getServer().getConsoleSender().sendMessage("Portal glass: " + i);
                    }
                }
           }

           //here should be y direction, it's same as code as above, only couple variables are differend

    }
     
     
  2. You have nothing, you're looping through nothing.
    for(nothing; x1 <= x2)
     
    • Funny Funny x 1
  3. oh, I tested with like x1 = x1 but it's same as (; x1 <= x2...)
     
  4. Okay, I find a solution for this.
     
Thread Status:
Not open for further replies.

Share This Page