Combit/src/main/java/io/gitlab/jfronny/combit/events/PlayerAttackEvent.java

24 lines
843 B
Java
Raw Normal View History

2021-12-29 23:36:10 +01:00
package io.gitlab.jfronny.combit.events;
2020-10-27 20:13:31 +01:00
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ActionResult;
2021-12-29 23:36:10 +01:00
public interface PlayerAttackEvent {
Event<PlayerAttackEvent> EVENT = EventFactory.createArrayBacked(PlayerAttackEvent.class,
2020-10-27 20:13:31 +01:00
(listeners) -> (player, target) -> {
2021-12-29 23:36:10 +01:00
for (PlayerAttackEvent event : listeners) {
2020-10-27 20:13:31 +01:00
ActionResult result = event.attackEntity(player, target);
if (result != ActionResult.PASS) {
return result;
}
}
return ActionResult.PASS;
});
ActionResult attackEntity(PlayerEntity player, Entity target);
}