Scoreboard Math Engine
The math module provides trigonometric and algebraic functions using scoreboard operations. All values use fixed-point arithmetic scaled by 1000 to preserve decimal precision inside integer-only scoreboards.
Registering the math module
This generates a load function that creates the kore_math objective and sets useful constants (#2, #360, #scale).
Reading the results
Because scoreboards only store integers, every result is scaled by 1000:
1000means1.0500means0.5-707means approximately-0.707
That convention stays consistent across trigonometric helpers and formulas, which makes it easier to combine several math operations in the same datapack.
Trigonometric functions
Sine and cosine use a pre-computed 360-entry lookup table (one entry per degree). The input score holds an angle in degrees; the output receives value × 1000.
Negative angles are normalized safely before the lookup, so inputs such as -90 behave exactly like 270 even though Minecraft scoreboards keep the sign when using %.
This is particularly handy for scoreboard-driven movement systems, orbiting particles, or knockback calculations where the input angle is already tracked as an integer.
Delegate-based syntax
If you already use scoreboard delegates, the math helpers also expose infix wrappers that preserve the same runtime behavior while removing string boilerplate:
Square root
An iterative Babylonian / Newton approximation (8 iterations by default):
The initial guess is clamped away from zero, which prevents the scoreboard division step from failing for inputs like 0 or 1.
Use sqrt when you need a real distance magnitude from squared values, or when another formula requires a root instead of a squared distance.
Euclidean distance (squared)
Computes (x2−x1)² + (y2−y1)² + (z2−z1)²:
Computing the squared distance is often enough for range checks and is cheaper to chain with threshold comparisons than an actual square root.
You can also call the helper with scoreboard delegates directly:
Parabolic trajectory
Computes Y = v0 × t − (g × t²) / 2 for projectile simulation:
There is also a delegate-based overload when velocity, gravity, time, and output are all tracked as scoreboards.
Example: projectile preview
The helpers are intentionally small and composable: you can build a more complex simulation by combining multiple scoreboard operations rather than relying on one giant black-box function.
Function reference
| Function | Description |
|---|---|
cos |
Cosine lookup (degrees → scaled result) |
sin |
Sine lookup (degrees → scaled result) |
sqrt |
Integer square root (Newton's method) |
distanceSquared |
Squared 3D Euclidean distance |
parabola |
Parabolic Y from time, velocity, and gravity |
cosTo / sinTo / sqrtTo |
Delegate-based infix wrappers |
See also
- State Delegates – Write scoreboard-backed values with less boilerplate before feeding them into math helpers.
- Cooldowns – Pair time-based gameplay gates with scoreboard-driven calculations.
- Scoreboards – Higher-level scoreboard utilities that fit naturally around these formulas.
