Skip to content

1.21.5 #892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d01a5b8
25w02a
basaigh Feb 12, 2025
fc05f74
25w03a
basaigh Mar 2, 2025
09dbaea
25w04a (hopefully)
basaigh Mar 18, 2025
b9561d7
25w05a
basaigh Mar 20, 2025
75a74b5
25w06a
basaigh Mar 22, 2025
f5d2a77
Add some missing changes from 25w03/4a
basaigh Mar 23, 2025
902f278
25w07a
basaigh Mar 23, 2025
c46eee9
25w08a
basaigh Mar 23, 2025
d26ed90
Fix test
basaigh Mar 23, 2025
737e251
1.21.5-pre1
basaigh Mar 23, 2025
c94a8b8
1.21.5-rc1
basaigh Mar 23, 2025
9c39bee
Fix tests again
basaigh Mar 23, 2025
6e60afe
Ensure components and metadata is correct
basaigh Mar 24, 2025
2249d72
Update to reflect the use of fixed length long arrays in data palettes.
basaigh Mar 24, 2025
5f39532
Fix data palette reading/writing (#891)
eclipseisoffline Mar 25, 2025
788fbdf
Target 1.21.5 release protocol
basaigh Mar 27, 2025
b2d8a92
Correctly read exact component matchers in villager trades
basaigh Mar 28, 2025
df60c28
Fix ChickenVariant type and correctly encode untrusted data components
basaigh Mar 28, 2025
2f8df1f
Allow for unexpected `CommandType` values as vanilla does
basaigh Mar 28, 2025
47c3ded
Add missing argument type
basaigh Mar 28, 2025
290d84c
Fix unit reader/writer for the INTANGIBLE_PROJECTILE component
onebeastchris Apr 5, 2025
ac5af38
Fix `Can't join: ByteToMessageCodec$1.decode() did not read anything …
basaigh Apr 10, 2025
1e8f791
Fix EquipmentSlot reader in the Equippable item component
onebeastchris Apr 28, 2025
36a4c73
Data components map improvements (#894)
eclipseisoffline May 5, 2025
af3d4ae
Add BuiltinFlags.ALLOCATOR
onebeastchris May 8, 2025
30e2bad
Properly put null values in data component map (#895)
eclipseisoffline May 9, 2025
c69cefd
Support netty 4.2.1, add system property for opt-in io_uring (#897)
onebeastchris May 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private static void login() {
@Override
public void packetReceived(Session session, Packet packet) {
if (packet instanceof ClientboundLoginPacket) {
session.send(new ServerboundChatPacket("Hello, this is a test of MCProtocolLib.", Instant.now().toEpochMilli(), 0L, null, 0, new BitSet()));
session.send(new ServerboundChatPacket("Hello, this is a test of MCProtocolLib.", Instant.now().toEpochMilli(), 0L, null, 0, new BitSet(), 0));
} else if (packet instanceof ClientboundSystemChatPacket systemChatPacket) {
Component message = systemChatPacket.getContent();
log.info("Received Message: {}", message);
Expand Down
5 changes: 1 addition & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ cloudburstnbt = "3.0.0.Final"
slf4j = "2.0.9"
math = "2.0"
fastutil-maps = "8.5.3"
netty = "4.1.103.Final"
netty-io_uring = "0.0.24.Final"
netty = "4.2.1.Final"
gson = "2.11.0"
minecraftauth = "4.1.1"
checkerframework = "3.42.0"
Expand Down Expand Up @@ -37,7 +36,6 @@ fastutil-int2object-maps = { module = "com.nukkitx.fastutil:fastutil-int-object-
fastutil-int2int-maps = { module = "com.nukkitx.fastutil:fastutil-int-int-maps", version.ref = "fastutil-maps" }

netty-all = { module = "io.netty:netty-all", version.ref = "netty" }
netty-incubator-transport-native-io_uring = { module = "io.netty.incubator:netty-incubator-transport-native-io_uring", version.ref = "netty-io_uring" }

gson = { module = "com.google.code.gson:gson", version.ref = "gson" }

Expand All @@ -57,4 +55,3 @@ lombok = { module = "io.freefair.gradle:lombok-plugin", version.ref = "lombok-pl
adventure = ["adventure-text-serializer-gson", "adventure-text-serializer-json-legacy-impl"]
math = ["math-api", "math-immutable"]
fastutil = ["fastutil-object2int-maps", "fastutil-int2object-maps", "fastutil-int2int-maps"]
netty = ["netty-all", "netty-incubator-transport-native-io_uring"]
4 changes: 2 additions & 2 deletions protocol/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
jacoco
}

version = "1.21.4-SNAPSHOT"
version = "1.21.5-SNAPSHOT"
description = "MCProtocolLib is a simple library for communicating with Minecraft clients and servers."

dependencies {
Expand All @@ -29,7 +29,7 @@ dependencies {
api(libs.bundles.fastutil)

// Netty
api(libs.bundles.netty)
api(libs.netty.all)

// Checker Framework
api(libs.checkerframework.qual)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.geysermc.mcprotocollib.network;

import io.netty.buffer.ByteBufAllocator;

import java.net.InetSocketAddress;

/**
Expand Down Expand Up @@ -46,6 +48,12 @@ public class BuiltinFlags {
*/
public static final Flag<Integer> WRITE_TIMEOUT = new Flag<>("write-timeout", Integer.class);

/**
* The netty allocator to use.
* Used by both server and client
*/
public static final Flag<ByteBufAllocator> ALLOCATOR = new Flag<>("allocator", ByteBufAllocator.class);

private BuiltinFlags() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,39 @@

import io.netty.channel.ChannelFactory;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.MultiThreadIoEventLoopGroup;
import io.netty.channel.epoll.Epoll;
import io.netty.channel.epoll.EpollDatagramChannel;
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.epoll.EpollIoHandler;
import io.netty.channel.epoll.EpollServerSocketChannel;
import io.netty.channel.epoll.EpollSocketChannel;
import io.netty.channel.kqueue.KQueue;
import io.netty.channel.kqueue.KQueueDatagramChannel;
import io.netty.channel.kqueue.KQueueEventLoopGroup;
import io.netty.channel.kqueue.KQueueIoHandler;
import io.netty.channel.kqueue.KQueueServerSocketChannel;
import io.netty.channel.kqueue.KQueueSocketChannel;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.nio.NioIoHandler;
import io.netty.channel.socket.DatagramChannel;
import io.netty.channel.socket.ServerSocketChannel;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioDatagramChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.incubator.channel.uring.IOUring;
import io.netty.incubator.channel.uring.IOUringDatagramChannel;
import io.netty.incubator.channel.uring.IOUringEventLoopGroup;
import io.netty.incubator.channel.uring.IOUringServerSocketChannel;
import io.netty.incubator.channel.uring.IOUringSocketChannel;
import io.netty.channel.uring.IoUring;
import io.netty.channel.uring.IoUringDatagramChannel;
import io.netty.channel.uring.IoUringIoHandler;
import io.netty.channel.uring.IoUringServerSocketChannel;
import io.netty.channel.uring.IoUringSocketChannel;

import java.util.concurrent.ThreadFactory;
import java.util.function.Function;
import java.util.function.BiFunction;

public class TransportHelper {
public static final TransportHelper.TransportType TRANSPORT_TYPE = TransportHelper.determineTransportMethod();
public static final boolean NEW_NETTY = isClassAvailable("io.netty.channel.MultiThreadIoEventLoopGroup");

public enum TransportMethod {
NIO, EPOLL, KQUEUE, IO_URING
Expand All @@ -42,24 +47,28 @@ public record TransportType(TransportMethod method,
ChannelFactory<? extends SocketChannel> socketChannelFactory,
Class<? extends DatagramChannel> datagramChannelClass,
ChannelFactory<? extends DatagramChannel> datagramChannelFactory,
Function<ThreadFactory, EventLoopGroup> eventLoopGroupFactory,
BiFunction<Integer, ThreadFactory, EventLoopGroup> eventLoopGroupFactory,
boolean supportsTcpFastOpenServer,
boolean supportsTcpFastOpenClient) {
}

@SuppressWarnings("deprecation")
private static TransportType determineTransportMethod() {
if (isClassAvailable("io.netty.incubator.channel.uring.IOUring") && IOUring.isAvailable()) {
if (isClassAvailable("io.netty.channel.uring.IoUring")
&& IoUring.isAvailable()
&& Boolean.getBoolean("Mcpl.io_uring")
) {
return new TransportType(
TransportMethod.IO_URING,
IOUringServerSocketChannel.class,
IOUringServerSocketChannel::new,
IOUringSocketChannel.class,
IOUringSocketChannel::new,
IOUringDatagramChannel.class,
IOUringDatagramChannel::new,
factory -> new IOUringEventLoopGroup(0, factory),
IOUring.isTcpFastOpenServerSideAvailable(),
IOUring.isTcpFastOpenClientSideAvailable()
IoUringServerSocketChannel.class,
IoUringServerSocketChannel::new,
IoUringSocketChannel.class,
IoUringSocketChannel::new,
IoUringDatagramChannel.class,
IoUringDatagramChannel::new,
(threads, factory) -> new MultiThreadIoEventLoopGroup(threads, factory, IoUringIoHandler.newFactory()),
IoUring.isTcpFastOpenServerSideAvailable(),
IoUring.isTcpFastOpenClientSideAvailable()
);
}

Expand All @@ -72,7 +81,8 @@ private static TransportType determineTransportMethod() {
EpollSocketChannel::new,
EpollDatagramChannel.class,
EpollDatagramChannel::new,
factory -> new EpollEventLoopGroup(0, factory),
NEW_NETTY ? (threads, factory) ->
new MultiThreadIoEventLoopGroup(threads, factory, EpollIoHandler.newFactory()) : EpollEventLoopGroup::new,
Epoll.isTcpFastOpenServerSideAvailable(),
Epoll.isTcpFastOpenClientSideAvailable()
);
Expand All @@ -87,7 +97,8 @@ private static TransportType determineTransportMethod() {
KQueueSocketChannel::new,
KQueueDatagramChannel.class,
KQueueDatagramChannel::new,
factory -> new KQueueEventLoopGroup(0, factory),
NEW_NETTY ? (threads, factory) ->
new MultiThreadIoEventLoopGroup(threads, factory, KQueueIoHandler.newFactory()) : KQueueEventLoopGroup::new,
KQueue.isTcpFastOpenServerSideAvailable(),
KQueue.isTcpFastOpenClientSideAvailable()
);
Expand All @@ -101,7 +112,8 @@ private static TransportType determineTransportMethod() {
NioSocketChannel::new,
NioDatagramChannel.class,
NioDatagramChannel::new,
factory -> new NioEventLoopGroup(0, factory),
NEW_NETTY ? (threads, factory) ->
new MultiThreadIoEventLoopGroup(threads, factory, NioIoHandler.newFactory()) : NioEventLoopGroup::new,
false,
false
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) t
try {
config.encryption().decrypt(heapBuf.array(), baseOffset, inBytes, heapBuf.array(), baseOffset);
out.add(heapBuf);
if (in.hasArray()) in.readerIndex(inBytes); // This is required as otherwise the ByteBuf doesn't know it has been read
} catch (Exception e) {
heapBuf.release();
throw e;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.geysermc.mcprotocollib.network.server;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.ByteBufAllocator;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFactory;
import io.netty.channel.ChannelFutureListener;
Expand Down Expand Up @@ -86,11 +87,11 @@ protected ChannelFactory<? extends ServerChannel> getChannelFactory() {
}

protected EventLoopGroup createBossEventLoopGroup() {
return TransportHelper.TRANSPORT_TYPE.eventLoopGroupFactory().apply(null);
return TransportHelper.TRANSPORT_TYPE.eventLoopGroupFactory().apply(0, null);
}

protected EventLoopGroup createWorkerEventLoopGroup() {
return TransportHelper.TRANSPORT_TYPE.eventLoopGroupFactory().apply(null);
return TransportHelper.TRANSPORT_TYPE.eventLoopGroupFactory().apply(0, null);
}

protected void setOptions(ServerBootstrap bootstrap) {
Expand All @@ -100,6 +101,8 @@ protected void setOptions(ServerBootstrap bootstrap) {
if (getGlobalFlag(BuiltinFlags.TCP_FAST_OPEN, false) && TransportHelper.TRANSPORT_TYPE.supportsTcpFastOpenServer()) {
bootstrap.option(ChannelOption.TCP_FASTOPEN, 3);
}

bootstrap.option(ChannelOption.ALLOCATOR, getGlobalFlag(BuiltinFlags.ALLOCATOR, ByteBufAllocator.DEFAULT));
}

protected ChannelHandler getChannelHandler() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.geysermc.mcprotocollib.network.session;

import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBufAllocator;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFactory;
import io.netty.channel.ChannelHandler;
Expand Down Expand Up @@ -100,6 +101,8 @@ protected void setOptions(Bootstrap bootstrap) {
if (getFlag(BuiltinFlags.TCP_FAST_OPEN, false) && TransportHelper.TRANSPORT_TYPE.supportsTcpFastOpenClient()) {
bootstrap.option(ChannelOption.TCP_FASTOPEN_CONNECT, true);
}

bootstrap.option(ChannelOption.ALLOCATOR, getFlag(BuiltinFlags.ALLOCATOR, ByteBufAllocator.DEFAULT));
}

protected ChannelHandler getChannelHandler() {
Expand All @@ -124,7 +127,7 @@ private static void createEventLoopGroup() {
return;
}

EVENT_LOOP_GROUP = TransportHelper.TRANSPORT_TYPE.eventLoopGroupFactory().apply(newThreadFactory());
EVENT_LOOP_GROUP = TransportHelper.TRANSPORT_TYPE.eventLoopGroupFactory().apply(0, newThreadFactory());

Runtime.getRuntime().addShutdownHook(new Thread(
() -> EVENT_LOOP_GROUP.shutdownGracefully(SHUTDOWN_QUIET_PERIOD_MS, SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundStopSoundPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundTabListPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundTestInstanceBlockStatus;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundTickingStatePacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundTickingStepPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundUpdateAdvancementsPacket;
Expand Down Expand Up @@ -92,8 +93,7 @@
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundSetExperiencePacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHealthPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHeldSlotPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddEntityPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddExperienceOrbPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundAddEntityPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundContainerClosePacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundContainerSetContentPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundContainerSetDataPacket;
Expand Down Expand Up @@ -186,8 +186,10 @@
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundMoveVehiclePacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundPaddleBoatPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundPlayerInputPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundSetTestBlockPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundSignUpdatePacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundTeleportToEntityPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundTestInstanceBlockActionPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundInteractPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosRotPacket;
Expand Down Expand Up @@ -216,8 +218,8 @@

public class MinecraftCodec {
public static final PacketCodec CODEC = PacketCodec.builder()
.protocolVersion(769)
.minecraftVersion("1.21.4")
.protocolVersion(770)
.minecraftVersion("1.21.5")
.state(ProtocolState.HANDSHAKE, MinecraftPacketRegistry.builder()
.registerServerboundPacket(ClientIntentionPacket.class, ClientIntentionPacket::new)
)
Expand Down Expand Up @@ -267,7 +269,6 @@ public class MinecraftCodec {
).state(ProtocolState.GAME, MinecraftPacketRegistry.builder()
.registerClientboundPacket(ClientboundDelimiterPacket.class, ClientboundDelimiterPacket::new)
.registerClientboundPacket(ClientboundAddEntityPacket.class, ClientboundAddEntityPacket::new)
.registerClientboundPacket(ClientboundAddExperienceOrbPacket.class, ClientboundAddExperienceOrbPacket::new)
.registerClientboundPacket(ClientboundAnimatePacket.class, ClientboundAnimatePacket::new)
.registerClientboundPacket(ClientboundAwardStatsPacket.class, ClientboundAwardStatsPacket::new)
.registerClientboundPacket(ClientboundBlockChangedAckPacket.class, ClientboundBlockChangedAckPacket::new)
Expand Down Expand Up @@ -385,6 +386,7 @@ public class MinecraftCodec {
.registerClientboundPacket(ClientboundTagQueryPacket.class, ClientboundTagQueryPacket::new)
.registerClientboundPacket(ClientboundTakeItemEntityPacket.class, ClientboundTakeItemEntityPacket::new)
.registerClientboundPacket(ClientboundTeleportEntityPacket.class, ClientboundTeleportEntityPacket::new)
.registerClientboundPacket(ClientboundTestInstanceBlockStatus.class, ClientboundTestInstanceBlockStatus::new)
.registerClientboundPacket(ClientboundTickingStatePacket.class, ClientboundTickingStatePacket::new)
.registerClientboundPacket(ClientboundTickingStepPacket.class, ClientboundTickingStepPacket::new)
.registerClientboundPacket(ClientboundTransferPacket.class, ClientboundTransferPacket::new)
Expand Down Expand Up @@ -453,9 +455,11 @@ public class MinecraftCodec {
.registerServerboundPacket(ServerboundSetCreativeModeSlotPacket.class, ServerboundSetCreativeModeSlotPacket::new)
.registerServerboundPacket(ServerboundSetJigsawBlockPacket.class, ServerboundSetJigsawBlockPacket::new)
.registerServerboundPacket(ServerboundSetStructureBlockPacket.class, ServerboundSetStructureBlockPacket::new)
.registerServerboundPacket(ServerboundSetTestBlockPacket.class, ServerboundSetTestBlockPacket::new)
.registerServerboundPacket(ServerboundSignUpdatePacket.class, ServerboundSignUpdatePacket::new)
.registerServerboundPacket(ServerboundSwingPacket.class, ServerboundSwingPacket::new)
.registerServerboundPacket(ServerboundTeleportToEntityPacket.class, ServerboundTeleportToEntityPacket::new)
.registerServerboundPacket(ServerboundTestInstanceBlockActionPacket.class, ServerboundTestInstanceBlockActionPacket::new)
.registerServerboundPacket(ServerboundUseItemOnPacket.class, ServerboundUseItemOnPacket::new)
.registerServerboundPacket(ServerboundUseItemPacket.class, ServerboundUseItemPacket::new)
)
Expand Down
Loading
Loading