Setting a block through a ID at a specific location.....

Discussion in 'Plugin Development' started by -_Husky_-, Apr 26, 2012.

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

    -_Husky_-

    Ok, i need to set a block at a location, with a ID of a block. is it possible?

    for example.

    int x = p.getLocation().getBlockX();
    int y = p.getLocation().getBlockY();
    int z = p.getLocation().getBlockZ();
    int id = 1; // this is stone- i need to set x,y,z to ID 1 (stone)
     
  2. Offline

    r0306

    Here you go:
    Code:
    Block block = world.getBlockAt(x,y,z);
    block.setTypeId(1);
     
    -_Husky_- likes this.
  3. Offline

    Njol

    firstly you can use location.getBlock, and secondly it's easier to read the code if you use a Material:
    p.getLocation().getBlock().setType(Material.STONE)
     
    vtg_the_kid likes this.
Thread Status:
Not open for further replies.

Share This Page