Skip to content

Wrappers

Gunnar edited this page Jul 3, 2025 · 4 revisions

Wrappers in scafall are kept very light-weight. That is for a good reason. Scafalls goal is not to wrap all the features of each platform using wrappers!

The main goal of scafall wrappers is to make it possible to communicate over a common interface. This is what allows for cross-platform APIs.

Before sending an object from a platform to the API, it is wrapped.
Then on the other side, any receiver can unwrap that object to its own platform specific API or Minecraft internal type.

In some cases, very basic features are accessible via the wrapper without having to unwrap the object, but scafall generally tries to keep that to a minimum to move quicker on updates and cause less breaking changes.

As mentioned above each platform has its own wrapper and unwrapper that allow to wrap platform specific objects and unwrap them back to the platform specific API type.

Minecraft Wrapper

This one is the default and already included in the base scafall API module. When working with minecraft internals this is the one to use, no additional modules are required.

In a modding scenario with access to net.minecraft unwrap it to the Minecraft object, modify it, and wrap it again when necessary.

// Get wrapper util
val wrapper = ScafallProvider.get().minecraftWrapper

// wrap an ItemStack
wrapper.wrapMCStack(minecraftItemStack)
// or
minecraftItemStack.wrap()

Spigot Wrapper

On Spigot, you can decide if you want to unwrap it to the Spigot representation or the Minecraft one if you are using NMS.

Important

Spigot wrapping requires an additional api extension com.wolfyscript.scafall.spigot:spigot-api

dependencies {
  implementation("com.wolfyscript.scafall.spigot:spigot-api:<same_version_as_api>")
}

This then allows you to get the spigot specific wrapper.

var wrapper = ScafallProvider.get().spigotWrapper

// wrap Spigot ItemStack
wrapper.wrapItemStack(spigotItemStack)
// or
spigotItemStack.wrap()

Clone this wiki locally