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

GroundLevel

Discussion in 'Development' started by abimalek, Oct 29, 2017.

  1. abimalek

    abimalek Witch

    Messages:
    74
    GitHub:
    megagastpvp
    I'm trying to spawn a chest and add items to it and one of the problems I've encountered is spawning it at ground level how would I do that?
     
  2. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    spawning it at ground level? are you currently spawning it in the air or what?
     
    EdwardHamHam likes this.
  3. abimalek

    abimalek Witch

    Messages:
    74
    GitHub:
    megagastpvp
    I'm trying to make y groundlevel so it always spawns on the ground insteade of y being like 80 its groundlevel for the block its at or I should say one block above ground level
     
  4. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    :facepalm:
     
  5. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Ah so you want to get the highest real block (not air) at a position (X,Y)
    PHP:
    /** @var $level pocketmine\level\Level */
    /** @var $x int */
    /** @var $y int */
    $highestBlockY $level->getHighestBlockAt($x$z);
    $y $highestBlockY 1;
    //now spawn your chest at $x, $y, $z
     
    Muqsit and NickTehUnicorn like this.
  6. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    Y'all know that this won't work right ? Chest can't be opened when it's far more than blocks from the player (Client side)
     
  7. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    he is populating a map with random chests for players to find. Your comment is useless to this thread.
     
    jasonwynn10, Irish and EdwardHamHam like this.
  8. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    If you want to avoid placing the chest block on a non-solid block to make it look natural, you can check for transparency of the block at $highestBlockY (from robske's reply)
    PHP:
    $blockBeneath $level->getBlockAt($x$highestBlockY$z);
    $canPlaceChest = !$blockBeneath->isTransparent() && !$blockBeneath->isFlowable();
    if(
    $canPlaceChest){
        
    //place chest at ($x, $y, $z)
    }
    This is just to avoid things like these from happening, but will also avoid chest from being placed on glass too.
    cee.PNG
     
    jasonwynn10 likes this.
  9. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    i didn't undertsand what he wanted.
     
  10. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    and hey your comment is useless aswell
     
  11. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Both of those comments are useless also! So is this one!
     
  12. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    If you feel insulted, I didn't want to do that at all, sorry.
    Even more useless comment(s)!
     
  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.