Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

setBlock help PLSSSSSSSSSSS

Comments in 'Plugin Development' started by PEMapModder, Nov 19, 2013.

  1. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I am trying to use the function $level->setBlock(), but I am not sure what parameters to use.
    For example, when a player destroys a block at (new Vector3(X,Y,Z)), how do I turn the block at (new Vector3(X,Y,Z+1)) to air?
    I know I should use
    PHP:
    $level->setBlock(new Vector3(X,Y,Z+1), $block)
    , but how do I make a block?
    I tried
    PHP:
    new Block(0)
    , but error dump said Block cannot be instaniated.

    PLEASE HELP.
  2. Qub1
    Offline

    Qub1 New Member

    Joined:
    Nov 6, 2013
    Posts:
    16
    Minecraft User:
    Qub1
    Usage:
    Code:
    $air = BlockAPI::get(0, 0);
    $level->setBlock(new Vector3($x, $y, $z + 1), $air);
    Where the first 0 in the Block API is the air block ID, and the second 0 is the binary indicator, which is usually not used.
    The rest is pretty much self-explanatory.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    thx
    PocketKiller likes this.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    So the second parameter is saying whether it is in denary? Can I omit it?
  5. Qub1
    Offline

    Qub1 New Member

    Joined:
    Nov 6, 2013
    Posts:
    16
    Minecraft User:
    Qub1
    If you mean the parameters of BlockAPI then yes you are right, you can leave it at 0. Don't completely leave it out though, just set it to 0.

Share This Page

Advertisement