1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved setBlock

Discussion in 'Development' started by esh123cookie, Jul 21, 2020.

  1. esh123cookie

    esh123cookie Baby Zombie

    Messages:
    104
    GitHub:
    esh123cookie
    How do you set a minecraft stone slab on the top half of a block
     
  2. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    Wow, Good Question Lol.
    try to use setBlock like
    PHP:
    //for setting bloch slab i think you should use:
    $y 0.25
    i dont know if its working or not, but this is my idea pls try it on InteractEvent and tell me Resault ;)
     
  3. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    $y is $player->y or $block->y
    and every 0.5 is the center of a block, i mean when you want to get player under block, you use $y - 0.5 and when you get $y - 0.25 or $y - 1.25 it'll get slab under player.
    it should work but im not sure.:rolleyes:;)
     
  4. esh123cookie

    esh123cookie Baby Zombie

    Messages:
    104
    GitHub:
    esh123cookie
    Well usually settings blocks like stairs you would do
    Code:
    $player->getDirection()
    And by doing that you can place stairs, but whats super confusing is if you are not using $player and just cords onRun function. Ive tried $block->setDirection but that doesnt work
     
  5. esh123cookie

    esh123cookie Baby Zombie

    Messages:
    104
    GitHub:
    esh123cookie
    Figured it out


    PHP:
                   $stair BlockFactory::get(Block::BRICK_STAIRS);
                            
    $stairdown Block::get(Block::BRICK_STAIRS,1);
     
  6. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    Bruh its not full code (i used in here)
    so you should know when i said $y - 0.5, $y is $player->y Lol i didnt send full code, i though you know
     
  7. esh123cookie

    esh123cookie Baby Zombie

    Messages:
    104
    GitHub:
    esh123cookie
    Ye my bad I forgot to ask about stairs aswell.
    Both ways work for slabs though

    Just something that confuses me is brick slabs
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.