This is a Minecraft Fabric mod that adds callbacks using the Fabric event system for the mixins I frequently use.
This mod does not do much by itself, other than log example messages for each callback. It is designed as a dependency for my other mods.
The mixins in this mod are accurate as of release 1.20.1. Feel free to submit pull requests to keep them up-to-date if they break. See the Gradle properties file for the versions this mod was last built against.
I found it frustrating constantly searching through mapped Minecraft source code for the right function to hook into every time I need to write a mixin. They are not documented enough in my opinion, so this project serves as a place for me to house all the mixins I come across while developing my mods.
This project was originally a demonstration of how to use common mixins in Java around June 2022. See tag 0.1.0.
It was later rewritten using Kotlin for Fabric around May 2023. See 0.2.0.
Finally, it was converted into an API that other mods can depend on. See main.
Documentation for each callback is written within the source code as comments.
- Server
PlayerCanJoinCallback
- When a player attempts to join the server.PlayerJoinCallback
- When a player has joined the server.PlayerLeaveCallback
- When a player has left the server.PlayerDeathCallback
- When a player has died.PlayerChatMessageCallback
- When a player has sent a chat message.PlayerEnterPortalCallback
- When a player is about to change dimension.PlayerGainExperienceCallback
- When a player has gained experience.PlayerCompleteAdvancementCallback
- When a player has completed an advancement (including challenges & goals).
Firstly, add this repository's Gradle package registry to your Gradle configuration.
Gradle Groovy:
repositories {
maven {
url = uri( "https://maven.pkg.github.com/viral32111/events" )
credentials {
username = project.findProperty( "gpr.user" ) ?: System.getenv( "USERNAME" )
password = project.findProperty( "gpr.key" ) ?: System.getenv( "TOKEN" )
}
}
}
Kotlin DSL:
repositories {
maven {
url = uri( "https://maven.pkg.github.com/viral32111/events" )
credentials {
username = project.findProperty( "gpr.user" ) as String? ?: System.getenv( "USERNAME" )
password = project.findProperty( "gpr.key" ) as String? ?: System.getenv( "TOKEN" )
}
}
}
Next, add this mod as a dependency in your Gradle configuration.
Gradle Groovy:
dependencies {
implementation "com.viral32111.events:0.3.5"
}
Kotlin DSL:
dependencies {
implementation( "com.viral32111.events", "events", "0.3.5" )
}
Finally, import this mod's package in your source code.
Java:
import com.viral32111.events.callback.*;
import com.viral32111.events.callback.server.*;
import com.viral32111.events.callback.client.*;
Kotlin:
import com.viral32111.events.callback.*
import com.viral32111.events.callback.server.*
import com.viral32111.events.callback.client.*
Copyright (C) 2022-2023 viral32111.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses.