mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 20:49:43 +00:00
hotbar fixes
This commit is contained in:
parent
053ac5abb9
commit
a4a5f1dfdf
6 changed files with 16 additions and 9 deletions
|
|
@ -365,7 +365,7 @@ class PlayerAPI{
|
||||||
"z" => $this->server->spawn->z,
|
"z" => $this->server->spawn->z,
|
||||||
],
|
],
|
||||||
"inventory" => array_fill(0, PLAYER_SURVIVAL_SLOTS, [AIR, 0, 0]),
|
"inventory" => array_fill(0, PLAYER_SURVIVAL_SLOTS, [AIR, 0, 0]),
|
||||||
"hotbar" => [0, -1, -1, -1, -1, -1, -1, -1, -1],
|
"hotbar" => [0, 1, 2, 3, 4, 5, 6, 7, 8],
|
||||||
"armor" => array_fill(0, 4, [AIR, 0]),
|
"armor" => array_fill(0, 4, [AIR, 0]),
|
||||||
"gamemode" => $this->server->gamemode,
|
"gamemode" => $this->server->gamemode,
|
||||||
"health" => 20,
|
"health" => 20,
|
||||||
|
|
|
||||||
|
|
@ -1682,7 +1682,10 @@ class Player{
|
||||||
$this->slot = 0;
|
$this->slot = 0;
|
||||||
$this->hotbar = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
$this->hotbar = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
||||||
}
|
}
|
||||||
|
for($i = 0; $i < count($this->hotbar); ++$i){
|
||||||
|
if($this->hotbar[$i] > 36) $this->hotbar[$i] = -1; //XXX unsafe?
|
||||||
|
if($this->hotbar[$i] < -1) $this->hotbar[$i] = -1;
|
||||||
|
}
|
||||||
if($this->data->exists("slot-count")){
|
if($this->data->exists("slot-count")){
|
||||||
$this->slotCount = $this->data->get("slot-count");
|
$this->slotCount = $this->data->get("slot-count");
|
||||||
}else{
|
}else{
|
||||||
|
|
@ -1827,7 +1830,7 @@ class Player{
|
||||||
$this->slot = -1;
|
$this->slot = -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}else{
|
}else if($packet->slot > 0){
|
||||||
$packet->slot -= 9;
|
$packet->slot -= 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1878,8 +1881,7 @@ class Player{
|
||||||
if(Player::$experimentalHotbar) {
|
if(Player::$experimentalHotbar) {
|
||||||
$this->slot = $packet->slot;
|
$this->slot = $packet->slot;
|
||||||
$this->hotbar[$this->curHotbarIndex] = $packet->slot;
|
$this->hotbar[$this->curHotbarIndex] = $packet->slot;
|
||||||
}
|
}else{
|
||||||
else{
|
|
||||||
$this->curHotbarIndex = 0;
|
$this->curHotbarIndex = 0;
|
||||||
array_pop($this->hotbar);
|
array_pop($this->hotbar);
|
||||||
array_unshift($this->hotbar, $this->slot);
|
array_unshift($this->hotbar, $this->slot);
|
||||||
|
|
|
||||||
|
|
@ -1279,7 +1279,7 @@ class Entity extends Position
|
||||||
$this->speedMeasure = array(0, 0, 0, 0, 0, 0, 0);
|
$this->speedMeasure = array(0, 0, 0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSpeed() //TODO rename to getBaseSpeed
|
public function getSpeed()
|
||||||
{
|
{
|
||||||
return $this->speed;
|
return $this->speed;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ class ItemEntity extends Entity{
|
||||||
$this->speedZ = (lcg_value() - lcg_value()) * 0.2;
|
$this->speedZ = (lcg_value() - lcg_value()) * 0.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//$this->searchForOtherItemsNearby(); //not in vanilla 0.8.1, TODO reenable after fixing not correct count in inv
|
//$this->searchForOtherItemsNearby(); //not in vanilla 0.8.1
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->closed) return;
|
if($this->closed) return;
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class PlayerEquipmentPacket extends RakNetDataPacket{
|
||||||
$this->eid = $this->getInt();
|
$this->eid = $this->getInt();
|
||||||
$this->item = $this->getShort();
|
$this->item = $this->getShort();
|
||||||
$this->meta = $this->getShort();
|
$this->meta = $this->getShort();
|
||||||
$this->slot = $this->getByte();
|
$this->slot = $this->getSignedByte();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function encode(){
|
public function encode(){
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,11 @@ abstract class RakNetDataPacket extends stdClass{
|
||||||
return Utils::readShort($this->get(2), $unsigned);
|
return Utils::readShort($this->get(2), $unsigned);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSignedByte(){
|
||||||
|
$b = ord($this->get(1));
|
||||||
|
return $b >= 0x80 ? ($b-256) : $b;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getByte(){
|
protected function getByte(){
|
||||||
return ord($this->get(1));
|
return ord($this->get(1));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue