Fabric API

Fabric API

108M Downloads

[1.21.1] CustomIngredientPacketCodec always falls back.

MerchantPug opened this issue ยท 1 comments

commented

Fabric Loader: 0.16.9
Fabric API: 0.108.0+1.21.1

Hello, I've found a bit of an edge case with the class I mentioned in the title.

Whenever a custom ingredient is attempted to be synced, it will always fall back.

I think that this might be because of the current supported ingredients set being cleared unconditionally.

@Inject(
at = {
// Normal target after writing
@At(
value = "INVOKE",
target = "Lnet/minecraft/network/codec/PacketCodec;encode(Ljava/lang/Object;Ljava/lang/Object;)V",
shift = At.Shift.AFTER,
by = 1
),
// In the catch handler in case some exception was thrown
@At(
value = "INVOKE",
target = "net/minecraft/network/packet/Packet.isWritingErrorSkippable()Z"
)
},
method = "encode(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/packet/Packet;Lio/netty/buffer/ByteBuf;)V"
)
private void releasePacketEncoder(ChannelHandlerContext channelHandlerContext, Packet<?> packet, ByteBuf byteBuf, CallbackInfo ci) {
CustomIngredientSync.CURRENT_SUPPORTED_INGREDIENTS.set(null);
}

commented

If anybody is curious on how I found this. I was implementing an EMI plugin that required the custom ingredient data to be sent to the client, so that the remainder stack may be updated.