-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Packet fixes - disable neoforge splitter and send minecraft:register (#…
…170) * Disable NeoForge packet splitting for Fabric packets * Send minecraft:register for Fabric packets * Remove unused import
- Loading branch information
Showing
6 changed files
with
85 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...api-v1/src/main/java/net/fabricmc/fabric/mixin/networking/GenericPacketSplitterMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package net.fabricmc.fabric.mixin.networking; | ||
|
||
import io.netty.channel.ChannelHandlerContext; | ||
import net.minecraft.network.HandlerNames; | ||
import net.minecraft.network.PacketEncoder; | ||
import net.minecraft.network.protocol.Packet; | ||
import net.minecraft.network.protocol.PacketFlow; | ||
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; | ||
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket; | ||
import net.neoforged.neoforge.network.filters.GenericPacketSplitter; | ||
import net.neoforged.neoforge.network.payload.SplitPacketPayload; | ||
import org.sinytra.fabric.networking_api.NeoNetworkRegistrar; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.util.List; | ||
|
||
@Mixin(GenericPacketSplitter.class) | ||
public class GenericPacketSplitterMixin { | ||
|
||
/* | ||
* Disable NeoForge packet splitting for Fabric packets | ||
*/ | ||
|
||
@Inject(method = "encode(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/protocol/Packet;Ljava/util/List;)V", at = @At("HEAD"), cancellable = true) | ||
public void encode(ChannelHandlerContext ctx, Packet<?> packet, List<Object> out, CallbackInfo ci) { | ||
if (packet instanceof ClientboundCustomPayloadPacket clientboundCustomPayloadPacket) { | ||
if (ctx.pipeline().get(HandlerNames.ENCODER) instanceof PacketEncoder<?> encoder) { | ||
var registry = NeoNetworkRegistrar.getPayloadRegistry(encoder.getProtocolInfo().id(), PacketFlow.CLIENTBOUND); | ||
if (registry.get(clientboundCustomPayloadPacket.payload().type()) != null) { | ||
out.add(packet); | ||
ci.cancel(); | ||
} | ||
} | ||
} else if (packet instanceof ServerboundCustomPayloadPacket serverboundCustomPayloadPacket) { | ||
if (ctx.pipeline().get(HandlerNames.ENCODER) instanceof PacketEncoder<?> encoder) { | ||
var registry = NeoNetworkRegistrar.getPayloadRegistry(encoder.getProtocolInfo().id(), PacketFlow.SERVERBOUND); | ||
if (registry.get(serverboundCustomPayloadPacket.payload().type()) != null) { | ||
out.add(packet); | ||
ci.cancel(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters