Skip to content

Commit

Permalink
Switch to AutoHeader patches.
Browse files Browse the repository at this point in the history
  • Loading branch information
marchermans committed Nov 19, 2023
1 parent c3fc54d commit 87fbaa6
Show file tree
Hide file tree
Showing 24 changed files with 131 additions and 92 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
--- a/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java
+++ b/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java
@@ -49,6 +49,7 @@
@@ -49,6 +_,7 @@
import net.minecraft.resources.ResourceKey;
import net.minecraft.tags.TagKey;
import net.minecraft.tags.TagNetworkSerialization;
+import net.minecraft.util.thread.ReentrantBlockableEventLoop;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import org.slf4j.Logger;
@@ -97,12 +98,12 @@
@@ -97,12 +_,12 @@
this.serverBrand = brandpayload.brand();
this.telemetryManager.onServerBrandReceived(brandpayload.brand());
} else {
Expand All @@ -23,7 +23,7 @@

protected abstract RegistryAccess.Frozen registryAccess();

@@ -231,6 +232,10 @@
@@ -231,6 +_,10 @@
}

public void send(Packet<?> p_295097_) {
Expand All @@ -34,7 +34,7 @@
this.connection.send(p_295097_);
}

@@ -263,5 +268,15 @@
@@ -263,5 +_,15 @@

@OnlyIn(Dist.CLIENT)
static record DeferredPacket(Packet<? extends ServerboundPacketListener> packet, BooleanSupplier sendCondition, long expirationTime) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java
+++ b/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java
@@ -3,28 +3,39 @@
@@ -3,28 +_,39 @@
import com.mojang.authlib.GameProfile;
import com.mojang.logging.LogUtils;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -40,7 +40,7 @@

public ClientConfigurationPacketListenerImpl(Minecraft p_295262_, Connection p_296339_, CommonListenerCookie p_294706_) {
super(p_295262_, p_296339_, p_294706_);
@@ -44,11 +55,38 @@
@@ -44,11 +_,38 @@
}

@Override
Expand Down Expand Up @@ -82,15 +82,15 @@
LOGGER.warn("Unknown custom packet payload: {}", p_296412_.id());
}

@@ -84,6 +122,7 @@
@@ -84,6 +_,7 @@
this.telemetryManager,
this.receivedRegistries,
this.enabledFeatures,
+ this.isModdedConnection,
this.serverBrand,
this.serverData,
this.postDisconnectScreen
@@ -97,5 +136,14 @@
@@ -97,5 +_,14 @@
@Override
public void tick() {
this.sendDeferredPackets();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
--- a/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java
+++ b/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java
@@ -165,6 +165,7 @@
@@ -165,6 +_,7 @@
this.minecraft.getTelemetryManager().createWorldSessionManager(this.newWorld, this.worldLoadDuration, this.minigameName),
ClientRegistryLayer.createRegistryAccess().compositeAccess(),
FeatureFlags.DEFAULT_FLAGS,
+ false,
null,
this.serverData,
this.parent
@@ -180,7 +181,7 @@
@@ -180,7 +_,7 @@
if (this.serverData != null && this.serverData.isRealm()) {
this.minecraft.setScreen(new DisconnectedRealmsScreen(this.parent, CommonComponents.CONNECT_FAILED, p_104543_));
} else {
Expand All @@ -17,7 +17,7 @@
}
}

@@ -203,6 +204,7 @@
@@ -203,6 +_,7 @@

@Override
public void handleCustomQuery(ClientboundCustomQueryPacket p_104545_) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
--- a/net/minecraft/client/multiplayer/ClientPacketListener.java
+++ b/net/minecraft/client/multiplayer/ClientPacketListener.java
@@ -334,6 +334,7 @@
@@ -334,6 +_,7 @@
private MessageSignatureCache messageSignatureCache = MessageSignatureCache.createDefault();
private final ChunkBatchSizeCalculator chunkBatchSizeCalculator = new ChunkBatchSizeCalculator();
private final PingDebugMonitor pingDebugMonitor;
+ private final boolean isModdedConnection;
private boolean seenInsecureChatWarning = false;
private volatile boolean closed;

