mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
Add PlayerEvent.ATTACK_ENTITY (#380)
[ci skip] * Add PlayerEvent.ATTACK_ENTITY * Fired from Forge's AttackEntityEvent and Fabric's AttackEntityCallback * When player is about to attack any entity (not just living) with left-click * javadoc parameter alignment * import cleanup
This commit is contained in:
@@ -431,6 +431,14 @@ public class EventHandlerImplCommon {
|
||||
LootEvent.MODIFY_LOOT_TABLE.invoker().modifyLootTable(event.getLootTableManager(), event.getName(), new LootTableModificationContextImpl(event.getTable()), true);
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void event(AttackEntityEvent event) {
|
||||
EventResult result = PlayerEvent.ATTACK_ENTITY.invoker().attack(event.getPlayer(), event.getPlayer().level, event.getTarget(), event.getPlayer().getUsedItemHand(), null);
|
||||
if (result.isFalse()) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public interface WorldEventAttachment {
|
||||
LevelAccessor architectury$getAttachedLevel();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user