How do I limit a number from exceeding a certain value

Started by Disevro on

Topic category: Help with modding (Java Edition)

Last seen on 22:49, 17. Feb 2024
Joined Jan 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I limit a number from exceeding a certain value

In this case, I'm trying to keep a player's velocity from becoming too high since the system using the velocity is multiplying the current player velocity by a number to produce a sort of dash. The current solution I've come up with so far limits the speed well, but also limits the direction of dashing to only 4 directions, creating odd moments where dashing appears to send you at an angle instead of the direction you wanted to dash.

https://drive.google.com/file/d/1SX67BgaBp6Wu0MFGKr7ZH9V5W8zvVpy8/view?usp=sharing

Image of my solution so far.

Last seen on 21:56, 18. Feb 2024
Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I don't have access to your…
Fri, 02/02/2024 - 01:05

I don't have access to your image, so my best advice is to use the Pythagorean theorem to calculate speed. That's all I can give you for now. 

Last seen on 21:56, 18. Feb 2024
Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I can't find X and Z…
Fri, 02/02/2024 - 01:36

I can't find X and Z velocity in MCreator.

Last seen on 22:49, 17. Feb 2024
Joined Jan 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
X and Z velocities are…
Fri, 02/02/2024 - 01:52

X and Z velocities are located in the entity data section

Last seen on 21:56, 18. Feb 2024
Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This took way too long. …
Fri, 02/02/2024 - 02:37

This took way too long. 

https://www.mediafire.com/file/t5uii7exdps1672/Screenshot_2024-02-01_183317.png/file

I hope this works for limiting speed. Besides the formula (big blob of math before the greater than sign), you can customize the numbers.