mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 04:56:29 +00:00
8c5b837e05
Firstly, the old methods all routed to the CompletableFuture method. However, the CF method could not guarantee that if the caller was off-main that the future would be "completed" on-main. Since the callback methods used the CF one, this meant that the callback methods did not guarantee that the callbacks were to be called on the main thread. Now, all methods route to getChunkAtAsync(x, z, gen, urgent, cb) so that the methods with the callback are guaranteed to invoke the callback on the main thread. The CF behavior remains unchanged; it may still appear to complete on main if invoked off-main. Secondly, remove the scheduleOnMain invocation in the async chunk completion. This unnecessarily delays the callback by 1 tick. Thirdly, add getChunksAtAsync(minX, minZ, maxX, maxZ, ...) which will load chunks within an area. This method is provided as a helper as keeping all chunks loaded within an area can be complicated to implement for plugins (due to the lacking ticket API), and is already implemented internally anyways. Fourthly, remove the ticket addition that occured with getChunkAt and getChunkAtAsync. The ticket addition may delay the unloading of the chunk unnecessarily. It also fixes a very rare timing bug where the future/callback would be completed after the chunk unloads.
55 lines
4.0 KiB
Diff
55 lines
4.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Tamion <70228790+notTamion@users.noreply.github.com>
|
|
Date: Sun, 26 May 2024 22:20:21 +0200
|
|
Subject: [PATCH] Fix CraftBukkit drag system
|
|
|
|
== AT ==
|
|
public net.minecraft.world.inventory.AbstractContainerMenu quickcraftSlots
|
|
public net.minecraft.world.inventory.AbstractContainerMenu quickcraftStatus
|
|
public net.minecraft.world.inventory.AbstractContainerMenu quickcraftType
|
|
public net.minecraft.world.inventory.AbstractContainerMenu resetQuickCraft()V
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index bb3d444f7bf2b20a557cd39997f9943c90763432..65ee382684fe2d8dec621ca709880f7349208eae 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -3081,6 +3081,25 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
}
|
|
break;
|
|
case QUICK_CRAFT:
|
|
+ // Paper start - Fix CraftBukkit drag system
|
|
+ AbstractContainerMenu containerMenu = this.player.containerMenu;
|
|
+ int currentStatus = this.player.containerMenu.quickcraftStatus;
|
|
+ int newStatus = AbstractContainerMenu.getQuickcraftHeader(packet.getButtonNum());
|
|
+ if ((currentStatus != 1 || newStatus != 2 && currentStatus != newStatus)) {
|
|
+ } else if (containerMenu.getCarried().isEmpty()) {
|
|
+ } else if (newStatus == 0) {
|
|
+ } else if (newStatus == 1) {
|
|
+ } else if (newStatus == 2) {
|
|
+ if (!this.player.containerMenu.quickcraftSlots.isEmpty()) {
|
|
+ if (this.player.containerMenu.quickcraftSlots.size() == 1) {
|
|
+ int index = containerMenu.quickcraftSlots.iterator().next().index;
|
|
+ containerMenu.resetQuickCraft();
|
|
+ this.handleContainerClick(new ServerboundContainerClickPacket(packet.getContainerId(), packet.getStateId(), index, containerMenu.quickcraftType, net.minecraft.world.inventory.ClickType.PICKUP, packet.getCarriedItem(), packet.getChangedSlots()));
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Paper end - Fix CraftBukkit drag system
|
|
this.player.containerMenu.clicked(packet.getSlotNum(), packet.getButtonNum(), packet.getClickType(), this.player);
|
|
break;
|
|
case PICKUP_ALL:
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
|
|
index 78d0ff45c016e900d87010e8b26b0bb10e63f445..4680f77a275d8d2b226018db89a571ac25998dd8 100644
|
|
--- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
|
|
+++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
|
|
@@ -468,7 +468,7 @@ public abstract class AbstractContainerMenu {
|
|
}
|
|
} else if (this.quickcraftStatus == 2) {
|
|
if (!this.quickcraftSlots.isEmpty()) {
|
|
- if (false && this.quickcraftSlots.size() == 1) { // CraftBukkit - treat everything as a drag since we are unable to easily call InventoryClickEvent instead
|
|
+ if (this.quickcraftSlots.size() == 1) { // Paper - Fix CraftBukkit drag system
|
|
k = ((Slot) this.quickcraftSlots.iterator().next()).index;
|
|
this.resetQuickCraft();
|
|
this.doClick(k, this.quickcraftType, ClickType.PICKUP, player);
|