This library mod aims to unify networking and packet registration between mod loaders so that Developers using Jared's MultiLoader Template only need to deal with networking in the common module. But, it is not limited to only usage with MultiLoader. This can be used in other projects as well.
This also allows your mod to be loader agnostic. The way packets are built and constructed, Forge version of the mod on the client, can talk to the Fabric version on the server. Though you will need to create your own handshake packet.
repositories {
maven {
url = "https://jm.gserv.me/repository/maven-public/"
}
}
Fabric:
dependencies {
modImplementation 'mysticdrew:common-networking-fabric:1.0.16-1.21'
}
Forge:
dependencies {
implementation 'mysticdrew:common-networking-forge:1.0.16-1.21'
}
NeoForge:
dependencies {
implementation 'mysticdrew:common-networking-neoforge:1.0.16-1.21'
}
Common:
dependencies {
implementation 'mysticdrew:common-networking-common:1.0.16-1.21'
}
Using the mod is quite simple.
Register your packets anytime during startup in your Common Mod Class and/or your Common Client Mod Class.
See Packet Registration Class the example uses a class with an init method. This is not required.
Creating packets are very similar to how you would do it in Forge or Fabric already, see ExamplePacketOne.
Sending a packet can either use the Dispatcher for static calls or by getting the NetworkHandler from the Network Class.
Pull Requests are welcome and encouraged.
- IntelliJ IDEA
- OpenJDK 1.17
Common Networking uses the MultiLoader Template for combining sources of Fabric and Forge.
- If your default JVM/JDK is not Java 17 you will encounter an error when opening the project. This error is fixed by going to
File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JVM
and changing the value to a valid Java 17 JVM. You will also need to set the Project SDK to Java 17. This can be done by going toFile > Project Structure > Project SDK
. Once both have been set open the Gradle tab in IDEA and click the refresh button to reload the project. - Open the Gradle tab in IDEA if it has not already been opened. Navigate to
Your Project > Common > Tasks > vanilla gradle > decompile
. Run this task to decompile Minecraft. - Open the Gradle tab in IDEA if it has not already been opened. Navigate to
Your Project > Forge > Tasks > forgegradle runs > genIntellijRuns
. Run this task to set up run configurations for Forge. - Open your Run/Debug Configurations. Under the Application category there should now be options to run Forge and Fabric projects. Select one of the client options and try to run it.
- Assuming you were able to run the game in step 7 your workspace should now be set up.