@@ -345,6 +346,7 @@
@@ -345,6 +_,7 @@
this.advancements = new ClientAdvancements(p_253924_, this.telemetryManager);
this.suggestionsProvider = new ClientSuggestionProvider(this, p_253924_);
this.pingDebugMonitor = new PingDebugMonitor(this, p_253924_.getDebugOverlay().getPingLogger());
+ this.isModdedConnection = p_295121_.isModdedConnection();
}

public ClientSuggestionProvider getSuggestionsProvider() {
@@ -403,6 +405,7 @@
@@ -403,6 +_,7 @@

this.minecraft.debugRenderer.clear();
this.minecraft.player.resetPos();
+ net.neoforged.neoforge.client.ClientHooks.firePlayerLogin(this.minecraft.gameMode, this.minecraft.player, this.minecraft.getConnection().connection);
this.minecraft.player.setId(p_105030_.playerId());
this.level.addEntity(this.minecraft.player);
this.minecraft.player.input = new KeyboardInput(this.minecraft.options);
@@ -764,6 +767,7 @@
@@ -764,6 +_,7 @@
this.telemetryManager,
this.registryAccess,
this.enabledFeatures,
+ this.isModdedConnection,
this.serverBrand,
this.serverData,
this.postDisconnectScreen
@@ -1110,7 +1114,9 @@
@@ -1110,7 +_,9 @@
localplayer1.getAttributes().assignValues(localplayer.getAttributes());
}

Expand All @@ -42,7 +42,7 @@
this.level.addEntity(localplayer1);
localplayer1.setYRot(-180.0F);
localplayer1.input = new KeyboardInput(this.minecraft.options);
@@ -1230,10 +1236,7 @@
@@ -1230,10 +_,7 @@
PacketUtils.ensureRunningOnSameThread(p_104976_, this, this.minecraft);
BlockPos blockpos = p_104976_.getPos();
this.minecraft.level.getBlockEntity(blockpos, p_104976_.getType()).ifPresent(p_205557_ -> {
Expand All @@ -54,7 +54,7 @@

if (p_205557_ instanceof CommandBlockEntity && this.minecraft.screen instanceof CommandBlockEditScreen) {
((CommandBlockEditScreen)this.minecraft.screen).updateGui();
@@ -1395,7 +1398,9 @@
@@ -1395,7 +_,9 @@
@Override
public void handleCommands(ClientboundCommandsPacket p_104990_) {
PacketUtils.ensureRunningOnSameThread(p_104990_, this, this.minecraft);
Expand All @@ -65,15 +65,15 @@
}

@Override
@@ -1417,6 +1422,7 @@
@@ -1417,6 +_,7 @@
ClientRecipeBook clientrecipebook = this.minecraft.player.getRecipeBook();
clientrecipebook.setupCollections(this.recipeManager.getRecipes(), this.minecraft.level.registryAccess());
this.minecraft.populateSearchTree(SearchRegistry.RECIPE_COLLECTIONS, clientrecipebook.getCollections());
+ net.neoforged.neoforge.client.ClientHooks.onRecipesUpdated(this.recipeManager);
}

@Override
@@ -1523,7 +1529,8 @@
@@ -1523,7 +_,8 @@
Blocks.rebuildCache();
}

Expand All @@ -83,7 +83,7 @@
}

@Override
@@ -1855,7 +1862,7 @@
@@ -1855,7 +_,7 @@
}

@Override
Expand All @@ -92,7 +92,7 @@
if (p_295851_ instanceof PathfindingDebugPayload pathfindingdebugpayload) {
this.minecraft
.debugRenderer
@@ -1922,10 +1929,16 @@
@@ -1922,10 +_,16 @@
.gameEventListenerRenderer
.trackListener(gameeventlistenerdebugpayload.listenerPos(), gameeventlistenerdebugpayload.listenerRange());
} else {
Expand All @@ -110,7 +110,7 @@
private void handleUnknownCustomPayload(CustomPacketPayload p_294389_) {
LOGGER.warn("Unknown custom packet payload: {}", p_294389_.id());
}
@@ -2302,6 +2315,8 @@
@@ -2302,6 +_,8 @@
}

