Back to 9Minecraft
Wiki 9Minecraft Wiki 9Minecraft
Baguettelib Wiki › Guides › Using BaguetteLib Events in Your Mod

Using BaguetteLib Events in Your Mod

Getting Started with BaguetteLib

BaguetteLib is a small library mod that other mods depend on to handle common events more easily. It does not add gameplay content on its own; instead, it gives developers tools for tracking player deaths and inventory changes.

To use it, add the library to your mod and register the event you want to listen for. Events are handled through @SubscribeEvent methods, the same pattern used by many Minecraft mod loaders.

For death handling, listen for PlayerDeathEvent.Pre to run code before a player dies. This lets you cancel the death before it happens, or perform custom actions after a mob dies. It works for all mobs, including players.

For inventory handling, BaguetteLib tracks hotbar changes, armor swaps, and item pickups. Each change gives you access to both the old and new item, with special handling for the main hand and offhand. This makes it simpler to react to what a player is holding or wearing.