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