Download KubeJS Sanity — Minecraft Mods — MetaMods

KubeJS Sanity

Active

Downloads

0

Last update

5 months ago
Client
Addons

🧰 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 level
  • getPreviousSanity(): Shows sanity value before change
  • setSanity(value): Sets specific sanity value (0-100)
  • addSanity(value): Increases sanity by specified amount
  • player.getSanity(): Direct retrieval of player's sanity

3. Utility Functions

Mathematical utilities for working with sanity values:

  • clampNorm(value): Normalizes number to range 0-1
  • unclampNorm(normalizedValue): Converts normalized value back to readable number
  • approximation(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.

Project members
PickAID

PickAID

Created: 6 May 2025

ID: 92699