Skip to content

Commit

Permalink
Updated Upstream (Leaves)
Browse files Browse the repository at this point in the history
Upstream has released updates that appear to apply and compile correctly

Leaves Changes:
LeavesMC/Leaves@3992c79 Update Paper (#261)
LeavesMC/Leaves@df31300 Fix loop initialization (#263)
LeavesMC/Leaves@103beaa Disable crystal-portal proximity check (#260)
LeavesMC/Leaves@6ed6771 Fix fast resume (#258)
LeavesMC/Leaves@2ac9175 Fix Jade Protocol (#264)
LeavesMC/Leaves@fd5e8be Fix Empty ShulkerBox stack (#257)
LeavesMC/Leaves@d490f0d Update Syncmatica Protocol (#249)
LeavesMC/Leaves@072c07f Fix Empty ShulkerBox stack, again (#257)
LeavesMC/Leaves@752a60d Can disable LivingEntity aiStep alive check (#219)
LeavesMC/Leaves@1ad3ede Fix Replay not save mode, and issue #209 done
LeavesMC/Leaves@658cb0e Update alternative block placement protocol
LeavesMC/Leaves@d2a4562 Update Paper
LeavesMC/Leaves@bc4cd4f Update Servux Protocol
LeavesMC/Leaves@632f5c3 Leaves Plugin (#271)
LeavesMC/Leaves@6a3a5cd [release-skip] Enable Gradle parallel & cache
LeavesMC/Leaves@347e621 update leavesclip
LeavesMC/Leaves@21be64a Add scheduled bot remove (#274)
LeavesMC/Leaves@36813ac Update Paper
LeavesMC/Leaves@7d09a3a Fix #276 and #277
LeavesMC/Leaves@86d8553 Update PCA, fix #280
  • Loading branch information
Dreeam-qwq committed Jul 27, 2024
1 parent e3035c3 commit 921784f
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 59 deletions.
2 changes: 1 addition & 1 deletion patches/server/0029-Leaves-Server-Utils.patch
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and change store way to sql maybe?
Original license: GPLv3
Original project: https://github.com/LeavesMC/Leaves

Commit: a872cd0de5ea02a7abf6174842b7ba4b530bb025
Commit: 86d85530bc3cc448aea134690ae415fabec8e891

diff --git a/src/main/java/org/leavesmc/leaves/LeavesLogger.java b/src/main/java/org/leavesmc/leaves/LeavesLogger.java
new file mode 100644
Expand Down
64 changes: 59 additions & 5 deletions patches/server/0030-Leaves-Protocol-Core.patch
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,13 @@ index 0000000000000000000000000000000000000000..986d2a6641ff8017dddf3e5f2655adfc
+}
diff --git a/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
new file mode 100644
index 0000000000000000000000000000000000000000..e7ce2e7a1686f1775c0a2e0cd731294025d2833b
index 0000000000000000000000000000000000000000..b76eb38942171d22dcd767ea353f012e5920f1f5
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
@@ -0,0 +1,384 @@
@@ -0,0 +1,436 @@
+package org.leavesmc.leaves.protocol.core;
+
+import com.google.common.collect.ImmutableSet;
+import net.minecraft.network.FriendlyByteBuf;
+import net.minecraft.network.chat.Component;
+import net.minecraft.resources.ResourceLocation;
Expand All @@ -236,6 +237,7 @@ index 0000000000000000000000000000000000000000..e7ce2e7a1686f1775c0a2e0cd7312940
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
Expand All @@ -251,6 +253,7 @@ index 0000000000000000000000000000000000000000..e7ce2e7a1686f1775c0a2e0cd7312940
+
+ private static final Map<LeavesProtocol, Map<ProtocolHandler.PayloadReceiver, Executable>> KNOWN_TYPES = new HashMap<>();
+ private static final Map<LeavesProtocol, Map<ProtocolHandler.PayloadReceiver, Method>> KNOW_RECEIVERS = new HashMap<>();
+ private static Set<ResourceLocation> ALL_KNOWN_ID = new HashSet<>();
+
+ private static final List<Method> TICKERS = new ArrayList<>();
+ private static final List<Method> PLAYER_JOIN = new ArrayList<>();
Expand Down Expand Up @@ -310,8 +313,10 @@ index 0000000000000000000000000000000000000000..e7ce2e7a1686f1775c0a2e0cd7312940
+ if (!found) {
+ Constructor<? extends LeavesCustomPayload<?>> constructor = receiver.payload().getConstructor(PAYLOAD_PARAMETER_TYPES);
+ if (constructor.isAnnotationPresent(LeavesCustomPayload.New.class)) {
+ map.put(receiver, constructor);
+ constructor.setAccessible(true);
+ map.put(receiver, constructor);
+ } else {
+ throw new NoSuchMethodException();
+ }
+ }
+ } catch (NoSuchMethodException exception) {
Expand Down Expand Up @@ -363,6 +368,20 @@ index 0000000000000000000000000000000000000000..e7ce2e7a1686f1775c0a2e0cd7312940
+ KNOWN_TYPES.put(protocol, map);
+ }
+ }
+
+ for (LeavesProtocol protocol : KNOWN_TYPES.keySet()) {
+ Map<ProtocolHandler.PayloadReceiver, Executable> map = KNOWN_TYPES.get(protocol);
+ for (ProtocolHandler.PayloadReceiver receiver : map.keySet()) {
+ if (receiver.sendFabricRegister() && !receiver.ignoreId()) {
+ for (String payloadId : receiver.payloadId()) {
+ for (String namespace : protocol.namespace()) {
+ ALL_KNOWN_ID.add(new ResourceLocation(namespace, payloadId));
+ }
+ }
+ }
+ }
+ }
+ ALL_KNOWN_ID = ImmutableSet.copyOf(ALL_KNOWN_ID);
+ }
+
+ public static LeavesCustomPayload<?> decode(ResourceLocation id, FriendlyByteBuf buf) {
Expand Down Expand Up @@ -439,6 +458,8 @@ index 0000000000000000000000000000000000000000..e7ce2e7a1686f1775c0a2e0cd7312940
+ LOGGER.warning("Failed to handle player join, " + exception.getCause() + ": " + exception.getMessage());
+ }
+ }
+
+ ProtocolUtils.sendPayloadPacket(player, new FabricRegisterPayload(ALL_KNOWN_ID));
+ }
+
+ public static void handlePlayerLeave(ServerPlayer player) {
Expand Down Expand Up @@ -591,13 +612,44 @@ index 0000000000000000000000000000000000000000..e7ce2e7a1686f1775c0a2e0cd7312940
+ buf.writeBytes(data);
+ }
+ }
+
+ public record FabricRegisterPayload(
+ Set<ResourceLocation> channels) implements LeavesCustomPayload<FabricRegisterPayload> {
+
+ public static final ResourceLocation CHANNEL = ResourceLocation.withDefaultNamespace("register");
+
+ @New
+ public FabricRegisterPayload(ResourceLocation location, FriendlyByteBuf buf) {
+ this(buf.readCollection(HashSet::new, FriendlyByteBuf::readResourceLocation));
+ }
+
+ @Override
+ public void write(FriendlyByteBuf buf) {
+ boolean first = true;
+
+ ResourceLocation channel;
+ for (Iterator<ResourceLocation> var3 = this.channels.iterator(); var3.hasNext(); buf.writeBytes(channel.toString().getBytes(StandardCharsets.US_ASCII))) {
+ channel = var3.next();
+ if (first) {
+ first = false;
+ } else {
+ buf.writeByte(0);
+ }
+ }
+ }
+
+ @Override
+ public ResourceLocation id() {
+ return CHANNEL;
+ }
+ }
+}
diff --git a/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolHandler.java b/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..f941f095184cf4b7af284d1357ea1a85815e8a66
index 0000000000000000000000000000000000000000..9d71f8e6af24301bedf60f5c87e0bb3c1697d5e3
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolHandler.java
@@ -0,0 +1,61 @@
@@ -0,0 +1,63 @@
+package org.leavesmc.leaves.protocol.core;
+
+import java.lang.annotation.ElementType;
Expand All @@ -622,6 +674,8 @@ index 0000000000000000000000000000000000000000..f941f095184cf4b7af284d1357ea1a85
+ String[] payloadId() default "";
+
+ boolean ignoreId() default false;
+
+ boolean sendFabricRegister() default true;
+ }
+
+ @Target(ElementType.METHOD)
Expand Down
11 changes: 6 additions & 5 deletions patches/server/0031-Leaves-Jade-Protocol.patch
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ index c63bdbd72ecd45b8d5862a996636c0ce1e87166e..4e91895387b214cadc658b150ed6b88e
}
diff --git a/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java
new file mode 100644
index 0000000000000000000000000000000000000000..43ad624bbe334384de4e79d0075e67389648c014
index 0000000000000000000000000000000000000000..cc9f71e2bc8261f07fdb4d296cc8d13cfa2753ad
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java
@@ -0,0 +1,396 @@
@@ -0,0 +1,397 @@
+package org.leavesmc.leaves.protocol.jade;
+
+import io.netty.buffer.ByteBuf;
Expand Down Expand Up @@ -242,7 +242,7 @@ index 0000000000000000000000000000000000000000..43ad624bbe334384de4e79d0075e6738
+public class JadeProtocol {
+
+ public static PriorityStore<ResourceLocation, IJadeProvider> priorities;
+ private static List<Block> shearableBlocks = List.of();
+ private static List<Block> shearableBlocks = null;
+
+ public static final String PROTOCOL_ID = "jade";
+
Expand Down Expand Up @@ -325,9 +325,10 @@ index 0000000000000000000000000000000000000000..43ad624bbe334384de4e79d0075e6738
+
+ try {
+ shearableBlocks = Collections.unmodifiableList(LootTableMineableCollector.execute(
+ MinecraftServer.getServer().registryAccess().registryOrThrow(Registries.LOOT_TABLE),
+ Items.SHEARS.getDefaultInstance()));
+ MinecraftServer.getServer().reloadableRegistries().get().registryOrThrow(Registries.LOOT_TABLE),
+ Items.SHEARS.getDefaultInstance()));
+ } catch (Throwable ignore) {
+ shearableBlocks = List.of();
+ LeavesLogger.LOGGER.severe("Failed to collect shearable blocks");
+ }
+ }
Expand Down
63 changes: 48 additions & 15 deletions patches/server/0034-Leaves-Syncmatica-Protocol.patch
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ index c159340c3d7d90601bb69a4e1b997e372d48841a..9bff9c7fce4fec7687940f4212ac05d4
}
diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java
new file mode 100644
index 0000000000000000000000000000000000000000..3f06c2006877bd35dedca02ffba9e30b0391e022
index 0000000000000000000000000000000000000000..0704ac7825c69e69097b3e7c77763044f9fa9e1e
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java
@@ -0,0 +1,396 @@
Expand Down Expand Up @@ -158,12 +158,12 @@ index 0000000000000000000000000000000000000000..3f06c2006877bd35dedca02ffba9e30b
+ playerMap.remove(oldPlayer);
+ }
+
+ @ProtocolHandler.PayloadReceiver(payload = LeavesProtocolManager.LeavesPayload.class, ignoreId = true)
+ public static void onPacketGet(ServerPlayer player, LeavesProtocolManager.LeavesPayload payload) {
+ @ProtocolHandler.PayloadReceiver(payload = SyncmaticaPayload.class, payloadId = "main")
+ public static void onPacketGet(ServerPlayer player, SyncmaticaPayload payload) {
+ if (!org.dreeam.leaf.config.modules.network.ProtocolSupport.syncmaticaProtocol) {
+ return;
+ }
+ onPacket(player.connection.exchangeTarget, payload.id(), payload.data());
+ onPacket(player.connection.exchangeTarget, payload.packetType(), payload.data());
+ }
+
+ public static void onPacket(final @NotNull ExchangeTarget source, final ResourceLocation id, final FriendlyByteBuf packetBuf) {
Expand Down Expand Up @@ -1331,9 +1331,42 @@ index 0000000000000000000000000000000000000000..27a056b306daa91400946a30e68ce01d
+ }
+ }
+}
diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java
new file mode 100644
index 0000000000000000000000000000000000000000..cb5dffe81c4f0becad0ae2fbf7e9143f4fa577ef
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java
@@ -0,0 +1,27 @@
+package org.leavesmc.leaves.protocol.syncmatica;
+
+import net.minecraft.network.FriendlyByteBuf;
+import net.minecraft.resources.ResourceLocation;
+import org.leavesmc.leaves.protocol.core.LeavesCustomPayload;
+
+public record SyncmaticaPayload(ResourceLocation packetType,
+ FriendlyByteBuf data) implements LeavesCustomPayload<SyncmaticaPayload> {
+
+ private static final ResourceLocation NETWORK_ID = new ResourceLocation(SyncmaticaProtocol.PROTOCOL_ID, "main");
+
+ @New
+ public static SyncmaticaPayload decode(ResourceLocation location, FriendlyByteBuf buf) {
+ return new SyncmaticaPayload(buf.readResourceLocation(), new FriendlyByteBuf(buf.readBytes(buf.readableBytes())));
+ }
+
+ @Override
+ public void write(FriendlyByteBuf buf) {
+ buf.writeResourceLocation(this.packetType);
+ buf.writeBytes(this.data.readBytes(this.data.readableBytes()));
+ }
+
+ @Override
+ public ResourceLocation id() {
+ return NETWORK_ID;
+ }
+}
diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java
new file mode 100644
index 0000000000000000000000000000000000000000..4efe181c5fd6e0251b6beb148bd3fa07ed509c78
index 0000000000000000000000000000000000000000..d2625b1ca6fc207dfb8c282d3dc0baa2701479c9
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java
@@ -0,0 +1,122 @@
Expand All @@ -1354,7 +1387,7 @@ index 0000000000000000000000000000000000000000..4efe181c5fd6e0251b6beb148bd3fa07
+public class SyncmaticaProtocol {
+
+ public static final String PROTOCOL_ID = "syncmatica";
+ public static final String PROTOCOL_VERSION = "leaves-syncmatica-1.0.0";
+ public static final String PROTOCOL_VERSION = "leaves-syncmatica-1.1.0";
+
+ private static final File litematicFolder = new File("." + File.separator + "syncmatics");
+ private static final PlayerIdentifierProvider playerIdentifierProvider = new PlayerIdentifierProvider();
Expand Down Expand Up @@ -1690,17 +1723,18 @@ index 0000000000000000000000000000000000000000..0f45ef7f4abcd7cff627e5a3df2a9fca
+}
diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java
new file mode 100644
index 0000000000000000000000000000000000000000..1ce637d91f12f8fdd54fce38534861836b6a93ca
index 0000000000000000000000000000000000000000..b0da7abf0748d4bdb3141c28f201906157a0eaad
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java
@@ -0,0 +1,40 @@
@@ -0,0 +1,39 @@
+package org.leavesmc.leaves.protocol.syncmatica.exchange;
+
+import net.minecraft.network.FriendlyByteBuf;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.network.ServerGamePacketListenerImpl;
+import org.leavesmc.leaves.protocol.core.ProtocolUtils;
+import org.leavesmc.leaves.protocol.syncmatica.FeatureSet;
+import org.leavesmc.leaves.protocol.syncmatica.SyncmaticaPayload;
+
+import java.util.ArrayList;
+import java.util.Collection;
Expand All @@ -1717,9 +1751,7 @@ index 0000000000000000000000000000000000000000..1ce637d91f12f8fdd54fce3853486183
+ }
+
+ public void sendPacket(final ResourceLocation id, final FriendlyByteBuf packetBuf) {
+ ProtocolUtils.sendPayloadPacket(client.player, id, buf -> {
+ buf.writeBytes(packetBuf);
+ });
+ ProtocolUtils.sendPayloadPacket(client.player, new SyncmaticaPayload(id, packetBuf));
+ }
+
+ public FeatureSet getFeatureSet() {
Expand Down Expand Up @@ -1984,16 +2016,17 @@ index 0000000000000000000000000000000000000000..065a39942603f7b884cca40d8d7b4b47
+}
diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java
new file mode 100644
index 0000000000000000000000000000000000000000..9614fce87e2522690aac0af4c04d9fbcb72167af
index 0000000000000000000000000000000000000000..cb7aed6c0aa31cd46c071da7b483c63e755a6bff
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java
@@ -0,0 +1,65 @@
@@ -0,0 +1,66 @@
+package org.leavesmc.leaves.protocol.syncmatica.exchange;
+
+import io.netty.buffer.Unpooled;
+import net.minecraft.network.FriendlyByteBuf;
+import net.minecraft.resources.ResourceLocation;
+import org.jetbrains.annotations.NotNull;
+import org.leavesmc.leaves.protocol.syncmatica.CommunicationManager;
+import org.leavesmc.leaves.protocol.syncmatica.FeatureSet;
+import org.leavesmc.leaves.protocol.syncmatica.PacketType;
+import org.leavesmc.leaves.protocol.syncmatica.ServerPlacement;
Expand All @@ -2016,7 +2049,7 @@ index 0000000000000000000000000000000000000000..9614fce87e2522690aac0af4c04d9fbc
+ @Override
+ public void handle(final @NotNull ResourceLocation id, final FriendlyByteBuf packetBuf) {
+ if (id.equals(PacketType.REGISTER_VERSION.identifier)) {
+ String partnerVersion = packetBuf.readUtf(32767);
+ String partnerVersion = packetBuf.readUtf();
+ if (partnerVersion.equals("0.0.1")) {
+ close(false);
+ return;
Expand All @@ -2040,7 +2073,7 @@ index 0000000000000000000000000000000000000000..9614fce87e2522690aac0af4c04d9fbc
+ final Collection<ServerPlacement> l = SyncmaticaProtocol.getSyncmaticManager().getAll();
+ newBuf.writeInt(l.size());
+ for (final ServerPlacement p : l) {
+ getManager().putMetaData(p, newBuf, getPartner());
+ CommunicationManager.putMetaData(p, newBuf, getPartner());
+ }
+ getPartner().sendPacket(PacketType.CONFIRM_USER.identifier, newBuf);
+ succeed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Subject: [PATCH] Leaves: Disable moved wrongly threshold
Original license: GPLv3
Original project: https://github.com/LeavesMC/Leaves

Commit: e234432bd99e1c4b07c24d1dd247977226a7516a

diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index f0105e01f94352dee85f91ca2ae951311f4c052f..c9cf3499de2809c9983881c88029b39264030f94 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
Expand Down
Loading

0 comments on commit 921784f

Please sign in to comment.