Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Fix CraftBukkit drag system

Open notTamion opened this issue 1 year ago • 3 comments

resolves #9915

notTamion avatar May 12 '24 13:05 notTamion

I feel like despite what CB's comment says about being unable to call the click event, we could call it by just mimicking some of the checks in the case QUICK_CRAFT in ServerGamePacketListenerImpl.

int currentStatus = this.player.containerMenu.quickcraftStatus;
int newStatus = AbstractContainerMenu.getQuickcraftHeader(packet.getButtonNum());
if ((currentStatus != 1 || newStatus != 2 && currentStatus != newStatus)) {
} else if (this.player.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) {
            // fire "click" event
        }
    }
}

Just put this right before the call to AbstractContainerMenu#clicked

Machine-Maker avatar May 12 '24 21:05 Machine-Maker

I am having a bit of trouble understanding what you mean exactly. but if i am interpreting your comment correctly that wouldn't work because we don't have access to the new Items that early in the stack. i should probably also mention that cb's comment is wrong (assuming we want to call InventoryDragEvent if the mouse is moved in just the same slot, this way we don't break the existing calls for InventoryDragEvent and this also allows plugins to check whether or not the single item was dragged into the slot or clicked which might be useful for some developers)

notTamion avatar May 13 '24 13:05 notTamion

@Machine-Maker i was able to construct a packet that seems to be calling the event correctly aswell as not breaking vanilla logic (i think) like you proposed yesterday.

notTamion avatar May 27 '24 17:05 notTamion