mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
hotbar is limited to 7 slots by default, changeable with /hotbar
This commit is contained in:
parent
99954b67d6
commit
ae59d3da59
2 changed files with 37 additions and 2 deletions
|
|
@ -69,6 +69,7 @@ class Player{
|
|||
private $chunkCount = [];
|
||||
private $received = [];
|
||||
|
||||
public $slotCount = 7;
|
||||
|
||||
public $entityMovementQueue;
|
||||
public $entityMovementQueueLength = 0;
|
||||
|
|
@ -1617,6 +1618,13 @@ class Player{
|
|||
$this->slot = -1;//0
|
||||
$this->hotbar = [-1, -1, -1, -1, -1, -1, -1, -1, -1];
|
||||
}
|
||||
|
||||
if($this->data->exists("slot-count")){
|
||||
$this->slotCount = $this->data->get("slot-count");
|
||||
}else{
|
||||
$this->data->set("slot-count", $this->slotCount);
|
||||
}
|
||||
|
||||
$this->entity = $this->server->api->entity->add($this->level, ENTITY_PLAYER, 0, ["player" => $this]);
|
||||
$this->eid = $this->entity->eid;
|
||||
$this->server->query("UPDATE players SET EID = " . $this->eid . " WHERE CID = " . $this->CID . ";");
|
||||
|
|
@ -1786,7 +1794,16 @@ class Player{
|
|||
if($this->server->handle("player.equipment.change", $data) !== false){
|
||||
$this->slot = $packet->slot;
|
||||
if(($this->gamemode & 0x01) === SURVIVAL){
|
||||
if(!in_array($this->slot, $this->hotbar)){
|
||||
|
||||
$has = false;
|
||||
for($i = 0; $i < $this->slotCount; ++$i){
|
||||
if($this->slot == $this->hotbar[$i]){
|
||||
$has = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$has){
|
||||
array_pop($this->hotbar);
|
||||
array_unshift($this->hotbar, $this->slot);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue