Skip to content

Commit

Permalink
fix forge 50.0.9+ networking
Browse files Browse the repository at this point in the history
  • Loading branch information
fayer3 committed May 12, 2024
1 parent 3edcb74 commit eed9892
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
17 changes: 9 additions & 8 deletions forge/src/main/java/org/vivecraft/forge/Vivecraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ 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

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


Expand Down

0 comments on commit eed9892

Please sign in to comment.