mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
Fix Item pickup not being cancellable on Forge (#301)
(cherry picked from commit 128141a99d)
This commit is contained in:
@@ -295,7 +295,14 @@ public class EventHandlerImplCommon {
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void event(EntityItemPickupEvent event) {
|
||||
PlayerEvent.PICKUP_ITEM_PRE.invoker().canPickup(event.getEntity(), event.getItem(), event.getItem().getItem());
|
||||
// note: this event is weird, cancel is equivalent to denying the pickup,
|
||||
// and setting the result to ALLOW will pick it up without adding it to the player's inventory
|
||||
var result = PlayerEvent.PICKUP_ITEM_PRE.invoker().canPickup(event.getEntity(), event.getItem(), event.getItem().getItem());
|
||||
if (result.isFalse()) {
|
||||
event.setCanceled(true);
|
||||
} else if (result.isTrue()) {
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
|
||||
Reference in New Issue
Block a user