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