Skip to content

Commit

Permalink
Fix Replay API (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yh-china committed Jun 5, 2024
1 parent 7dc9e87 commit 472b55d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions patches/server/0042-Jade-Protocol.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@
Expand Down Expand Up @@ -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 @@
Expand Down Expand Up @@ -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 @@
Expand Down
13 changes: 6 additions & 7 deletions patches/server/0105-Replay-Mod-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -703,15 +703,13 @@ 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;
+import net.minecraft.network.protocol.game.ClientboundSystemChatPacket;
+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;
Expand Down Expand Up @@ -792,7 +790,7 @@ index 0000000000000000000000000000000000000000..94bda07ec3eafb902023801a4f10e294
+ List<KnownPack> knownPackslist = server.getResourceManager().listPacks().flatMap((iresourcepack) -> iresourcepack.location().knownPackInfo().stream()).toList();
+ LayeredRegistryAccess<RegistryLayer> layeredregistryaccess = server.registries();
+
+ savePacket(new ClientboundSelectKnownPacks(knownPackslist));
+ savePacket(new ClientboundSelectKnownPacks(knownPackslist), ConnectionProtocol.CONFIGURATION);
+ DynamicOps<Tag> dynamicOps = layeredregistryaccess.compositeAccess().createSerializationContext(NbtOps.INSTANCE);
+ RegistrySynchronization.packRegistries(
+ dynamicOps,
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 472b55d

Please sign in to comment.