New Block

Discussion in 'Plugin Development' started by GH0STX05, Jan 18, 2011.

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

    GH0STX05

    How do I create a block and set it at a player's location?
     
  2. Offline

    Meta1203

    If you have the Player variable, try this code:
    Code:
    import org.bukkit.World;
    
    //everything in between
    
    Location loc = player.getLocation();
    World world[] = getServer().getWorlds();
    Block blocktoset = world[0].getBlockAt(loc.getX(),loc.getY(),loc.getZ());
    blocktoset.setTypeId(id);
    
    
     
  3. Offline

    Archelaus

    I thought "getBlockAt" would get the block, not set it.
     
  4. Offline

    Lycake

    There are no empty spaces in minecraft. Blocks you can't see are most likely air blocks (TypeId = 0). So just get the (already existing) block at the players position (with getBlockAt) and change the TypeId of it to whatever you want.

    €dit: I think you have to convert the double from getX()/getY()/getZ() to int !? (Haven't tried, just something that came into my mind)

    Cake
     
  5. Offline

    Meta1203

    It does. You get the block object then you edit the block from what you have.
     
Thread Status:
Not open for further replies.

Share This Page