fabric/fabric-lifecycle-events-v1
modmuss50 9ff28f4026
Split client only code into its own sourceset. (#2179)
A common source of crashes on modded Minecraft servers comes from modders accidently calling client only code from the client, this PR is another large step towards elimitating that.

This PR has been months in the making and years in the planning, requiring major changes to Loom & Loader. In recent Minecraft versions Mojang has made it easier than ever to cleanly split the jar, going against the status-quo of merging the client and server into one jar.

From the start we have designed Fabric to have a very clear split between client and common (client & server) code. Fabric has always encoraged keeping client only code seprate from the server, this can be seen at a fundamental level with the entrypoints in Loader. Fabric API's have all been designed with this mind.

This PR provides a compile safety net around Fabric API using client only code on the server. Even though there are almost 400 changed files, minimal changes beyond moving the files were required to achieve this in Fabric API, thanks to the effort of all contributors in the past.

These changes should not affect modders or players in anyway, a single "universal" jar is still produced. Im happy to awnswer any questions.
2022-05-21 16:26:46 +01:00
..
src Split client only code into its own sourceset. (#2179) 2022-05-21 16:26:46 +01:00
build.gradle Port to 22w06a (#1989) 2022-02-11 17:02:44 +00:00
README.md Add readme for fabric-lifecycle-events-v1 (#1119) 2020-12-05 19:05:40 +00:00

Fabric Lifecycle Events (V1)

Contains events which indicate when the lifecycle of a Minecraft client, Minecraft server and the lifecycle objects which exist on the client and server has changed.

Organization

Events in this module belong to a single class which relates to the category of events. The event callbacks to be implemented are nested classes within.

For example, if you are listening to ServerLifecycleEvents.SERVER_STARTING in ServerLifecycleEvents the callback interface that would be implemented is ServerLifecycleEvents.ServerStarting.

Server Events

Events related to objects on a logical server. These classes are located in net.fabricmc.fabric.api.event.lifecycle.v1.

ServerLifecycleEvents

Contains lifecycle events related to a Minecraft server. This includes events which indicate when a server is starting up, is in a data pack reload or shutting down.

ServerTickEvents

Contains events related to the ticking of a Minecraft server. There are events that indicate the beginning and end of the tick for the server and each ServerWorld.

ServerWorldEvents

Events related to the lifecycle a ServerWorld. Currently, this contains events related to loading and unloading ServerWorlds.

ServerChunkEvents

Events related to the lifecycle of chunks in a ServerWorld. Currently, this contains events related to loading and unloading chunks in a ServerWorld.

ServerEntityEvents

Events related to the lifecycle of entities in a ServerWorld. Currently, this only contains an event for an entity being loaded into a ServerWorld. The unload event has not been implemented yet.

ServerBlockEntityEvents

Events related to the lifecycle of block entities in a ServerWorld. Currently, this contains events related to loading and unloading block entities in a ServerWorld.

Client Events

Events related to objects on a logical client. These classes are located in net.fabricmc.fabric.api.client.event.lifecycle.v1.

Note: These events are only available on a client. Trying to access these events on a dedicated server will cause the game to crash.

ClientLifecycleEvents

Events related to the lifecycle of a Minecraft client. Currently, this contains events related to when the Minecraft Client is starting or stopping.

ClientTickEvents

Events related to ticking of a Minecraft client. There are events that indicate the beginning and end of the tick for the client and the ClientWorld if in game.

ClientChunkEvents

Events related to the lifecycle of chunks on a Minecraft client. Currently, this contains events related to loading and unloading chunks in a ClientWorld.

ClientEntityEvents

Events related to the lifecycle of entities in a ClientWorld. Currently, this contains event for an entity being loaded into a ClientWorld.

ClientBlockEntityEvents

Events related to the lifecycle of block entities in a ClientWorld. Currently, this contains events related to loading and unloading block entities in a ClientWorld.