/** * Render little splashes around the fishing hook. * simulating fish movement. * * @param worldServer the server side world. */ private void renderLittleSplash(@NotNull final WorldServer worldServer) { final double sinYPosition = (double) MathHelper.nextFloat(this.rand, 0.0F, 360.0F) * 0.017453292D; final double cosYPosition = MathHelper.nextFloat(this.rand, 25.0F, 60.0F); final double bubbleX = this.posX + (Math.sin(sinYPosition) * cosYPosition * 0.1); final double increasedYPosition = Math.floor(this.getEntityBoundingBox().minY) + 1.0; final double bubbleZ = this.posZ + (Math.cos(sinYPosition) * cosYPosition * 0.1); worldServer.spawnParticle(WATER_SPLASH, bubbleX, increasedYPosition, bubbleZ, 2 + this.rand.nextInt(2), SUNKEN_OFFSET, 0.0, SUNKEN_OFFSET, 0.0); }
private void renderBubble(final int fishingProgressStep, @NotNull final WorldServer worldServer) { this.countdownFishNear -= fishingProgressStep; double bubbleY = 0.15; if (this.countdownFishNear < 20) { bubbleY = bubbleY + (double) (20 - this.countdownFishNear) * 0.05; } else if (this.countdownFishNear < 40) { bubbleY = bubbleY + (double) (40 - this.countdownFishNear) * 0.02; } else if (this.countdownFishNear < 60) { bubbleY = bubbleY + (double) (60 - this.countdownFishNear) * 0.01; } if (this.rand.nextDouble() < bubbleY) { renderLittleSplash(worldServer); } if (this.countdownFishNear <= 0) { this.relativeRotation = MathHelper.nextFloat(this.rand, 0.0F, 360.0F); this.countdownFishBites = MathHelper.getInt(this.rand, 20, 80); } }
@Override protected void processImpact(RayTraceResult mop) { if (mop.entityHit != null) { float damage = MathHelper.nextFloat(world.rand, DAMAGE_MIN, DAMAGE_MAX); mop.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage); } else { // drop as item UtilItemStack.dropItemStackInWorld(world, mop.getBlockPos(), bullet); } this.setDead(); } }
@Override protected void processImpact(RayTraceResult mop) { if (mop.entityHit != null) { if (isOwner(mop.entityHit)) { //i hit owner, im done dropAsItem(); } else { float damage = MathHelper.nextFloat(world.rand, DAMAGE_MIN, DAMAGE_MAX); mop.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage); if (mop.entityHit instanceof EntityLivingBase) { EntityLivingBase living = (EntityLivingBase) mop.entityHit; if (living.isPotionActive(PotionEffectRegistry.STUN) == false) { living.addPotionEffect(new PotionEffect(PotionEffectRegistry.STUN, STUN_TICKS, 1)); } } } } else { // hit a block or something, go back setIsReturning(); } }
float f7 = MathHelper.nextFloat(rand, 0.0F, 360.0F) * 0.017453292F; float f9 = MathHelper.nextFloat(rand, 25.0F, 60.0F); double d12 = posX + (double) (MathHelper.sin(f7) * f9 * 0.1F); double d14 = (double) ((float) MathHelper.floor(getEntityBoundingBox().minY) + 1.0F); fishApproachAngle = MathHelper.nextFloat(rand, 0.0F, 360.0F); ticksCatchableDelay = MathHelper.getInt(rand, 20, 80);