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();
}
Aggregations