Skip to content

Erasing and wards ​

Both are server side. EraseApi is for strikes that must finish their target. WardApi lets your mod protect something from other mods' strikes.

Erasing ​

Make a policy with your own damage types, then keep it. erase is the type for the final blow, and hit is for normal damage.

PolicyResult
EraseApi.unmake(erase, hit)The target stops existing
EraseApi.kill(erase, hit)The target dies the normal way
java
ErasePolicy policy = EraseApi.kill(MyDamage.ERASE, MyDamage.HIT);

// Damage that the policy can turn into an erase
EraseApi.hit(policy, level, victim, attacker, 40.0F);

// Erase straight away
EraseApi.strike(policy, level, victim, attacker);

// Stop following up on an entity
EraseApi.letGo(victim);

ErasePolicy also has forceKill(value, hardest) and intercept(rule). An intercept can take over a blow for an entity your mod handles itself.

Wards ​

A ward senses threats near it and can answer with a shape. Cuts leave the columns under a held shape standing, and erasing passes over what lies under it.

java
Ward ward = WardApi.raise(level, ownerUuid, centre, 128.0, (w, threat) -> {
    // Return a shape to hold, or null to ignore the threat
    return WardApi.dome(32.0);
});

Each owner has one ward, so raising a new one lowers the old one. Your own mod's threats never reach your own wards.

ShapeCovers
dome(radius)A canopy, sheltering everything below it
wall(nx, nz, offset, halfWidth, height, depth)A shield facing one direction
bowl(radius, lift)A raised ball and the ground under it
everywhere()The whole level. No cut can touch the land

Ward has methods to move it (sense), hold a shape directly (hold), and take it down (release, lower).

Warn before you strike ​

Warn wards before a strike lands, so they can answer in time. true means a ward held up a shape.

java
boolean blocked = WardApi.warn(level, "mymod", Threat.Kind.BLAST, at, 20.0, 0xFFFF4040, 40, 20);

The last two values are the ticks until it lands and how long it lasts. Cuts made with CarveApi warn wards automatically.