pmmp / PocketMine-MP

A server software for Minecraft: Bedrock Edition in PHP
https://pmmp.io
GNU Lesser General Public License v3.0
3.28k stars 1.56k forks source link

Slowness Effect levels >= 7 do not reset FOV when removed #1551

Open Muqsit opened 7 years ago

Muqsit commented 7 years ago

Issue description

Steps to reproduce the issue

  1. /give slowness 1 100
  2. Your FOV wont revert back.

OS and versions

Plugins

sylvrs commented 7 years ago

I remember having this issue on earlier versions(dating back to 0.15). Running fixed it for me.

dktapps commented 7 years ago

The only way I can reproduce this is by using excessive amplifiers (>= 7) so that the player's speed decreases to zero. Is that what you're describing?

Muqsit commented 7 years ago

Yes. In vanilla, the speed does get put to zero when you use amplifier >= 7 but the FOV reverts back to normal once slowness goes away.

dktapps commented 6 years ago

The problem arises here: https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/Effect.php#L474 - due to the dividend of the operation being zero. It's capped (is that the right word?) at zero when adding the effect and can't go below that.

In vanilla I think this is handled using attribute modifiers which effectively change the output value of an attribute, instead of modifying its base value directly. This is not implemented in PocketMine-MP.

Not sure how best to fix this - I don't think there's any real non-hacky way to do it.

djdisodo commented 6 years ago

https://github.com/pmmp/PocketMine-MP/blob/2d3ce9e8b027161c9d8b4145c94a3813d1ab9497/src/pocketmine/entity/Effect.php#L361 this sets negative value if effectlevel is >=7 how about $attr->setValue(max($attr->getMinValue(),$attr->getValue() / (1 - 0.15 * $instance->getEffectLevel())));