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

How to make fake beacon/light?

Discussion in 'Development' started by YogaLose, May 18, 2021.

  1. YogaLose

    YogaLose Spider

    Messages:
    10
    Couldn't the beacon light just appear?
    How to make the block appear or just the light (if possible) for only one player to see?
    or leave the blocks invisible and untouchable and only the light will appear

    PHP:
    private function startBeacon(Player $player): void{
            
    $level $player->getLevel();
            
    $x =    $player->getX();
            
    $y  =   $player->getY();
            
    $z  =   $player->getZ();
            
    $block $level->getBlockAt($x$y$z);
            
    $level->setBlock($blockBlockFactory::get(Block::BEACON), truetrue);
            
    $pos $block->getSide(0);
            for(
    $blockX $pos->1$blockX <= $pos->1$blockX++){
                for(
    $blockZ $pos->1$blockZ <= $pos->1$blockZ++){
                    
    $baseBlock $level->getBlockAt($blockX$pos->y$blockZ);
                    
    $level->setBlock($baseBlockBlockFactory::get(Block::IRON_BLOCK), truefalse);
                }
            }
            return;
        }
     
    Last edited: May 18, 2021
  2. Axon

    Axon Zombie

    Messages:
    276
    You can spawn the beacon light to a location.
    Send BlockEntityDataPacket to the player you want to spawn the beacon to.
    Notice: This will send a ghost tile and will not be handled by Pocketmine.
    PHP:
    $pk = new BlockEntityDataPacket();
    $pk->$x;
    $pk->$y;
    $pk->$z;
    $pk->namedtag = new CompoundTag("", [
        new 
    StringTag("id""Beacon"),
        new 
    IntTag("x"$x),
        new 
    IntTag("y"$y),
        new 
    IntTag("z"$z)
    ]);
    $player->dataPacket($pk);
    Make sure to set the variables x, y and z to the coordinates like this.
    PHP:
    $x = (int) 54;
    $y = (int) 72;
    $z = (int) 100;
     
    Agent likes this.
  3. YogaLose

    YogaLose Spider

    Messages:
    10
    This is old, BlockEntityDataPacket doesn't even exist anymore, not even this link works. What you did was ctrl + c ctrl + v.
     
  4. Axon

    Axon Zombie

    Messages:
    276
    I did. I attempted to research which you can also do rather than asking other people to do it.
     
    Last edited: Nov 30, 2021
    Agent likes this.
  5. YogaLose

    YogaLose Spider

    Messages:
    10
    thanks, but i had already done it.
     
  6. None

    None Creeper

    Messages:
    5
    Can I ask that how can you do it?
     
  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.