Merge branch 'kotyaralih:master' into master

This commit is contained in:
yefengeeeeeeeeeee 2026-07-11 17:00:16 +08:00 • committed by GitHub
commit 75e0d593c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 45 additions and 13 deletions

View file

@ -1474,10 +1474,11 @@ class Player{
}
public function makeInvisibleForAllPlayers(){
foreach($this->server->api->player->getA as $player){
foreach($this->server->api->player->getAll() as $player){
if($player->CID != $this->CID) $this->setInvisibleFor($player, true);
}
}
public function getGamemode(){
switch($this->gamemode){
case SURVIVAL:
@ -2803,8 +2804,37 @@ class Player{
break;
}
if($this->isSleeping) break;
//prevent crash caused by nan values
if(is_nan($packet->x) || is_nan($packet->y) || is_nan($packet->z)){
ConsoleAPI::warn("{$this->username} Attempted to crash the server using NaN position!");
$this->close("invalid position");
break;
}
if(is_infinite($packet->yaw) || is_infinite($packet->pitch) || is_infinite($packet->bodyYaw)){
ConsoleAPI::warn("{$this->username} Attempted to crash other clients using INF rotation!");
$this->close("invalid rotation");
break;
}
//doesnt crash anything but allows players to break their model rendering(make them/head invisible)
if(is_nan($packet->yaw) || is_nan($packet->pitch) || is_nan($packet->bodyYaw)){
ConsoleAPI::warn("{$this->username} Attempted to break their model using NAN rotation!");
$this->close("invalid rotation");
break;
}
if(($this->entity instanceof Entity) && $packet->messageIndex > $this->lastMovement){
$this->lastMovement = $packet->messageIndex;
//prevent all movement this far - vanilla collisions break there
//farther distances(like inf) may cause client and server crash
if(abs($packet->x) >= 8388608 || abs($packet->y) >= 8388608 || abs($packet->z) >= 8388608){
$this->addEntityMovementUpdateToQueue($this->entity);
break;
}
$newPos = new Vector3($packet->x, $packet->y, $packet->z);
if($this->forceMovement instanceof Vector3){
if($this->forceMovement->distance($newPos) <= 0.7){

View file

@ -756,8 +756,8 @@ class Entity extends Position
public function positionRider($dead){
if($this->rider != 0){
$e = $this->level->entityList[$this->rider];
if($e === false) return;
$e = $this->level->entityList[$this->rider] ?? false;
if(!($e instanceof Entity)) return;
$v3 = $this->getRideHeight();
if($dead || $this->dead) $v3 = 0.01;
@ -918,7 +918,7 @@ class Entity extends Position
}
}
if($prevGroundState == $this->onGround && !$this->onGround && $this->player->isSleeping == false && !$this->dead){ //isSleeping may be a vector
if($prevGroundState == $this->onGround && !$this->onGround && $this->player->isSleeping == false && !$this->dead && $this->riding == 0){ //isSleeping may be a vector
++$this->notOnGroundTicks;
}else if($this->onGround){
$this->notOnGroundTicks = 0;

View file

@ -24,14 +24,14 @@ class TaskEatTileGoal extends TaskBase
if (--$this->selfCounter == 4)
{
$id = $ai->entity->level->level->getBlockID($ai->entity->x, $ai->entity->y, $ai->entity->z);
$idb = $ai->entity->level->level->getBlockID($ai->entity->x, $ai->entity->y - 1, $ai->entity->z);
$id = $ai->entity->level->level->getBlockID((int)$ai->entity->x, (int)$ai->entity->y, (int)$ai->entity->z);
$idb = $ai->entity->level->level->getBlockID((int)$ai->entity->x, (int)$ai->entity->y - 1, (int)$ai->entity->z);
if($id === TALL_GRASS){
$ai->entity->level->fastSetBlockUpdate($ai->entity->x, $ai->entity->y, $ai->entity->z, AIR, 0);
$ai->entity->level->fastSetBlockUpdate((int)$ai->entity->x, (int)$ai->entity->y, (int)$ai->entity->z, AIR, 0);
$ai->entity->eatGrass();
}elseif($idb === GRASS){
$ai->entity->level->fastSetBlockUpdate($ai->entity->x, $ai->entity->y - 1, $ai->entity->z, DIRT, 0);
$ai->entity->level->fastSetBlockUpdate((int)$ai->entity->x, (int)$ai->entity->y - 1, (int)$ai->entity->z, DIRT, 0);
$ai->entity->eatGrass();
}
}

View file

@ -29,7 +29,7 @@ class SlabBlock extends TransparentBlock{
[$id, $meta] = $level->level->getBlock($x, $y, $z);
if($meta & 0x08 == 0x08){
if(($meta & 0x08) == 0x08){
StaticBlock::setBlockBounds($id, 0, 0, 0, 1, 1, 1);
}else{
$bottom = (($meta ^ 8) >> 3) & 1;

View file

@ -25,7 +25,7 @@ class WoodSlabBlock extends TransparentBlock{
[$id, $meta] = $level->level->getBlock($x, $y, $z);
if($meta & 0x08 == 0x08){
if(($meta & 0x08) == 0x08){
StaticBlock::setBlockBounds($id, 0, 0, 0, 1, 1, 1);
}else{
$bottom = (($meta ^ 8) >> 3) & 1;

View file

@ -663,9 +663,11 @@ class PMFLevel extends PMF{
}elseif($this->chunks[$index][$Y] === false){
$this->fillMiniChunk($X, $Z, $Y);
}
$aX = $x - ($X << 4);
$aZ = $z - ($Z << 4);
$aY = $y - ($Y << 4);
$aX = $x & 0xf;
$aZ = $z & 0xf;
$aY = $y & 0xf;
$bindex = (int) ($aY + ($aX << 5) + ($aZ << 9));
$mindex = (int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9));
$old_b = ord($this->chunks[$index][$Y][$bindex]);