mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
Fixed #1642
This commit is contained in:
parent
d2ed0aa9f0
commit
e29ddadd2f
@ -505,9 +505,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->dataPacket($pk);
|
||||
$this->getLevel()->freeChunk($x, $z, $this);
|
||||
unset($this->usedChunks[$index]);
|
||||
|
||||
$this->orderChunks();
|
||||
}
|
||||
unset($this->loadQueue[$index]);
|
||||
$this->orderChunks();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1479,6 +1479,7 @@ class Server{
|
||||
|
||||
PluginManager::$pluginParentTimer = new TimingsHandler("** Plugins");
|
||||
Timings::init();
|
||||
|
||||
$this->pluginManager = new PluginManager($this, $this->commandMap);
|
||||
$this->pluginManager->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this->consoleSender);
|
||||
$this->pluginManager->setUseTimings($this->getProperty("settings.enable-profiling", false));
|
||||
|
@ -43,6 +43,8 @@ use pocketmine\metadata\Metadatable;
|
||||
use pocketmine\metadata\MetadataValue;
|
||||
use pocketmine\nbt\tag\Byte;
|
||||
use pocketmine\nbt\tag\Compound;
|
||||
use pocketmine\nbt\tag\Double;
|
||||
use pocketmine\nbt\tag\Enum;
|
||||
use pocketmine\nbt\tag\Float;
|
||||
use pocketmine\nbt\tag\Short;
|
||||
use pocketmine\network\protocol\MoveEntityPacket;
|
||||
@ -202,22 +204,28 @@ abstract class Entity extends Position implements Metadatable{
|
||||
}
|
||||
|
||||
public function saveNBT(){
|
||||
$this->namedtag["Pos"][0] = $this->x;
|
||||
$this->namedtag["Pos"][1] = $this->y;
|
||||
$this->namedtag["Pos"][2] = $this->z;
|
||||
$this->namedtag->Pos = new Enum("Pos", [
|
||||
new Double(0, $this->x),
|
||||
new Double(1, $this->y),
|
||||
new Double(2, $this->z)
|
||||
]);
|
||||
|
||||
$this->namedtag["Motion"][0] = $this->motionX;
|
||||
$this->namedtag["Motion"][1] = $this->motionY;
|
||||
$this->namedtag["Motion"][2] = $this->motionZ;
|
||||
$this->namedtag->Motion = new Enum("Motion", [
|
||||
new Double(0, $this->motionX),
|
||||
new Double(1, $this->motionY),
|
||||
new Double(2, $this->motionZ)
|
||||
]);
|
||||
|
||||
$this->namedtag["Rotation"][0] = $this->yaw;
|
||||
$this->namedtag["Rotation"][1] = $this->pitch;
|
||||
$this->namedtag->Rotation = new Enum("Rotation", [
|
||||
new Float(0, $this->yaw),
|
||||
new Float(1, $this->pitch)
|
||||
]);
|
||||
|
||||
$this->namedtag["FallDistance"] = $this->fallDistance;
|
||||
$this->namedtag["Fire"] = $this->fireTicks;
|
||||
$this->namedtag["Air"] = $this->airTicks;
|
||||
$this->namedtag["OnGround"] = $this->onGround == true ? 1 : 0;
|
||||
$this->namedtag["Invulnerable"] = $this->invulnerable == true ? 1 : 0;
|
||||
$this->namedtag->FallDistance = new Float("FallDistance", $this->fallDistance);
|
||||
$this->namedtag->Fire = new Short("Fire", $this->fireTicks);
|
||||
$this->namedtag->Air = new Short("Air", $this->airTicks);
|
||||
$this->namedtag->OnGround = new Byte("OnGround", $this->onGround == true ? 1 : 0);
|
||||
$this->namedtag->Invulnerable = new Byte("Invulnerable", $this->invulnerable == true ? 1 : 0);
|
||||
}
|
||||
|
||||
protected abstract function initEntity();
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
namespace pocketmine\entity;
|
||||
|
||||
use pocketmine\inventory\Inventory;
|
||||
use pocketmine\inventory\InventoryHolder;
|
||||
use pocketmine\inventory\PlayerInventory;
|
||||
use pocketmine\item\Item;
|
||||
@ -83,47 +84,36 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
parent::saveNBT();
|
||||
$this->namedtag->Inventory = new Enum("Inventory", []);
|
||||
$this->namedtag->Inventory->setTagType(NBT::TAG_Compound);
|
||||
for($slot = 0; $slot < 9; ++$slot){
|
||||
$hotbarSlot = $this->inventory->getHotbarSlotIndex($slot);
|
||||
if($hotbarSlot !== -1){
|
||||
$item = $this->inventory->getItem($hotbarSlot);
|
||||
if($item->getID() !== 0 and $item->getCount() > 0){
|
||||
$this->namedtag->Inventory[$slot] = new Compound(false, array(
|
||||
new Byte("Count", $item->getCount()),
|
||||
new Short("Damage", $item->getDamage()),
|
||||
new Byte("Slot", $slot),
|
||||
new Byte("TrueSlot", $hotbarSlot),
|
||||
new Short("id", $item->getID()),
|
||||
));
|
||||
continue;
|
||||
if($this->inventory instanceof PlayerInventory){
|
||||
for($slot = 0; $slot < 9; ++$slot){
|
||||
$hotbarSlot = $this->inventory->getHotbarSlotIndex($slot);
|
||||
if($hotbarSlot !== -1){
|
||||
$item = $this->inventory->getItem($hotbarSlot);
|
||||
if($item->getID() !== 0 and $item->getCount() > 0){
|
||||
$this->namedtag->Inventory[$slot] = new Compound(false, array(
|
||||
new Byte("Count", $item->getCount()),
|
||||
new Short("Damage", $item->getDamage()),
|
||||
new Byte("Slot", $slot),
|
||||
new Byte("TrueSlot", $hotbarSlot),
|
||||
new Short("id", $item->getID()),
|
||||
));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$this->namedtag->Inventory[$slot] = new Compound(false, array(
|
||||
new Byte("Count", 0),
|
||||
new Short("Damage", 0),
|
||||
new Byte("Slot", $slot),
|
||||
new Byte("TrueSlot", -1),
|
||||
new Short("id", 0),
|
||||
));
|
||||
}
|
||||
$this->namedtag->Inventory[$slot] = new Compound(false, array(
|
||||
new Byte("Count", 0),
|
||||
new Short("Damage", 0),
|
||||
new Byte("Slot", $slot),
|
||||
new Byte("TrueSlot", -1),
|
||||
new Short("id", 0),
|
||||
));
|
||||
}
|
||||
|
||||
//Normal inventory
|
||||
$slotCount = Player::SURVIVAL_SLOTS + 9;
|
||||
//$slotCount = (($this instanceof Player and ($this->gamemode & 0x01) === 1) ? Player::CREATIVE_SLOTS : Player::SURVIVAL_SLOTS) + 9;
|
||||
for($slot = 9; $slot < $slotCount; ++$slot){
|
||||
$item = $this->inventory->getItem($slot - 9);
|
||||
$this->namedtag->Inventory[$slot] = new Compound(false, array(
|
||||
new Byte("Count", $item->getCount()),
|
||||
new Short("Damage", $item->getDamage()),
|
||||
new Byte("Slot", $slot),
|
||||
new Short("id", $item->getID()),
|
||||
));
|
||||
}
|
||||
|
||||
//Armor
|
||||
for($slot = 100; $slot < 104; ++$slot){
|
||||
$item = $this->inventory->getItem($this->inventory->getSize() + $slot - 100);
|
||||
if($item instanceof Item and $item->getID() !== Item::AIR){
|
||||
//Normal inventory
|
||||
$slotCount = Player::SURVIVAL_SLOTS + 9;
|
||||
//$slotCount = (($this instanceof Player and ($this->gamemode & 0x01) === 1) ? Player::CREATIVE_SLOTS : Player::SURVIVAL_SLOTS) + 9;
|
||||
for($slot = 9; $slot < $slotCount; ++$slot){
|
||||
$item = $this->inventory->getItem($slot - 9);
|
||||
$this->namedtag->Inventory[$slot] = new Compound(false, array(
|
||||
new Byte("Count", $item->getCount()),
|
||||
new Short("Damage", $item->getDamage()),
|
||||
@ -131,6 +121,19 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
new Short("id", $item->getID()),
|
||||
));
|
||||
}
|
||||
|
||||
//Armor
|
||||
for($slot = 100; $slot < 104; ++$slot){
|
||||
$item = $this->inventory->getItem($this->inventory->getSize() + $slot - 100);
|
||||
if($item instanceof Item and $item->getID() !== Item::AIR){
|
||||
$this->namedtag->Inventory[$slot] = new Compound(false, array(
|
||||
new Byte("Count", $item->getCount()),
|
||||
new Short("Damage", $item->getDamage()),
|
||||
new Byte("Slot", $slot),
|
||||
new Short("id", $item->getID()),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user