Search in sources :

Example 1 with EntityFishHook

use of net.minecraft.entity.projectile.EntityFishHook in project SpongeCommon by SpongePowered.

the class MixinItemFishingRod method onNewEntityFishHook.

@Redirect(method = "onItemRightClick", at = @At(value = "NEW", target = "net/minecraft/entity/projectile/EntityFishHook"))
private EntityFishHook onNewEntityFishHook(World world, EntityPlayer player) {
    // Use the fish hook we created for the event
    EntityFishHook fishHook = this.fishHook;
    this.fishHook = null;
    return fishHook;
}
Also used : EntityFishHook(net.minecraft.entity.projectile.EntityFishHook) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Example 2 with EntityFishHook

use of net.minecraft.entity.projectile.EntityFishHook 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)2 FishHook (org.spongepowered.api.entity.projectile.FishHook)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1 Redirect (org.spongepowered.asm.mixin.injection.Redirect)1