PrismarineJS / prismarine-physics

Provide the physics engine for minecraft entities
MIT License
35 stars 39 forks source link

From WhoTho - fix speed and slowness effect #51

Closed U5B closed 2 years ago

U5B commented 2 years ago

https://github.com/PrismarineJS/mineflayer/issues/2241#issuecomment-939384631

rom1504 commented 2 years ago

can you explain why this is the right fix with some reference on minecraft code or some other implementation ?

U5B commented 2 years ago

can you explain why this is the right fix with some reference on minecraft code or some other implementation ?

Sorry for not getting back to you sooner. WhoTho didn't respond and I thought he did. Fandom says that it is 20% multiplied by the effect level. https://minecraft.fandom.com/wiki/Speed 0.2 'effect.level' instead of 1.2 'effect.level'

Fandom says 15% 'effect.level' 0.15 'effect.level' instead of 0.85 * 'effect.level'

Math.max is used with 0 because past level 7, slowness makes your speed basically 0 unless you are jumping.

nickelpro commented 2 years ago

Would much rather see an explanation from the Minecraft physics implementation than Fandom

U5B commented 2 years ago

Would much rather see an explanation from the Minecraft physics implementation than Fandom

I cannot find where the speed and slowness effects are calculated in the source, only jump height. Found jump height here client/net/minecraft/world/entity/LivingEntity.java in function jumpFromGround()

EDIT: here is a different wiki source https://www.mcpk.wiki/wiki/Status_Effects but evidence from Minecraft source would be better, I JUST CAN'T FIND IT

nickelpro commented 2 years ago

That's sort of my point, those wikis might be outdated or just copying one another and wrong. If we don't fully understand the behavior, we shouldn't implement it on a rumor. If there's a discrepancy that needs to be fixed it needs to be linked to a section of Minecraft physics source that we're currently not handling. This way everyone can review and concur that the PR matches the behavior of vanilla.

U5B commented 2 years ago

Thank you for the input. From the Minecraft source, it uses attributes modifiers for effects instead of the effect levels themselves I will make a PR trying to implement attributes later.