diff --git a/forge/src/main/java/org/vivecraft/forge/Vivecraft.java b/forge/src/main/java/org/vivecraft/forge/Vivecraft.java index c2546b32b..8f8a13d85 100644 --- a/forge/src/main/java/org/vivecraft/forge/Vivecraft.java +++ b/forge/src/main/java/org/vivecraft/forge/Vivecraft.java @@ -5,7 +5,6 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.network.ChannelBuilder; import net.minecraftforge.network.EventNetworkChannel; -import net.minecraftforge.network.NetworkDirection; import org.vivecraft.client.network.ClientNetworking; import org.vivecraft.common.network.CommonNetworkHelper; import org.vivecraft.server.ServerNetworking; @@ -15,17 +14,19 @@ public class Vivecraft { public static final String MODID = "vivecraft"; - public Vivecraft() { - // init server config - ServerConfig.init(null); - - EventNetworkChannel channel = ChannelBuilder.named(CommonNetworkHelper.CHANNEL) + public static final EventNetworkChannel VIVECRAFT_NETWORK_CHANNEL = + ChannelBuilder.named(CommonNetworkHelper.CHANNEL) .acceptedVersions((status, version) -> true) .optional() .networkProtocolVersion(0) .eventNetworkChannel(); - channel.addListener(event -> { - if (event.getSource().getDirection() == NetworkDirection.PLAY_TO_SERVER) { + + public Vivecraft() { + // init server config + ServerConfig.init(null); + + VIVECRAFT_NETWORK_CHANNEL.addListener(event -> { + if (event.getSource().isServerSide()) { handleServerVivePacket(event.getPayload(), event.getSource()); } else { handleClientVivePacket(event.getPayload(), event.getSource()); diff --git a/forge/src/main/java/org/vivecraft/forge/mixin/ForgeConnectionMixin.java b/forge/src/main/java/org/vivecraft/forge/mixin/ForgeConnectionMixin.java index 52a3753cb..e6b653544 100644 --- a/forge/src/main/java/org/vivecraft/forge/mixin/ForgeConnectionMixin.java +++ b/forge/src/main/java/org/vivecraft/forge/mixin/ForgeConnectionMixin.java @@ -11,6 +11,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.vivecraft.common.network.packets.VivecraftDataPacket; +import org.vivecraft.forge.Vivecraft; @Mixin(Connection.class) public class ForgeConnectionMixin { @@ -21,11 +22,11 @@ public class ForgeConnectionMixin { if (packet instanceof ClientboundCustomPayloadPacket clientPacket && clientPacket.payload() instanceof VivecraftDataPacket vivecraftDataPacket) { FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer()); vivecraftDataPacket.write(buffer); - packet = NetworkDirection.PLAY_TO_CLIENT.buildPacket(buffer, vivecraftDataPacket.type().id()).getThis(); + packet = NetworkDirection.PLAY_TO_CLIENT.buildPacket(Vivecraft.VIVECRAFT_NETWORK_CHANNEL, buffer).getThis(); } else if (packet instanceof ServerboundCustomPayloadPacket serverPacket && serverPacket.payload() instanceof VivecraftDataPacket vivecraftDataPacket) { FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer()); vivecraftDataPacket.write(buffer); - packet = NetworkDirection.PLAY_TO_SERVER.buildPacket(buffer, vivecraftDataPacket.type().id()).getThis(); + packet = NetworkDirection.PLAY_TO_SERVER.buildPacket(Vivecraft.VIVECRAFT_NETWORK_CHANNEL, buffer).getThis(); } return packet; } diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 04ee548d3..52ad5d445 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -23,7 +23,7 @@ updateJSONURL = "https://raw.githubusercontent.com/Vivecraft/VivecraftMod/forge- [[dependencies.vivecraft]] modId = "forge" mandatory = true -versionRange = "[50.0.7,)" +versionRange = "[50.0.9,)" ordering = "NONE" side = "BOTH" diff --git a/gradle.properties b/gradle.properties index f46a3e7d6..72894e1b7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ minecraft_version=1.20.6 enabled_platforms=fabric,forge,neoforge archives_base_name=vivecraft -mod_version=1.1.9-b1 +mod_version=1.1.9-b2 maven_group=org.vivecraft architectury_version=12.0.26 @@ -12,7 +12,7 @@ architectury_version=12.0.26 fabric_loader_version=0.15.7 fabric_api_version=0.97.8+1.20.6 -forge_version=1.20.6-50.0.5 +forge_version=1.20.6-50.0.18 neoforge_version=20.6.1-beta