Java Code Examples for net.minecraft.entity.projectile.EntityFishHook

The following are top voted examples for showing how to use net.minecraft.entity.projectile.EntityFishHook. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: DecompiledMinecraft   File: ItemFishingRod.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (playerIn.fishEntity != null)
    {
        int i = playerIn.fishEntity.handleHookRetraction();
        itemStackIn.damageItem(i, playerIn);
        playerIn.swingItem();
    }
    else
    {
        worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!worldIn.isRemote)
        {
            worldIn.spawnEntityInWorld(new EntityFishHook(worldIn, playerIn));
        }

        playerIn.swingItem();
        playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    }

    return itemStackIn;
}
 
Example 2
Project: DecompiledMinecraft   File: ItemFishingRod.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (playerIn.fishEntity != null)
    {
        int i = playerIn.fishEntity.handleHookRetraction();
        itemStackIn.damageItem(i, playerIn);
        playerIn.swingItem();
    }
    else
    {
        worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!worldIn.isRemote)
        {
            worldIn.spawnEntityInWorld(new EntityFishHook(worldIn, playerIn));
        }

        playerIn.swingItem();
        playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    }

    return itemStackIn;
}
 
Example 3
Project: BaseClient   File: ItemFishingRod.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (playerIn.fishEntity != null)
    {
        int i = playerIn.fishEntity.handleHookRetraction();
        itemStackIn.damageItem(i, playerIn);
        playerIn.swingItem();
    }
    else
    {
        worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!worldIn.isRemote)
        {
            worldIn.spawnEntityInWorld(new EntityFishHook(worldIn, playerIn));
        }

        playerIn.swingItem();
        playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    }

    return itemStackIn;
}
 
Example 4
Project: BaseClient   File: ItemFishingRod.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (playerIn.fishEntity != null)
    {
        int i = playerIn.fishEntity.handleHookRetraction();
        itemStackIn.damageItem(i, playerIn);
        playerIn.swingItem();
    }
    else
    {
        worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!worldIn.isRemote)
        {
            worldIn.spawnEntityInWorld(new EntityFishHook(worldIn, playerIn));
        }

        playerIn.swingItem();
        playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    }

    return itemStackIn;
}
 
Example 5
Project: CustomWorldGen   File: ItemFishingRod.java   Source Code and License 6 votes vote down vote up
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (playerIn.fishEntity != null)
    {
        int i = playerIn.fishEntity.handleHookRetraction();
        itemStackIn.damageItem(i, playerIn);
        playerIn.swingArm(hand);
    }
    else
    {
        worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!worldIn.isRemote)
        {
            worldIn.spawnEntityInWorld(new EntityFishHook(worldIn, playerIn));
        }

        playerIn.swingArm(hand);
        playerIn.addStat(StatList.getObjectUseStats(this));
    }

    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
 
Example 6
Project: Mob-Amputation   File: EventHandlerClient.java   Source Code and License 6 votes vote down vote up
@SubscribeEvent
public void onEntitySpawn(EntityJoinWorldEvent event)
{
    if(event.getEntity().world.isRemote)
    {
        Minecraft mc = Minecraft.getMinecraft();
        if(event.getEntity() instanceof EntityFishHook)
        {
            fishHooks.add((EntityFishHook)event.getEntity());
        }
        if(event.getEntity() instanceof EntityZombie && !(event.getEntity() instanceof EntityZombieVillager) || event.getEntity() instanceof EntitySkeleton || MobAmputation.config.playerGibs == 1 && event.getEntity() instanceof EntityPlayer && event.getEntity() != mc.player)
        {
            EntityLivingBase living = (EntityLivingBase)event.getEntity();
            if(!amputationMap.containsKey(living) && !living.isChild())
            {
                attachGibs(event.getEntity().world, living);
            }
        }
    }
}
 
Example 7
Project: OldMods   File: FishingRodItem.java   Source Code and License 6 votes vote down vote up
@SideOnly( Side.CLIENT )
  public ItemStack onItemRightClick( ItemStack stack, World world, EntityPlayer player )
  {
ItemStack ret = super.onItemRightClick( stack, world, player );

if ( world.isRemote )
{
	Minecraft mc = FMLClientHandler.instance().getClient();
	
	EntityFishHook hook = player.fishEntity;
	if ( player == mc.thePlayer && hook != null )
	{
		stagnated = false;
		prevMotionY = 0;
		timeSinceCasted = 0;
	}
}

return ret;
  }
 
