Hi, I have posted this issue in development but no one seems to answer. I would be grateful if you could help me. So what I'm trying to do is set a specific block in the players position as they move. As the player moves, a series of setting block to air and that block. So it looks like the block is following the player. But the issue I'm getting is that despite the player staying still (no physical movement given on the device) the player starts jiggering back and forth and so does the block. It does not stay still. This is the full code below PHP: * @param PlayerMoveEvent $e */ public function onMove(PlayerMoveEvent $event){ $player = $event->getPlayer(); $this->main->moveHiderBlock ( $event->getPlayer (), $event->getFrom (), $event->getTo () ); }/** * * @param Player $player * @param Position $from * @param Position $to */ public function moveHiderBlock(Player $player, Position $from, Position $to) { $blockid = 58; $this->keepBlockMoving ( $player, $from, $to, $blockid ); } /** * * @param Player $player * @param Vector3 $from * @param Vector3 $to * @param unknown $blockid */ public function keepBlockMoving(Player $player, Vector3 $from, Vector3 $to, $blockid) { $envbid = $player->getLevel ()->getBlockIdAt ( $from->getX(), $from->getY(), $from->getZ() ); if ($envbid === $blockid) { $player->getLevel ()->setBlock ( new Vector3 ( $from->getX(), $from->getY(), $from->getZ(), $player->getLevel () ), $block = Item::get ( Item::AIR )->getBlock (), true, false ); } $envbid = $player->getLevel ()->getBlockIdAt ( $player->getX(), $player->getY(), $player->getZ() ); if ($envbid === Item::AIR || $envbid === Item::TALL_GRASS) { $player->getLevel ()->setBlock ( new Vector3 ( $player->getX(), $player->getY(), $player->getZ(), $player->getLevel ()) , Item::get ( $blockid )->getBlock (), true, false ); } elseif ($envbid === $blockid) { $player->getLevel ()->setBlock ( new Vector3 ( $player->getX(), $player->getY(), $player->getZ(), $player->getLevel ()), Item::get ( $blockid )->getBlock (), true, false ); } if (round ( $player->getX() ) != round ( $from->getX() ) || round ( $player->getY() ) != round ( $from->getY() ) || round ( $player->getZ()) != round ( $from->getZ())) { $envbid = $player->level->getBlockIdAt ( $to->getX(), $to->getY(), $to->getZ() ); if ($envbid === Item::AIR || $envbid === Item::TALL_GRASS) { $player->level->setBlock ( $to, Item::get ( $blockid )->getBlock (), true, false ); } } } Any help would be greatly appreciated.
Would this be correct? PHP: * @param PlayerMoveEvent $e */ public function onMove(PlayerMoveEvent $event){ $player = $event->getPlayer(); $this->main->moveHiderBlock ( $event->getPlayer (), $event->getFrom (), $event->getTo () ); }/** * * @param Player $player * @param Position $from * @param Position $to */ public function moveHiderBlock(Player $player, Position $from, Position $to) { $blockid = 58; $this->keepBlockMoving ( $player, $from, $to, $blockid ); } /** * * @param Player $player * @param Vector3 $from * @param Vector3 $to * @param unknown $blockid */ public function keepBlockMoving(Player $player, Vector3 $from, Vector3 $to, $blockid) { $envbid = $player->getLevel ()->getBlockIdAt ( $from->getX(), $from->getY(), $from->getZ() ); if ($envbid === $blockid) { $player->getLevel ()->setBlock ( $from->getOppositeSide($player->getDirection()), $block = Item::get ( Item::AIR )->getBlock (), true, false ); } $envbid = $player->getLevel ()->getBlockIdAt ( $player->getX(), $player->getY(), $player->getZ() ); if ($envbid === Item::AIR || $envbid === Item::TALL_GRASS) { $player->getLevel ()->setBlock ( $from->getOppositeSide($player->getDirection()), Item::get ( $blockid )->getBlock (), true, false ); } elseif ($envbid === $blockid) { $player->getLevel ()->setBlock ( from->getOppositeSide($player->getDirection()), Item::get ( $blockid )->getBlock (), true, false ); } if (round ( $player->getX() ) != round ( $from->getX() ) || round ( $player->getY() ) != round ( $from->getY() ) || round ( $player->getZ()) != round ( $from->getZ())) { $envbid = $player->level->getBlockIdAt ( $to->getX(), $to->getY(), $to->getZ() ); if ($envbid === Item::AIR || $envbid === Item::TALL_GRASS) { $player->level->setBlock ( $to, Item::get ( $blockid )->getBlock (), true, false ); } } }
I'm not sure how I would set the block at the opposite side of the players current direction. I'm quite new to coding. I've managed to do the other parts of the plugin which is a block hunt plugin. but this is the only bit I'm stuck on. The other block hunt plugins I've seen use the same initial code to set the block. But that block jiggering/moving issue persists. Iv also tried adding 1 to player->x so that the block is set some further distance behind the player. But this affects the players ability to move as the block gets in the way when turning around.
Is this even possible? I mean I don't think I've seen any plugins use setblock to make a block look like it's following the player. I don't know how mineplex and other servers do it with blockhunt but no matter what I do, the block does not properly follow the players direction. It keeps in one direction to the player therefore the block becomes an obstruction when the player changes direction.