Skip to main content

Overview

The ModelRenderer is the entry point for spawning and managing model instances in BetterModel. It represents a loaded model definition (typically from a .bbmodel file) and provides methods to create trackers that render the model in the world.

Model Structure

A ModelRenderer contains:
  • Name - Unique identifier for the model
  • Type - Either GENERAL or PLAYER
  • Renderer Groups - Hierarchical bone structure with display entities
  • Animations - Named animation definitions

Renderer Types

General models can be attached to any entity or location. They support saving/serialization.

Loading Models

Models are automatically discovered from the BetterModel/models/ and BetterModel/players/ directories.

Model Discovery

Model names are derived from the .bbmodel filename without the extension.

Creating Trackers

The ModelRenderer provides multiple create() methods for spawning model instances.

Entity Trackers

Attach a model to an entity:
src/main/java/com/example/EntityModelExample.java

Dummy Trackers

Spawn a standalone model at a location:
src/main/java/com/example/DummyModelExample.java
Dummy trackers are stationary and don’t follow entities. Use them for environmental decorations, holograms, or stationary NPCs.

Get or Create Pattern

For entity trackers, you can retrieve existing trackers or create new ones:
src/main/java/com/example/GetOrCreateExample.java

Working with Animations

Renderers provide access to their animation definitions:

Renderer Groups

Renderer groups represent the bone hierarchy of the model:

Tracker Modifiers

Customize tracker behavior with TrackerModifier:
src/main/java/com/example/ModifierExample.java

Modifier Options

int
default:"64"
Maximum distance in blocks from which players can see the model.
boolean
default:"false"
Whether to hide the model when the player’s line of sight is blocked.
boolean
default:"true"
Whether to smoothly interpolate entity movement.

Profile Support

For player models or custom textures, use ModelProfile:
src/main/java/com/example/ProfileExample.java
Profiles handle player skins and custom textures asynchronously. The model will update automatically when the texture loads.

Best Practices

Retrieve renderers once and cache them. Don’t look up models on every tracker creation.
Model loading can fail. Always handle Optional.empty() cases.
For entities that may already have trackers, use getOrCreate() to avoid duplicates.
Always close trackers when they’re no longer needed.

Example: Complete Model Spawning

src/main/java/com/example/CompleteExample.java

See Also

Trackers

Learn about managing tracker lifecycle

Animations

Playing and controlling animations

Bones & Hitboxes

Working with individual bones

API Reference

Complete ModelRenderer API