Interface EntityVariant
- All Known Subinterfaces:
BoundEntityVariant
,UnboundEntityVariant
public sealed interface EntityVariant
permits UnboundEntityVariant, BoundEntityVariant (not exhaustive)
Represents a Bestium entity variant.
A variant defines a specific model for an entity, identified by a per-entity-unique variant ID
(matching [a-z0-9_.-]
). Each entity may have multiple variants registered through an
EntityInjection
.
Variants are first created as unbound using one of the static factory methods:
fromModelUrl(String, URL)
fromModelFile(String, File)
fromModelResource(String, PluginBootstrap, String)
EntityInjection
(e.g., via EntityInjection.Builder.addVariant(UnboundEntityVariant)
),
the variant is automatically bound to that injection and becomes a BoundEntityVariant
.-
Method Summary
Modifier and TypeMethodDescriptionstatic UnboundEntityVariant
fromModelFile
(String id, File modelFile) Constructs an unbound entity variant from a variant ID and a model file on the local filesystem.static UnboundEntityVariant
fromModelResource
(String id, PluginBootstrap bootstrapper, String resourceName) Constructs an unbound entity variant from a variant ID and a resource file bundled with a plugin.static UnboundEntityVariant
fromModelUrl
(String id, URL modelUrl) Constructs an unbound entity variant from a variant ID and a model URL.getId()
Returns the ID of this entity variant.Returns the URL of the model associated with this variant.
-
Method Details
-
fromModelUrl
Constructs an unbound entity variant from a variant ID and a model URL.- Parameters:
id
- the ID of this variant, e.g.,"warm"
or"cold"
modelUrl
- the URL of the model to apply when an entity uses this variant- Returns:
- the unbound entity variant
-
fromModelFile
Constructs an unbound entity variant from a variant ID and a model file on the local filesystem.- Parameters:
id
- the ID of this variant, e.g.,"warm"
or"cold"
modelFile
- the model file to apply when an entity uses this variant- Returns:
- the unbound entity variant
- Throws:
IllegalArgumentException
- if the file cannot be converted to a valid URL
-
fromModelResource
static UnboundEntityVariant fromModelResource(@Namespace String id, PluginBootstrap bootstrapper, String resourceName) Constructs an unbound entity variant from a variant ID and a resource file bundled with a plugin.- Parameters:
id
- the ID of this variant, e.g.,"warm"
or"cold"
bootstrapper
- the plugin bootstrapper whose classloader is used to locate the resourceresourceName
- the name of the resource (e.g.,"models/capybara.bbmodel"
)- Returns:
- the unbound entity variant
- Throws:
IllegalArgumentException
- if the resource is not found
-
getId
Returns the ID of this entity variant.- Returns:
- the variant ID
-
getModelUrl
URL getModelUrl()Returns the URL of the model associated with this variant.- Returns:
- the model URL
-