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

[NEW API][SOLVED] Put a block from the console? Help me please

Comments in 'Plugin Development' started by xionbig, Jul 20, 2014.

  1. xionbig
    Offline

    xionbig Active Member Plugin Developer

    Joined:
    Jun 11, 2014
    Posts:
    106
    Plugins:
    2
    Minecraft User:
    NikoZazza
    Hello everyone, I have a little big problem:
    then the code is this
    PHP:
    Server::getInstance()->getLevelByName("world")->setBlockIdAt(4501625046);
    With this code I would like to put a block in the world "world" from the console! Is it possible?

    When I use it appears this error: "Tried to modify an empty Chunk"

    Thanks
  2. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    like you want execute a command then it well change the id of that block?
  3. xionbig
    Offline

    xionbig Active Member Plugin Developer

    Joined:
    Jun 11, 2014
    Posts:
    106
    Plugins:
    2
    Minecraft User:
    NikoZazza
    This was an example, the id of the block is taken from the file. yml
  4. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    It seems that the chunk is not generated yet, play around with the cords and see if you can get it to work.
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The "execute a command" thing is just not important to you at all.
    Maybe they should generate that chunk first?
    xionbig likes this.
  6. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    :p
  7. xionbig
    Offline

    xionbig Active Member Plugin Developer

    Joined:
    Jun 11, 2014
    Posts:
    106
    Plugins:
    2
    Minecraft User:
    NikoZazza
    I do not know why, this code was not working yesterday, now it works!
    The mysteries of life!
    PHP:
    Server::getInstance()->getLevelByName("world")->generateChunk(400 250);
    Thanks to everyone for the help!
    PEMapModder likes this.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I thought the numbers should be chunk ID instead of coordinates.
    xionbig likes this.
  9. xionbig
    Offline

    xionbig Active Member Plugin Developer

    Joined:
    Jun 11, 2014
    Posts:
    106
    Plugins:
    2
    Minecraft User:
    NikoZazza
    But how do I make the changes visible to users?
    When I use setBlockIdAt (), the player does not see the changes until he comes out and enters on the server
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    That Level->setBlockIdAt() function is for world generation purposes. If you want to set them in-game like world editors, use Level->setBlock() with $direct set to true.
    xionbig likes this.
  11. xionbig
    Offline

    xionbig Active Member Plugin Developer

    Joined:
    Jun 11, 2014
    Posts:
    106
    Plugins:
    2
    Minecraft User:
    NikoZazza
    Thank you very much, I solved this way:
    PHP:
    Server::getInstance()->getLevelByName("world")->setBlock(new Vector3($x$y$z$c), Block::get($block_id0), true);

Share This Page

Advertisement