Skip to content

Data Driven Resources

Zac edited this page Jan 2, 2025 · 1 revision

Resources

A key component of CuTAPI is its method of handling resources. Resources can be anything; something that goes into your server's resource pack like a 3D model, something that doesn't go into your server's resource pack like a texture used to create a map, or any other piece of deserializable data.

Initialization

By default, CuTAPI will try to read resources from your plugin's resources/pack folder. This can be changed with PluginOptionsBuilder#packFolder

CuTAPI.registerPlugin(this, "my_plugin") {
  packFolder = "whatever/you/want"
}

Creating a resource

CuTAPI has several resource types built in. These include:

  • Texture2D - A texture that can be used in-game and that will be included in the output resource pack.
  • Model3D - A model that can be used in-game and that will be included in the output resource pack.
  • MetadataResource (abstract) - A special abstract resource that contains its own metadata.

All resource types derive from Resource. Optionally, they may implement ByteArraySerializable and provide a fun toBytes(): ByteArray function to allow them to be saved to disk using (Resource & ByteArraySerializable).saveTo(File) or (Resource & ByteArraySerializable).saveWithMetadata(File, KSerializer<in CuTMeta>?)

Clone this wiki locally