Skip to content

Identity API

Draylar edited this page Oct 10, 2021 · 2 revisions

Identity provides several events for other mods to hook into.

IdentitySwapCallback

Called when a player attempts to switch Identities. If any listener returns ActionResult.FAIL, the switch is canceled.

IdentitySwapCallback.EVENT.register((player, to) -> {
    // 'to' will be null when the user is attempting to switch back into a player.
    // Return FAIL to deny the switch.
    if(to == null) {
        return ActionResult.FAIL;
    }
            
    // Return SUCCESS to force the swap.
    if(to instanceof CowEntity) {
        return ActionResult.SUCCESS;
    }
            
    // Default to PASS to allow the next listener to run.
    return ActionResult.PASS;
});
Clone this wiki locally