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

[Help] Place block under player's feet?

Comments in 'Plugin Development' started by Jaxius, Jul 19, 2015.

  1. Jaxius
    Offline

    Jaxius New Member

    Joined:
    Jul 19, 2015
    Posts:
    1
    Minecraft User:
    Jaxius
    Hello! I am making a "Snow Wizard" plugin just for fun and to learn. I have a lot of the basics down. I am just a little stumped on how to place a block. My objective is to make a magic-carpet like plugin that does not allow to jump up and walk in air (you stay on the ground) and it puts a SnowLayer over the blocks the player walks on in a 5 block area. I have most of this learned. Besides placing the actual block .-. (yeh I'm a nub) I checked the help docs and this is what is provided: place (Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player=null) Honestly I really do not know how to put this to use.
    I do believe you need to define the item id with $id = *id* or something of the sorts.
    This may be posted somewhere, if so then sorry for wasting your time.
  2. Asidert
    Offline

    Asidert Active Member Plugin Developer

    Joined:
    Oct 21, 2014
    Posts:
    123
    Plugins:
    1
    Minecraft User:
    Asidert
    It's easy...
    PHP:
    $level->setBlock(new Vector3($p->getX(), $p->getY()-1$p->getZ()), Block::get(/*BlockID*/));
  3. Asidert
    Offline

    Asidert Active Member Plugin Developer

    Joined:
    Oct 21, 2014
    Posts:
    123
    Plugins:
    1
    Minecraft User:
    Asidert
    PHP:
    $level=$this->getServer()->getDefaultLevel(); /*For example*/
    $p=$event->getPlayer(); /*If you use this in player event*/
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Or simply
    PHP:
    $Player->getLevel()->setBlock($Player->subtract(01), $Block);
    :)
    $Block can be accessed through Block::get($blockId, $blockDamage) where $blockDamage is 0 if you don't put anything there.
    Could the level be anything other than the player's current level?
  5. Asidert
    Offline

    Asidert Active Member Plugin Developer

    Joined:
    Oct 21, 2014
    Posts:
    123
    Plugins:
    1
    Minecraft User:
    Asidert
    How work substract()?
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder

Share This Page

Advertisement