Can not cancel DropItemEvent.Pre event in sponge 8.0

@Listener(order = Order.FIRST)
public void onDropItem(DropItemEvent.Pre e) {
e.setCancelled(true);
}

not working.

please help me.

DropItemEvent.Pre’s javadoc:

    /**
     * Handles {@link ItemStack}s and may be called before an {@link Item}
     * entity is actually constructed.
     *
     * <p>Note: This is not guaranteed to fire due to custom handling within
     * a mod or plugin.</p>
     *
     * <p>Canceling this event only prevents the items from being dropped.
     * Inventories or blocks affected are not rolled back.</p>
     */

“not working” is very unclear but I think you should cancel DropItemEvent directly instead.

1 Like