Example 8
Project: Resilience-Client-Source   File: ItemFishingRod.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
    if (par3EntityPlayer.fishEntity != null)
    {
        int var4 = par3EntityPlayer.fishEntity.func_146034_e();
        par1ItemStack.damageItem(var4, par3EntityPlayer);
        par3EntityPlayer.swingItem();
    }
    else
    {
        par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!par2World.isClient)
        {
            par2World.spawnEntityInWorld(new EntityFishHook(par2World, par3EntityPlayer));
        }

        par3EntityPlayer.swingItem();
    }

    return par1ItemStack;
}
 
Example 9
Project: mod_autofish   File: AutoFish.java   Source Code and License 6 votes vote down vote up
public void onBobberSplashDetected(float x, float y, float z) {
        if (playerHookInWater(this.player)) {
            EntityFishHook hook = this.player.fishEntity;
//                double yDifference = Math.abs(hook.posY - y);
            // Ignore Y component when calculating distance from hook
            double xzDistanceFromHook = hook.getDistanceSq(x, hook.posY, z);
            if (xzDistanceFromHook <= CLOSE_BOBBER_SPLASH_THRESHOLD) {
//                    AutoFishLogger.info("[%d] Close bobber splash at %f /  %f", this.minecraft.world.getTotalWorldTime(), xzDistanceFromHook, yDifference);
                this.closeBobberSplashDetectedAt = this.minecraftClient.world.getTotalWorldTime();
//                    if (xzDistanceFromHook <= EXACT_BOBBER_SPLASH_THRESHOLD) {
//    //                    AutoFishLogger.info("[%d] Exact bobber splash at %f /  %f", this.minecraft.world.getTotalWorldTime(), xzDistanceFromHook, yDifference);
//                        this.exactBobberSplashDetectedAt = this.minecraft.world.getTotalWorldTime();
//                    } 
            }
        }
    }
 
Example 10
Project: mod_autofish   File: AutoFish.java   Source Code and License 6 votes vote down vote up
/**
     * Callback from the WorldEventListener to tell us whenever a WATER_WAKE particle
     * is spawned in the world.
     * 
     * @param x
     * @param y
     * @param z
     */
    public void onWaterWakeDetected(double x, double y, double z) {
        if (this.minecraftClient != null && this.minecraftClient.player != null && playerHookInWater(this.minecraftClient.player)) {
            EntityFishHook hook = this.minecraftClient.player.fishEntity;
            double distanceFromHook = new BlockPos(x, y, z).distanceSq(hook.posX, hook.posY, hook.posZ);
            if (distanceFromHook <= CLOSE_WATER_WAKE_THRESHOLD) {
                if (this.closeWaterWakeDetectedAt <= 0) {
//                    AutoFishLogger.info("[%d] Close water wake at %f", this.minecraft.world.getTotalWorldTime(), distanceFromHook);
                    this.closeWaterWakeDetectedAt = this.minecraftClient.world.getTotalWorldTime();
                }
//                if (distanceFromHook <= EXACT_WATER_WAKE_THRESHOLD) {
//                    if (this.exactWaterWakeDetectedAt <=0) {
////                        AutoFishLogger.info("[%d] Exact water wake at %f", this.minecraft.world.getTotalWorldTime(), distanceFromHook);
//                        this.exactWaterWakeDetectedAt = this.minecraft.world.getTotalWorldTime();
//                    }
//                }
            }
        }
    }
 
Example 11
Project: mod_autofish   File: AutoFish.java   Source Code and License 6 votes vote down vote up
private boolean isFishBiting_fromAll() {
        /** Assume a bit if the following conditions are true:
         * (1) There is at least a little Y motion of the fish hook
         * (2) Either (a) There has been a "close" bobber splash very recently; OR
         *            (b) A "close" water wake was detected long enough ago  
         */
        EntityFishHook fishEntity = this.player.fishEntity;
        if (fishEntity != null 
                // Checking for no X and Z motion prevents a false alarm when the hook is moving through the air
                && fishEntity.motionX == 0 
                && fishEntity.motionZ == 0 
                && fishEntity.motionY < MOTION_Y_MAYBE_THRESHOLD) {
//            long totalWorldTime = this.minecraft.world.getTotalWorldTime();
            if (recentCloseBobberSplash() || recentCloseWaterWake()) {
                Logger.debug("[%d] Detected bite by ALL", this.minecraftClient.world.getTotalWorldTime());
                return true;
            }
        }
        return false;
    }
 
