Skip to content

Corruption

Gugas749 edited this page Nov 5, 2026 · 1 revision

Corruption

A shared 0–100 value per player, built on AbyssSyncedAttachment. AbyssCore stores it, keeps it on death, syncs it, and draws a purple HUD bar left of the hotbar while it's above 0. Your mod decides what raises it and what it does. For example, AbyssItems' Void Essence raises it slowly and gives Strength/Dodge based on it, and AbyssOrigins skills inflict it.

import com.gugas749.abysscore.api.corruption.AbyssCorruption;
import com.gugas749.abysscore.api.corruption.CorruptionData;

Read (both sides)

int level = AbyssCorruption.get(player);               // 0–100
CorruptionData data = AbyssCorruption.data(player);    // level + progress
boolean maxed = level >= AbyssCorruption.MAX;          // MAX = 100

On the client this returns the local player's last synced value, so you can use it for HUDs and client effects.

Write (server)

AbyssCorruption.add(target, 5);        // +5 (clamped to 0–100)
AbyssCorruption.add(target, -10);      // negative lowers it
AbyssCorruption.set(target, 50);       // set the level (keeps progress)
AbyssCorruption.reset(target);         // level AND progress back to 0

Slow, passive gain — addProgress

Call it once per tick. After ticksPerLevel calls the level goes up by 1. It does nothing at 100, and it only sends a packet when something visible changes (not 20 packets per second).

// Holding a cursed item: +1 corruption per in-game day (24,000 ticks)
if (player.getMainHandItem().is(MyItems.CURSED_BLADE.get())) {
    AbyssCorruption.addProgress(player, 24_000);
}

CorruptionData

public record CorruptionData(int level, int progress)   // level clamped 0–100, progress ≥ 0
CorruptionData.NONE   // (0, 0)
CorruptionData.CODEC  // saved as {"corruption": level, "tick_counter": progress}

AbyssCorruption.ATTACHMENT is the underlying AbyssSyncedAttachment<CorruptionData> (abysscore:corruption), if you ever need it directly.

Examples

A skill that inflicts corruption on hit:

public static void voidStrike(ServerPlayer caster, LivingEntity target) {
    AbyssDamage.deal(target, AbyssDamageSources.corruption(caster.level(), caster), 6f);   // caster gets kill credit
    if (target instanceof ServerPlayer victim) {
        AbyssCorruption.add(victim, 5);
    }
}

Effects that scale with corruption (server, every second):

if (player.tickCount % 20 == 0) {
    int c = AbyssCorruption.get(player);
    if (c >= 25) player.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, 40, c / 25 - 1, false, false));
    if (c >= 90) player.hurt(AbyssDamageSources.corruption(player.level()), 1f);   // "was corrupted to death"
}

A purification item:

@Override
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
    if (player instanceof ServerPlayer sp && AbyssCorruption.get(sp) > 0) {
        AbyssCorruption.add(sp, -25);
        player.getItemInHand(hand).shrink(1);
        return InteractionResultHolder.consume(player.getItemInHand(hand));
    }
    return InteractionResultHolder.pass(player.getItemInHand(hand));
}

Client-side visual (e.g. a shader or particles at high corruption):

var p = Minecraft.getInstance().player;
if (p != null && AbyssCorruption.get(p) >= 75) {
    // spawn ambient particles around the player
}

Players can hide the HUD bar with the client command /corruptionhud. Admins manage it with /abysscore corruption check|set|add|reset <player> [value].

Clone this wiki locally