mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Fixed FOV and attributes
This commit is contained in:
parent
86ed0f1397
commit
8f9574dec5
@ -1213,23 +1213,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
return false;
|
||||
}
|
||||
|
||||
public function entityBaseTick($tickDiff = 1){
|
||||
$hasUpdate = parent::entityBaseTick($tickDiff);
|
||||
|
||||
$entries = $this->attributeMap->needSend();
|
||||
if(count($entries) > 0){
|
||||
$pk = new UpdateAttributesPacket();
|
||||
$pk->entityId = 0;
|
||||
$pk->entries = $entries;
|
||||
$this->dataPacket($pk);
|
||||
foreach($entries as $entry){
|
||||
$entry->markSynchronized();
|
||||
}
|
||||
}
|
||||
|
||||
return $hasUpdate;
|
||||
}
|
||||
|
||||
protected function checkGroundState($movX, $movY, $movZ, $dx, $dy, $dz){
|
||||
if(!$this->onGround or $movY != 0){
|
||||
$bb = clone $this->boundingBox;
|
||||
@ -1468,6 +1451,20 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
}
|
||||
|
||||
protected function updateMovement(){
|
||||
|
||||
}
|
||||
|
||||
public function sendAttributes(bool $sendAll = false){
|
||||
$entries = $sendAll ? $this->attributeMap->getAll() : $this->attributeMap->needSend();
|
||||
if(count($entries) > 0){
|
||||
$pk = new UpdateAttributesPacket();
|
||||
$pk->entityId = 0;
|
||||
$pk->entries = $entries;
|
||||
$this->dataPacket($pk);
|
||||
foreach($entries as $entry){
|
||||
$entry->markSynchronized();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onUpdate($currentTick){
|
||||
@ -1485,6 +1482,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
|
||||
$this->lastUpdate = $currentTick;
|
||||
|
||||
$this->sendAttributes();
|
||||
|
||||
if(!$this->isAlive() and $this->spawned){
|
||||
++$this->deadTicks;
|
||||
if($this->deadTicks >= 10){
|
||||
@ -1719,9 +1718,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$pk->started = $this->level->stopTime == false;
|
||||
$this->dataPacket($pk);
|
||||
|
||||
$pk = new SetHealthPacket();
|
||||
$pk->health = $this->getHealth();
|
||||
$this->dataPacket($pk);
|
||||
$this->sendAttributes(true);
|
||||
|
||||
$this->server->getLogger()->info($this->getServer()->getLanguage()->translateString("pocketmine.player.logIn", [
|
||||
TextFormat::AQUA . $this->username . TextFormat::WHITE,
|
||||
|
@ -50,17 +50,18 @@ class Attribute{
|
||||
protected static $attributes = [];
|
||||
|
||||
public static function init(){
|
||||
self::addAttribute(self::ABSORPTION, "generic.absorption", 0.00, 340282346638528859811704183484516925440.00, 0.00);
|
||||
self::addAttribute(self::SATURATION, "player.saturation", 0.00, 20.00, 5.00);
|
||||
self::addAttribute(self::EXHAUSTION, "player.exhaustion", 0.00, 5.00, 0.41);
|
||||
self::addAttribute(self::KNOCKBACK_RESISTANCE, "generic.knockbackResistance", 0.00, 1.00, 0.00);
|
||||
self::addAttribute(self::HEALTH, "generic.health", 0.00, 20.00, 20.00);
|
||||
self::addAttribute(self::MOVEMENT_SPEED, "generic.movementSpeed", 0.00, 340282346638528859811704183484516925440.00, 0.10);
|
||||
self::addAttribute(self::FOLLOW_RANGE, "generic.followRange", 0.00, 2048.00, 16.00, false);
|
||||
self::addAttribute(self::HUNGER, "player.hunger", 0.00, 20.00, 20.00);
|
||||
self::addAttribute(self::ATTACK_DAMAGE, "generic.attackDamage", 0.00, 340282346638528859811704183484516925440.00, 1.00, false);
|
||||
self::addAttribute(self::EXPERIENCE_LEVEL, "player.level", 0.00, 24791.00, 0.00);
|
||||
self::addAttribute(self::EXPERIENCE, "player.experience", 0.00, 1.00, 0.00);
|
||||
self::addAttribute(self::ABSORPTION, "minecraft:absorption", 0.00, 340282346638528859811704183484516925440.00, 0.00);
|
||||
self::addAttribute(self::SATURATION, "minecraft:player.saturation", 0.00, 20.00, 5.00);
|
||||
self::addAttribute(self::EXHAUSTION, "minecraft:player.exhaustion", 0.00, 5.00, 0.41);
|
||||
self::addAttribute(self::KNOCKBACK_RESISTANCE, "minecraft:knockback_resistance", 0.00, 1.00, 0.00);
|
||||
self::addAttribute(self::HEALTH, "minecraft:health", 0.00, 20.00, 20.00);
|
||||
self::addAttribute(self::MOVEMENT_SPEED, "minecraft:movement", 0.00, 340282346638528859811704183484516925440.00, 0.10);
|
||||
self::addAttribute(self::FOLLOW_RANGE, "minecraft:follow_range", 0.00, 2048.00, 16.00, false);
|
||||
self::addAttribute(self::HUNGER, "minecraft:player.hunger", 0.00, 20.00, 20.00);
|
||||
self::addAttribute(self::ATTACK_DAMAGE, "minecraft:attack_damage", 0.00, 340282346638528859811704183484516925440.00, 1.00, false);
|
||||
self::addAttribute(self::EXPERIENCE_LEVEL, "minecraft:player.level", 0.00, 24791.00, 0.00);
|
||||
self::addAttribute(self::EXPERIENCE, "minecraft:player.experience", 0.00, 1.00, 0.00);
|
||||
//TODO: minecraft:luck (for fishing?)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,6 +38,10 @@ class AttributeMap implements \ArrayAccess{
|
||||
return $this->attributes[$id] ?? null;
|
||||
}
|
||||
|
||||
public function getAll(): array{
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute[]
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user