Search in sources :

Example 1 with PlayerTakeLecternBookEvent

use of org.bukkit.event.player.PlayerTakeLecternBookEvent in project Arclight by IzzelAliz.

the class LecternContainerMixin method arclight$takeBook.

@Inject(method = "enchantItem", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/inventory/IInventory;removeStackFromSlot(I)Lnet/minecraft/item/ItemStack;"))
public void arclight$takeBook(PlayerEntity playerIn, int id, CallbackInfoReturnable<Boolean> cir) {
    PlayerTakeLecternBookEvent event = new PlayerTakeLecternBookEvent(((ServerPlayerEntityBridge) this.playerInventory.player).bridge$getBukkitEntity(), ((CraftInventoryLectern) getBukkitView().getTopInventory()).getHolder());
    Bukkit.getServer().getPluginManager().callEvent(event);
    if (event.isCancelled()) {
        cir.setReturnValue(false);
    }
}
Also used : PlayerTakeLecternBookEvent(org.bukkit.event.player.PlayerTakeLecternBookEvent) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

PlayerTakeLecternBookEvent (org.bukkit.event.player.PlayerTakeLecternBookEvent)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1