[SPIGOT-1299] InventoryDragEvent unable to change both cursor and content Created: 18/Nov/15  Updated: 18/Nov/15

Status: Open
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Noisy Cat Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: 1.8, Craftbukkit, Spigot, bug, event
Environment:

Craftbukkit/Spigot 1.8.R3
git-Spigot-5f38d38-18fbb24 (MC: 1.8.8) (Implementing API version 1.8.8-R0.1-SNAPSHOT)



 Description   

In the description of InventoryDragEvent one can read:
Any modifications to slots that are modified by the results of this InventoryDragEvent will be overwritten. To change these slots, this event should be cancelled and the changes applied.

However, after cancelling the event you are unable to change the cursor contents.

From Container.patch, line 78:

if (event.getResult() != Result.DENY) {
    for (Map.Entry<Integer, ItemStack> dslot : draggedSlots.entrySet()) {
    view.setItem(dslot.getKey(), CraftItemStack.asBukkitCopy(dslot.getValue()));
    
    if (playerinventory.getCarried() != null) {
        playerinventory.setCarried(CraftItemStack.asNMSCopy(event.getCursor()));
        needsUpdate = true;
    }
} else {
    playerinventory.setCarried(oldCursor);
}

There is no way to edit both the contents and cursor during the event execution. The event could set the cursor to event-changed value regardless of event result:

if (event.getResult() != Result.DENY) {
    for (Map.Entry<Integer, ItemStack> dslot : draggedSlots.entrySet()) {
    view.setItem(dslot.getKey(), CraftItemStack.asBukkitCopy(dslot.getValue()));
} else {
    playerinventory.setCarried(oldCursor);
}

if (playerinventory.getCarried() != null) {
    playerinventory.setCarried(CraftItemStack.asNMSCopy(event.getCursor()));
    needsUpdate = true;
}


 Comments   
Comment by SpigotMC [ 18/Nov/15 ]

Your build is not the latest and therefore may be the reason you are having this issue. Spigot is 1 version(s) behind. CraftBukkit is 0 version(s) behind. This message was automatically generated and is not guaranteed to be a solution to your issue.

Generated at Sat Dec 13 15:25:08 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.