mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
[ci skip] Fix Item pickup not being cancellable on Forge (#301)
This commit is contained in:
@@ -296,7 +296,14 @@ public class EventHandlerImplCommon {
|
|||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||||
public static void event(EntityItemPickupEvent event) {
|
public static void event(EntityItemPickupEvent event) {
|
||||||
PlayerEvent.PICKUP_ITEM_PRE.invoker().canPickup(event.getPlayer(), 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.getPlayer(), event.getItem(), event.getItem().getItem());
|
||||||
|
if (result.isFalse()) {
|
||||||
|
event.setCanceled(true);
|
||||||
|
} else if (result.isTrue()) {
|
||||||
|
event.setResult(Event.Result.ALLOW);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||||
|
|||||||
Reference in New Issue
Block a user