made REQUEST_CHUNK_PACKET useful(experemental chunk loading system), reactor can be disabled in properties(for some reason it didnt work before)

This commit is contained in:
GameHerobrine 2022-08-13 17:35:38 +03:00
parent 5982e379e7
commit fc8111c152
3 changed files with 25 additions and 4 deletions

View file

@ -238,7 +238,7 @@ class Player{
$this->entity->calculateVelocity();
if($terrain === true){
$this->orderChunks();
$this->getNextChunk();
//$this->getNextChunk();
}
$this->entity->check = true;
if($force === true){
@ -428,7 +428,27 @@ class Player{
}
asort($this->chunksOrder);
}
public function useChunk($X, $Z){
$Yndex = 0;
for($iY = 0; $iY < 8; ++$iY){
if(isset($this->chunksOrder["$X:$iY:$Z"])){
unset($this->chunksOrder["$X:$iY:$Z"]);
$this->chunksLoaded["$X:$iY:$Z"] = true;
$Yndex |= 1 << $iY;
}
}
$pk = new ChunkDataPacket;
$pk->chunkX = $X;
$pk->chunkZ = $Z;
$pk->data = $this->level->getOrderedChunk($X, $Z, $Yndex);
$cnt = $this->dataPacket($pk);
if($cnt === false){
return false;
}
}
public function getNextChunk(){
if($this->connected === false){
return false;
@ -457,7 +477,7 @@ class Player{
}
$c = key($this->chunksOrder);
$d = $c != null ? $this->chunksOrder[$c] : null; //not sure why was ?? placed here
$d = $c != null ? $this->chunksOrder[$c] : null;
if($c === null or $d === null){
$this->server->schedule(40, [$this, "getNextChunk"]);
return false;
@ -1538,6 +1558,7 @@ class Player{
}
break;
case ProtocolInfo::REQUEST_CHUNK_PACKET:
$this->useChunk($packet->chunkX, $packet->chunkZ);
break;
case ProtocolInfo::USE_ITEM_PACKET:
if(!($this->entity instanceof Entity)){

View file

@ -26,7 +26,7 @@ class Sheep extends Animal{
public function getMetadata(){
$d = parent::getMetadata();
if(!isset($this->data["Sheared"])){
$this->data["Sheared"] = NOT_SHEARED;
$this->data["Sheared"] = Sheep::NOT_SHEARED;
}
if(!isset($this->data["Color"])){ //Make a new random color if it is not in data
$this->data["Color"] = $this->sheepColor();

View file

@ -9,7 +9,7 @@ class NetherReactorBlock extends SolidBlock{
public function onActivate(Item $item, Player $player){
//if(($item->getID() === IRON_SWORD || $item->getID() === WOODEN_SWORD || $item->getID() === STONE_SWORD || $item->getID() === DIAMOND_SWORD || $item->getID() === GOLD_SWORD) /*&& $player->gamemode === 0*/){
if($this->isCorrect($this->getX(),$this->getY(),$this->getZ()) && $this->getY() < 101){
if($this->isCorrect($this->getX(),$this->getY(),$this->getZ()) && $this->getY() < 101 && NetherReactorBlock::$enableReactor){
NetherReactorStructure::buildReactor($this->level, $this->getX(),$this->getY(),$this->getZ());
$this->meta = 1;
$this->level->setBlock($this,$this);