Created
October 10, 2020 20:13
-
-
Save Commoble/88dfc91c3c56ccfbeb4e7fea91572f84 to your computer and use it in GitHub Desktop.
Water Slowdown Mechanics in Minecraft Forge 1.16.3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
water slowdown mechanics | |
assume an entity is in water | |
let moveSpeed = movement speed attribute | |
defaults to 0.7 for players? | |
let swimSpeed = swim speed modifier attribute | |
defaults to 1.0 | |
let depthStriderEnchantment be 0F, 1F, 2F, or 3F (depends on enchantment tier, hard capped at 3) if on ground, or half that if treading water | |
let depthStriderFactor = depthStriderEnchantment / 3F (results in a number in the range [0,1]) | |
let attenuation = | |
entity has dolphin's grace? 0.96F, else | |
let baseAttenuation = 0.9F if sprinting, otherwise check entity.getWaterSlowdown(): | |
0.98 for polar bears | |
0.96 for skeleton horses | |
0.80 for everything else | |
let attenuation = baseAttenuation + (0.546F - baseAttenuation) * depthStriderFactor | |
(this results in baseAttenuation with no depth strider, or 0.546 at max depth strider and on ground) | |
let unmodifiedWaterSpeed = (0.02F + (moveSpeed - waterSpeed) * depthStriderFactor) | |
(this results in 0.02F if no depth strider, or moveSpeed at max depth strider and on ground) | |
let waterSpeed = unmodifiedWaterSpeed * swimSpeed | |
set velocity to waterSpeed in current forward vector | |
apply that velocity to position | |
multiply current motion vector by (attenuation, 0.8, attenuation) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment