Pocketmine-mp: setScale() nametag height issue.

Created on 12 Apr 2017  路  11Comments  路  Source: pmmp/PocketMine-MP

Issue description




Using setScale() set's the entity's nametag very high.
sx

Steps to reproduce the issue


Code executed:

//class extending Creature
protected function initEntity(){
    parent::initEntity();
    $this->setNameTagVisible(true);
    $this->setNameTagAlwaysVisible(true);
    $this->setMaxHealth(400);
    $this->setHealth(400);
    $this->setNameTag(TextFormat::BOLD.TextFormat::YELLOW.'Cute Slime');
    $this->setScale(6.5);
}

OS and versions

  • PocketMine-MP: 172d733
  • PHP: 7.0.17
  • Server OS: Ubuntu 14.04 64-bit
  • Game version: Win10

Crashdump, backtrace or other files


-=-

Gameplay Fixed

All 11 comments

That would be due to the bounding box changes

hmm, I also noticed that players' POV doesn't change when setting scale... not sure why, probably related.

Yeah; but for the most part, the function works fine.
There are two ways to deal with entity scaling.
1. $this->setDataProperty(self::DATA_SCALE, self::DATA_TYPE_FLOAT, _float_);
2. $this->setScale(_float_);

Both the functions do the same thing except the second function calls the first function and also updates the bounding boxes of the entity. It could be a bounding box issue, or not. It did exist well before the bounding box update to setScale function.

There's yet a difference between using the first function and the second function:
1st function: The height of the nametag would be 2 - 3 blocks above the entity.
2nd function: The height of the nametag would be well over 40 blocks above the entity.

The nametag didn't move positions when setting the scale as a property. The perspective of it's location only changed because the player looks smaller. The second function, however, i believe to be because of the bounding box change. Also, looking at the code, you set the scale to 6.5 which should be 6.5 times the player's default size. I think the nametag is in the correct place, but the players size is incorrect.

https://github.com/pmmp/PocketMine-MP/blob/api3/network/src/pocketmine/entity/Entity.php#L407
According to the math in setScale() the current player scale is used instead of the default for the bounding box changes. Are we sure this is correct usage?

@jasonwynn10 yes, since the default isn't stored.

Setting entity scale to 0.5 when it was previously 2.0 will result in all lengths being multiplied by 0.25, which is correct.

As far as I'm aware, add-ons that change player scale don't modify the player's POV.

Is there even a way to change where the player's POV is looking from? as in, can the view be moved to the feet of the player? If so, that same method may be able to be used in scaling

You'd think the developers wouldn't hardcode the POV, but alas it seems as if they did.

I noticed that it doesn't modify the items that the player holds, I have no idea if this affects vanilla too.

Photo proof minecraft_ windows 10 edition 4_12_2017 9_22_24 pm

Yea, the player's held item is always at the same location no matter what scale it's set to

The item and nametag issue both happen on pe too for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zKoz210 picture zKoz210  路  27Comments

Muqsit picture Muqsit  路  23Comments

Sandertv picture Sandertv  路  37Comments

Frago9876543210 picture Frago9876543210  路  50Comments

matcracker picture matcracker  路  17Comments