mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-23 08:59:23 +00:00
Upstream has released updates that appear to apply and compile correctly Leaves Changes: LeavesMC/Leaves@08bfa446 Lithium Sleeping Block Entity(#618) (#630) LeavesMC/Leaves@610eee60 fix: fix bot resume CME (#635) LeavesMC/Leaves@04dac366 Fix vanilla display name (#638) LeavesMC/Leaves@e5aba7eb feat: hopper counter unlimited speed(#625) (#639) LeavesMC/Leaves@e44e469a fix: fix SleepingBlockEntity crash when /tick freeze (#640) LeavesMC/Leaves@5d653e31 fix: fix faster chunk serialization patch (#641) LeavesMC/Leaves@cb6cd658 [ci/skip] chore: fix patch header LeavesMC/Leaves@8d9a5b2f [ci/skip]chore: rename hopper counter enable config (#644) LeavesMC/Leaves@cc019e8f [ci/skip] feat: add Bukkit.getFeatureManager api (#645) LeavesMC/Leaves@81da0c5e [ci/skip] Bring back LivingEntity effect CME (#648) LeavesMC/Leaves@ea91106a fix: fix hopper counter config (#646) LeavesMC/Leaves@230e0987 feat: mount action(#619) (#649) LeavesMC/Leaves@d9f7afc4 fix: fix sleeping block entity(#654) (#655) LeavesMC/Leaves@12f665c0 Refactor actions (#650) LeavesMC/Leaves@c29ff9a8 feat: swap action (#657) LeavesMC/Leaves@3c09044e fix: fix grindstone curse book overstacking(#658) (#659) LeavesMC/Leaves@e05f3f7c Update paper, revert #632 (#662) LeavesMC/Leaves@0c866281 Bot Improvements (#661) LeavesMC/Leaves@956f0227 feat: add skipTripwireHookPlacementValidation to mc-technical-mode, and format config (#664) LeavesMC/Leaves@e047327c fix: fix bot use raytrace (#669) LeavesMC/Leaves@29327349 Fix #667 (#668) LeavesMC/Leaves@08f53c97 Fix bot cant get entity tracker (#670) LeavesMC/Leaves@e0d62b4e fix photographer bugs (#666) LeavesMC/Leaves@d094bdad fix: fix raid(#626) (#671) LeavesMC/Leaves@678d4e20 Revert "Fix bot cant get entity tracker (#670)" LeavesMC/Leaves@e298d097 [ci/skip] fix: fix patch name (#672) LeavesMC/Leaves@099be5b8 [ci/skip] fix: fix push to api fail when commit contains double quotation marks (#677) LeavesMC/Leaves@ba8993d3 Fix fakeplayer cant get entity tracker correctly (#676) LeavesMC/Leaves@d93e9766 feat: merge old raid config, fix bugs (#680) LeavesMC/Leaves@bf55b2a4 fix: fix sleeping block entity bug (#682) LeavesMC/Leaves@5366b382 Fix creative no clip with projectile (#683) LeavesMC/Leaves@e55edbf8 Resolves #685 (#687) LeavesMC/Leaves@a591ec57 Do not tick Arrow life regardless (#688) LeavesMC/Leaves@3623aea8 fix: stupid me (#689) LeavesMC/Leaves@73e63912 feat: update leavesclip to 3.0.7 (#681) LeavesMC/Leaves@bb5a1dff [ci/skip] fix: fix comment (#692) LeavesMC/Leaves@d87bc544 Fix #690 (#691) LeavesMC/Leaves@79d9ef74 Update paper (#693) LeavesMC/Leaves@71790286 Fix optimize noise generation LeavesMC/Leaves@3ffbde0b Optimize config transfer and remove LeavesMC/Leaves@62e62242 feat: add logger for internal plugin, and format api code (#696) LeavesMC/Leaves@f37e9d37 Fix fakeplayer break action LeavesMC/Leaves@aeb8e07d Fix fakeplayer break action * 2 LeavesMC/Leaves@40af0399 Fix StackableShulker config validator LeavesMC/Leaves@122c7365 Fix fakeplayer use action LeavesMC/Leaves@0ee80784 fix: fix photographer bugs (#699) LeavesMC/Leaves@a30c9abb Remove, and opt config and config command LeavesMC/Leaves@4b21a968 New shears wrench (#700) LeavesMC/Leaves@0f40159c Enhance update suppression (#701) LeavesMC/Leaves@374605cd Fix bot (#705) LeavesMC/Leaves@ff563baf Fix creative no clip can attract xp-orb (#706) LeavesMC/Leaves@f0de3ecd refactor: use client side judgement instead of special judgement (#708)
128 lines
7.5 KiB
Diff
128 lines
7.5 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
|
|
|
|
Original license: GPLv3
|
|
Original project: https://github.com/LeavesMC/Leaves
|
|
|
|
Commit: f0de3ecd91c89fc7da1230eb5633eac76982fd06
|
|
|
|
diff --git a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
|
|
index fb263fa1f30a7dfcb7ec2656abfb38e5fe88eac9..56fd1ed7ccaf96e7eedea60fbdbf7f934939d563 100644
|
|
--- a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
|
|
+++ b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
|
|
@@ -40,13 +40,22 @@ public interface CustomPacketPayload {
|
|
|
|
@Override
|
|
public void encode(B buffer, CustomPacketPayload value) {
|
|
+ // Leaves start - protocol core
|
|
+ if (value instanceof org.leavesmc.leaves.protocol.core.LeavesCustomPayload payload) {
|
|
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.encode(buffer, payload);
|
|
+ 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 payload = org.leavesmc.leaves.protocol.core.LeavesProtocolManager.decode(resourceLocation, buffer);
|
|
+ return java.util.Objects.requireNonNullElseGet(payload, () -> this.findCodec(resourceLocation).decode(buffer));
|
|
+ // Leaves end - protocol core
|
|
}
|
|
};
|
|
}
|
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
|
index 7b4437c06c2ede0be7dd58b42863e88b4b205106..73c63330b67b3d16ceebc644ce177980af25266b 100644
|
|
--- a/net/minecraft/server/MinecraftServer.java
|
|
+++ b/net/minecraft/server/MinecraftServer.java
|
|
@@ -1738,6 +1738,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
GameTestTicker.SINGLETON.tick();
|
|
}
|
|
|
|
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleTick(tickCount); // 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 9af8f731bd583c46b93336b635ba9a5cea7e1ff3..82c22ca54cc7c8371b744c93f133dfc2b798195b 100644
|
|
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
@@ -64,6 +64,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
|
public @Nullable String playerBrand;
|
|
public final java.util.Set<String> pluginMessagerChannels;
|
|
// Paper end - retain certain values
|
|
+ public final GameProfile profile; // Leaves - protocol core
|
|
|
|
public ServerCommonPacketListenerImpl(MinecraftServer server, Connection connection, CommonListenerCookie cookie) {
|
|
this.server = server;
|
|
@@ -77,6 +78,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
|
this.pluginMessagerChannels = cookie.channels();
|
|
this.keepAlive = cookie.keepAlive();
|
|
// Paper end
|
|
+ this.profile = cookie.gameProfile(); // Leaves - protocol core
|
|
}
|
|
|
|
// Paper start - configuration phase API
|
|
@@ -169,6 +171,18 @@ 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(org.leavesmc.leaves.protocol.core.ProtocolUtils.createSelector(this), leavesPayload);
|
|
+ return;
|
|
+ }
|
|
+ if (packet.payload() instanceof net.minecraft.network.protocol.common.custom.DiscardedPayload(net.minecraft.resources.ResourceLocation id, byte[] data)) {
|
|
+ if (org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleBytebuf(org.leavesmc.leaves.protocol.core.ProtocolUtils.createSelector(this), id, io.netty.buffer.Unpooled.wrappedBuffer(data))) {
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+ // Leaves end - protocol
|
|
+
|
|
// Paper start
|
|
if (!(packet.payload() instanceof final net.minecraft.network.protocol.common.custom.DiscardedPayload discardedPayload)) {
|
|
return;
|
|
@@ -234,6 +248,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
|
final String channel = new String(data, from, length, java.nio.charset.StandardCharsets.US_ASCII);
|
|
if (register) {
|
|
bridge.addChannel(channel);
|
|
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleMinecraftRegister(channel, org.leavesmc.leaves.protocol.core.ProtocolUtils.createSelector(this)); // Leaves - protocol
|
|
} else {
|
|
bridge.removeChannel(channel);
|
|
}
|
|
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
|
index c315655501aa79333c4a1c5b58382f186df5f7a1..8724b03cbe22492c17d8d8c60fbd06d60a32925a 100644
|
|
--- a/net/minecraft/server/players/PlayerList.java
|
|
+++ b/net/minecraft/server/players/PlayerList.java
|
|
@@ -346,6 +346,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
|
|
@@ -525,6 +527,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 @Nullable 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.level();
|
|
@@ -1496,6 +1499,7 @@ public abstract class PlayerList {
|
|
serverPlayer.connection.send(clientboundUpdateRecipesPacket);
|
|
serverPlayer.getRecipeBook().sendInitialRecipeBook(serverPlayer);
|
|
}
|
|
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleDataPackReload(); // Leaves - protocol core
|
|
}
|
|
|
|
public boolean isAllowCommandsForAllPlayers() {
|