Example 12
Project: RTM   File: ItemCatToyWIP.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
    if (par3EntityPlayer.fishEntity != null)
    {
        int i = par3EntityPlayer.fishEntity.func_146034_e();
        par1ItemStack.damageItem(i, par3EntityPlayer);
        par3EntityPlayer.swingItem();
    }
    else
    {
        par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!par2World.isRemote)
        {
            par2World.spawnEntityInWorld(new EntityFishHook(par2World, par3EntityPlayer));
        }

        par3EntityPlayer.swingItem();
    }

    return par1ItemStack;
}
 
Example 13
Project: ExpandedRailsMod   File: ItemFishingRod.java   Source Code and License 6 votes vote down vote up
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (playerIn.fishEntity != null)
    {
        int i = playerIn.fishEntity.handleHookRetraction();
        itemStackIn.damageItem(i, playerIn);
        playerIn.swingArm(hand);
    }
    else
    {
        worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!worldIn.isRemote)
        {
            worldIn.spawnEntityInWorld(new EntityFishHook(worldIn, playerIn));
        }

        playerIn.swingArm(hand);
        playerIn.addStat(StatList.getObjectUseStats(this));
    }

    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
 
Example 14
Project: Cauldron   File: ItemFishingRod.java   Source Code and License 6 votes vote down vote up
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_)
{
    if (p_77659_3_.fishEntity != null)
    {
        int i = p_77659_3_.fishEntity.func_146034_e();
        p_77659_1_.damageItem(i, p_77659_3_);
        p_77659_3_.swingItem();
    }
    else
    {
        p_77659_2_.playSoundAtEntity(p_77659_3_, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!p_77659_2_.isRemote)
        {
            p_77659_2_.spawnEntityInWorld(new EntityFishHook(p_77659_2_, p_77659_3_));
        }

        p_77659_3_.swingItem();
    }

    return p_77659_1_;
}
 
Example 15
Project: RuneCraftery   File: ItemFishingRod.java   Source Code and License 6 votes vote down vote up
public ItemStack func_77659_a(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) {
   if(p_77659_3_.field_71104_cf != null) {
      int var4 = p_77659_3_.field_71104_cf.func_70198_d();
      p_77659_1_.func_77972_a(var4, p_77659_3_);
      p_77659_3_.func_71038_i();
   } else {
      p_77659_2_.func_72956_a(p_77659_3_, "random.bow", 0.5F, 0.4F / (field_77697_d.nextFloat() * 0.4F + 0.8F));
      if(!p_77659_2_.field_72995_K) {
         p_77659_2_.func_72838_d(new EntityFishHook(p_77659_2_, p_77659_3_));
      }

      p_77659_3_.func_71038_i();
   }

   return p_77659_1_;
}
 
Example 16
Project: RuneCraftery   File: ItemFishingRod.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
    if (par3EntityPlayer.fishEntity != null)
    {
        int i = par3EntityPlayer.fishEntity.catchFish();
        par1ItemStack.damageItem(i, par3EntityPlayer);
        par3EntityPlayer.swingItem();
    }
    else
    {
        par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!par2World.isRemote)
        {
            par2World.spawnEntityInWorld(new EntityFishHook(par2World, par3EntityPlayer));
        }

        par3EntityPlayer.swingItem();
    }

    return par1ItemStack;
}
 
Example 17
Project: BetterNutritionMod   File: ItemFishingRod.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
    if (par3EntityPlayer.fishEntity != null)
    {
        int i = par3EntityPlayer.fishEntity.catchFish();
        par1ItemStack.damageItem(i, par3EntityPlayer);
        par3EntityPlayer.swingItem();
    }
    else
    {
        par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!par2World.isRemote)
        {
            par2World.spawnEntityInWorld(new EntityFishHook(par2World, par3EntityPlayer));
        }

        par3EntityPlayer.swingItem();
    }

    return par1ItemStack;
}
 
