From 472b55dfdb1845bd9ba45ee7a0a34f86d72e1ce7 Mon Sep 17 00:00:00 2001 From: violetc <58360096+s-yh-china@users.noreply.github.com> Date: Wed, 5 Jun 2024 18:18:15 +0800 Subject: [PATCH] Fix Replay API (#221) --- patches/server/0042-Jade-Protocol.patch | 6 +++--- patches/server/0105-Replay-Mod-API.patch | 13 ++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/patches/server/0042-Jade-Protocol.patch b/patches/server/0042-Jade-Protocol.patch index 49113e62..29c22d7b 100644 --- a/patches/server/0042-Jade-Protocol.patch +++ b/patches/server/0042-Jade-Protocol.patch @@ -536,7 +536,7 @@ index 0000000000000000000000000000000000000000..14613e35a6785fc599b1520a667e1311 +} diff --git a/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java b/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java new file mode 100644 -index 0000000000000000000000000000000000000000..7ddbc03b39b2a9863ed7b223e235366ddb0de894 +index 0000000000000000000000000000000000000000..7ef50f5b7437d8ec918d26b7a564161ed08aabbd --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java @@ -0,0 +1,142 @@ @@ -717,7 +717,7 @@ index 0000000000000000000000000000000000000000..9d2b6bf80eaaf67b4a9df6bd46470838 +} diff --git a/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BlockStorageProvider.java b/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BlockStorageProvider.java new file mode 100644 -index 0000000000000000000000000000000000000000..400686ce911049aab224cd42d5ee018f37d2f014 +index 0000000000000000000000000000000000000000..89f040d390d017807f2baf7ed8925acd62d083bb --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BlockStorageProvider.java @@ -0,0 +1,65 @@ @@ -1294,7 +1294,7 @@ index 0000000000000000000000000000000000000000..d75c6889c16d77c251fbc5d921d43cee +} diff --git a/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/EntityStorageProvider.java b/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/EntityStorageProvider.java new file mode 100644 -index 0000000000000000000000000000000000000000..4f2bb19247f05cfae47243cf9950c6010d6d16e0 +index 0000000000000000000000000000000000000000..851dd6f0a8e8a13746a40c8b372103fd3d03bfc6 --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/EntityStorageProvider.java @@ -0,0 +1,56 @@ diff --git a/patches/server/0105-Replay-Mod-API.patch b/patches/server/0105-Replay-Mod-API.patch index 30f475c4..3e2faf5f 100644 --- a/patches/server/0105-Replay-Mod-API.patch +++ b/patches/server/0105-Replay-Mod-API.patch @@ -674,23 +674,23 @@ index 0000000000000000000000000000000000000000..0e8cd7e878ec1294d6cb830a004eeefd +} diff --git a/src/main/java/org/leavesmc/leaves/replay/Recorder.java b/src/main/java/org/leavesmc/leaves/replay/Recorder.java new file mode 100644 -index 0000000000000000000000000000000000000000..94bda07ec3eafb902023801a4f10e294a12d4cf1 +index 0000000000000000000000000000000000000000..49cf69a916eed2ec4753f286e3a53cc8d0429a41 --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/replay/Recorder.java -@@ -0,0 +1,289 @@ +@@ -0,0 +1,288 @@ +package org.leavesmc.leaves.replay; + +import com.mojang.serialization.DynamicOps; +import io.netty.channel.local.LocalChannel; +import net.minecraft.SharedConstants; +import net.minecraft.core.LayeredRegistryAccess; -+import net.minecraft.core.RegistryAccess; +import net.minecraft.core.RegistrySynchronization; +import net.minecraft.nbt.NbtOps; +import net.minecraft.nbt.Tag; +import net.minecraft.network.Connection; +import net.minecraft.network.ConnectionProtocol; +import net.minecraft.network.PacketSendListener; ++import net.minecraft.network.protocol.BundlePacket; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.PacketFlow; +import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; @@ -703,7 +703,6 @@ index 0000000000000000000000000000000000000000..94bda07ec3eafb902023801a4f10e294 +import net.minecraft.network.protocol.configuration.ClientboundSelectKnownPacks; +import net.minecraft.network.protocol.configuration.ClientboundUpdateEnabledFeaturesPacket; +import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; -+import net.minecraft.network.protocol.game.ClientboundBundlePacket; +import net.minecraft.network.protocol.game.ClientboundGameEventPacket; +import net.minecraft.network.protocol.game.ClientboundPlayerChatPacket; +import net.minecraft.network.protocol.game.ClientboundSetTimePacket; @@ -711,7 +710,6 @@ index 0000000000000000000000000000000000000000..94bda07ec3eafb902023801a4f10e294 +import net.minecraft.network.protocol.login.ClientboundGameProfilePacket; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.RegistryLayer; -+import net.minecraft.server.network.config.ServerResourcePackConfigurationTask; +import net.minecraft.server.packs.repository.KnownPack; +import net.minecraft.tags.TagNetworkSerialization; +import net.minecraft.world.entity.EntityType; @@ -792,7 +790,7 @@ index 0000000000000000000000000000000000000000..94bda07ec3eafb902023801a4f10e294 + List knownPackslist = server.getResourceManager().listPacks().flatMap((iresourcepack) -> iresourcepack.location().knownPackInfo().stream()).toList(); + LayeredRegistryAccess layeredregistryaccess = server.registries(); + -+ savePacket(new ClientboundSelectKnownPacks(knownPackslist)); ++ savePacket(new ClientboundSelectKnownPacks(knownPackslist), ConnectionProtocol.CONFIGURATION); + DynamicOps dynamicOps = layeredregistryaccess.compositeAccess().createSerializationContext(NbtOps.INSTANCE); + RegistrySynchronization.packRegistries( + dynamicOps, @@ -856,10 +854,11 @@ index 0000000000000000000000000000000000000000..94bda07ec3eafb902023801a4f10e294 + @Override + public void send(@NotNull Packet packet, @Nullable PacketSendListener callbacks, boolean flush) { + if (!stopped) { -+ if (packet instanceof ClientboundBundlePacket packet1) { ++ if (packet instanceof BundlePacket packet1) { + packet1.subPackets().forEach(subPacket -> { + send(subPacket, null); + }); ++ return; + } + + if (packet instanceof ClientboundAddEntityPacket packet1) {