Search in sources :

Example 1 with EntityEnterBlockEvent

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

the class BeehiveTileEntityMixin method arclight$beeEnterBlock.

@Inject(method = "tryEnterHive(Lnet/minecraft/entity/Entity;ZI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;stopRiding()V"))
private void arclight$beeEnterBlock(Entity entity, boolean p_226962_2_, int p_226962_3_, CallbackInfo ci) {
    if (this.world != null) {
        EntityEnterBlockEvent event = new EntityEnterBlockEvent(((EntityBridge) entity).bridge$getBukkitEntity(), CraftBlock.at(this.world, this.getPos()));
        Bukkit.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            if (entity instanceof BeeEntity) {
                ((BeeEntity) entity).setStayOutOfHiveCountdown(400);
            }
            ci.cancel();
        }
    }
}
Also used : BeeEntity(net.minecraft.entity.passive.BeeEntity) EntityEnterBlockEvent(org.bukkit.event.entity.EntityEnterBlockEvent) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

BeeEntity (net.minecraft.entity.passive.BeeEntity)1 EntityEnterBlockEvent (org.bukkit.event.entity.EntityEnterBlockEvent)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1