Quick question

Discussion in 'Plugin Development' started by CraterHater, Jul 14, 2015.

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

    CraterHater

    I've got a location called egg, and I want to set the blocks around that location to fire, how do I do that? And how do I check that if the block that he attempts to transform into fire is already a block and not air so he doesn't set it.

    Help would be appreciated, CraterHater.
     
  2. Offline

    mine-care

    @CraterHater can we see what you tried so far?
    Use Block#getRelative(BlockFace.X) for west, southm north, east and set them alight if their type is air.
     
  3. Offline

    mariosunny

    "Around" is ambiguous here. Do you mean the 6 cardinal blocks around egg, or the 3x3x3 cube of blocks centered at egg?
     
  4. Offline

    lilian58660

    just add to your location
     
  5. Offline

    CraterHater

  6. Offline

    lilian58660

    Code:
    //Your location
    Location yourlocation = something
    // 9 new locations
            Location l1 = new Location(getServer().getWorld("something"), b.getLocation().getBlockX()+1, b.getLocation().getY()+1, b.getLocation().getZ()+1);
    You use this 9 times to get the 9 blocks ^^
    btw b is yourlocation ^^
     
  7. Offline

    mariosunny

    Or use the add() method. It's less verbose.

    Code:
    Block block;
    Location egg;
           
    for(int x = -1;x <= 1; x++) {
       
        for(int y = -1; y <= 1; y++) {
           
            for(int z = -1; z <= 1; z++) {
               
                if(x == 0 && y == 0 && z == 0) continue;
               
                block = egg.add(x, y, z).getBlock();
           
                if(block.getType() == Material.AIR) {
                   
                    block.setType(Material.FIRE);
                }
            }
        }
    }
     
  8. Offline

    CraterHater

    @mariosunny @lilian58660 why doesn't this work?
    Code:
     Location l1 = new Location(getServer().getWorld("Pvp"), egg.getLocation().getBlockX()+1, egg.getLocation().getY(), egg.getLocation().getZ());
            ((Block) l1).setType(Material.FIRE);
    @mariosunny @lilian58660 why doesn't this work?
    Code:
     Location l1 = new Location(getServer().getWorld("Pvp"), egg.getLocation().getBlockX()+1, egg.getLocation().getY(), egg.getLocation().getZ());
            ((Block) l1).setType(Material.FIRE);
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  9. Offline

    Zombie_Striker

    @CraterHater
    1. Double posting
    2. A LOCATION IS NOT THE SAME AS A BLOCK, SO WHY ARE YOU CASTING IT TO BE A BLOCK
     
  10. Offline

    CraterHater

  11. Offline

    Zombie_Striker

    @CraterHater
    Location#getBlock

    This is really basic bukkit coding? Why have you not thought of this already?
     
  12. Offline

    CraterHater

    @Zombie_Striker yeah but I can't seem to get how it works, would you mind giving me the code... I know this is spoonfeeding but its so small that I will learn more of just reading it again and refreshing my mind about that
     
  13. Offline

    mariosunny

  14. Offline

    Zombie_Striker

    @CraterHater
    Its one thing to spoonfeed methods, because with that it giving the Developer the method to do the thing they want without them learning what to do. This is worse because this is one line with TWO BITS TO IT! Its not even that hard to understand. THE NAME SAYS EXACTLY WHAT IT DOES! If you cant' figure out how to use Location#getBlock, then you really need to learn Java, because that shows you do not know how to use classes or methods.
     
  15. Offline

    lilian58660

    #getBlockat(l1)
    or #getBlockAt (l1) idk i'm not at home ^^
     
  16. Offline

    Zombie_Striker

    @lilian58660
    getBlockat a location is only used for the fields that extend World. Use getBlock for field that extends Location
     
  17. Offline

    lilian58660

    Okay, I just saw this line somewhere ^^
     
  18. Offline

    Zombie_Striker

  19. Offline

    lilian58660


     
Thread Status:
Not open for further replies.

Share This Page