Custom Vanilla Information
We have covered how to completely intercept and take over the display for a block or entity using Custom Handlers. However, if you return true in a custom handler, the player loses all default vanilla information (like break progress, crop age, or entity health).
If you just want to append a small piece of custom information to the existing vanilla display, you can inject functions directly into the default MinecraftCompat handler.
Injecting Custom Information
The MinecraftCompat class maintains lists of functions that run every time a vanilla block or entity is looked at.
You can add your own logic to these lists to supply additional Component prefixes or suffixes.
MinecraftCompat.getBlockPrefix()MinecraftCompat.getBlockSuffix()MinecraftCompat.getEntityPrefix()MinecraftCompat.getEntitySuffix()
Example: Adding a Block Suffix
Let's say you have a custom plugin that applies "Radiation" to certain blocks, and you want players to see the radiation level when they look at them, alongside the standard vanilla break progress.
Example: Adding an Entity Prefix
Similarly, you can inject information before the name of an entity. This is commonly used for showing things like Factions, Guilds, or custom ownership.
Reloading Considerations
Just like Custom Handlers, the MinecraftCompat lists are cleared whenever a server administrator runs /wit reload to ensure old configurations and caches are purged.
Make sure you are registering your block and entity injection functions inside the onWITReload() method of your WITPlugin addon so they persist after a reload!