Example 18
Project: Thaumic-Tools   File: ItemInfusedFishingPole.java   Source Code and License 6 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
	///LoggerHelper.log(Level.INFO, "Right Clicked");
    if (par3EntityPlayer.fishEntity != null)
    {
        int i = par3EntityPlayer.fishEntity.catchFish();
        par1ItemStack.damageItem(i, par3EntityPlayer);
        par3EntityPlayer.swingItem();
        //LoggerHelper.log(Level.INFO, "Entity!=null");
    }
    else
    {
        par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
       // LoggerHelper.log(Level.INFO, "Entity=null");
        if (!par2World.isRemote)
        {
            par2World.spawnEntityInWorld(new EntityFishHook(par2World, par3EntityPlayer));
        }

        par3EntityPlayer.swingItem();
    }

    return par1ItemStack;
}
 
Example 19
Project: Thaumic-Tools   File: ItemThaumiumFishingPole.java   Source Code and License 6 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
	///LoggerHelper.log(Level.INFO, "Right Clicked");
    if (par3EntityPlayer.fishEntity != null)
    {
        int i = par3EntityPlayer.fishEntity.catchFish();
        par1ItemStack.damageItem(i, par3EntityPlayer);
        par3EntityPlayer.swingItem();
        //LoggerHelper.log(Level.INFO, "Entity!=null");
    }
    else
    {
        par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
       // LoggerHelper.log(Level.INFO, "Entity=null");
        if (!par2World.isRemote)
        {
            par2World.spawnEntityInWorld(new EntityFishHook(par2World, par3EntityPlayer));
        }

        par3EntityPlayer.swingItem();
    }

    return par1ItemStack;
}
 
Example 20
Project: Uranium   File: CraftFish.java   Source Code and License 5 votes vote down vote up
public double getBiteChance() {
    EntityFishHook hook = getHandle();

    if (this.biteChance == -1) {
        if (hook.worldObj.canLightningStrikeAt(MathHelper.floor_double(hook.posX), net.minecraft.util.MathHelper.floor_double(hook.posY) + 1, net.minecraft.util.MathHelper.floor_double(hook.posZ))) {
            return 1/300.0;
        }
        return 1/500.0;
    }
    return this.biteChance;
}
 
Example 21
Project: Backmemed   File: ItemFishingRod.java   Source Code and License 5 votes vote down vote up
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = worldIn.getHeldItem(playerIn);

    if (worldIn.fishEntity != null)
    {
        int i = worldIn.fishEntity.handleHookRetraction();
        itemstack.damageItem(i, worldIn);
        worldIn.swingArm(playerIn);
    }
    else
    {
        itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!itemStackIn.isRemote)
        {
            EntityFishHook entityfishhook = new EntityFishHook(itemStackIn, worldIn);
            int j = EnchantmentHelper.func_191528_c(itemstack);

            if (j > 0)
            {
                entityfishhook.func_191516_a(j);
            }

            int k = EnchantmentHelper.func_191529_b(itemstack);

            if (k > 0)
            {
                entityfishhook.func_191517_b(k);
            }

            itemStackIn.spawnEntityInWorld(entityfishhook);
        }

        worldIn.swingArm(playerIn);
        worldIn.addStat(StatList.getObjectUseStats(this));
    }

    return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
 
Example 22
Project: CrystalMod   File: EventHandler.java   Source Code and License 5 votes vote down vote up
@SubscribeEvent 
  public void addWhiteFish(ItemFishedEvent event){
  	EntityFishHook hook = event.getHookEntity();
  	World world = hook.getEntityWorld();
Biome biome = world.getBiomeForCoordsBody(new BlockPos(hook));
boolean editedList = false;
List<ItemStack> drops = Lists.newArrayList();
if(BiomeDictionary.hasType(biome, Type.COLD) || BiomeDictionary.hasType(biome, Type.SNOWY)){
	for(ItemStack stack : event.getDrops()){
		if(ItemStackTools.isValid(stack) && stack.getItem() == Items.FISH && stack.getMetadata() == FishType.COD.getMetadata()){
			if(Config.whiteFishRarity > 0 && Util.rand.nextInt(Config.whiteFishRarity) == 0){
				//Go ahead and replace with whitefish
				drops.add(new ItemStack(ModItems.miscFood, 1, FoodType.WHITE_FISH_RAW.getMetadata()));
				editedList = true;
				continue;
			}
		}
		drops.add(stack);
	}
}

if(editedList){
	event.damageRodBy(1);
	for (ItemStack itemstack : drops)
          {
              EntityItem entityitem = new EntityItem(hook.world, hook.posX, hook.posY, hook.posZ, itemstack);
              double d0 = event.getEntityPlayer().posX - hook.posX;
              double d1 = event.getEntityPlayer().posY - hook.posY;
              double d2 = event.getEntityPlayer().posZ - hook.posZ;
              double d3 = (double)MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
              entityitem.motionX = d0 * 0.1D;
              entityitem.motionY = d1 * 0.1D + (double)MathHelper.sqrt(d3) * 0.08D;
              entityitem.motionZ = d2 * 0.1D;
              hook.world.spawnEntity(entityitem);
              event.getEntityPlayer().world.spawnEntity(new EntityXPOrb(event.getEntityPlayer().world, event.getEntityPlayer().posX, event.getEntityPlayer().posY + 0.5D, event.getEntityPlayer().posZ + 0.5D, Util.rand.nextInt(6) + 1));
              Item item = itemstack.getItem();

              if (item == Items.FISH || item == Items.COOKED_FISH)
              {
              	event.getEntityPlayer().addStat(StatList.FISH_CAUGHT, 1);
              }
          }
	event.setCanceled(true);
}
  }
 