public void sendChat(String p_249888_) {
Expand All @@ -119,7 +119,7 @@
Instant instant = Instant.now();
long i = Crypt.SaltSupplier.getLong();
LastSeenMessagesTracker.Update lastseenmessagestracker$update = this.lastSeenMessages.generateAndApplyUpdate();
@@ -2311,6 +2326,7 @@
@@ -2311,6 +_,7 @@
}

public void sendCommand(String p_250092_) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/CommonListenerCookie.java
+++ b/net/minecraft/client/multiplayer/CommonListenerCookie.java
@@ -15,6 +15,7 @@
@@ -15,6 +_,7 @@
WorldSessionTelemetryManager telemetryManager,
RegistryAccess.Frozen receivedRegistries,
FeatureFlagSet enabledFeatures,
Expand Down
12 changes: 6 additions & 6 deletions patches/net/minecraft/network/Connection.java.patch
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
--- a/net/minecraft/network/Connection.java
+++ b/net/minecraft/network/Connection.java
@@ -110,6 +110,7 @@
@@ -110,6 +_,7 @@
if (this.delayedDisconnect != null) {
this.disconnect(this.delayedDisconnect);
}
+ net.neoforged.neoforge.network.connection.ConnectionUtils.setConnection(p_129525_, this);
}

public static void setInitialProtocolAttributes(Channel p_294962_) {
@@ -120,6 +121,7 @@
@@ -120,6 +_,7 @@
@Override
public void channelInactive(ChannelHandlerContext p_129527_) {
this.disconnect(Component.translatable("disconnect.endOfStream"));
+ net.neoforged.neoforge.network.connection.ConnectionUtils.removeConnection(p_129527_);
}

@Override
@@ -371,7 +373,7 @@
@@ -371,7 +_,7 @@
if (this.address == null) {
return "local";
} else {
Expand All @@ -25,23 +25,23 @@
}
}

@@ -410,6 +412,7 @@
@@ -410,6 +_,7 @@
}

