MOAR CLOSER
This commit is contained in:
parent
dece4d851a
commit
0274aa525e
6 changed files with 71 additions and 15 deletions
|
@ -0,0 +1,8 @@
|
||||||
|
import at.petrak.hexcasting.fabric.network.FabricPacketHandler
|
||||||
|
import net.fabricmc.api.ClientModInitializer
|
||||||
|
|
||||||
|
object FabricHexClientInitializer : ClientModInitializer {
|
||||||
|
override fun onInitializeClient() {
|
||||||
|
FabricPacketHandler.initClient()
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +1,12 @@
|
||||||
import at.petrak.hexcasting.fabric.FabricHexConfig
|
import at.petrak.hexcasting.fabric.FabricHexConfig
|
||||||
|
import at.petrak.hexcasting.fabric.network.FabricPacketHandler
|
||||||
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||||
import net.fabricmc.api.ModInitializer
|
import net.fabricmc.api.ModInitializer
|
||||||
|
|
||||||
object HexMod : ModInitializer {
|
object FabricHexInitializer : ModInitializer {
|
||||||
override fun onInitialize() {
|
override fun onInitialize() {
|
||||||
IXplatAbstractions.INSTANCE.init()
|
IXplatAbstractions.INSTANCE.init()
|
||||||
|
FabricPacketHandler.init()
|
||||||
FabricHexConfig.setup()
|
FabricHexConfig.setup()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,52 @@
|
||||||
package at.petrak.hexcasting.fabric.network;
|
package at.petrak.hexcasting.fabric.network;
|
||||||
|
|
||||||
|
import at.petrak.hexcasting.common.network.*;
|
||||||
|
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||||
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import org.apache.logging.log4j.util.TriConsumer;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class FabricPacketHandler {
|
public class FabricPacketHandler {
|
||||||
|
public static void init() {
|
||||||
|
ServerPlayNetworking.registerGlobalReceiver(MsgNewSpellPatternSyn.ID,
|
||||||
|
makeServerBoundHandler(MsgNewSpellPatternSyn::deserialize, MsgNewSpellPatternSyn::handle));
|
||||||
|
ServerPlayNetworking.registerGlobalReceiver(
|
||||||
|
MsgShiftScrollSyn.ID, makeServerBoundHandler(MsgShiftScrollSyn::deserialize, MsgShiftScrollSyn::handle));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> ServerPlayNetworking.PlayChannelHandler makeServerBoundHandler(
|
||||||
|
Function<FriendlyByteBuf, T> decoder, TriConsumer<T, MinecraftServer, ServerPlayer> handle) {
|
||||||
|
return (server, player, _handler, buf, _responseSender) -> handle.accept(decoder.apply(buf), server, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void initClient() {
|
||||||
|
ClientPlayNetworking.registerGlobalReceiver(MsgNewSpellPatternAck.ID,
|
||||||
|
makeClientBoundHandler(MsgNewSpellPatternAck::deserialize, MsgNewSpellPatternAck::handle));
|
||||||
|
ClientPlayNetworking.registerGlobalReceiver(
|
||||||
|
MsgBlinkAck.ID, makeClientBoundHandler(MsgBlinkAck::deserialize, MsgBlinkAck::handle));
|
||||||
|
ClientPlayNetworking.registerGlobalReceiver(MsgSentinelStatusUpdateAck.ID,
|
||||||
|
makeClientBoundHandler(MsgSentinelStatusUpdateAck::deserialize, MsgSentinelStatusUpdateAck::handle));
|
||||||
|
ClientPlayNetworking.registerGlobalReceiver(MsgColorizerUpdateAck.ID,
|
||||||
|
makeClientBoundHandler(MsgColorizerUpdateAck::deserialize, MsgColorizerUpdateAck::handle));
|
||||||
|
ClientPlayNetworking.registerGlobalReceiver(MsgCastParticleAck.ID,
|
||||||
|
makeClientBoundHandler(MsgCastParticleAck::deserialize, MsgCastParticleAck::handle));
|
||||||
|
ClientPlayNetworking.registerGlobalReceiver(MsgOpenSpellGuiAck.ID,
|
||||||
|
makeClientBoundHandler(MsgOpenSpellGuiAck::deserialize, MsgOpenSpellGuiAck::handle));
|
||||||
|
ClientPlayNetworking.registerGlobalReceiver(MsgBeepAck.ID,
|
||||||
|
makeClientBoundHandler(MsgBeepAck::deserialize, MsgBeepAck::handle));
|
||||||
|
ClientPlayNetworking.registerGlobalReceiver(MsgBrainsweepAck.ID,
|
||||||
|
makeClientBoundHandler(MsgBrainsweepAck::deserialize, MsgBrainsweepAck::handle));
|
||||||
|
ClientPlayNetworking.registerGlobalReceiver(MsgUpdateComparatorVisualsAck.ID,
|
||||||
|
makeClientBoundHandler(MsgUpdateComparatorVisualsAck::deserialize, MsgUpdateComparatorVisualsAck::handle));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> ClientPlayNetworking.PlayChannelHandler makeClientBoundHandler(
|
||||||
|
Function<FriendlyByteBuf, T> decoder, Consumer<T> handler) {
|
||||||
|
return (_client, _handler, buf, _responseSender) -> handler.accept(decoder.apply(buf));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,15 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"icon": "assets/logo.png",
|
"icon": "logo.png",
|
||||||
|
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": [
|
"main": [
|
||||||
{"adapter": "kotlin", "value": "at.petrak.hexcasting.HexMod"}
|
{"adapter": "kotlin", "value": "at.petrak.hexcasting.FabricHexInitializer"}
|
||||||
|
],
|
||||||
|
"client": [
|
||||||
|
{"adapter": "kotlin", "value": "at.petrak.hexcasting.FabricHexInitializer"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
@ -28,8 +31,8 @@
|
||||||
|
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.13",
|
"fabricloader": ">=0.13",
|
||||||
"fabric": "*",
|
"fabric": ">=0.50",
|
||||||
"minecraft": "1.18.x",
|
"minecraft": ">=1.18.2",
|
||||||
"java": ">=17",
|
"java": ">=17",
|
||||||
"fabric-language-kotlin": ">=1.7.4+kotlin.1.6.21",
|
"fabric-language-kotlin": ">=1.7.4+kotlin.1.6.21",
|
||||||
"patchouli": ">=1.18.2-66",
|
"patchouli": ">=1.18.2-66",
|
||||||
|
|
|
@ -17,12 +17,8 @@ import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent
|
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent
|
||||||
import org.apache.logging.log4j.Logger
|
import org.apache.logging.log4j.Logger
|
||||||
|
|
||||||
@Mod(HexMod.MOD_ID)
|
@Mod(HexAPI.MOD_ID)
|
||||||
object HexMod {
|
object ForgeHexInitializer {
|
||||||
|
|
||||||
// mumblemumble thanks shy mumble mumble
|
|
||||||
const val MOD_ID = "hexcasting"
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
IXplatAbstractions.INSTANCE.init()
|
IXplatAbstractions.INSTANCE.init()
|
||||||
|
|
||||||
|
@ -42,7 +38,7 @@ object HexMod {
|
||||||
|
|
||||||
ForgeListenersSetup.init()
|
ForgeListenersSetup.init()
|
||||||
ForgePacketHandler.init()
|
ForgePacketHandler.init()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
// mod lifecycle
|
// mod lifecycle
|
|
@ -1,6 +1,6 @@
|
||||||
package at.petrak.hexcasting.forge.network;
|
package at.petrak.hexcasting.forge.network;
|
||||||
|
|
||||||
import at.petrak.hexcasting.HexMod;
|
import at.petrak.hexcasting.ForgeHexInitializer;
|
||||||
import at.petrak.hexcasting.common.network.*;
|
import at.petrak.hexcasting.common.network.*;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
@ -17,7 +17,7 @@ import java.util.function.Supplier;
|
||||||
public class ForgePacketHandler {
|
public class ForgePacketHandler {
|
||||||
private static final String PROTOCOL_VERSION = "1";
|
private static final String PROTOCOL_VERSION = "1";
|
||||||
private static final SimpleChannel NETWORK = NetworkRegistry.newSimpleChannel(
|
private static final SimpleChannel NETWORK = NetworkRegistry.newSimpleChannel(
|
||||||
new ResourceLocation(HexMod.MOD_ID, "main"),
|
new ResourceLocation(ForgeHexInitializer.MOD_ID, "main"),
|
||||||
() -> PROTOCOL_VERSION,
|
() -> PROTOCOL_VERSION,
|
||||||
PROTOCOL_VERSION::equals,
|
PROTOCOL_VERSION::equals,
|
||||||
PROTOCOL_VERSION::equals
|
PROTOCOL_VERSION::equals
|
||||||
|
|
Loading…
Reference in a new issue