mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 10:53:05 +00:00
Anvil fixes, improved memory settings
This commit is contained in:
@ -2200,10 +2200,6 @@ class Level implements ChunkManager, Metadatable{
|
||||
unset($this->chunkTickList[$index]);
|
||||
unset($this->chunkCache[$index]);
|
||||
|
||||
$refs = \pocketmine\getReferenceCount($chunk);
|
||||
|
||||
//$this->server->getLogger()->debug("Unloaded $x $z (".count($this->getChunks()).") [refs $refs]");
|
||||
|
||||
$this->timings->doChunkUnload->stopTiming();
|
||||
|
||||
return true;
|
||||
|
@ -135,7 +135,7 @@ class Chunk extends BaseChunk{
|
||||
*
|
||||
* @return Chunk
|
||||
*/
|
||||
public static function fromBinary($data, LevelProvider $provider = null){
|
||||
public static function fromBinary(&$data, LevelProvider $provider = null){
|
||||
$nbt = new NBT(NBT::BIG_ENDIAN);
|
||||
|
||||
try{
|
||||
@ -152,7 +152,7 @@ class Chunk extends BaseChunk{
|
||||
}
|
||||
}
|
||||
|
||||
public function toBinary(){
|
||||
public function &toBinary(){
|
||||
$nbt = clone $this->getNBT();
|
||||
|
||||
$nbt->xPos = new Int("xPos", $this->x);
|
||||
|
@ -133,7 +133,8 @@ class ChunkRequestTask extends AsyncTask{
|
||||
public function onCompletion(Server $server){
|
||||
$level = $server->getLevel($this->levelId);
|
||||
if($level instanceof Level and $this->hasResult()){
|
||||
$level->chunkRequestCallback($this->chunkX, $this->chunkZ, $this->getResult());
|
||||
$result = $this->getResult();
|
||||
$level->chunkRequestCallback($this->chunkX, $this->chunkZ, $result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
}
|
||||
}
|
||||
|
||||
public function getBlockIdColumn($x, $z){
|
||||
public function &getBlockIdColumn($x, $z){
|
||||
$i = ($z << 4) + $x;
|
||||
$column = "";
|
||||
for($y = 0; $y < 16; ++$y){
|
||||
@ -165,7 +165,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
return $column;
|
||||
}
|
||||
|
||||
public function getBlockDataColumn($x, $z){
|
||||
public function &getBlockDataColumn($x, $z){
|
||||
$i = ($z << 3) + ($x >> 1);
|
||||
$column = "";
|
||||
if(($x & 1) === 0){
|
||||
@ -181,7 +181,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
return $column;
|
||||
}
|
||||
|
||||
public function getBlockSkyLightColumn($x, $z){
|
||||
public function &getBlockSkyLightColumn($x, $z){
|
||||
$i = ($z << 3) + ($x >> 1);
|
||||
$column = "";
|
||||
if(($x & 1) === 0){
|
||||
@ -197,7 +197,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
return $column;
|
||||
}
|
||||
|
||||
public function getBlockLightColumn($x, $z){
|
||||
public function &getBlockLightColumn($x, $z){
|
||||
$i = ($z << 3) + ($x >> 1);
|
||||
$column = "";
|
||||
if(($x & 1) === 0){
|
||||
@ -213,19 +213,19 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
return $column;
|
||||
}
|
||||
|
||||
public function getIdArray(){
|
||||
public function &getIdArray(){
|
||||
return $this->blocks;
|
||||
}
|
||||
|
||||
public function getDataArray(){
|
||||
public function &getDataArray(){
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function getSkyLightArray(){
|
||||
public function &getSkyLightArray(){
|
||||
return $this->skyLight;
|
||||
}
|
||||
|
||||
public function getLightArray(){
|
||||
public function &getLightArray(){
|
||||
return $this->blockLight;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,8 @@ class RegionLoader extends \pocketmine\level\format\mcregion\RegionLoader{
|
||||
return null;
|
||||
}
|
||||
|
||||
$chunk = Chunk::fromBinary(fread($this->filePointer, $length - 1), $this->levelProvider);
|
||||
$data = fread($this->filePointer, $length - 1);
|
||||
$chunk = Chunk::fromBinary($data, $this->levelProvider);
|
||||
if($chunk instanceof Chunk){
|
||||
return $chunk;
|
||||
}elseif($forward === false){
|
||||
@ -123,7 +124,8 @@ class RegionLoader extends \pocketmine\level\format\mcregion\RegionLoader{
|
||||
$nbt->TerrainPopulated = new Byte("TerrainPopulated", 0);
|
||||
$nbt->V = new Byte("V", self::VERSION);
|
||||
$nbt->InhabitedTime = new Long("InhabitedTime", 0);
|
||||
$nbt->Biomes = new ByteArray("Biomes", str_repeat(Binary::writeByte(-1), 256));
|
||||
$biomes = str_repeat(Binary::writeByte(-1), 256);
|
||||
$nbt->Biomes = new ByteArray("Biomes", $biomes);
|
||||
$nbt->BiomeColors = new IntArray("BiomeColors", array_fill(0, 156, Binary::readInt("\x00\x85\xb2\x4a")));
|
||||
$nbt->HeightMap = new IntArray("HeightMap", array_fill(0, 256, 127));
|
||||
$nbt->Sections = new Enum("Sections", []);
|
||||
|
@ -165,7 +165,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
|
||||
}
|
||||
}
|
||||
|
||||
public function getBlockIdColumn($x, $z){
|
||||
public function &getBlockIdColumn($x, $z){
|
||||
$column = "";
|
||||
for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){
|
||||
$column .= $this->sections[$y]->getBlockIdColumn($x, $z);
|
||||
@ -174,7 +174,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
|
||||
return $column;
|
||||
}
|
||||
|
||||
public function getBlockDataColumn($x, $z){
|
||||
public function &getBlockDataColumn($x, $z){
|
||||
$column = "";
|
||||
for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){
|
||||
$column .= $this->sections[$y]->getBlockDataColumn($x, $z);
|
||||
@ -183,7 +183,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
|
||||
return $column;
|
||||
}
|
||||
|
||||
public function getBlockSkyLightColumn($x, $z){
|
||||
public function &getBlockSkyLightColumn($x, $z){
|
||||
$column = "";
|
||||
for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){
|
||||
$column .= $this->sections[$y]->getBlockSkyLightColumn($x, $z);
|
||||
@ -192,7 +192,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
|
||||
return $column;
|
||||
}
|
||||
|
||||
public function getBlockLightColumn($x, $z){
|
||||
public function &getBlockLightColumn($x, $z){
|
||||
$column = "";
|
||||
for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){
|
||||
$column .= $this->sections[$y]->getBlockLightColumn($x, $z);
|
||||
@ -227,7 +227,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
|
||||
return $this->getProvider() === null ? false : $this->getProvider()->getChunk($this->getX(), $this->getZ(), true) instanceof Chunk;
|
||||
}
|
||||
|
||||
public function getBlockIdArray(){
|
||||
public function &getBlockIdArray(){
|
||||
$blocks = "";
|
||||
for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){
|
||||
$blocks .= $this->sections[$y]->getIdArray();
|
||||
@ -236,7 +236,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
|
||||
return $blocks;
|
||||
}
|
||||
|
||||
public function getBlockDataArray(){
|
||||
public function &getBlockDataArray(){
|
||||
$data = "";
|
||||
for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){
|
||||
$data .= $this->sections[$y]->getDataArray();
|
||||
@ -245,7 +245,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getBlockSkyLightArray(){
|
||||
public function &getBlockSkyLightArray(){
|
||||
$skyLight = "";
|
||||
for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){
|
||||
$skyLight .= $this->sections[$y]->getSkyLightArray();
|
||||
@ -254,7 +254,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
|
||||
return $skyLight;
|
||||
}
|
||||
|
||||
public function getBlockLightArray(){
|
||||
public function &getBlockLightArray(){
|
||||
$blockLight = "";
|
||||
for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){
|
||||
$blockLight .= $this->sections[$y]->getLightArray();
|
||||
|
@ -82,7 +82,7 @@ abstract class BaseFullChunk implements FullChunk{
|
||||
* @param Compound[] $entities
|
||||
* @param Compound[] $tiles
|
||||
*/
|
||||
protected function __construct($provider, $x, $z, $blocks, $data, $skyLight, $blockLight, $biomeIds = null, array $biomeColors = [], array $heightMap = [], array $entities = [], array $tiles = []){
|
||||
protected function __construct($provider, $x, $z, &$blocks, &$data, &$skyLight, &$blockLight, &$biomeIds = null, array $biomeColors = [], array $heightMap = [], array $entities = [], array $tiles = []){
|
||||
$this->provider = $provider;
|
||||
$this->x = (int) $x;
|
||||
$this->z = (int) $z;
|
||||
|
@ -32,7 +32,7 @@ class Chunk extends BaseFullChunk{
|
||||
protected $isPopulated = false;
|
||||
protected $isGenerated = false;
|
||||
|
||||
public function __construct($level, $chunkX, $chunkZ, $terrain, array $entityData = null, array $tileData = null){
|
||||
public function __construct($level, $chunkX, $chunkZ, &$terrain, array $entityData = null, array $tileData = null){
|
||||
$heightMap = array_fill(0, 256, 127);
|
||||
|
||||
$offset = 0;
|
||||
|
Reference in New Issue
Block a user