Search in sources :

Example 1 with EntityCombustByBlockEvent

use of org.bukkit.event.entity.EntityCombustByBlockEvent in project Arclight by IzzelAliz.

the class EntityMixin method arclight$setOnFireFromLava$bukkitEvent.

@Redirect(method = "setOnFireFromLava", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setFire(I)V"))
public void arclight$setOnFireFromLava$bukkitEvent(Entity entity, int seconds) {
    if ((Object) this instanceof LivingEntity && fire <= 0) {
        // ((WorldServer) this.l).getWorld().getBlockAt(i, j, k);
        org.bukkit.block.Block damager = null;
        org.bukkit.entity.Entity damagee = this.getBukkitEntity();
        EntityCombustEvent combustEvent = new EntityCombustByBlockEvent(damager, damagee, 15);
        Bukkit.getPluginManager().callEvent(combustEvent);
        if (!combustEvent.isCancelled()) {
            this.setFire(combustEvent.getDuration());
        }
    } else {
        // This will be called every single tick the entity is in lava, so don't throw an event
        this.setFire(15);
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) EntityCombustByBlockEvent(org.bukkit.event.entity.EntityCombustByBlockEvent) EntityCombustEvent(org.bukkit.event.entity.EntityCombustEvent) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Example 2 with EntityCombustByBlockEvent

use of org.bukkit.event.entity.EntityCombustByBlockEvent in project Citizens2 by CitizensDev.

the class EventListen method onEntityCombust.

/*
     * Entity events
     */
@EventHandler
public void onEntityCombust(EntityCombustEvent event) {
    NPC npc = CitizensAPI.getNPCRegistry().getNPC(event.getEntity());
    if (npc == null)
        return;
    event.setCancelled(npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true));
    if (event instanceof EntityCombustByEntityEvent) {
        Bukkit.getPluginManager().callEvent(new NPCCombustByEntityEvent((EntityCombustByEntityEvent) event, npc));
    } else if (event instanceof EntityCombustByBlockEvent) {
        Bukkit.getPluginManager().callEvent(new NPCCombustByBlockEvent((EntityCombustByBlockEvent) event, npc));
    } else {
        Bukkit.getPluginManager().callEvent(new NPCCombustEvent(event, npc));
    }
}
Also used : NPC(net.citizensnpcs.api.npc.NPC) EntityCombustByBlockEvent(org.bukkit.event.entity.EntityCombustByBlockEvent) NPCCombustByBlockEvent(net.citizensnpcs.api.event.NPCCombustByBlockEvent) NPCCombustByEntityEvent(net.citizensnpcs.api.event.NPCCombustByEntityEvent) NPCCombustEvent(net.citizensnpcs.api.event.NPCCombustEvent) EntityCombustByEntityEvent(org.bukkit.event.entity.EntityCombustByEntityEvent) EventHandler(org.bukkit.event.EventHandler)

Example 3 with EntityCombustByBlockEvent

use of org.bukkit.event.entity.EntityCombustByBlockEvent in project Arclight by IzzelAliz.

the class EntityMixin method arclight$move$EntityCombustEvent.

@Redirect(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setFire(I)V"))
public void arclight$move$EntityCombustEvent(Entity entity, int seconds) {
    EntityCombustEvent event = new EntityCombustByBlockEvent(null, getBukkitEntity(), 8);
    Bukkit.getPluginManager().callEvent(event);
    if (!event.isCancelled()) {
        this.setFire(event.getDuration());
    }
}
Also used : EntityCombustByBlockEvent(org.bukkit.event.entity.EntityCombustByBlockEvent) EntityCombustEvent(org.bukkit.event.entity.EntityCombustEvent) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Aggregations

EntityCombustByBlockEvent (org.bukkit.event.entity.EntityCombustByBlockEvent)3 EntityCombustEvent (org.bukkit.event.entity.EntityCombustEvent)2 Redirect (org.spongepowered.asm.mixin.injection.Redirect)2 NPCCombustByBlockEvent (net.citizensnpcs.api.event.NPCCombustByBlockEvent)1 NPCCombustByEntityEvent (net.citizensnpcs.api.event.NPCCombustByEntityEvent)1 NPCCombustEvent (net.citizensnpcs.api.event.NPCCombustEvent)1 NPC (net.citizensnpcs.api.npc.NPC)1 LivingEntity (net.minecraft.entity.LivingEntity)1 EventHandler (org.bukkit.event.EventHandler)1 EntityCombustByEntityEvent (org.bukkit.event.entity.EntityCombustByEntityEvent)1