Skip to content

Conversation

@wiflow
Copy link

@wiflow wiflow commented Dec 16, 2025

Summary

When BetterModel exports models to Minecraft JSON format, element coordinates can exceed Minecraft's hard bounds (-16 to 32), causing errors like:

java.lang.IllegalArgumentException: Value at Z axis (-20.0) is out of bounds

This happens when the original bbmodel has coordinates slightly outside bounds, or when the split/export process applies offsets that push coordinates out of range.

Solution

This PR adds automatic bounds validation and coordinate shifting:

  • Pre-calculates the bounding box of all cubes before JSON export
  • Computes an offset to shift coordinates within valid bounds (-16 to 32)
  • Applies uniformly to from, to, and rotation origin to keep model parts aligned

Example

A model part with Z range -20 to +9:

  • Detects minZ = -20 is below -16
  • Calculates offsetZ = +4
  • Result: Z range -16 to +13 (within bounds)

Changes

  • Added MIN_BOUND and MAX_BOUND constants
  • Added calculateFrom() and calculateTo() helper methods
  • Added calculateBoundsOffset() to compute required shift
  • Modified Group.buildJson() to pre-calculate bounds and offset
  • Modified Cube.buildJson() to accept and apply the offset

Testing

  • Tested with models that have coordinates outside the -16 to 32 range
  • Build compiles successfully
  • Coordinates are shifted uniformly, preserving model alignment

When exporting models to Minecraft JSON format, element coordinates
could exceed Minecraft's allowed bounds (-16 to 32), causing errors
like "Value at Z axis (-20.0) is out of bounds" in tools like Nexo.

This fix:
- Calculates the bounding box of all cubes before JSON export
- Computes an offset to shift coordinates within valid bounds
- Applies the offset uniformly to from, to, and rotation origin

For example, a model with Z range -20 to +9 will be shifted by +4
to produce Z range -16 to +13, keeping all parts aligned.

Fixes models with coordinates slightly outside the -16 to 32 range.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant