For developers
Adding VeroxLib to a project, reading and changing sanity, and writing your own effects and modifiers.
Installation
CurseMaven Setup
Add the CurseMaven repository to your build.gradle.
repositories {
maven {
url "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
}
}Add the dependency:
dependencies {
modApi "curse.maven:PROJECT_ID:FILE_ID"
}Quick Start
Reading Player Sanity
float sanity = SanityAPI.getSanity(player);Modifying Sanity
SanityAPI.modifySanity(player, -5.0f);Checking Cultist State
if (SanityAPI.isCultist(player)) {
}Developer Guide
Creating Custom Sanity Effects
Implement ISanityEffect.
Example: Door Creak hallucination.
public class DoorCreakEffect implements ISanityEffect {
@Override
public float getThreshold() {
return 40.0f;
}
@Override
public void apply(Player player, float currentSanity) {
if (player.getRandom().nextFloat() < 0.05f) {
Vec3 pos = player.position().add(
(player.getRandom().nextDouble() - 0.5) * 10,
0,
(player.getRandom().nextDouble() - 0.5) * 10
);
player.level().playLocalSound(
pos.x,
pos.y,
pos.z,
SoundEvents.WOODEN_DOOR_OPEN,
SoundSource.AMBIENT,
0.4f,
0.5f + player.getRandom().nextFloat() * 0.3f,
false
);
}
}
@Override
public boolean isClientSide() {
return true;
}
}Adding Sanity Modifiers to Items
Items can influence sanity loss by implementing ISanityModifier.
public class SanityCharmItem extends Item implements ISanityModifier {
@Override
public float getSanityResistance(ItemStack stack) {
return 0.5f;
}
}