ftw wall?

Discussion in 'Plugin Development' started by DevManABCD, Aug 29, 2014.

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

    DevManABCD

    Someone knows why my code does that:

    [​IMG]


    Not that:

    [​IMG]

    Its very interesting...


    Code:java
    1. public void set(Player p, double y, double z) {
    2. Location l = new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY() + y, p.getLocation().getZ() + z);
    3. l.getBlock().setType(Material.GLASS);
    4. }
    5.  
    6. for (int i = 0; i < 10; i++) {
    7. set(p, i, i);
    8.  
    9. }
     
    hintss likes this.
  2. Offline

    TheOddPuff

    DevManABCD Your loop only sets ten block, and every time it increases it's Y & Z coordinate, causing the blocks to be placed diagonal.
     
  3. Offline

    DevManABCD

    What i need to change? ;x
     
  4. Offline

    Necrodoom

    DevManABCD Actually use 2 seperate loops?
    Not sure how do you expect a single variable to hold 2 different values.
     
  5. Offline

    DevManABCD

    I believe its possible in one ;)
     
  6. Offline

    TheOddPuff

    DevManABCD You need to select a cuboid of blocks, and then set them all to glass.

    Use this resource to make this possible: http://forums.bukkit.org/threads/protection-region-cuboid-creation.164161/

    Code:java
    1. Location loc1 = new Location(p.getLocation().getWorld(), p.getX(), p.getLocation().getY() + 1, p.getLocation().getZ());
    2. Location loc2 = new Location(p.getLocation().getWorld(), p.getX() + 10, p.getLocation().getY(), p.getLocation().getZ() + 10);
    3. Cuboid cuboid = new Cuboid(loc1, loc2);
    4. for (Block block : cuboid) {
    5. lock.setType(Material.GLASS);
    6. }
     
  7. Offline

    Necrodoom

    DevManABCD Go ahead and write a 2D iterator in a single loop, then.
     
    timtower likes this.
  8. Online

    timtower Administrator Administrator Moderator

    Prove it please. Wish to see code of that.
     
  9. Code:java
    1. //...
    2. for(int i=0; i<100; i++){
    3. set(p, i%10, i/10);
    4. }
    5.  


    Edit: DevManABCD , please don't use this in your plugin; just go with 2 loops.
     
  10. Online

    timtower Administrator Administrator Moderator

    Well, didn't think of that. The math behind it is more complicated then a double loop.
     
  11. Offline

    DevManABCD

    Need to create dynamic generating wall

    Watch at 0:26.


     
  12. Online

    timtower Administrator Administrator Moderator

    DevManABCD That would be 2 loops for the left and forward stuff. And a loop for the height.
    Or a timelapse
     
  13. Offline

    DevManABCD

    For me fresh java/bukkit codder its too dificult and i need some tips for that. I dont expect ready code.
     
  14. Offline

    Necrodoom

  15. Online

    timtower Administrator Administrator Moderator

    I have a tip: Don't start in bukkit at the same moment that you start with java. Get to know the java basics first. Then come back to bukkit. It will help you a lot.
     
  16. Offline

    DevManABCD

    I know something about java...

    Theres no problem with code, but with... idea, good idea...
     
  17. Online

    timtower Administrator Administrator Moderator

    Then:
    Multiple people told you that already.
    And don't try to do things when you don't know how. Take small steps
     
  18. Offline

    Necrodoom

    DevManABCD But yet you expect a variable to hold 2 different values.
    I dont see why you dont use a nested loop to do a 2D rectangle.
     
Thread Status:
Not open for further replies.

Share This Page