Search in sources :

Example 1 with FishHook

use of org.spongepowered.api.entity.projectile.FishHook in project SpongeCommon by SpongePowered.

the class MixinItemFishingRod method onThrowEvent.

@Inject(method = "onItemRightClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;playSound" + "(Lnet/minecraft/entity/player/EntityPlayer;DDDLnet/minecraft/util/SoundEvent;Lnet/minecraft/util/SoundCategory;FF)V", ordinal = 1), cancellable = true)
private void onThrowEvent(World world, EntityPlayer player, EnumHand hand, CallbackInfoReturnable<ActionResult<ItemStack>> cir) {
    if (world.isRemote) {
        // Only fire event on server-side to avoid crash on client
        return;
    }
    EntityFishHook fishHook = new EntityFishHook(world, player);
    Sponge.getCauseStackManager().pushCause(player);
    if (SpongeImpl.postEvent(SpongeEventFactory.createFishingEventStart(Sponge.getCauseStackManager().getCurrentCause(), (FishHook) fishHook))) {
        // Bye
        fishHook.setDead();
        cir.setReturnValue(new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand)));
    } else {
        this.fishHook = fishHook;
    }
    Sponge.getCauseStackManager().popCause();
}
Also used : EntityFishHook(net.minecraft.entity.projectile.EntityFishHook) FishHook(org.spongepowered.api.entity.projectile.FishHook) EntityFishHook(net.minecraft.entity.projectile.EntityFishHook) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

EntityFishHook (net.minecraft.entity.projectile.EntityFishHook)1 FishHook (org.spongepowered.api.entity.projectile.FishHook)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1