mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 20:49:43 +00:00
experimental hotbar changes (enabled by default)
This commit is contained in:
parent
e81b2a0a1e
commit
40dfb144eb
3 changed files with 37 additions and 14 deletions
|
|
@ -110,7 +110,7 @@ class PlayerAPI{
|
||||||
$sc = (int)$scrw;
|
$sc = (int)$scrw;
|
||||||
if($sc < 5 || $sc > 9) return "Slot count must be between 5 and 9.";
|
if($sc < 5 || $sc > 9) return "Slot count must be between 5 and 9.";
|
||||||
|
|
||||||
$issuer->slotCount = $sc;
|
$issuer->setSlotCount($sc);
|
||||||
$issuer->sendInventory();
|
$issuer->sendInventory();
|
||||||
return "Changed slot count to $sc";
|
return "Changed slot count to $sc";
|
||||||
}else{
|
}else{
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
class Player{
|
class Player{
|
||||||
|
|
||||||
public static $smallChunks = false;
|
public static $smallChunks = false, $experimentalHotbar = true;
|
||||||
/** @var Config */
|
/** @var Config */
|
||||||
public $data;
|
public $data;
|
||||||
/** @var Entity */
|
/** @var Entity */
|
||||||
|
|
@ -15,6 +15,7 @@ class Player{
|
||||||
public $inventory;
|
public $inventory;
|
||||||
public $slot;
|
public $slot;
|
||||||
public $hotbar;
|
public $hotbar;
|
||||||
|
public $curHotbarIndex = 0;
|
||||||
public $armor = [];
|
public $armor = [];
|
||||||
public $loggedIn = false;
|
public $loggedIn = false;
|
||||||
public $gamemode;
|
public $gamemode;
|
||||||
|
|
@ -106,7 +107,7 @@ class Player{
|
||||||
$this->gamemode = $this->server->gamemode;
|
$this->gamemode = $this->server->gamemode;
|
||||||
$this->level = $this->server->api->level->getDefault();
|
$this->level = $this->server->api->level->getDefault();
|
||||||
$this->slot = 0;
|
$this->slot = 0;
|
||||||
$this->hotbar = [0, -1, -1, -1, -1, -1, -1, -1, -1];
|
$this->hotbar = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
||||||
$this->packetStats = [0, 0];
|
$this->packetStats = [0, 0];
|
||||||
|
|
||||||
$this->buffer = new RakNetPacket(RakNetInfo::DATA_PACKET_0);
|
$this->buffer = new RakNetPacket(RakNetInfo::DATA_PACKET_0);
|
||||||
|
|
@ -165,7 +166,12 @@ class Player{
|
||||||
$this->setSpawn($spawnPoint);
|
$this->setSpawn($spawnPoint);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setSlotCount($cnt){
|
||||||
|
$this->slotCount = $cnt;
|
||||||
|
$this->data->set("slot-count", $this->slotCount);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Vector3 $pos
|
* @param Vector3 $pos
|
||||||
* @param float|boolean $yaw
|
* @param float|boolean $yaw
|
||||||
|
|
@ -1660,8 +1666,8 @@ class Player{
|
||||||
$this->hotbar = $this->data->get("hotbar");
|
$this->hotbar = $this->data->get("hotbar");
|
||||||
$this->slot = $this->hotbar[0];
|
$this->slot = $this->hotbar[0];
|
||||||
}else{
|
}else{
|
||||||
$this->slot = -1;//0
|
$this->slot = 0;
|
||||||
$this->hotbar = [-1, -1, -1, -1, -1, -1, -1, -1, -1];
|
$this->hotbar = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->data->exists("slot-count")){
|
if($this->data->exists("slot-count")){
|
||||||
|
|
@ -1837,21 +1843,36 @@ class Player{
|
||||||
$data["slot"] = $packet->slot;
|
$data["slot"] = $packet->slot;
|
||||||
|
|
||||||
if($this->server->handle("player.equipment.change", $data) !== false){
|
if($this->server->handle("player.equipment.change", $data) !== false){
|
||||||
$this->slot = $packet->slot;
|
if(!Player::$experimentalHotbar) $this->slot = $packet->slot;
|
||||||
if(($this->gamemode & 0x01) === SURVIVAL && count($this->hotbar) >= $this->slotCount){
|
if(($this->gamemode & 0x01) === SURVIVAL){
|
||||||
|
|
||||||
$has = false;
|
$has = false;
|
||||||
|
$slotPos = 0;
|
||||||
|
$packetSlotPos = 0;
|
||||||
for($i = 0; $i < $this->slotCount; ++$i){
|
for($i = 0; $i < $this->slotCount; ++$i){
|
||||||
if($this->slot == $this->hotbar[$i]){
|
if($this->slot == $this->hotbar[$i]) $slotPos = $i;
|
||||||
|
if($packet->slot == $this->hotbar[$i]){
|
||||||
|
$packetSlotPos = $i;
|
||||||
$has = true;
|
$has = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$has){
|
if(Player::$experimentalHotbar && $has) {
|
||||||
array_pop($this->hotbar);
|
$this->slot = $packet->slot;
|
||||||
array_unshift($this->hotbar, $this->slot);
|
$this->curHotbarIndex = $packetSlotPos;
|
||||||
}
|
}
|
||||||
|
if(!$has){
|
||||||
|
if(Player::$experimentalHotbar) {
|
||||||
|
$this->slot = $packet->slot;
|
||||||
|
$this->hotbar[$this->curHotbarIndex] = $packet->slot;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$this->curHotbarIndex = 0;
|
||||||
|
array_pop($this->hotbar);
|
||||||
|
array_unshift($this->hotbar, $this->slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(Player::$experimentalHotbar) $this->sendInventory();
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//$this->sendInventorySlot($packet->slot);
|
//$this->sendInventorySlot($packet->slot);
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,10 @@ class PocketMinecraftServer{
|
||||||
"experimental-mob-ai" => false,
|
"experimental-mob-ai" => false,
|
||||||
"force-20-tps" => false,
|
"force-20-tps" => false,
|
||||||
"enable-mob-pushing" => Living::$entityPushing,
|
"enable-mob-pushing" => Living::$entityPushing,
|
||||||
"keep-chunks-loaded" => self::$KEEP_CHUNKS_LOADED
|
"keep-chunks-loaded" => self::$KEEP_CHUNKS_LOADED,
|
||||||
|
"use-experimental-hotbar" => Player::$experimentalHotbar
|
||||||
]);
|
]);
|
||||||
|
Player::$experimentalHotbar = $this->extraprops->get("use-experimental-hotbar");
|
||||||
Player::$smallChunks = $this->extraprops->get("16x16x16_chunk_sending");
|
Player::$smallChunks = $this->extraprops->get("16x16x16_chunk_sending");
|
||||||
Living::$despawnMobs = $this->extraprops->get("despawn-mobs");
|
Living::$despawnMobs = $this->extraprops->get("despawn-mobs");
|
||||||
Living::$despawnTimer = $this->extraprops->get("mob-despawn-ticks");
|
Living::$despawnTimer = $this->extraprops->get("mob-despawn-ticks");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue