Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.21] Config Equations #514

Open
SomewhatDamaged opened this issue Apr 30, 2024 · 1 comment
Open

[1.21] Config Equations #514

SomewhatDamaged opened this issue Apr 30, 2024 · 1 comment
Labels
1-21 Improvement refine and existing feature (tweaks not additions)

Comments

@SomewhatDamaged
Copy link
Contributor

Describe the solution you'd like
I had a thought about a possibly better way to handle things like level-up equations and possibly death equations.

You could use String.format to basically build an equation and then evaluate it as the level-up/death equations.

So, for the exponential leveling curve in 1.20.1:
String levelFunction=String.format("250 * 1.104088404342588^(1.1 * %d)",level);
Or the linear one:
String levelFunction=String.format("250 + 500 * %d",level);
Then use javax.script.ScriptEngine to evaluate it and cache the value.
Then all the config would need is that string: "250 * 1.104088404342588^(1.1 * %d)"
Rather than the multiple variables needed, and the switch between leveling type.

Why is this feature needed
To make equations a little more friendly to edit and a lot more powerful.

Describe alternatives you've considered
Hugging Blåhaj.

Additional context

natural.1.mp4
@SomewhatDamaged
Copy link
Contributor Author

Ah, more safe than eval. There's a java eval for math only posted over here, with a waived-rights license on it: https://stackoverflow.com/a/26227947/19846989

@Caltinor Caltinor added the 1-21 label May 7, 2024
@Caltinor Caltinor added the Improvement refine and existing feature (tweaks not additions) label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1-21 Improvement refine and existing feature (tweaks not additions)
Projects
Status: New Features
Development

No branches or pull requests

2 participants