This commit is contained in:
Alex 2024-11-16 12:11:54 +00:00 committed by GitHub
commit a4714d1c05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
196 changed files with 945 additions and 91 deletions

View file

@ -9,13 +9,14 @@ import org.geysermc.mcprotocollib.network.Session;
public interface Packet {
/**
* Gets whether the packet has handling priority.
* If the result is true, the packet will be handled immediately after being
* decoded.
* Gets whether the packet should run on an async game thread rather than blocking the network (Netty) thread.
* Packets that qualify for this are usually packets with an ensureRunningOnSameThread call at the top of their packet listener method in the Minecraft code.
* Packets which need extra attention because they aren't "fully" handled async are marked using.
* // GAME THREAD DETAIL comments in the MCProtocolLib code.
*
* @return Whether the packet has priority.
* @return Whether the packet be handled async from the Netty thread.
*/
default boolean isPriority() {
default boolean shouldRunOnGameThread() {
return false;
}

View file

@ -0,0 +1,34 @@
package org.geysermc.mcprotocollib.network.tcp;
import io.netty.channel.DefaultEventLoopGroup;
import io.netty.channel.EventLoopGroup;
import io.netty.util.concurrent.DefaultThreadFactory;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
public class DefaultPacketHandlerExecutor {
/**
* Controls whether non-priority packets are handled in a separate event loop
*/
public static boolean USE_EVENT_LOOP_FOR_PACKETS = true;
private static EventLoopGroup PACKET_EVENT_LOOP;
private static final int SHUTDOWN_QUIET_PERIOD_MS = 100;
private static final int SHUTDOWN_TIMEOUT_MS = 500;
public static Executor createExecutor() {
if (!USE_EVENT_LOOP_FOR_PACKETS) {
return Runnable::run;
}
if (PACKET_EVENT_LOOP == null) {
// See TcpClientSession.newThreadFactory() for details on
// daemon threads and their interaction with the runtime.
PACKET_EVENT_LOOP = new DefaultEventLoopGroup(new DefaultThreadFactory(DefaultPacketHandlerExecutor.class, true));
Runtime.getRuntime().addShutdownHook(new Thread(
() -> PACKET_EVENT_LOOP.shutdownGracefully(SHUTDOWN_QUIET_PERIOD_MS, SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS)));
}
return PACKET_EVENT_LOOP.next();
}
}

View file

@ -43,6 +43,7 @@ import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
@ -76,7 +77,11 @@ public class TcpClientSession extends TcpSession {
}
public TcpClientSession(String host, int port, String bindAddress, int bindPort, PacketProtocol protocol, ProxyInfo proxy) {
super(host, port, protocol);
this(host, port, bindAddress, bindPort, protocol, proxy, DefaultPacketHandlerExecutor.createExecutor());
}
public TcpClientSession(String host, int port, String bindAddress, int bindPort, PacketProtocol protocol, ProxyInfo proxy, Executor packetHandlerExecutor) {
super(host, port, protocol, packetHandlerExecutor);
this.bindAddress = bindAddress;
this.bindPort = bindPort;
this.proxy = proxy;

View file

@ -13,7 +13,7 @@ public class TcpServerSession extends TcpSession {
private final PacketCodecHelper codecHelper;
public TcpServerSession(String host, int port, PacketProtocol protocol, TcpServer server) {
super(host, port, protocol);
super(host, port, protocol, DefaultPacketHandlerExecutor.createExecutor());
this.server = server;
this.codecHelper = protocol.createHelper();
}

View file

@ -3,11 +3,7 @@ package org.geysermc.mcprotocollib.network.tcp;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.DefaultEventLoopGroup;
import io.netty.channel.EventLoop;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.util.concurrent.DefaultThreadFactory;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -33,24 +29,16 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeoutException;
public abstract class TcpSession extends SimpleChannelInboundHandler<Packet> implements Session {
private static final Logger log = LoggerFactory.getLogger(TcpSession.class);
/**
* Controls whether non-priority packets are handled in a separate event loop
*/
public static boolean USE_EVENT_LOOP_FOR_PACKETS = true;
private static EventLoopGroup PACKET_EVENT_LOOP;
private static final int SHUTDOWN_QUIET_PERIOD_MS = 100;
private static final int SHUTDOWN_TIMEOUT_MS = 500;
protected String host;
protected int port;
private final PacketProtocol protocol;
private final EventLoop eventLoop = createEventLoop();
private final Executor packetHandlerExecutor;
private final Map<String, Object> flags = new HashMap<>();
private final List<SessionListener> listeners = new CopyOnWriteArrayList<>();
@ -58,10 +46,11 @@ public abstract class TcpSession extends SimpleChannelInboundHandler<Packet> imp
private Channel channel;
protected boolean disconnected = false;
public TcpSession(String host, int port, PacketProtocol protocol) {
public TcpSession(String host, int port, PacketProtocol protocol, Executor packetHandlerExecutor) {
this.host = host;
this.port = port;
this.protocol = protocol;
this.packetHandlerExecutor = packetHandlerExecutor;
}
@Override
@ -269,21 +258,6 @@ public abstract class TcpSession extends SimpleChannelInboundHandler<Packet> imp
}
}
private @Nullable EventLoop createEventLoop() {
if (!USE_EVENT_LOOP_FOR_PACKETS) {
return null;
}
if (PACKET_EVENT_LOOP == null) {
// See TcpClientSession.newThreadFactory() for details on
// daemon threads and their interaction with the runtime.
PACKET_EVENT_LOOP = new DefaultEventLoopGroup(new DefaultThreadFactory(this.getClass(), true));
Runtime.getRuntime().addShutdownHook(new Thread(
() -> PACKET_EVENT_LOOP.shutdownGracefully(SHUTDOWN_QUIET_PERIOD_MS, SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS)));
}
return PACKET_EVENT_LOOP.next();
}
@Override
public Channel getChannel() {
return this.channel;
@ -322,8 +296,8 @@ public abstract class TcpSession extends SimpleChannelInboundHandler<Packet> imp
@Override
protected void channelRead0(ChannelHandlerContext ctx, Packet packet) {
if (!packet.isPriority() && eventLoop != null) {
eventLoop.execute(() -> this.callPacketReceived(packet));
if (packet.shouldRunOnGameThread()) {
packetHandlerExecutor.execute(() -> this.callPacketReceived(packet));
} else {
this.callPacketReceived(packet);
}

View file

@ -37,9 +37,9 @@ import org.geysermc.mcprotocollib.protocol.packet.login.clientbound.ClientboundL
import org.geysermc.mcprotocollib.protocol.packet.login.serverbound.ServerboundHelloPacket;
import org.geysermc.mcprotocollib.protocol.packet.login.serverbound.ServerboundKeyPacket;
import org.geysermc.mcprotocollib.protocol.packet.login.serverbound.ServerboundLoginAcknowledgedPacket;
import org.geysermc.mcprotocollib.protocol.packet.status.clientbound.ClientboundPongResponsePacket;
import org.geysermc.mcprotocollib.protocol.packet.ping.clientbound.ClientboundPongResponsePacket;
import org.geysermc.mcprotocollib.protocol.packet.status.clientbound.ClientboundStatusResponsePacket;
import org.geysermc.mcprotocollib.protocol.packet.status.serverbound.ServerboundPingRequestPacket;
import org.geysermc.mcprotocollib.protocol.packet.ping.serverbound.ServerboundPingRequestPacket;
import org.geysermc.mcprotocollib.protocol.packet.status.serverbound.ServerboundStatusRequestPacket;
import javax.crypto.KeyGenerator;

View file

@ -35,9 +35,9 @@ import org.geysermc.mcprotocollib.protocol.packet.login.clientbound.ClientboundL
import org.geysermc.mcprotocollib.protocol.packet.login.serverbound.ServerboundHelloPacket;
import org.geysermc.mcprotocollib.protocol.packet.login.serverbound.ServerboundKeyPacket;
import org.geysermc.mcprotocollib.protocol.packet.login.serverbound.ServerboundLoginAcknowledgedPacket;
import org.geysermc.mcprotocollib.protocol.packet.status.clientbound.ClientboundPongResponsePacket;
import org.geysermc.mcprotocollib.protocol.packet.ping.clientbound.ClientboundPongResponsePacket;
import org.geysermc.mcprotocollib.protocol.packet.status.clientbound.ClientboundStatusResponsePacket;
import org.geysermc.mcprotocollib.protocol.packet.status.serverbound.ServerboundPingRequestPacket;
import org.geysermc.mcprotocollib.protocol.packet.ping.serverbound.ServerboundPingRequestPacket;
import org.geysermc.mcprotocollib.protocol.packet.status.serverbound.ServerboundStatusRequestPacket;
import javax.crypto.SecretKey;

View file

@ -1,7 +1,7 @@
package org.geysermc.mcprotocollib.protocol.codec;
import org.geysermc.mcprotocollib.protocol.data.ProtocolState;
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundCookieRequestPacket;
import org.geysermc.mcprotocollib.protocol.packet.cookie.clientbound.ClientboundCookieRequestPacket;
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundCustomPayloadPacket;
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundCustomReportDetailsPacket;
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundDisconnectPacket;
@ -13,7 +13,7 @@ import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.Clientbound
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundStoreCookiePacket;
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundTransferPacket;
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundUpdateTagsPacket;
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ServerboundCookieResponsePacket;
import org.geysermc.mcprotocollib.protocol.packet.cookie.serverbound.ServerboundCookieResponsePacket;
import org.geysermc.mcprotocollib.protocol.packet.common.serverbound.ServerboundClientInformationPacket;
import org.geysermc.mcprotocollib.protocol.packet.common.serverbound.ServerboundCustomPayloadPacket;
import org.geysermc.mcprotocollib.protocol.packet.common.serverbound.ServerboundKeepAlivePacket;
@ -207,9 +207,9 @@ import org.geysermc.mcprotocollib.protocol.packet.login.serverbound.ServerboundC
import org.geysermc.mcprotocollib.protocol.packet.login.serverbound.ServerboundHelloPacket;
import org.geysermc.mcprotocollib.protocol.packet.login.serverbound.ServerboundKeyPacket;
import org.geysermc.mcprotocollib.protocol.packet.login.serverbound.ServerboundLoginAcknowledgedPacket;
import org.geysermc.mcprotocollib.protocol.packet.status.clientbound.ClientboundPongResponsePacket;
import org.geysermc.mcprotocollib.protocol.packet.ping.clientbound.ClientboundPongResponsePacket;
import org.geysermc.mcprotocollib.protocol.packet.status.clientbound.ClientboundStatusResponsePacket;
import org.geysermc.mcprotocollib.protocol.packet.status.serverbound.ServerboundPingRequestPacket;
import org.geysermc.mcprotocollib.protocol.packet.ping.serverbound.ServerboundPingRequestPacket;
import org.geysermc.mcprotocollib.protocol.packet.status.serverbound.ServerboundStatusRequestPacket;
public class MinecraftCodec {

View file

@ -26,4 +26,10 @@ public class ClientboundCustomPayloadPacket implements MinecraftPacket {
helper.writeResourceLocation(out, this.channel);
out.writeBytes(this.data);
}
@Override
public boolean shouldRunOnGameThread() {
// GAME THREAD DETAIL: Only non-discarded payloads are handled async.
return false; // False, you need to handle making it async yourself
}
}

View file

@ -33,4 +33,9 @@ public class ClientboundCustomReportDetailsPacket implements MinecraftPacket {
helper.writeString(out, entry.getValue());
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -28,9 +28,4 @@ public class ClientboundDisconnectPacket implements MinecraftPacket {
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
helper.writeComponent(out, this.reason);
}
@Override
public boolean isPriority() {
return true;
}
}

View file

@ -21,4 +21,9 @@ public class ClientboundPingPacket implements MinecraftPacket {
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
out.writeInt(this.id);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -28,4 +28,9 @@ public class ClientboundResourcePackPopPacket implements MinecraftPacket {
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
helper.writeNullable(out, this.id, helper::writeUUID);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -38,4 +38,9 @@ public class ClientboundResourcePackPushPacket implements MinecraftPacket {
out.writeBoolean(this.required);
helper.writeNullable(out, this.prompt, helper::writeComponent);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -52,4 +52,9 @@ public class ClientboundServerLinksPacket implements MinecraftPacket {
helper.writeString(out, link.link());
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -25,4 +25,9 @@ public class ClientboundStoreCookiePacket implements MinecraftPacket {
helper.writeResourceLocation(out, this.key);
helper.writeByteArray(out, this.payload);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -24,4 +24,10 @@ public class ClientboundTransferPacket implements MinecraftPacket {
helper.writeString(out, this.host);
helper.writeVarInt(out, this.port);
}
@Override
public boolean shouldRunOnGameThread() {
// GAME THREAD DETAIL: Code runs before packet is made async.
return false; // False, you need to handle making it async yourself
}
}

View file

@ -53,4 +53,9 @@ public class ClientboundUpdateTagsPacket implements MinecraftPacket {
}
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -72,4 +72,10 @@ public class ServerboundClientInformationPacket implements MinecraftPacket {
out.writeBoolean(allowsListing);
helper.writeVarInt(out, this.particleStatus.ordinal());
}
@Override
public boolean shouldRunOnGameThread() {
// GAME THREAD DETAIL: Code is only async during GAME state.
return false; // False, you need to handle making it async yourself
}
}

View file

@ -29,4 +29,9 @@ public class ServerboundResourcePackPacket implements MinecraftPacket {
helper.writeUUID(out, id);
helper.writeVarInt(out, this.status.ordinal());
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -16,6 +16,11 @@ public class ClientboundFinishConfigurationPacket implements MinecraftPacket {
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
@Override
public boolean isTerminal() {
return true;

View file

@ -31,4 +31,9 @@ public class ClientboundRegistryDataPacket implements MinecraftPacket {
helper.writeNullable(buf, entry.getData(), helper::writeAnyTag);
});
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -28,4 +28,9 @@ public class ClientboundSelectKnownPacks implements MinecraftPacket {
helper.writeString(buf, entry.getVersion());
});
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -16,6 +16,11 @@ public class ServerboundFinishConfigurationPacket implements MinecraftPacket {
public void serialize(ByteBuf buf, MinecraftCodecHelper helper) {
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
@Override
public boolean isTerminal() {
return true;

View file

@ -39,4 +39,9 @@ public class ServerboundSelectKnownPacks implements MinecraftPacket {
helper.writeString(out, entry.getVersion());
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -1,4 +1,4 @@
package org.geysermc.mcprotocollib.protocol.packet.common.clientbound;
package org.geysermc.mcprotocollib.protocol.packet.cookie.clientbound;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
@ -22,4 +22,9 @@ public class ClientboundCookieRequestPacket implements MinecraftPacket {
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
helper.writeResourceLocation(out, this.key);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -1,4 +1,4 @@
package org.geysermc.mcprotocollib.protocol.packet.common.clientbound;
package org.geysermc.mcprotocollib.protocol.packet.cookie.serverbound;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;

View file

@ -33,11 +33,6 @@ public class ClientIntentionPacket implements MinecraftPacket {
helper.writeVarInt(out, this.intent.ordinal() + 1);
}
@Override
public boolean isPriority() {
return true;
}
@Override
public boolean isTerminal() {
return true;

View file

@ -91,4 +91,9 @@ public class ClientboundAwardStatsPacket implements MinecraftPacket {
helper.writeVarInt(out, entry.getIntValue());
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -138,4 +138,9 @@ public class ClientboundBossEventPacket implements MinecraftPacket {
out.writeByte(flags);
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -16,4 +16,9 @@ public class ClientboundBundlePacket implements MinecraftPacket {
@Override
public void serialize(ByteBuf buf, MinecraftCodecHelper helper) {
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -26,4 +26,9 @@ public class ClientboundChangeDifficultyPacket implements MinecraftPacket {
out.writeByte(this.difficulty.ordinal());
out.writeBoolean(this.difficultyLocked);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -62,4 +62,9 @@ public class ClientboundCommandSuggestionsPacket implements MinecraftPacket {
}
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -300,4 +300,9 @@ public class ClientboundCommandsPacket implements MinecraftPacket {
helper.writeVarInt(out, this.firstNodeIndex);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -25,4 +25,9 @@ public class ClientboundCooldownPacket implements MinecraftPacket {
helper.writeResourceLocation(out, this.cooldownGroup);
helper.writeVarInt(out, this.cooldownTicks);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -31,4 +31,9 @@ public class ClientboundCustomChatCompletionsPacket implements MinecraftPacket {
helper.writeString(out, entry);
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -25,4 +25,9 @@ public class ClientboundDeleteChatPacket implements MinecraftPacket {
out.writeBytes(messageSignature.getMessageSignature());
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -35,4 +35,9 @@ public class ClientboundDisguisedChatPacket implements MinecraftPacket {
helper.writeComponent(out, this.name);
helper.writeNullable(out, this.targetName, helper::writeComponent);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -61,4 +61,9 @@ public class ClientboundLoginPacket implements MinecraftPacket {
helper.writePlayerSpawnInfo(out, this.commonPlayerSpawnInfo);
out.writeBoolean(this.enforcesSecureChat);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -84,4 +84,9 @@ public class ClientboundPlayerChatPacket implements MinecraftPacket {
helper.writeComponent(out, this.name);
helper.writeNullable(out, this.targetName, helper::writeComponent);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -23,4 +23,9 @@ public class ClientboundPlayerInfoRemovePacket implements MinecraftPacket {
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
helper.writeList(out, this.profileIds, helper::writeUUID);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -121,4 +121,9 @@ public class ClientboundPlayerInfoUpdatePacket implements MinecraftPacket {
}
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -60,6 +60,11 @@ public class ClientboundRecipeBookAddPacket implements MinecraftPacket {
out.writeBoolean(this.replace);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
public record Entry(RecipeDisplayEntry contents, boolean notification, boolean highlight) {
}
}

View file

@ -29,4 +29,9 @@ public class ClientboundRecipeBookRemovePacket implements MinecraftPacket {
helper.writeVarInt(out, recipe);
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -38,6 +38,11 @@ public class ClientboundRecipeBookSettingsPacket implements MinecraftPacket {
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
private record TypeSettings(boolean open, boolean filtering) {
}
}

View file

@ -39,4 +39,9 @@ public class ClientboundRespawnPacket implements MinecraftPacket {
}
out.writeByte(dataToKeep);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -22,4 +22,9 @@ public class ClientboundSelectAdvancementsTabPacket implements MinecraftPacket {
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
helper.writeNullable(out, this.tabId, helper::writeString);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -26,4 +26,9 @@ public class ClientboundServerDataPacket implements MinecraftPacket {
helper.writeComponent(out, this.motd);
helper.writeNullable(out, this.iconBytes, helper::writeByteArray);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -21,4 +21,9 @@ public class ClientboundSetCameraPacket implements MinecraftPacket {
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
helper.writeVarInt(out, this.cameraEntityId);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -46,4 +46,9 @@ public class ClientboundSoundEntityPacket implements MinecraftPacket {
out.writeFloat(this.pitch);
out.writeLong(this.seed);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -16,6 +16,11 @@ public class ClientboundStartConfigurationPacket implements MinecraftPacket {
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
@Override
public boolean isTerminal() {
return true;

View file

@ -55,4 +55,9 @@ public class ClientboundStopSoundPacket implements MinecraftPacket {
helper.writeResourceLocation(out, this.sound);
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -25,4 +25,9 @@ public class ClientboundSystemChatPacket implements MinecraftPacket {
helper.writeComponent(out, this.content);
out.writeBoolean(this.overlay);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -26,4 +26,9 @@ public class ClientboundTabListPacket implements MinecraftPacket {
helper.writeComponent(out, this.header);
helper.writeComponent(out, this.footer);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -25,4 +25,9 @@ public class ClientboundTickingStatePacket implements MinecraftPacket {
out.writeFloat(tickRate);
out.writeBoolean(isFrozen);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -22,4 +22,9 @@ public class ClientboundTickingStepPacket implements MinecraftPacket {
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
helper.writeVarInt(out, this.tickSteps);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -166,4 +166,9 @@ public class ClientboundUpdateAdvancementsPacket implements MinecraftPacket {
}
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -60,4 +60,9 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
public record SelectableRecipe(Ingredient input, SlotDisplay recipe) {
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -30,4 +30,9 @@ public class ClientboundAnimatePacket implements MinecraftPacket {
out.writeByte(this.animation.getId());
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -41,4 +41,9 @@ public class ClientboundDamageEventPacket implements MinecraftPacket {
out.writeBoolean(false);
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -26,4 +26,9 @@ public class ClientboundEntityEventPacket implements MinecraftPacket {
out.writeInt(this.entityId);
helper.writeEntityEvent(out, this.event);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -41,4 +41,9 @@ public class ClientboundEntityPositionSyncPacket implements MinecraftPacket {
out.writeFloat(this.xRot);
out.writeBoolean(this.onGround);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -24,4 +24,9 @@ public class ClientboundHurtAnimationPacket implements MinecraftPacket {
helper.writeVarInt(out, this.id);
out.writeFloat(this.yaw);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -33,4 +33,9 @@ public class ClientboundMoveEntityPosPacket implements MinecraftPacket {
out.writeShort((int) (this.moveZ * 4096));
out.writeBoolean(this.onGround);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -39,4 +39,9 @@ public class ClientboundMoveEntityPosRotPacket implements MinecraftPacket {
out.writeByte((byte) (this.pitch * 256 / 360));
out.writeBoolean(this.onGround);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -30,4 +30,9 @@ public class ClientboundMoveEntityRotPacket implements MinecraftPacket {
out.writeByte((byte) (this.pitch * 256 / 360));
out.writeBoolean(this.onGround);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -50,4 +50,9 @@ public class ClientboundMoveMinecartPacket implements MinecraftPacket {
output.writeFloat(lerpStep.weight());
});
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -33,4 +33,9 @@ public class ClientboundMoveVehiclePacket implements MinecraftPacket {
out.writeFloat(this.yaw);
out.writeFloat(this.pitch);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -24,4 +24,9 @@ public class ClientboundProjectilePowerPacket implements MinecraftPacket {
helper.writeVarInt(out, this.id);
out.writeDouble(this.accelerationPower);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -28,4 +28,9 @@ public class ClientboundRemoveEntitiesPacket implements MinecraftPacket {
helper.writeVarInt(out, entityId);
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -26,4 +26,9 @@ public class ClientboundRemoveMobEffectPacket implements MinecraftPacket {
helper.writeVarInt(out, this.entityId);
helper.writeEffect(out, this.effect);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -24,4 +24,9 @@ public class ClientboundRotateHeadPacket implements MinecraftPacket {
helper.writeVarInt(out, this.entityId);
out.writeByte((byte) (this.headYaw * 256 / 360));
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -26,4 +26,9 @@ public class ClientboundSetEntityDataPacket implements MinecraftPacket {
helper.writeVarInt(out, this.entityId);
helper.writeEntityMetadata(out, this.metadata);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -24,4 +24,9 @@ public class ClientboundSetEntityLinkPacket implements MinecraftPacket {
out.writeInt(this.entityId);
out.writeInt(this.attachedToId);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -30,4 +30,9 @@ public class ClientboundSetEntityMotionPacket implements MinecraftPacket {
out.writeShort((int) (this.motionY * 8000));
out.writeShort((int) (this.motionZ * 8000));
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -47,4 +47,9 @@ public class ClientboundSetEquipmentPacket implements MinecraftPacket {
helper.writeOptionalItemStack(out, this.equipment[i].getItem());
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -31,4 +31,9 @@ public class ClientboundSetPassengersPacket implements MinecraftPacket {
helper.writeVarInt(out, entityId);
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -27,4 +27,9 @@ public class ClientboundTakeItemEntityPacket implements MinecraftPacket {
helper.writeVarInt(out, this.collectorEntityId);
helper.writeVarInt(out, this.itemCount);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -64,4 +64,9 @@ public class ClientboundTeleportEntityPacket implements MinecraftPacket {
out.writeBoolean(this.onGround);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -54,4 +54,9 @@ public class ClientboundUpdateAttributesPacket implements MinecraftPacket {
}
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -63,4 +63,9 @@ public class ClientboundUpdateMobEffectPacket implements MinecraftPacket {
out.writeByte(flags);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -21,4 +21,9 @@ public class ClientboundBlockChangedAckPacket implements MinecraftPacket {
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
helper.writeVarInt(out, this.sequence);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -58,4 +58,9 @@ public class ClientboundPlayerAbilitiesPacket implements MinecraftPacket {
out.writeFloat(this.flySpeed);
out.writeFloat(this.walkSpeed);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -25,4 +25,9 @@ public class ClientboundPlayerCombatKillPacket implements MinecraftPacket {
helper.writeVarInt(out, this.playerId);
helper.writeComponent(out, this.message);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -55,4 +55,9 @@ public class ClientboundPlayerLookAtPacket implements MinecraftPacket {
out.writeBoolean(false);
}
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -66,4 +66,9 @@ public class ClientboundPlayerPositionPacket implements MinecraftPacket {
out.writeInt(flags);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -24,4 +24,9 @@ public class ClientboundPlayerRotationPacket implements MinecraftPacket {
out.writeFloat(this.yRot);
out.writeFloat(this.xRot);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -27,4 +27,9 @@ public class ClientboundSetExperiencePacket implements MinecraftPacket {
helper.writeVarInt(out, this.level);
helper.writeVarInt(out, this.totalExperience);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -27,4 +27,9 @@ public class ClientboundSetHealthPacket implements MinecraftPacket {
helper.writeVarInt(out, this.food);
out.writeFloat(this.saturation);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -21,4 +21,9 @@ public class ClientboundSetHeldSlotPacket implements MinecraftPacket {
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
out.writeByte(this.slot);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -120,4 +120,9 @@ public class ClientboundAddEntityPacket implements MinecraftPacket {
out.writeShort((int) (this.motionY * 8000));
out.writeShort((int) (this.motionZ * 8000));
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -33,4 +33,9 @@ public class ClientboundAddExperienceOrbPacket implements MinecraftPacket {
out.writeDouble(this.z);
out.writeShort(this.exp);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -21,4 +21,9 @@ public class ClientboundContainerClosePacket implements MinecraftPacket {
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
helper.writeVarInt(out, this.containerId);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -39,4 +39,9 @@ public class ClientboundContainerSetContentPacket implements MinecraftPacket {
}
helper.writeOptionalItemStack(out, this.carriedItem);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -32,4 +32,9 @@ public class ClientboundContainerSetDataPacket implements MinecraftPacket {
out.writeShort(this.rawProperty);
out.writeShort(this.value);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -32,4 +32,9 @@ public class ClientboundContainerSetSlotPacket implements MinecraftPacket {
out.writeShort(this.slot);
helper.writeOptionalItemStack(out, this.item);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -27,4 +27,9 @@ public class ClientboundHorseScreenOpenPacket implements MinecraftPacket {
helper.writeVarInt(out, this.inventoryColumns);
out.writeInt(this.entityId);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -72,4 +72,9 @@ public class ClientboundMerchantOffersPacket implements MinecraftPacket {
out.writeBoolean(this.regularVillager);
out.writeBoolean(this.canRestock);
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -23,4 +23,9 @@ public class ClientboundOpenBookPacket implements MinecraftPacket {
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
helper.writeVarInt(out, this.hand.ordinal());
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

View file

@ -48,4 +48,9 @@ public class ClientboundOpenScreenPacket implements MinecraftPacket {
public ClientboundOpenScreenPacket withName(String name) {
return new ClientboundOpenScreenPacket(this.containerId, this.type, DefaultComponentSerializer.get().deserialize(name));
}
@Override
public boolean shouldRunOnGameThread() {
return true;
}
}

Some files were not shown because too many files have changed in this diff Show more