Fix recording in minimal mode on 1.20.6+
This commit is contained in:
@@ -15,6 +15,11 @@ import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.client.network.ClientConfigurationNetworkHandler;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.network.listener.ClientConfigurationPacketListener;
|
||||
import net.minecraft.network.packet.BrandCustomPayload;
|
||||
import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.config.ReadyS2CPacket;
|
||||
import net.minecraft.network.state.ConfigurationStates;
|
||||
import net.minecraft.registry.DynamicRegistryManager;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
@@ -45,9 +50,12 @@ public abstract class MixinNetHandlerConfigClient {
|
||||
byteBuf.readBytes(bytes);
|
||||
byteBuf.release();
|
||||
|
||||
int packetIdCustomPayload = getPacketId(new CustomPayloadS2CPacket(new BrandCustomPayload("")));
|
||||
int packetIdFinish = getPacketId(ReadyS2CPacket.INSTANCE);
|
||||
|
||||
PacketTypeRegistry registry = MCVer.getPacketTypeRegistry(State.CONFIGURATION);
|
||||
packetListener.save(new Packet(registry, PacketType.ConfigCustomPayload, com.github.steveice10.netty.buffer.Unpooled.wrappedBuffer(bytes)));
|
||||
packetListener.save(new Packet(registry, PacketType.ConfigFinish));
|
||||
packetListener.save(new Packet(registry, packetIdCustomPayload, PacketType.ConfigCustomPayload, com.github.steveice10.netty.buffer.Unpooled.wrappedBuffer(bytes)));
|
||||
packetListener.save(new Packet(registry, packetIdFinish, PacketType.ConfigFinish, com.github.steveice10.netty.buffer.Unpooled.buffer()));
|
||||
}
|
||||
|
||||
@Unique
|
||||
@@ -59,4 +67,19 @@ public abstract class MixinNetHandlerConfigClient {
|
||||
buf.writeNbt(codec.encodeStart(NbtOps.INSTANCE, entry.getValue()).getOrThrow());
|
||||
}
|
||||
}
|
||||
|
||||
@Unique
|
||||
private int getPacketId(net.minecraft.network.packet.Packet<? super ClientConfigurationPacketListener> packet) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
try {
|
||||
//#if MC>=12106
|
||||
//$$ ConfigurationStates.S2C.comp_2236().encode(byteBuf, packet);
|
||||
//#else
|
||||
ConfigurationStates.S2C.codec().encode(byteBuf, packet);
|
||||
//#endif
|
||||
return new PacketByteBuf(byteBuf).readVarInt();
|
||||
} finally {
|
||||
byteBuf.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user