Нужен код что бы под игроком спавнился блок слайма !
patt
03.Июнь.2022 22:22:50
#2
$player->getLevel()->setBlockIdAt($player->getX(), $player->getY() - 1, $player->getZ(), айди блока слайма);
patt:
setBlockIdAt
Нет, надо использовать setBlock, если использовать setBlockIdAt, то тогда чанк надо выгружать и сного грузить, в общем его не будет видно сразу под игроком
А теперь посмотри внимательно сюда
}
return $block;
}
/**
* Sets the block at the given Vector3 coordinates.
*
* @throws \InvalidArgumentException if the position is out of the world bounds
*/
public function setBlock(Vector3 $pos, Block $block, bool $update = true) : void{
$this->setBlockAt((int) floor($pos->x), (int) floor($pos->y), (int) floor($pos->z), $block, $update);
}
/**
* Sets the block at the given coordinates.
*
* If $update is true, it'll get the neighbour blocks (6 sides) and update them, and also update local lighting.
* If you are doing big changes, you might want to set this to false, then update manually.
*
* @throws \InvalidArgumentException if the position is out of the world bounds
И сюда
}
/**
* Sets the block at the given coordinates.
*
* If $update is true, it'll get the neighbour blocks (6 sides) and update them, and also update local lighting.
* If you are doing big changes, you might want to set this to false, then update manually.
*
* @throws \InvalidArgumentException if the position is out of the world bounds
*/
public function setBlockAt(int $x, int $y, int $z, Block $block, bool $update = true) : void{
if(!$this->isInWorld($x, $y, $z)){
throw new \InvalidArgumentException("Pos x=$x,y=$y,z=$z is outside of the world bounds");
}
$chunkX = $x >> Chunk::COORD_BIT_SIZE;
$chunkZ = $z >> Chunk::COORD_BIT_SIZE;
if($this->loadChunk($chunkX, $chunkZ) === null){ //current expected behaviour is to try to load the terrain synchronously
throw new WorldException("Cannot set a block in un-generated terrain");
}
$this->timings->setBlock->startTiming();
$player->getWorld()->setBlock($player->getPosition()->add(0, -1, 0), VanillaBlocks::SLIME());
Я все вижу, но @patt использует aetBlockIdAt, заметь, не setBlockAt, а setBlockIdAt
Разницы между setBlock и setBlockAt, нету, я не спорю и я не говорил что есть. Но setBlockIdAt это совсем другое.
За место блока айди и это с лайткора
Ладно, может я что то не догоняю…
system
Закрыл тему
06.Июнь.2022 08:22:28
#12
Эта тема была автоматически закрыта через 12 часов после последнего ответа. В ней больше нельзя отвечать.