Example 23
Project: Gravestone-mod-Extended   File: GSEventsHandler.java   Source Code and License 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void entityJoinWorldEvent(EntityJoinWorldEvent event) {
    Entity entity = event.getEntity();

    if (ExtendedConfig.overrideVanillaFishing && entity instanceof EntityFishHook && entity.getClass().equals(EntityFishHook.class)) {
        World world = event.getWorld();
        if (!world.isRemote) {
            EntityPlayer player = ((EntityFishHook) entity).getAngler();
            ItemStack stack = player.getHeldItem(EnumHand.MAIN_HAND);
            if (stack.getItem() != Items.FISHING_ROD) {
                stack = player.getHeldItem(EnumHand.OFF_HAND);
            }
            entity.setDead();

            EntityCustomFishHook hook = new EntityCustomFishHook(world, player);

            int speed = EnchantmentHelper.getFishingSpeedBonus(stack);
            if (speed > 0) {
                hook.setLureSpeed(speed);
            }
            int luck = EnchantmentHelper.getFishingLuckBonus(stack);
            if (luck > 0) {
                hook.setLuck(luck);
            }

            world.spawnEntity(hook);
        }

        event.setCanceled(true);
    }
}
 
Example 24
Project: ThermosRebased   File: CraftFish.java   Source Code and License 5 votes vote down vote up
public double getBiteChance() {
    EntityFishHook hook = getHandle();

    if (this.biteChance == -1) {
        if (hook.worldObj.canLightningStrikeAt(MathHelper.floor_double(hook.posX), net.minecraft.util.MathHelper.floor_double(hook.posY) + 1, net.minecraft.util.MathHelper.floor_double(hook.posZ))) {
            return 1/300.0;
        }
        return 1/500.0;
    }
    return this.biteChance;
}
 
Example 25
Project: Thermos   File: CraftFish.java   Source Code and License 5 votes vote down vote up
public double getBiteChance() {
    EntityFishHook hook = getHandle();

    if (this.biteChance == -1) {
        if (hook.worldObj.canLightningStrikeAt(MathHelper.floor_double(hook.posX), net.minecraft.util.MathHelper.floor_double(hook.posY) + 1, net.minecraft.util.MathHelper.floor_double(hook.posZ))) {
            return 1/300.0;
        }
        return 1/500.0;
    }
    return this.biteChance;
}
 
Example 26
Project: KCauldron   File: CraftFish.java   Source Code and License 5 votes vote down vote up
public double getBiteChance() {
    EntityFishHook hook = getHandle();

    if (this.biteChance == -1) {
        if (hook.worldObj.canLightningStrikeAt(MathHelper.floor_double(hook.posX), net.minecraft.util.MathHelper.floor_double(hook.posY) + 1, net.minecraft.util.MathHelper.floor_double(hook.posZ))) {
            return 1/300.0;
        }
        return 1/500.0;
    }
    return this.biteChance;
}
 
Example 27
Project: CauldronGit   File: CraftFish.java   Source Code and License 5 votes vote down vote up
public double getBiteChance() {
    EntityFishHook hook = getHandle();

    if (this.biteChance == -1) {
        if (hook.worldObj.canLightningStrikeAt(MathHelper.floor_double(hook.posX), net.minecraft.util.MathHelper.floor_double(hook.posY) + 1, net.minecraft.util.MathHelper.floor_double(hook.posZ))) {
            return 1/300.0;
        }
        return 1/500.0;
    }
    return this.biteChance;
}
 
