mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 04:29:43 +00:00
Merge branch 'kotyaralih:master' into master
This commit is contained in:
commit
75e0d593c8
6 changed files with 45 additions and 13 deletions
|
|
@ -1474,10 +1474,11 @@ class Player{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function makeInvisibleForAllPlayers(){
|
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);
|
if($player->CID != $this->CID) $this->setInvisibleFor($player, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGamemode(){
|
public function getGamemode(){
|
||||||
switch($this->gamemode){
|
switch($this->gamemode){
|
||||||
case SURVIVAL:
|
case SURVIVAL:
|
||||||
|
|
@ -2803,8 +2804,37 @@ class Player{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if($this->isSleeping) 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){
|
if(($this->entity instanceof Entity) && $packet->messageIndex > $this->lastMovement){
|
||||||
$this->lastMovement = $packet->messageIndex;
|
$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);
|
$newPos = new Vector3($packet->x, $packet->y, $packet->z);
|
||||||
if($this->forceMovement instanceof Vector3){
|
if($this->forceMovement instanceof Vector3){
|
||||||
if($this->forceMovement->distance($newPos) <= 0.7){
|
if($this->forceMovement->distance($newPos) <= 0.7){
|
||||||
|
|
|
||||||
|
|
@ -756,8 +756,8 @@ class Entity extends Position
|
||||||
|
|
||||||
public function positionRider($dead){
|
public function positionRider($dead){
|
||||||
if($this->rider != 0){
|
if($this->rider != 0){
|
||||||
$e = $this->level->entityList[$this->rider];
|
$e = $this->level->entityList[$this->rider] ?? false;
|
||||||
if($e === false) return;
|
if(!($e instanceof Entity)) return;
|
||||||
|
|
||||||
$v3 = $this->getRideHeight();
|
$v3 = $this->getRideHeight();
|
||||||
if($dead || $this->dead) $v3 = 0.01;
|
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;
|
++$this->notOnGroundTicks;
|
||||||
}else if($this->onGround){
|
}else if($this->onGround){
|
||||||
$this->notOnGroundTicks = 0;
|
$this->notOnGroundTicks = 0;
|
||||||
|
|
|
||||||
|
|
@ -24,14 +24,14 @@ class TaskEatTileGoal extends TaskBase
|
||||||
|
|
||||||
if (--$this->selfCounter == 4)
|
if (--$this->selfCounter == 4)
|
||||||
{
|
{
|
||||||
$id = $ai->entity->level->level->getBlockID($ai->entity->x, $ai->entity->y, $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($ai->entity->x, $ai->entity->y - 1, $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){
|
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();
|
$ai->entity->eatGrass();
|
||||||
|
|
||||||
}elseif($idb === GRASS){
|
}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();
|
$ai->entity->eatGrass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class SlabBlock extends TransparentBlock{
|
||||||
|
|
||||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
[$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);
|
StaticBlock::setBlockBounds($id, 0, 0, 0, 1, 1, 1);
|
||||||
}else{
|
}else{
|
||||||
$bottom = (($meta ^ 8) >> 3) & 1;
|
$bottom = (($meta ^ 8) >> 3) & 1;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class WoodSlabBlock extends TransparentBlock{
|
||||||
|
|
||||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
[$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);
|
StaticBlock::setBlockBounds($id, 0, 0, 0, 1, 1, 1);
|
||||||
}else{
|
}else{
|
||||||
$bottom = (($meta ^ 8) >> 3) & 1;
|
$bottom = (($meta ^ 8) >> 3) & 1;
|
||||||
|
|
|
||||||
|
|
@ -663,9 +663,11 @@ class PMFLevel extends PMF{
|
||||||
}elseif($this->chunks[$index][$Y] === false){
|
}elseif($this->chunks[$index][$Y] === false){
|
||||||
$this->fillMiniChunk($X, $Z, $Y);
|
$this->fillMiniChunk($X, $Z, $Y);
|
||||||
}
|
}
|
||||||
$aX = $x - ($X << 4);
|
|
||||||
$aZ = $z - ($Z << 4);
|
$aX = $x & 0xf;
|
||||||
$aY = $y - ($Y << 4);
|
$aZ = $z & 0xf;
|
||||||
|
$aY = $y & 0xf;
|
||||||
|
|
||||||
$bindex = (int) ($aY + ($aX << 5) + ($aZ << 9));
|
$bindex = (int) ($aY + ($aX << 5) + ($aZ << 9));
|
||||||
$mindex = (int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9));
|
$mindex = (int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9));
|
||||||
$old_b = ord($this->chunks[$index][$Y][$bindex]);
|
$old_b = ord($this->chunks[$index][$Y][$bindex]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue