mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Creative inventory fixes
This commit is contained in:
parent
98ea674d20
commit
92784054cd
@ -1098,6 +1098,9 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->inventory->sendContents($this);
|
||||
$this->inventory->sendContents($this->getViewers());
|
||||
$this->inventory->sendHeldItem($this->hasSpawned);
|
||||
if($this->isCreative()){
|
||||
$this->inventory->sendCreativeContents();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1733,6 +1736,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->setRemoveFormat(false);
|
||||
}
|
||||
|
||||
if($this->isCreative()){
|
||||
$this->inventory->sendCreativeContents();
|
||||
}
|
||||
|
||||
$this->forceMovement = $this->teleportPosition = $this->getPosition();
|
||||
|
||||
$this->server->onPlayerLogin($this);
|
||||
|
@ -399,15 +399,6 @@ class PlayerInventory extends BaseInventory{
|
||||
$index = $this->getHotbarSlotIndex($i);
|
||||
$pk->hotbar[] = $index <= -1 ? -1 : $index + $this->getHotbarSize();
|
||||
}
|
||||
|
||||
if($player->getGamemode() & 0x01 === 0x01){ //Send special inventory for creative or spectator
|
||||
$pk2 = new ContainerSetContentPacket();
|
||||
$pk2->windowid = ContainerSetContentPacket::SPECIAL_CREATIVE;
|
||||
if($player->getGamemode() === Player::CREATIVE){
|
||||
$pk2->slots = Item::getCreativeItems();
|
||||
}
|
||||
$player->dataPacket($pk2);
|
||||
}
|
||||
}
|
||||
if(($id = $player->getWindowId($this)) === -1 or $player->spawned !== true){
|
||||
$this->close($player);
|
||||
@ -418,6 +409,17 @@ class PlayerInventory extends BaseInventory{
|
||||
}
|
||||
}
|
||||
|
||||
public function sendCreativeContents(){
|
||||
$pk = new ContainerSetContentPacket();
|
||||
$pk->windowid = ContainerSetContentPacket::SPECIAL_CREATIVE;
|
||||
if($this->getHolder()->getGamemode() === Player::CREATIVE){
|
||||
foreach(Item::getCreativeItems() as $i => $item){
|
||||
$pk->slots[$i] = clone $item;
|
||||
}
|
||||
}
|
||||
$this->getHolder()->dataPacket($pk);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $index
|
||||
* @param Player|Player[] $target
|
||||
|
Loading…
x
Reference in New Issue
Block a user