Example 28
Project: Cauldron-Old   File: CraftFish.java   Source Code and License 5 votes vote down vote up
public double getBiteChance() {
    EntityFishHook hook = getHandle();

    if (this.biteChance == -1) {
        if (hook.worldObj.canLightningStrikeAt(MathHelper.floor_double(hook.posX), net.minecraft.util.MathHelper.floor_double(hook.posY) + 1, net.minecraft.util.MathHelper.floor_double(hook.posZ))) {
            return 1/300.0;
        }
        return 1/500.0;
    }
    return this.biteChance;
}
 
Example 29
Project: Cauldron-Reloaded   File: CraftFish.java   Source Code and License 5 votes vote down vote up
public double getBiteChance() {
    EntityFishHook hook = getHandle();

    if (this.biteChance == -1) {
        if (hook.worldObj.canLightningStrikeAt(MathHelper.floor_double(hook.posX), net.minecraft.util.MathHelper.floor_double(hook.posY) + 1, net.minecraft.util.MathHelper.floor_double(hook.posZ))) {
            return 1/300.0;
        }
        return 1/500.0;
    }
    return this.biteChance;
}
 
Example 30
Project: FFoKC   File: CraftFish.java   Source Code and License 5 votes vote down vote up
public double getBiteChance() {
    EntityFishHook hook = getHandle();

    if (this.biteChance == -1) {
        if (hook.worldObj.canLightningStrikeAt(MathHelper.floor_double(hook.posX), net.minecraft.util.MathHelper.floor_double(hook.posY) + 1, net.minecraft.util.MathHelper.floor_double(hook.posZ))) {
            return 1/300.0;
        }
        return 1/500.0;
    }
    return this.biteChance;
}
 
Example 31
Project: mod_autofish   File: AutoFish.java   Source Code and License 5 votes vote down vote up
/**
 * Determine whether a fish is biting the player's hook, using the server-side player entity.
 * This only works in Single Player, but is 100% accurate.
 * 
 * @param serverPlayerEntity
 * @return
 * @throws NumberFormatException
 * @throws NoSuchFieldException
 * @throws SecurityException
 * @throws IllegalArgumentException
 * @throws IllegalAccessException
 */
private boolean isFishBiting_fromServerEntity(EntityPlayer serverPlayerEntity) throws NumberFormatException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
    /*
     * The fish hook entity on the server side knows whether a fish is catchable at any given time.  However,
     * that field is private and not exposed in any way.  So we must use reflection to access that field.
     */
    EntityFishHook serverFishEntity = serverPlayerEntity.fishEntity;
    int ticksCatchable = ReflectionUtils.getPrivateIntFieldFromObject(serverFishEntity, "ticksCatchable", "field_146045_ax");
    if (ticksCatchable > 0) {
        return true;
    }
    return false;
}
 
Example 32
Project: mod_autofish   File: AutoFish.java   Source Code and License 5 votes vote down vote up
private boolean isFishBiting_fromMovement() {
    EntityFishHook fishEntity = this.player.fishEntity;
    if (fishEntity != null 
            // Checking for no X and Z motion prevents a false alarm when the hook is moving through the air
            && fishEntity.motionX == 0 
            && fishEntity.motionZ == 0 
            && fishEntity.motionY < MOTION_Y_THRESHOLD) {
        Logger.debug("[%d] Detected bite by MOVEMENT", this.minecraftClient.world.getTotalWorldTime());
        return true;
    }
    return false;
}
 
Example 33
Project: mod_autofish   File: AutoFish.java   Source Code and License 5 votes vote down vote up
/**
 * For the current player, trigger a bite on the fish hook.
 */
@SuppressWarnings("unused")
private void triggerBite() {
    EntityPlayer serverPlayerEntity = getServerPlayerEntity();
    if (serverPlayerEntity != null) {
        /*
         * If we are single player and have access to the server player entity, try to hack the fish hook entity
         * to make fish bite sooner.
         */
        EntityFishHook serverFishEntity = serverPlayerEntity.fishEntity;
        int ticks = FAST_FISH_CATCHABLE_DELAY_TICKS + MathHelper.getInt(this.rand, 0, FAST_FISH_DELAY_VARIANCE);
        setTicksCatchableDelay(serverFishEntity, ticks);
    }
}
 
