Skip to content

Commit

Permalink
Try to fix LeavesMC#378 & LeavesMC#384
Browse files Browse the repository at this point in the history
  • Loading branch information
Lumine1909 committed Dec 27, 2024
1 parent e64ef21 commit 43f9f7d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions patches/server/0114-Bytebuf-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ index 5941800692ed06e17925ec6526ea38793a65de12..f77b2e12fb43039cf16a8511c9820859
}

diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 0a88fb90b72e9f4bda6067cb42e024bb44b5101b..b39a6c5dd2cde112c5c5a317591f5ca51701a0a0 100644
index 13dea31c8232cdb08aff09627e84711d2ef0aa6b..44371c123e4cdd2d5257cfeaaf3139b20e785769 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -471,6 +471,12 @@ public abstract class PlayerList {
Expand Down Expand Up @@ -63,7 +63,7 @@ index ea4def367b645a442e7ee4fd8b1b2075b8604ccb..54d99e5b42082c306e0ac16b2b5ba9ff
+ // Leaves end - Bytebuf API
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 08de38dfc4b2f6f48e9f3ae1d303712ea619e21f..707c64ec946bafd78da5f070ec3af750ebc1d5e7 100644
index d0132751fb057dc29e13ae3489beedb580225fa7..723db803297e06c053e160fd593dbed597eab82c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -3580,4 +3580,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
Expand Down Expand Up @@ -409,7 +409,7 @@ index 0000000000000000000000000000000000000000..9601eb5aa8cbcf1836cba7853af9ece2
+}
diff --git a/src/main/java/org/leavesmc/leaves/bytebuf/internal/InternalBytebufHandler.java b/src/main/java/org/leavesmc/leaves/bytebuf/internal/InternalBytebufHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..04dbb4cb7c3ea4979c33dba595208e22e6552b0a
index 0000000000000000000000000000000000000000..6d54803cf8007f16f41613ce4ca0e3a997de0c4e
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/bytebuf/internal/InternalBytebufHandler.java
@@ -0,0 +1,234 @@
Expand Down Expand Up @@ -577,7 +577,7 @@ index 0000000000000000000000000000000000000000..04dbb4cb7c3ea4979c33dba595208e22
+ return nmsPacket;
+ }
+ PacketType type = toEnumType(nmsPacket.type());
+ if (type == null) {
+ if (type == null || !type2CodecMap.containsKey(type)) {
+ return nmsPacket;
+ }
+ Packet packet = createBytebufPacket(type, nmsPacket);
Expand Down Expand Up @@ -638,11 +638,11 @@ index 0000000000000000000000000000000000000000..04dbb4cb7c3ea4979c33dba595208e22
+ }
+
+ public Packet createBytebufPacket(PacketType type, net.minecraft.network.protocol.Packet<?> nmsPacket) {
+ RegistryFriendlyByteBuf buf = new RegistryFriendlyByteBuf(Unpooled.buffer(), MinecraftServer.getServer().registryAccess());
+ StreamCodec<FriendlyByteBuf, net.minecraft.network.protocol.Packet<?>> codec = type2CodecMap.get(type);
+ if (codec == null) {
+ throw new UnsupportedOperationException("This feature is not completely finished yet, packet type " + type + " is not supported temporary.");
+ }
+ RegistryFriendlyByteBuf buf = new RegistryFriendlyByteBuf(Unpooled.buffer(), MinecraftServer.getServer().registryAccess());
+ codec.encode(buf, nmsPacket);
+ return new Packet(type, new WrappedBytebuf(buf));
+ }
Expand Down

0 comments on commit 43f9f7d

Please sign in to comment.