9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-26 02:19:19 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0235-Protocol-Core.patch
Dreeam 9a4efaa230 Drop patch that causes performance regression
Originally vanilla logic is to use stream, and Mojang switched it to Guava's Collections2
since 1.21.4. It is much faster than using stream or manually adding to a new ArrayList.
Manually adding to a new ArrayList requires allocating a new object array. However, the Collections2
lazy handles filter condition on iteration, so much better.
2025-08-04 19:25:56 +08:00

77 lines
4.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: hayanesuru <hayanesuru@outlook.jp>
Date: Tue, 6 May 2025 17:44:16 +0900
Subject: [PATCH] Protocol Core
diff --git a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
index 56fd1ed7ccaf96e7eedea60fbdbf7f934939d563..d2f522ea6d0a209496848af073c9af1c45d6b6ce 100644
--- a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
+++ b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
@@ -46,6 +46,12 @@ public interface CustomPacketPayload {
return;
}
// Leaves end - protocol core
+ // Leaf start - Protocol core
+ if (value instanceof org.dreeam.leaf.protocol.LeafCustomPayload payload) {
+ org.dreeam.leaf.protocol.Protocols.write(buffer, payload);
+ return;
+ }
+ // Leaf end - Protocol core
this.writeCap(buffer, value.type(), value);
}
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index cf1f876c6caf1cb954749331fdeb6573f733c754..7849a905db35377da0931aa1c9b8770f30a51044 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -1804,6 +1804,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleTick(tickCount); // Leaves - protocol
+ org.dreeam.leaf.protocol.Protocols.tickServer(this); // Leaf - Protocol core
for (int i = 0; i < this.tickables.size(); i++) {
this.tickables.get(i).run();
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
index 258a90b1a35c2899481c6b37f949670d4d44e2f5..29f250f78bdd3c523b859d09d5561db088c6e72b 100644
--- a/net/minecraft/server/level/ServerPlayer.java
+++ b/net/minecraft/server/level/ServerPlayer.java
@@ -810,6 +810,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
}
}
// Purpur end - Ridables
+ org.dreeam.leaf.protocol.Protocols.tickPlayer(this); // Leaf - Protocol core
}
private void updatePlayerAttributes() {
diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
index 84030c40f2f91b433b3ccd21e0367d2f8b7c97b6..03cd2af813c3cca167b07115f03f6b5eae6d4185 100644
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
@@ -190,6 +190,12 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
net.minecraft.network.protocol.PacketUtils.ensureRunningOnSameThread(packet, this, this.server);
+ // Leaf start - Protocol core
+ if (this instanceof ServerGamePacketListenerImpl gamePacketListener) {
+ org.dreeam.leaf.protocol.Protocols.handle(gamePacketListener.player, discardedPayload);
+ }
+ // Leaf end - Protocol core
+
final net.minecraft.resources.ResourceLocation identifier = packet.payload().type().id();
final byte[] data = discardedPayload.data();
try {
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
index 76e7133c580725635d517bc8dd20aa10210133aa..d8bfb169b10bb2a742ecd0f4919db38da77998ad 100644
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -689,6 +689,7 @@ public abstract class PlayerList {
}
public @Nullable net.kyori.adventure.text.Component remove(ServerPlayer player, net.kyori.adventure.text.Component leaveMessage) {
org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerLeave(player); // Leaves - protocol
+ org.dreeam.leaf.protocol.Protocols.disconnected(player); // Leaf - Protocol core
// Paper end - Fix kick event leave message not being sent
org.purpurmc.purpur.task.BossBarTask.removeFromAll(player.getBukkitEntity()); // Purpur - Implement TPSBar
net.minecraft.server.network.ServerGamePacketListenerImpl.afkCooldown.remove(player.getBukkitEntity().getUniqueId()); // Leaf - Improve Purpur AFK system