public static ChannelFuture connect(InetSocketAddress p_290034_, boolean p_290035_, final Connection p_290031_) {
+ net.neoforged.neoforge.network.DualStackUtils.checkIPv6(p_290034_.getAddress());
Class<? extends SocketChannel> oclass;
EventLoopGroup eventloopgroup;
if (Epoll.isAvailable() && p_290035_) {
@@ -466,6 +469,7 @@
@@ -466,6 +_,7 @@

public static Connection connectToLocalServer(SocketAddress p_129494_) {
final Connection connection = new Connection(PacketFlow.CLIENTBOUND);
+ connection.activationHandler = net.neoforged.neoforge.network.NetworkHooks::registerClientLoginChannel;
new Bootstrap().group(LOCAL_WORKER_GROUP.get()).handler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel p_129557_) {
@@ -558,6 +562,14 @@
@@ -558,6 +_,14 @@

public float getAverageSentPackets() {
return this.averageSentPackets;
Expand Down
20 changes: 10 additions & 10 deletions patches/net/minecraft/network/ConnectionProtocol.java.patch
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
--- a/net/minecraft/network/ConnectionProtocol.java
+++ b/net/minecraft/network/ConnectionProtocol.java
@@ -3,6 +3,7 @@
@@ -3,6 +_,7 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.mojang.logging.LogUtils;
+import io.netty.channel.ChannelHandlerContext;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
@@ -12,6 +13,7 @@
@@ -12,6 +_,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.function.BiFunction;
import java.util.function.Function;
import javax.annotation.Nullable;
import net.minecraft.Util;
@@ -238,7 +240,7 @@
@@ -238,7 +_,7 @@
.addPacket(ClientboundContainerSetSlotPacket.class, ClientboundContainerSetSlotPacket::new)
.addPacket(ClientboundCooldownPacket.class, ClientboundCooldownPacket::new)
.addPacket(ClientboundCustomChatCompletionsPacket.class, ClientboundCustomChatCompletionsPacket::new)
Expand All @@ -25,7 +25,7 @@
.addPacket(ClientboundDamageEventPacket.class, ClientboundDamageEventPacket::new)
.addPacket(ClientboundDeleteChatPacket.class, ClientboundDeleteChatPacket::new)
.addPacket(ClientboundDisconnectPacket.class, ClientboundDisconnectPacket::new)
@@ -346,7 +348,7 @@
@@ -346,7 +_,7 @@
.addPacket(ServerboundContainerButtonClickPacket.class, ServerboundContainerButtonClickPacket::new)
.addPacket(ServerboundContainerClickPacket.class, ServerboundContainerClickPacket::new)
.addPacket(ServerboundContainerClosePacket.class, ServerboundContainerClosePacket::new)
Expand All @@ -34,7 +34,7 @@
.addPacket(ServerboundEditBookPacket.class, ServerboundEditBookPacket::new)
.addPacket(ServerboundEntityTagQuery.class, ServerboundEntityTagQuery::new)
.addPacket(ServerboundInteractPacket.class, ServerboundInteractPacket::new)
@@ -430,7 +432,7 @@
@@ -430,7 +_,7 @@
.addFlow(
PacketFlow.CLIENTBOUND,
new ConnectionProtocol.PacketSet<net.minecraft.network.protocol.configuration.ClientConfigurationPacketListener>()
Expand All @@ -43,7 +43,7 @@
.addPacket(ClientboundDisconnectPacket.class, ClientboundDisconnectPacket::new)
.addPacket(ClientboundFinishConfigurationPacket.class, ClientboundFinishConfigurationPacket::new)
.addPacket(ClientboundKeepAlivePacket.class, ClientboundKeepAlivePacket::new)
@@ -444,7 +446,7 @@
@@ -444,7 +_,7 @@
PacketFlow.SERVERBOUND,
new ConnectionProtocol.PacketSet<net.minecraft.network.protocol.configuration.ServerConfigurationPacketListener>()
.addPacket(ServerboundClientInformationPacket.class, ServerboundClientInformationPacket::new)
Expand All @@ -52,7 +52,7 @@
.addPacket(ServerboundFinishConfigurationPacket.class, ServerboundFinishConfigurationPacket::new)
.addPacket(ServerboundKeepAlivePacket.class, ServerboundKeepAlivePacket::new)
.addPacket(ServerboundPongPacket.class, ServerboundPongPacket::new)
@@ -456,6 +458,22 @@
@@ -456,6 +_,22 @@
private final String id;
private final Map<PacketFlow, ConnectionProtocol.CodecData<?>> flows;

Expand All @@ -75,7 +75,7 @@
private static ConnectionProtocol.ProtocolBuilder protocol() {
return new ConnectionProtocol.ProtocolBuilder();
}
@@ -514,8 +532,8 @@
@@ -514,8 +_,8 @@
}

@Nullable
Expand All @@ -86,7 +86,7 @@
}

public boolean isValidPacketType(Packet<?> p_294142_) {
@@ -528,19 +546,28 @@
@@ -528,19 +_,28 @@
final Object2IntMap<Class<? extends Packet<? super T>>> classToId = Util.make(
new Object2IntOpenHashMap<>(), p_129613_ -> p_129613_.defaultReturnValue(-1)
);
Expand Down Expand Up @@ -120,7 +120,7 @@
return this;
}
}
@@ -566,9 +593,9 @@
@@ -566,9 +_,9 @@
}

@Nullable
Expand Down
2 changes: 1 addition & 1 deletion patches/net/minecraft/network/PacketDecoder.java.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/net/minecraft/network/PacketDecoder.java
+++ b/net/minecraft/network/PacketDecoder.java
@@ -28,7 +28,7 @@
@@ -28,7 +_,7 @@
ConnectionProtocol.CodecData<?> codecdata = attribute.get();
FriendlyByteBuf friendlybytebuf = new FriendlyByteBuf(p_130536_);
int j = friendlybytebuf.readVarInt();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/net/minecraft/network/protocol/PacketFlow.java
+++ b/net/minecraft/network/protocol/PacketFlow.java
@@ -1,6 +1,6 @@
@@ -1,6 +_,6 @@
package net.minecraft.network.protocol;

-public enum PacketFlow {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/net/minecraft/network/protocol/common/ClientCommonPacketListener.java
+++ b/net/minecraft/network/protocol/common/ClientCommonPacketListener.java
@@ -2,7 +2,7 @@
@@ -2,7 +_,7 @@

import net.minecraft.network.ClientboundPacketListener;

Expand Down
Loading

0 comments on commit 87fbaa6

Please sign in to comment.