Skip to content
BlueZeeKing edited this page Jul 8, 2022 · 3 revisions

Factions mod contains it's own API that you can hook into to develop your own mods. To register a callback, simply call the method register on the event with your callback method. The namespace in which all events are contained is io.icker.factions.api.events, which contains each type of event (indicated by the large headers), each of them containing the actual events.

int ExampleEvent(String exampleParameter)

1️⃣ The first word in the header (int) specifies the expected return type.

2️⃣ The second word ExampleEvent specifies the event name.

➕ Every parameter (String exampleParameter) is a value which will be passed to your callback

🔥 This symbol indicates the condition which causes this event to fire

↩️ This symbol indicates a possible return value, and what it does

Example

import io.icker.factions.api.events.PlayerEvents;

import net.minecraft.entity.Entity;
import net.minecraft.util.ActionResult;

public class Example {
    public static void register() {
        PlayerEvents.IS_INVULNERABLE.register(Example::isInvulnerable); // Register the event listener
    }

    private static ActionResult isInvulnerable(Entity source, Entity target) {
        if (target.getName().asString() != "Notch") {
            return ActionResult.FAIL; // If the targets name wasn't Notch, always take damage
        }

        return ActionResult.PASS; // Name was Notch, continue on executing callbacks
    }
}

Event documentation

MiscEvents

void ON_SAVE(MinecraftServer server)

    :fire: server saved, either due to an auto-save, shutting down, or /save-all

void ON_MOB_SPAWN_ATTEMPT()

    :fire: Mob spawned

    :information_source: This event is currently not implemented

FactionEvents

void CREATE(Faction faction, User owner)

    :fire: owner created faction

void DISBAND(Faction faction)

    :fire: faction disbanded

void MEMBER_JOIN(Faction faction, User user)

    :fire: user joined faction

void MEMBER_LEAVE(Faction faction, User user)

    :fire: user left faction

void MODIFY(Faction faction)

    :fire: faction modified

void POWER_CHANGE(Faction faction, int oldPower)

    :fire: faction's power was changed from oldPower

void SET_HOME(Faction faction)

    :fire: faction's home was set/changed

void REMOVE_ALL_CLAIMS(Faction faction)

    :fire: A member within faction ran /factions claim remove all, or the faction was disbanded

PlayerEvents

ActionResult USE_ENTITY(ServerPlayerEntity player, Entity entity, World world))

    :fire: player interacting with entity in world

    :leftwards_arrow_with_hook: ActionResult.FAIL cancels the interact event, and cancels further processing.

    :leftwards_arrow_with_hook: ActionResult.SUCCESS continues the interact event, and cancels further processing.

    :leftwards_arrow_with_hook: ActionResult.PASS continues further processing.

ActionResult IS_INVULNERABLE(Entity source, Entity target)

    :fire: source attacking target

    :leftwards_arrow_with_hook: ActionResult.FAIL cancels the damage event, and cancels further processing.

    :leftwards_arrow_with_hook: ActionResult.SUCCESS continues the damage event, and cancels further processing.

    :leftwards_arrow_with_hook: ActionResult.PASS continues further processing.

void ON_MOVE(ServerPlayerEntity player)

    :fire: player moved

void ON_KILLED_BY_PLAYER(ServerPlayerEntity player, DamageSource source)

    :fire: player killed by source

void ON_POWER_TICK(ServerPlayerEntity player)

    :fire: player faction power tick occured

ClaimEvents

void ADD(Claim claim)

    :fire: claim added

void REMOVE(int x, int z, String level, Faction faction)

    :fire: A claim belonging to faction and at chunk position (x, z) in level was removed

HomeEvents

void SET(Home home)

    :fire: Faction home set

RelationshipEvents

void NEW_DECLARATION(Relationship relationship)

    :fire: relationship formed

void NEW_MUTUAL(Relationship relationship)

    :fire: relationship mutually formed

void END_MUTUAL(Relationship relationship, Relationship.Status oldStatus)

    :fire: relationship mutually ended, was previously oldStatus