Skip to content
diskria edited this page Apr 21, 2026 · 23 revisions

I need to start from afar to describe the schema concept. Let's start with an example of methods. Look at this string:

"Lnet/minecraft/world/entity/player/Player;crit(Lnet/minecraft/world/entity/Entity;)V"

This is a long, magical string that's required for the Mixin but completely unreadable and would be an anti-pattern in modern Kotlin development. My goal was to come up with some kind of entity that would contain information from which this string could be deduced during compilation, but at the same time, make it so that the modder would never have to write it manually. The most elegant solution for this in Kotlin is callable references:

val crit = Player::crit

If the method is overloaded, then we need to clarify which one we mean. For this purpose, Kotlin provides us function types:

val crit: Player.(Entity) -> Unit = Player::crit

By using both features together on a consistent basis, we force the compiler to check that the crit is actually non-static method, exists in the Player class, takes single parameter of type Entity, and returns void.

Clone this wiki locally