mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/15288247521
This commit is contained in:
@ -27,6 +27,7 @@ use DateTimeImmutable;
|
||||
use pocketmine\block\BaseSign;
|
||||
use pocketmine\block\Bed;
|
||||
use pocketmine\block\BlockTypeTags;
|
||||
use pocketmine\block\RespawnAnchor;
|
||||
use pocketmine\block\UnknownBlock;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
use pocketmine\command\CommandSender;
|
||||
@ -137,6 +138,7 @@ use pocketmine\world\sound\EntityAttackNoDamageSound;
|
||||
use pocketmine\world\sound\EntityAttackSound;
|
||||
use pocketmine\world\sound\FireExtinguishSound;
|
||||
use pocketmine\world\sound\ItemBreakSound;
|
||||
use pocketmine\world\sound\RespawnAnchorDepleteSound;
|
||||
use pocketmine\world\sound\Sound;
|
||||
use pocketmine\world\World;
|
||||
use pocketmine\YmlServerProperties;
|
||||
@ -2543,6 +2545,21 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
}
|
||||
$this->logger->debug("Respawn position located, completing respawn");
|
||||
$ev = new PlayerRespawnEvent($this, $safeSpawn);
|
||||
$spawnPosition = $ev->getRespawnPosition();
|
||||
$spawnBlock = $spawnPosition->getWorld()->getBlock($spawnPosition);
|
||||
if($spawnBlock instanceof RespawnAnchor){
|
||||
if($spawnBlock->getCharges() > 0){
|
||||
$spawnPosition->getWorld()->setBlock($spawnPosition, $spawnBlock->setCharges($spawnBlock->getCharges() - 1));
|
||||
$spawnPosition->getWorld()->addSound($spawnPosition, new RespawnAnchorDepleteSound());
|
||||
}else{
|
||||
$defaultSpawn = $this->server->getWorldManager()->getDefaultWorld()?->getSpawnLocation();
|
||||
if($defaultSpawn !== null){
|
||||
$this->setSpawn($defaultSpawn);
|
||||
$ev->setRespawnPosition($defaultSpawn);
|
||||
$this->sendMessage(KnownTranslationFactory::tile_respawn_anchor_notValid()->prefix(TextFormat::GRAY));
|
||||
}
|
||||
}
|
||||
}
|
||||
$ev->call();
|
||||
|
||||
$realSpawn = Position::fromObject($ev->getRespawnPosition()->add(0.5, 0, 0.5), $ev->getRespawnPosition()->getWorld());
|
||||
|
Reference in New Issue
Block a user