Example 34
Project: Cauldron   File: ItemFishingRod.java   Source Code and License 5 votes vote down vote up
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_)
{
    if (p_77659_3_.fishEntity != null)
    {
        int i = p_77659_3_.fishEntity.func_146034_e();
        p_77659_1_.damageItem(i, p_77659_3_);
        p_77659_3_.swingItem();
    }
    else
    {
        // CraftBukkit start
        EntityFishHook hook = new EntityFishHook(p_77659_2_, p_77659_3_);
        PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) p_77659_3_.getBukkitEntity(), null, (org.bukkit.entity.Fish) hook.getBukkitEntity(), PlayerFishEvent.State.FISHING);
        p_77659_2_.getServer().getPluginManager().callEvent(playerFishEvent);

        if (playerFishEvent.isCancelled())
        {
            return p_77659_1_;
        }

        // CraftBukkit end
        p_77659_2_.playSoundAtEntity(p_77659_3_, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!p_77659_2_.isRemote)
        {
            p_77659_2_.spawnEntityInWorld(hook); // CraftBukkit - moved creation up
        }

        p_77659_3_.swingItem();
    }

    return p_77659_1_;
}
 
Example 35
Project: Cauldron   File: CraftFish.java   Source Code and License 5 votes vote down vote up
public double getBiteChance() {
    EntityFishHook hook = getHandle();

    if (this.biteChance == -1) {
        if (hook.worldObj.canLightningStrikeAt(MathHelper.floor_double(hook.posX), net.minecraft.util.MathHelper.floor_double(hook.posY) + 1, net.minecraft.util.MathHelper.floor_double(hook.posZ))) {
            return 1/300.0;
        }
        return 1/500.0;
    }
    return this.biteChance;
}
 
Example 36
Project: Thaumic-Tools   File: RenderTimer.java   Source Code and License 5 votes vote down vote up
public static void RenderEntityInfoInWorld(EntityFishHook entity, float partialTickTime)
 {
ItemStack itemstack = entity.angler.getCurrentEquippedItem();
   if (((mc.inGameHasFocus) || (mc.currentScreen == null) || (mc.currentScreen instanceof GuiChat) && (!mc.gameSettings.showDebugInfo)) && (itemstack.getItem() instanceof ItemInfusedFishingPole))
   		    {
     EntityFishHook fishhook = (EntityFishHook)entity;
     double distanceFromMe = mc.thePlayer.getDistanceToEntity(fishhook);
     if (distanceFromMe > 32) {
       return;
     }
     RenderCountdownOverlay(fishhook, partialTickTime);
   }
 }
 
Example 37
Project: Thaumic-Tools   File: RenderTimer.java   Source Code and License 5 votes vote down vote up
protected static void RenderCountdownOverlay(EntityFishHook entityfishhook, float partialTickTime)
{
  float x = (float)entityfishhook.posX;
  float y = (float)entityfishhook.posY;
  float z = (float)entityfishhook.posZ;
  

  String countdown = Integer.toString((entityfishhook.hookedTimer/20)+1);
  
  if (countdown != null && entityfishhook.hookedTimer != 1000) {
    RenderFloatingText(countdown, x, y, z, 16777215, true, partialTickTime);}
  }
 
Example 38
Project: Thaumic-Tools   File: RenderTickHandler.java   Source Code and License 5 votes vote down vote up
public static void RenderEntityInfo(float partialTickTime)
{
  if (mc.inGameHasFocus) {
    for (Object object : mc.theWorld.loadedEntityList) {
      if (object instanceof EntityFishHook) {
        RenderEntityInfoInWorld((EntityFishHook)object, partialTickTime);
        ItemStack itemstack = mc.thePlayer.getCurrentEquippedItem();
        if (itemstack.getItem() instanceof IFishingPole)
      	  if (itemstack.getItem() == ThaumicTools.thaumiumFishingPoleItem) {
      		  
      	  }
      }
    }
  }
}
 
Example 39
Project: Uranium   File: CraftFish.java   Source Code and License 4 votes vote down vote up
public CraftFish(CraftServer server, EntityFishHook entity) {
    super(server, entity);
}
 
Example 40
Project: Uranium   File: CraftFish.java   Source Code and License 4 votes vote down vote up
@Override
public EntityFishHook getHandle() {
    return (EntityFishHook) entity;
}