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 UnboundEntityVariantfromModelFile(String id, File modelFile) Constructs an unbound entity variant from a variant ID and a model file on the local filesystem.static UnboundEntityVariantfromModelResource(String id, PluginBootstrap bootstrapper, String resourceName) Constructs an unbound entity variant from a variant ID and a resource file bundled with a plugin.static UnboundEntityVariantfromModelResource(String id, Class<?> clazz, String resourceName) Constructs an unbound entity variant from a variant ID and a resource file bundled with a plugin.static UnboundEntityVariantfromModelUrl(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 class loader 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
-
fromModelResource
static UnboundEntityVariant fromModelResource(@Namespace String id, Class<?> clazz, 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"clazz- a class from your plugin whose class loader 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 or if the class loader is not a paper plugin class loader
-
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
-