mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
Basically Fixed Inventory
This commit is contained in:
parent
dcb8732335
commit
8aacc27795
3 changed files with 36 additions and 17 deletions
|
|
@ -2166,6 +2166,9 @@ class Player{
|
|||
$this->iusername = strtolower($this->username);
|
||||
$this->loginData = ["clientId" => $packet->clientId, "loginData" => $packet->loginData];
|
||||
$this->PROTOCOL = $packet->PROTOCOL;
|
||||
if($this->PROTOCOL <= ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||
Player::$experimentalHotbar = false;
|
||||
}
|
||||
if(count($this->server->clients) > $this->server->maxClients and !$this->server->api->ban->isOp($this->iusername)){
|
||||
$this->close("server is full!", false);
|
||||
return;
|
||||
|
|
@ -2806,6 +2809,13 @@ class Player{
|
|||
$data["posY"] = $packet->posY;
|
||||
$data["posZ"] = $packet->posZ;
|
||||
|
||||
if($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){ //TODO Emulate and Calcuate slot for version under 0.6.0
|
||||
if($this->hasItem($data["item"], $data["meta"])) {
|
||||
$handHeldItem = BlockAPI::getItem($data["item"], $data["meta"]);
|
||||
$this->setCurrentSlot($handHeldItem);
|
||||
}
|
||||
}
|
||||
|
||||
//nc: check item desync
|
||||
$heldItem = $this->getHeldItem();
|
||||
$pmeta = ($packet->meta & 0xff);
|
||||
|
|
@ -2850,7 +2860,12 @@ class Player{
|
|||
$this->addBlockUpdateIntoQueue($block->x, $block->y, $block->z, $block->getID(), $block->getMetadata());
|
||||
break;
|
||||
}elseif($packet->face === 0xff){
|
||||
|
||||
if($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){ //TODO Emulate and Calcuate slot for version under 0.6.0
|
||||
if($this->hasItem($data["item"], $data["meta"])) {
|
||||
$handHeldItem = BlockAPI::getItem($data["item"], $data["meta"]);
|
||||
$this->setCurrentSlot($handHeldItem);
|
||||
}
|
||||
}
|
||||
$slotItem = $this->getHeldItem();
|
||||
if($slotItem->getID() == SNOWBALL || $slotItem->getID() == EGG){ //TODO better way
|
||||
$x = $packet->x * 0.000030518;
|
||||
|
|
@ -3224,6 +3239,12 @@ class Player{
|
|||
|
||||
$packet->eid = $this->eid;
|
||||
$prevItem = $packet->item;
|
||||
if($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){ //TODO Emulate and Calcuate slot for version under 0.6.0
|
||||
if($this->hasItem($prevItem->getID(), $prevItem->getMetadata())) {
|
||||
$handHeldItem = BlockAPI::getItem($prevItem->getID(), $prevItem->getMetadata());
|
||||
$this->setCurrentSlot($handHeldItem);
|
||||
}
|
||||
}
|
||||
$newItem = $this->getHeldItem();
|
||||
|
||||
if(($n = $this->isExpectedSetSlot(-1, $prevItem))){
|
||||
|
|
@ -3264,7 +3285,6 @@ class Player{
|
|||
$this->toCraft = [];
|
||||
$this->craftingType = CraftingRecipes::TYPE_INVENTORY;
|
||||
$data["eid"] = $packet->eid;
|
||||
$data["unknown"] = $packet->randomly;
|
||||
$data["randomly"] = $packet->randomly;
|
||||
$data["item"] = $packet->item;
|
||||
$data["player"] = $this;
|
||||
|
|
@ -3583,8 +3603,19 @@ class Player{
|
|||
*/
|
||||
|
||||
public function getHeldItem(){
|
||||
if($this->PROTOCOL <= Protocolinfo9::CURRENT_PROTOCOL_9){
|
||||
ConsoleAPI::debug("Slot may exist issue , plz check the correct slot using setCurrentSlot first !");
|
||||
}
|
||||
return $this->getSlot($this->slot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dont use this if the protocol version >= MCPE 0.7
|
||||
* @return Boolean
|
||||
*/
|
||||
public function setCurrentSlot(Item $heldItem){
|
||||
$this->slot = $this->hasItem($heldItem->getID(), $heldItem->getMetadata()) ?: 0;
|
||||
}
|
||||
|
||||
public function stopSleep(){
|
||||
$this->isSleeping = false;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class PlayerEquipmentPacket extends RakNetDataPacket{
|
|||
$this->eid = $this->getInt();
|
||||
$this->item = $this->getShort();
|
||||
$this->meta = $this->getShort();
|
||||
if($this->PROTOCOL === ProtocolInfo::CURRENT_PROTOCOL){$this->slot = $this->getSignedByte();}
|
||||
if($this->PROTOCOL >= ProtocolInfo12::CURRENT_PROTOCOL_12){$this->slot = $this->getSignedByte();}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
|
|
@ -31,7 +31,7 @@ class PlayerEquipmentPacket extends RakNetDataPacket{
|
|||
$this->putInt($this->eid);
|
||||
$this->putShort(BlockAPI::convertHighItemIdsToOldItemIds($this->PROTOCOL, $this->item));
|
||||
$this->putShort($this->meta);
|
||||
if($this->PROTOCOL === ProtocolInfo::CURRENT_PROTOCOL){$this->putByte($this->slot);}
|
||||
if($this->PROTOCOL >= ProtocolInfo12::CURRENT_PROTOCOL_12){$this->putByte($this->slot);}
|
||||
}
|
||||
|
||||
public function eidsToGlobal(Player $p){
|
||||
|
|
|
|||
|
|
@ -41,10 +41,6 @@ class UseItemPacket extends RakNetDataPacket{
|
|||
$this->item = $this->getShort();
|
||||
$this->meta = $this->getByte();
|
||||
$this->eid = $this->getInt();
|
||||
if ($this->PROTOCOL > ProtocolInfo9::CURRENT_PROTOCOL_9) {
|
||||
$this->unknownInt1 = $this->getInt();
|
||||
return;
|
||||
}
|
||||
$this->fx = $this->getFloat();
|
||||
$this->fy = $this->getFloat();
|
||||
$this->fz = $this->getFloat();
|
||||
|
|
@ -56,15 +52,7 @@ class UseItemPacket extends RakNetDataPacket{
|
|||
}
|
||||
|
||||
public function encode(){
|
||||
/*$this->reset();
|
||||
$this->putInt($this->x);
|
||||
$this->putInt($this->y);
|
||||
$this->putInt($this->z);
|
||||
$this->putInt($this->face);
|
||||
$this->putShort($this->item);
|
||||
$this->putByte($this->meta);
|
||||
$this->putInt($this->eid);
|
||||
$this->putInt($this->unknownInt1);*/
|
||||
|
||||
}
|
||||
public function eidsToGlobal(Player $p){
|
||||
if($this->localEids){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue