mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 10:53:05 +00:00
Merge branch 'master' into api3/network
This commit is contained in:
@ -169,7 +169,7 @@ class Attribute{
|
||||
return $this->currentValue;
|
||||
}
|
||||
|
||||
public function setValue($value, $fit = false){
|
||||
public function setValue($value, $fit = false, bool $forceSend = false){
|
||||
if($value > $this->getMaxValue() or $value < $this->getMinValue()){
|
||||
if(!$fit){
|
||||
throw new \InvalidArgumentException("Value $value exceeds the range!");
|
||||
@ -180,7 +180,10 @@ class Attribute{
|
||||
if($this->currentValue != $value){
|
||||
$this->desynchronized = true;
|
||||
$this->currentValue = $value;
|
||||
}elseif($forceSend){
|
||||
$this->desynchronized = true;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -293,7 +293,7 @@ class Effect{
|
||||
$speed = $attr->getValue();
|
||||
}
|
||||
$speed *= (1 - 0.15 * $this->amplifier);
|
||||
$attr->setValue($speed);
|
||||
$attr->setValue($speed, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -423,7 +423,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
if($value !== $this->isSprinting()){
|
||||
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_SPRINTING, (bool) $value);
|
||||
$attr = $this->attributeMap->getAttribute(Attribute::MOVEMENT_SPEED);
|
||||
$attr->setValue($value ? ($attr->getValue() * 1.3) : ($attr->getValue() / 1.3));
|
||||
$attr->setValue($value ? ($attr->getValue() * 1.3) : ($attr->getValue() / 1.3), false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1643,10 +1643,15 @@ abstract class Entity extends Location implements Metadatable{
|
||||
$this->despawnFromAll();
|
||||
if($this->chunk !== null){
|
||||
$this->chunk->removeEntity($this);
|
||||
$this->chunk = null;
|
||||
}
|
||||
|
||||
if($this->getLevel() !== null){
|
||||
$this->getLevel()->removeEntity($this);
|
||||
$this->setLevel(null);
|
||||
}
|
||||
|
||||
$this->namedtag = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -285,6 +285,12 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($this->namedtag->SelectedInventorySlot) and $this->namedtag->SelectedInventorySlot instanceof IntTag){
|
||||
$this->inventory->setHeldItemIndex($this->namedtag->SelectedInventorySlot->getValue(), false);
|
||||
}else{
|
||||
$this->inventory->setHeldItemIndex(0, false);
|
||||
}
|
||||
|
||||
parent::initEntity();
|
||||
|
||||
if(!isset($this->namedtag->foodLevel) or !($this->namedtag->foodLevel instanceof IntTag)){
|
||||
@ -428,9 +434,8 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
}
|
||||
|
||||
//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){
|
||||
$slotCount = $this->inventory->getSize() + $this->inventory->getHotbarSize();
|
||||
for($slot = $this->inventory->getHotbarSize(); $slot < $slotCount; ++$slot){
|
||||
$item = $this->inventory->getItem($slot - 9);
|
||||
$this->namedtag->Inventory[$slot] = $item->nbtSerialize($slot);
|
||||
}
|
||||
@ -442,6 +447,8 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
$this->namedtag->Inventory[$slot] = $item->nbtSerialize($slot);
|
||||
}
|
||||
}
|
||||
|
||||
$this->namedtag->SelectedInventorySlot = new IntTag("SelectedInventorySlot", $this->inventory->getHeldItemIndex());
|
||||
}
|
||||
|
||||
if(strlen($this->getSkinData()) > 0){
|
||||
|
Reference in New Issue
Block a user