mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-23 00:49:31 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@30fdfb1a [ci/skip] Fix docs for DamageResistant (#11992) PaperMC/Paper@6b7650d8 Only add goat horn once (#12001) PaperMC/Paper@30046e04 Fix a rare crash with a concurrent modification of scaled health attributes (#12002) PaperMC/Paper@88bbead1 Flush regionfiles on save configuration option PaperMC/Paper@336ea9df Check for empty when sending equipment changes (#12008) PaperMC/Paper@939bb782 Add RayTraceConfigurationBuilder (#11907) PaperMC/Paper@81bb82f5 Fix wrong piston world border check (#12007) PaperMC/Paper@ce95b5d6 Use proper default for setting null display background color (#12010) PaperMC/Paper@2477f1f6 [ci/skip] fix and improvements for docs in ConsumeEffect component (#11998) PaperMC/Paper@fb5b173c Add PlayerClientLoadedWorldEvent (#11940) PaperMC/Paper@3af5e771 Add Player#give (#11995) PaperMC/Paper@7e21cb81 fix PlayerChangedMainHandEvent javadoc (#12020) PaperMC/Paper@5a34bf04 Correctly retrun true for empty input shapes in EntityGetter#isUnobstructed PaperMC/Paper@a392d475 Make Watchdog thread extend TickThread Gale Changes: Dreeam-qwq/Gale@f9080a7e Updated Upstream (Paper) Dreeam-qwq/Gale@ff0596c1 [ci/skip] Fix upstream commit sh on mac Dreeam-qwq/Gale@24970274 [ci/skip] Hermanez - Wutaf Dreeam-qwq/Gale@85eabf60 [ci/skip] cleanup Dreeam-qwq/Gale@7d9faf00 [ci/skip] cleanup & drop xor-shift random Dreeam-qwq/Gale@7af04981 [ci/skip] cleanup Dreeam-qwq/Gale@4d5d39df [ci/skip] Remove useless params standardize in upstream commit generator Dreeam-qwq/Gale@964f16ff Updated Upstream (Paper) Dreeam-qwq/Gale@0566a223 [ci/skip] cleanup Dreeam-qwq/Gale@5e3f6740 [ci/skip] cleanup work finished Dreeam-qwq/Gale@98a66cfb Updated Upstream (Paper) Dreeam-qwq/Gale@f7736578 [ci/skip] Update upstreamCommit.sh Dreeam-qwq/Gale@1c46c816 Updated Upstream (Paper) Dreeam-qwq/Gale@2b0a4c09 [ci/skip] Skip tests during auto update validate phase Purpur Changes: PurpurMC/Purpur@4a0a86b9 Updated Upstream (Paper) PurpurMC/Purpur@7399988c Fix hover in /plugins PurpurMC/Purpur@5e5857dc [ci/skip] modify ci skip references in paper upstream commits PurpurMC/Purpur@5583a3f1 Updated Upstream (Paper)
114 lines
6.7 KiB
Diff
114 lines
6.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
Date: Tue, 26 Sep 2023 19:00:41 +0800
|
|
Subject: [PATCH] Leaves: Protocol Core
|
|
|
|
TODO: Check whether Leaves's Return-nether-portal-fix.patch improves performance
|
|
and change store way to sql maybe?
|
|
|
|
Original license: GPLv3
|
|
Original project: https://github.com/LeavesMC/Leaves
|
|
|
|
Commit: 0O0oO00o0oO
|
|
|
|
diff --git a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
|
|
index fb263fa1f30a7dfcb7ec2656abfb38e5fe88eac9..96ec0a0133ec244a5eb79dfcb34e7f9de22ea0f4 100644
|
|
--- a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
|
|
+++ b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
|
|
@@ -40,13 +40,23 @@ public interface CustomPacketPayload {
|
|
|
|
@Override
|
|
public void encode(B buffer, CustomPacketPayload value) {
|
|
+ // Leaves start - protocol core
|
|
+ if (value instanceof org.leavesmc.leaves.protocol.core.LeavesCustomPayload<?> leavesCustomPayload) {
|
|
+ buffer.writeResourceLocation(leavesCustomPayload.id());
|
|
+ leavesCustomPayload.write(buffer);
|
|
+ return;
|
|
+ }
|
|
+ // Leaves end - protocol core
|
|
this.writeCap(buffer, value.type(), value);
|
|
}
|
|
|
|
@Override
|
|
public CustomPacketPayload decode(B buffer) {
|
|
ResourceLocation resourceLocation = buffer.readResourceLocation();
|
|
- return (CustomPacketPayload)this.findCodec(resourceLocation).decode(buffer);
|
|
+ // Leaves start - protocol core
|
|
+ var leavesCustomPayload = org.leavesmc.leaves.protocol.core.LeavesProtocolManager.decode(resourceLocation, buffer);
|
|
+ return java.util.Objects.requireNonNullElseGet(leavesCustomPayload, () -> this.findCodec(resourceLocation).decode(buffer));
|
|
+ // Leaves end - protocol core
|
|
}
|
|
};
|
|
}
|
|
diff --git a/net/minecraft/resources/ResourceLocation.java b/net/minecraft/resources/ResourceLocation.java
|
|
index ea8cfa76093c70a44d065c1f80adaa9127fe4e07..7435e2c3f0defe98cbaa488219974887ee572c57 100644
|
|
--- a/net/minecraft/resources/ResourceLocation.java
|
|
+++ b/net/minecraft/resources/ResourceLocation.java
|
|
@@ -36,7 +36,7 @@ public final class ResourceLocation implements Comparable<ResourceLocation> {
|
|
private final String namespace;
|
|
private final String path;
|
|
|
|
- private ResourceLocation(String namespace, String path) {
|
|
+ public ResourceLocation(String namespace, String path) { // Leaves - private -> public
|
|
assert isValidNamespace(namespace);
|
|
|
|
assert isValidPath(path);
|
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
|
index 047a09cf4a2c32e714aacedeccb0928ef2c7dfa9..dddbb18992348fb7e8a6552423d134809cd7fdbc 100644
|
|
--- a/net/minecraft/server/MinecraftServer.java
|
|
+++ b/net/minecraft/server/MinecraftServer.java
|
|
@@ -1747,6 +1747,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
GameTestTicker.SINGLETON.tick();
|
|
}
|
|
|
|
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleTick(); // Leaves - protocol
|
|
+
|
|
for (int i = 0; i < this.tickables.size(); i++) {
|
|
this.tickables.get(i).run();
|
|
}
|
|
diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
index de115ee71fa240440b54c553e0d3ddaf4c0dfca0..ee8cdd532b73180cb484fcc37c36f09c40faacda 100644
|
|
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
@@ -151,6 +151,11 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
|
|
|
@Override
|
|
public void handleCustomPayload(ServerboundCustomPayloadPacket packet) {
|
|
+ // Leaves start - protocol
|
|
+ if (packet.payload() instanceof org.leavesmc.leaves.protocol.core.LeavesCustomPayload<?> leavesPayload) {
|
|
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePayload(player, leavesPayload);
|
|
+ }
|
|
+ // Leaves end - protocol
|
|
// CraftBukkit start
|
|
// Paper start - Brand support
|
|
if (packet.payload() instanceof net.minecraft.network.protocol.common.custom.BrandPayload(String brand)) {
|
|
@@ -169,6 +174,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
|
String channels = payload.toString(com.google.common.base.Charsets.UTF_8);
|
|
for (String channel : channels.split("\0")) {
|
|
this.getCraftPlayer().addChannel(channel);
|
|
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleMinecraftRegister(channel, player); // Leaves - protocol
|
|
}
|
|
} catch (Exception ex) {
|
|
ServerGamePacketListenerImpl.LOGGER.error("Couldn't register custom payload", ex);
|
|
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
|
index d2c11832d3ff9b01ccc3cdd5f77673eb7a844dae..0e81a445a4f960eab5c873bc16f79a9ebfab0122 100644
|
|
--- a/net/minecraft/server/players/PlayerList.java
|
|
+++ b/net/minecraft/server/players/PlayerList.java
|
|
@@ -341,6 +341,8 @@ public abstract class PlayerList {
|
|
|
|
player.didPlayerJoinEvent = true; // Gale - EMC - do not process chat/commands before player has joined
|
|
|
|
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // Leaves - protocol
|
|
+
|
|
final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage();
|
|
|
|
if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure
|
|
@@ -518,6 +520,7 @@ public abstract class PlayerList {
|
|
return this.remove(player, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? player.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(player.getDisplayName())));
|
|
}
|
|
public net.kyori.adventure.text.Component remove(ServerPlayer player, net.kyori.adventure.text.Component leaveMessage) {
|
|
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerLeave(player); // Leaves - protocol
|
|
// Paper end - Fix kick event leave message not being sent
|
|
org.purpurmc.purpur.task.BossBarTask.removeFromAll(player.getBukkitEntity()); // Purpur - Implement TPSBar
|
|
ServerLevel serverLevel = player.serverLevel();
|