🧰 Introduction
Integration of the Sanity mod with KubeJS, providing developers with extended control over the sanity system functionality. KubeJS users gain the ability to customize and modify various aspects of the madness mechanics.
🔧 Implemented Features
1. Events in KubeJS
The event system allows reacting to changes in the player's sanity level:
SanityEvents.change(event => {
// Get previous and current sanity values
let oldSanity = event.getPreviousSanity();
let newSanity = event.getSanity();
// Example: applying effects at low sanity
if (newSanity <= 20) {
event.getEntity().addPotionEffect('minecraft:nausea', 200, 1);
}
});
SanityEvents.indicatorRender(event => {
event.cancel();
})
2. Sanity Management Methods
A set of tools for direct management of sanity values:
getSanity(): Returns current sanity levelgetPreviousSanity(): Shows sanity value before changesetSanity(value): Sets specific sanity value (0-100)addSanity(value): Increases sanity by specified amountplayer.getSanity(): Direct retrieval of player's sanity
3. Utility Functions
Mathematical utilities for working with sanity values:
clampNorm(value): Normalizes number to range 0-1unclampNorm(normalizedValue): Converts normalized value back to readable numberapproximation(value, n): Rounds number to n decimal places for precise calculations
🔍 Improvement Plans
Expanding the event system for complete control over Sanity's tickPlayer function. Adding additional rendering events for finer tuning of visual effects. Including new sources of sanity changes such as environmental effects or interactions with specific mobs.
🔄 Future Developments
Implementation of passive sanity recovery sources with hot reload capability. Configuration of visible rules based on the player's current sanity level. These enhancements will make the Sanity integration with KubeJS even more flexible and interactive for developers and players.