mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 04:59:46 +00:00
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:
parent
5982e379e7
commit
fc8111c152
3 changed files with 25 additions and 4 deletions
|
|
@ -238,7 +238,7 @@ class Player{
|
||||||
$this->entity->calculateVelocity();
|
$this->entity->calculateVelocity();
|
||||||
if($terrain === true){
|
if($terrain === true){
|
||||||
$this->orderChunks();
|
$this->orderChunks();
|
||||||
$this->getNextChunk();
|
//$this->getNextChunk();
|
||||||
}
|
}
|
||||||
$this->entity->check = true;
|
$this->entity->check = true;
|
||||||
if($force === true){
|
if($force === true){
|
||||||
|
|
@ -428,7 +428,27 @@ class Player{
|
||||||
}
|
}
|
||||||
asort($this->chunksOrder);
|
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(){
|
public function getNextChunk(){
|
||||||
if($this->connected === false){
|
if($this->connected === false){
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -457,7 +477,7 @@ class Player{
|
||||||
}
|
}
|
||||||
|
|
||||||
$c = key($this->chunksOrder);
|
$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){
|
if($c === null or $d === null){
|
||||||
$this->server->schedule(40, [$this, "getNextChunk"]);
|
$this->server->schedule(40, [$this, "getNextChunk"]);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1538,6 +1558,7 @@ class Player{
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ProtocolInfo::REQUEST_CHUNK_PACKET:
|
case ProtocolInfo::REQUEST_CHUNK_PACKET:
|
||||||
|
$this->useChunk($packet->chunkX, $packet->chunkZ);
|
||||||
break;
|
break;
|
||||||
case ProtocolInfo::USE_ITEM_PACKET:
|
case ProtocolInfo::USE_ITEM_PACKET:
|
||||||
if(!($this->entity instanceof Entity)){
|
if(!($this->entity instanceof Entity)){
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class Sheep extends Animal{
|
||||||
public function getMetadata(){
|
public function getMetadata(){
|
||||||
$d = parent::getMetadata();
|
$d = parent::getMetadata();
|
||||||
if(!isset($this->data["Sheared"])){
|
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
|
if(!isset($this->data["Color"])){ //Make a new random color if it is not in data
|
||||||
$this->data["Color"] = $this->sheepColor();
|
$this->data["Color"] = $this->sheepColor();
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class NetherReactorBlock extends SolidBlock{
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player){
|
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(($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());
|
NetherReactorStructure::buildReactor($this->level, $this->getX(),$this->getY(),$this->getZ());
|
||||||
$this->meta = 1;
|
$this->meta = 1;
|
||||||
$this->level->setBlock($this,$this);
|
$this->level->setBlock($this,$this);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue