mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 16:59:44 +00:00
Noclip in spectator mode, changed chunk format
This commit is contained in:
parent
3872a21474
commit
c2b3f7cd7f
@ -219,7 +219,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
|
|
||||||
protected $allowFlight = false;
|
protected $allowFlight = false;
|
||||||
|
|
||||||
|
|
||||||
private $needACK = [];
|
private $needACK = [];
|
||||||
|
|
||||||
private $batchedPackets = [];
|
private $batchedPackets = [];
|
||||||
@ -311,7 +310,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function spawnTo(Player $player){
|
public function spawnTo(Player $player){
|
||||||
if($this->spawned === true and $player->spawned === true and $this->dead !== true and $player->dead !== true and $player->getLevel() === $this->level and $player->canSee($this)){
|
if($this->spawned === true and $player->spawned === true and $this->dead !== true and $player->dead !== true and $player->getLevel() === $this->level and $player->canSee($this) and !$this->isSpectator()){
|
||||||
parent::spawnTo($player);
|
parent::spawnTo($player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1000,6 +999,12 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
|
|
||||||
$this->allowFlight = $this->isCreative();
|
$this->allowFlight = $this->isCreative();
|
||||||
|
|
||||||
|
if($this->isSpectator()){
|
||||||
|
$this->despawnFromAll();
|
||||||
|
}else{
|
||||||
|
$this->spawnToAll();
|
||||||
|
}
|
||||||
|
|
||||||
$this->namedtag->playerGameType = new Int("playerGameType", $this->gamemode);
|
$this->namedtag->playerGameType = new Int("playerGameType", $this->gamemode);
|
||||||
|
|
||||||
$spawnPosition = $this->getSpawn();
|
$spawnPosition = $this->getSpawn();
|
||||||
@ -1048,7 +1053,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
0x00000020 nametags_visible
|
0x00000020 nametags_visible
|
||||||
0x00000040 auto_jump
|
0x00000040 auto_jump
|
||||||
0x00000080 allow_fly
|
0x00000080 allow_fly
|
||||||
0x00000100 ?
|
0x00000100 noclip
|
||||||
0x00000200 ?
|
0x00000200 ?
|
||||||
0x00000400 ?
|
0x00000400 ?
|
||||||
0x00000800 ?
|
0x00000800 ?
|
||||||
@ -1090,6 +1095,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
$flags |= 0x80;
|
$flags |= 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($this->isSpectator()){
|
||||||
|
$flags |= 0x100;
|
||||||
|
}
|
||||||
|
|
||||||
$pk = new AdventureSettingsPacket();
|
$pk = new AdventureSettingsPacket();
|
||||||
$pk->flags = $flags;
|
$pk->flags = $flags;
|
||||||
$this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY));
|
$this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY));
|
||||||
@ -1103,6 +1112,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
return ($this->gamemode & 0x01) > 0;
|
return ($this->gamemode & 0x01) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isSpectator(){
|
||||||
|
return $this->gamemode === 3;
|
||||||
|
}
|
||||||
|
|
||||||
public function isAdventure(){
|
public function isAdventure(){
|
||||||
return ($this->gamemode & 0x02) > 0;
|
return ($this->gamemode & 0x02) > 0;
|
||||||
}
|
}
|
||||||
@ -1276,7 +1289,9 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!$this->isSpectator()){
|
||||||
$this->checkNearEntities($tickDiff);
|
$this->checkNearEntities($tickDiff);
|
||||||
|
}
|
||||||
|
|
||||||
$this->speed = $from->subtract($to);
|
$this->speed = $from->subtract($to);
|
||||||
}elseif($distanceSquared == 0){
|
}elseif($distanceSquared == 0){
|
||||||
@ -1333,6 +1348,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
|
|
||||||
$this->processMovement($tickDiff);
|
$this->processMovement($tickDiff);
|
||||||
|
|
||||||
|
if(!$this->isSpectator()){
|
||||||
$this->entityBaseTick($tickDiff);
|
$this->entityBaseTick($tickDiff);
|
||||||
|
|
||||||
if($this->onGround){
|
if($this->onGround){
|
||||||
@ -1354,6 +1370,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
++$this->inAirTicks;
|
++$this->inAirTicks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($this->nextChunkOrderRun-- <= 0 or $this->chunk === null){
|
if($this->nextChunkOrderRun-- <= 0 or $this->chunk === null){
|
||||||
$this->orderChunks();
|
$this->orderChunks();
|
||||||
|
@ -82,9 +82,10 @@ class ChunkRequestTask extends AsyncTask{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$heightmap = pack("C*", ...$chunk->getHeightMapArray());
|
||||||
$biomeColors = pack("N*", ...$chunk->getBiomeColorArray());
|
$biomeColors = pack("N*", ...$chunk->getBiomeColorArray());
|
||||||
|
|
||||||
$ordered = $orderedIds . $orderedData . $orderedSkyLight . $orderedLight . $biomeColors . $this->tiles;
|
$ordered = $orderedIds . $orderedData . $orderedSkyLight . $orderedLight . $heightmap . $biomeColors . $this->tiles;
|
||||||
|
|
||||||
$this->setResult($ordered, false);
|
$this->setResult($ordered, false);
|
||||||
}
|
}
|
||||||
|
@ -62,18 +62,22 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strlen($biomeIds) === 256){
|
|
||||||
$this->biomeIds = $biomeIds;
|
|
||||||
}else{
|
|
||||||
$this->biomeIds = str_repeat("\x01", 256);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(count($biomeColors) === 256){
|
if(count($biomeColors) === 256){
|
||||||
$this->biomeColors = $biomeColors;
|
$this->biomeColors = $biomeColors;
|
||||||
}else{
|
}else{
|
||||||
$this->biomeColors = array_fill(0, 256, Binary::readInt("\x00\x85\xb2\x4a"));
|
$this->biomeColors = array_fill(0, 256, Binary::readInt("\x00\x85\xb2\x4a"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(strlen($biomeIds) !== 256){
|
||||||
|
$biomeIds = str_repeat("\x01", 256);
|
||||||
|
}
|
||||||
|
|
||||||
|
for($i = 0; $i < 256; ++$i){
|
||||||
|
$this->biomeColors[$i] = ($this->biomeColors[$i] & 0xFFFFFF) | (ord($biomeIds{$i}) << 24);
|
||||||
|
}
|
||||||
|
|
||||||
if(count($heightMap) === 256){
|
if(count($heightMap) === 256){
|
||||||
$this->heightMap = $heightMap;
|
$this->heightMap = $heightMap;
|
||||||
}else{
|
}else{
|
||||||
|
@ -40,9 +40,6 @@ abstract class BaseFullChunk implements FullChunk{
|
|||||||
/** @var Tile[] */
|
/** @var Tile[] */
|
||||||
protected $tileList = [];
|
protected $tileList = [];
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
protected $biomeIds;
|
|
||||||
|
|
||||||
/** @var int[256] */
|
/** @var int[256] */
|
||||||
protected $biomeColors;
|
protected $biomeColors;
|
||||||
|
|
||||||
@ -92,18 +89,20 @@ abstract class BaseFullChunk implements FullChunk{
|
|||||||
$this->skyLight = $skyLight;
|
$this->skyLight = $skyLight;
|
||||||
$this->blockLight = $blockLight;
|
$this->blockLight = $blockLight;
|
||||||
|
|
||||||
if(strlen($biomeIds) === 256){
|
|
||||||
$this->biomeIds = $biomeIds;
|
|
||||||
}else{
|
|
||||||
$this->biomeIds = str_repeat("\x01", 256);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(count($biomeColors) === 256){
|
if(count($biomeColors) === 256){
|
||||||
$this->biomeColors = $biomeColors;
|
$this->biomeColors = $biomeColors;
|
||||||
}else{
|
}else{
|
||||||
$this->biomeColors = array_fill(0, 256, Binary::readInt("\x00\x85\xb2\x4a"));
|
$this->biomeColors = array_fill(0, 256, Binary::readInt("\x00\x85\xb2\x4a"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(strlen($biomeIds) !== 256){
|
||||||
|
$biomeIds = str_repeat("\x01", 256);
|
||||||
|
}
|
||||||
|
|
||||||
|
for($i = 0; $i < 256; ++$i){
|
||||||
|
$this->biomeColors[$i] = ($this->biomeColors[$i] & 0xFFFFFF) | (ord($biomeIds{$i}) << 24);
|
||||||
|
}
|
||||||
|
|
||||||
if(count($heightMap) === 256){
|
if(count($heightMap) === 256){
|
||||||
$this->heightMap = $heightMap;
|
$this->heightMap = $heightMap;
|
||||||
}else{
|
}else{
|
||||||
@ -161,9 +160,16 @@ abstract class BaseFullChunk implements FullChunk{
|
|||||||
|
|
||||||
$this->getProvider()->getLevel()->timings->syncChunkLoadTileEntitiesTimer->stopTiming();
|
$this->getProvider()->getLevel()->timings->syncChunkLoadTileEntitiesTimer->stopTiming();
|
||||||
|
|
||||||
|
for($z = 0; $z < 16; ++$z){
|
||||||
|
for($x = 0; $x < 16; ++$x){
|
||||||
|
$this->setHeightMap($x, $z, $this->getHighestBlockAt($x, $z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->NBTentities = null;
|
$this->NBTentities = null;
|
||||||
$this->NBTtiles = null;
|
$this->NBTtiles = null;
|
||||||
$this->hasChanged = false;
|
$this->hasChanged = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,12 +210,12 @@ abstract class BaseFullChunk implements FullChunk{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getBiomeId($x, $z){
|
public function getBiomeId($x, $z){
|
||||||
return ord($this->biomeIds{($z << 4) + $x});
|
return ($this->biomeColors[($z << 4) + $x] & 0xFF000000) >> 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBiomeId($x, $z, $biomeId){
|
public function setBiomeId($x, $z, $biomeId){
|
||||||
$this->hasChanged = true;
|
$this->hasChanged = true;
|
||||||
$this->biomeIds{($z << 4) + $x} = chr($biomeId);
|
$this->biomeColors[($z << 4) + $x] = ($this->biomeColors[($z << 4) + $x] & 0xFFFFFF) | ($biomeId << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBiomeColor($x, $z){
|
public function getBiomeColor($x, $z){
|
||||||
@ -220,7 +226,7 @@ abstract class BaseFullChunk implements FullChunk{
|
|||||||
|
|
||||||
public function setBiomeColor($x, $z, $R, $G, $B){
|
public function setBiomeColor($x, $z, $R, $G, $B){
|
||||||
$this->hasChanged = true;
|
$this->hasChanged = true;
|
||||||
$this->biomeColors[($z << 4) + $x] = 0 | (($R & 0xFF) << 16) | (($G & 0xFF) << 8) | ($B & 0xFF);
|
$this->biomeColors[($z << 4) + $x] = ($this->biomeColors[($z << 4) + $x] & 0xFF000000) | (($R & 0xFF) << 16) | (($G & 0xFF) << 8) | ($B & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHeightMap($x, $z){
|
public function getHeightMap($x, $z){
|
||||||
@ -338,7 +344,11 @@ abstract class BaseFullChunk implements FullChunk{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getBiomeIdArray(){
|
public function getBiomeIdArray(){
|
||||||
return $this->biomeIds;
|
$ids = "";
|
||||||
|
foreach($this->biomeColors as $d){
|
||||||
|
$ids .= chr(($d & 0xFF000000) >> 24);
|
||||||
|
}
|
||||||
|
return $ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBiomeColorArray(){
|
public function getBiomeColorArray(){
|
||||||
|
@ -146,12 +146,14 @@ class LevelDB extends BaseLevelProvider{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$heightmap = pack("C*", ...$chunk->getHeightMapArray());
|
||||||
$biomeColors = pack("N*", ...$chunk->getBiomeColorArray());
|
$biomeColors = pack("N*", ...$chunk->getBiomeColorArray());
|
||||||
|
|
||||||
$ordered = $chunk->getBlockIdArray() .
|
$ordered = $chunk->getBlockIdArray() .
|
||||||
$chunk->getBlockDataArray() .
|
$chunk->getBlockDataArray() .
|
||||||
$chunk->getBlockSkyLightArray() .
|
$chunk->getBlockSkyLightArray() .
|
||||||
$chunk->getBlockLightArray() .
|
$chunk->getBlockLightArray() .
|
||||||
|
$heightmap .
|
||||||
$biomeColors .
|
$biomeColors .
|
||||||
$tiles;
|
$tiles;
|
||||||
|
|
||||||
|
@ -128,12 +128,14 @@ class McRegion extends BaseLevelProvider{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$heightmap = pack("C*", ...$chunk->getHeightMapArray());
|
||||||
$biomeColors = pack("N*", ...$chunk->getBiomeColorArray());
|
$biomeColors = pack("N*", ...$chunk->getBiomeColorArray());
|
||||||
|
|
||||||
$ordered = $chunk->getBlockIdArray() .
|
$ordered = $chunk->getBlockIdArray() .
|
||||||
$chunk->getBlockDataArray() .
|
$chunk->getBlockDataArray() .
|
||||||
$chunk->getBlockSkyLightArray() .
|
$chunk->getBlockSkyLightArray() .
|
||||||
$chunk->getBlockLightArray() .
|
$chunk->getBlockLightArray() .
|
||||||
|
$heightmap .
|
||||||
$biomeColors .
|
$biomeColors .
|
||||||
$tiles;
|
$tiles;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user