/** Updates the JList with a new model. */ public void update() { MusicTicker.MusicType var1 = this.mc.getAmbientMusicType(); if (this.currentMusic != null) { if (!var1.getMusicLocation().equals(this.currentMusic.getSoundLocation())) { this.mc.getSoundHandler().stopSound(this.currentMusic); this.timeUntilNextMusic = MathHelper.getRandomIntegerInRange(this.rand, 0, var1.getMinDelay() / 2); } if (!this.mc.getSoundHandler().isSoundPlaying(this.currentMusic)) { this.currentMusic = null; this.timeUntilNextMusic = Math.min( MathHelper.getRandomIntegerInRange( this.rand, var1.getMinDelay(), var1.getMaxDelay()), this.timeUntilNextMusic); } } if (this.currentMusic == null && this.timeUntilNextMusic-- <= 0) { this.currentMusic = PositionedSoundRecord.createPositionedSoundRecord(var1.getMusicLocation()); this.mc.getSoundHandler().playSound(this.currentMusic); this.timeUntilNextMusic = Integer.MAX_VALUE; } }
public void update() { MusicTicker.MusicType localMusicType = this.field_147677_b.func_147109_W(); if (this.field_147678_c != null) { if (!localMusicType .getMusicTickerLocation() .equals(this.field_147678_c.getPositionedSoundLocation())) { this.field_147677_b.getSoundHandler().stopSound(this.field_147678_c); this.field_147676_d = MathHelper.getRandomIntegerInRange( this.field_147679_a, 0, localMusicType.func_148634_b() / 2); } if (!this.field_147677_b.getSoundHandler().isSoundPlaying(this.field_147678_c)) { this.field_147678_c = null; this.field_147676_d = Math.min( MathHelper.getRandomIntegerInRange( this.field_147679_a, localMusicType.func_148634_b(), localMusicType.func_148633_c()), this.field_147676_d); } } if ((this.field_147678_c == null) && (this.field_147676_d-- <= 0)) { this.field_147678_c = PositionedSoundRecord.func_147673_a(localMusicType.getMusicTickerLocation()); this.field_147677_b.getSoundHandler().playSound(this.field_147678_c); this.field_147676_d = 2147483647; } }
public static ArrayList<StructureVillagePieceWeightDeimos> getStructureVillageWeightedPieceList( Random par0Random, int par1) { final ArrayList<StructureVillagePieceWeightDeimos> var2 = new ArrayList<StructureVillagePieceWeightDeimos>(); var2.add( new StructureVillagePieceWeightDeimos( StructureComponentDeimosVillageWoodHut.class, 5, MathHelper.getRandomIntegerInRange(par0Random, 2 + par1, 5 + par1 * 3))); var2.add( new StructureVillagePieceWeightDeimos( StructureComponentDeimosVillageField.class, 5, MathHelper.getRandomIntegerInRange(par0Random, 3 + par1, 5 + par1))); var2.add( new StructureVillagePieceWeightDeimos( StructureComponentDeimosVillageHouse.class, 5, MathHelper.getRandomIntegerInRange(par0Random, 3 + par1, 4 + par1 * 2))); final Iterator<StructureVillagePieceWeightDeimos> var3 = var2.iterator(); while (var3.hasNext()) { if (var3.next().villagePiecesLimit == 0) { var3.remove(); } } return var2; }
/** * Generate one single component from the list. Min and max values from SubComponentData will be * ignored * * @param subCompData * @param rand * @return */ protected BaseStructureComponent generateOneComponent( ArrayList<SubComponentData> subCompData, Random rand) { BaseStructureComponent result = null; Class<? extends BaseStructureComponent> resultClass = null; for (SubComponentData entry : subCompData) { if (entry.probability < rand.nextFloat()) { resultClass = entry.clazz; break; } } if (resultClass == null) { // as fallback int i = MathHelper.getRandomIntegerInRange(rand, 0, subCompData.size() - 1); resultClass = subCompData.get(i).clazz; } try { result = resultClass.getConstructor().newInstance(); } catch (Throwable e) { FMLLog.info("Instantiating " + resultClass.getCanonicalName() + " failed"); e.printStackTrace(); } return result; }
@Override public PieceWeight getVillagePieceWeight(Random random, int i) { int num = MathHelper.getRandomIntegerInRange(random, 0 + i, 1 + i); if (!GrowthCraftBees.getConfig().generateApiaristStructure) num = 0; return new PieceWeight(ComponentVillageApiarist.class, 21, num); }
@Override public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int size) { return new StructureVillagePieces.PieceWeight( ComponentVillageBeeHouse.class, 15, MathHelper.getRandomIntegerInRange(random, size, 1 + size)); }
public void func_149874_m(World world, int x, int y, int z) { int l = world.getBlockMetadata(x, y, z) + MathHelper.getRandomIntegerInRange(world.rand, 2, 5); if (l > 7) { l = 7; } world.setBlockMetadataWithNotify(x, y, z, l, 2); }
/** Main function called by run() every loop. */ public void tick() { long var1 = System.nanoTime(); ++this.tickCounter; if (this.startProfiling) { this.startProfiling = false; this.theProfiler.profilingEnabled = true; this.theProfiler.clearProfiling(); } this.theProfiler.startSection("root"); this.updateTimeLightAndEntities(); if (var1 - this.nanoTimeSinceStatusRefresh >= 5000000000L) { this.nanoTimeSinceStatusRefresh = var1; this.statusResponse.setPlayerCountData( new ServerStatusResponse.PlayerCountData( this.getMaxPlayers(), this.getCurrentPlayerCount())); GameProfile[] var3 = new GameProfile[Math.min(this.getCurrentPlayerCount(), 12)]; int var4 = MathHelper.getRandomIntegerInRange( this.random, 0, this.getCurrentPlayerCount() - var3.length); for (int var5 = 0; var5 < var3.length; ++var5) { var3[var5] = ((EntityPlayerMP) this.serverConfigManager.playerEntityList.get(var4 + var5)) .getGameProfile(); } Collections.shuffle(Arrays.asList(var3)); this.statusResponse.getPlayerCountData().setPlayers(var3); } if (this.tickCounter % 900 == 0) { this.theProfiler.startSection("save"); this.serverConfigManager.saveAllPlayerData(); this.saveAllWorlds(true); this.theProfiler.endSection(); } this.theProfiler.startSection("tallying"); this.tickTimeArray[this.tickCounter % 100] = System.nanoTime() - var1; this.theProfiler.endSection(); this.theProfiler.startSection("snooper"); if (!this.usageSnooper.isSnooperRunning() && this.tickCounter > 100) { this.usageSnooper.startSnooper(); } if (this.tickCounter % 6000 == 0) { this.usageSnooper.addMemoryStatsToSnooper(); } this.theProfiler.endSection(); this.theProfiler.endSection(); }
@SuppressWarnings("unchecked") @Override public List<ItemStack> getDrops( IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { return new ArrayList<ItemStack>( Arrays.asList( new ItemStack[] { new ItemStack( UItems.infectedcrop, MathHelper.getRandomIntegerInRange(new Random(), 1, 4)) })); }
public void grow(World worldIn, BlockPos pos, IBlockState state) { int i = ((Integer) state.getValue(AGE)).intValue() + MathHelper.getRandomIntegerInRange(worldIn.rand, 2, 5); if (i > 7) { i = 7; } worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(i)), 2); }
@Override public void dropBlockAsItemWithChance( World w, int x, int y, int z, int blockID, float something, int meta) { super.dropBlockAsItemWithChance(w, x, y, z, blockID, something, meta); if (getItemDropped(blockID, w.rand, meta) != Item.getItemFromBlock(this)) { int xp = MathHelper.getRandomIntegerInRange(w.rand, 2, 5); this.dropXpOnBlockBreak(w, x, y, z, xp); } }
/** * Tries to find a sensible limit (aka total maximum of components) for the given list of * SubComponentData * * <p>helper for generateSubComponents * * @param subCompData * @param rand * @return */ private int findComponentLimit(ArrayList<SubComponentData> subCompData, Random rand) { int minComponents = 0; int maxComponents = 0; boolean everythingHasMax = true; for (SubComponentData entry : subCompData) { minComponents += entry.minAmount; if (entry.maxAmount > 0) { maxComponents += entry.maxAmount; } else { everythingHasMax = false; } } if (everythingHasMax) { return MathHelper.getRandomIntegerInRange(rand, minComponents, maxComponents); } // otherwise dunno. Kinda guess something? return MathHelper.getRandomIntegerInRange( rand, minComponents, minComponents + subCompData.size()); }
@Override public void func_149863_m(World p_149863_1_, int p_149863_2_, int p_149863_3_, int p_149863_4_) { int l = p_149863_1_.getBlockMetadata(p_149863_2_, p_149863_3_, p_149863_4_) + MathHelper.getRandomIntegerInRange(p_149863_1_.rand, 2, 5); if (l > 7) { l = 7; } p_149863_1_.setBlockMetadataWithNotify(p_149863_2_, p_149863_3_, p_149863_4_, l, 2); }
/** Drops the block items with a specified chance of dropping the specified items */ public void dropBlockAsItemWithChance( World par1World, int par2, int par3, int par4, int par5, float par6, int par7) { super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, par7); if (this.idDropped(par5, par1World.rand, par7) != this.blockID) { int j1 = 0; if (this.blockID == Block.oreCoal.blockID) { j1 = MathHelper.getRandomIntegerInRange(par1World.rand, 0, 2); } else if (this.blockID == Block.oreDiamond.blockID) { j1 = MathHelper.getRandomIntegerInRange(par1World.rand, 3, 7); } else if (this.blockID == Block.oreEmerald.blockID) { j1 = MathHelper.getRandomIntegerInRange(par1World.rand, 3, 7); } else if (this.blockID == Block.oreLapis.blockID) { j1 = MathHelper.getRandomIntegerInRange(par1World.rand, 2, 5); } else if (this.blockID == Block.field_94342_cr.blockID) { j1 = MathHelper.getRandomIntegerInRange(par1World.rand, 2, 5); } this.dropXpOnBlockBreak(par1World, par2, par3, par4, j1); } }
public void update() { MusicTicker.MusicType musictype = this.field_147677_b.func_147109_W(); if (FMLClientHandler.instance().getWorldClient() != null && FMLClientHandler.instance().getWorldClient().provider instanceof IGalacticraftWorldProvider) { musictype = MUSIC_TYPE_MARS; } if (this.field_147678_c != null) { if (!musictype .getMusicTickerLocation() .equals(this.field_147678_c.getPositionedSoundLocation())) { this.field_147677_b.getSoundHandler().stopSound(this.field_147678_c); this.field_147676_d = MathHelper.getRandomIntegerInRange( this.field_147679_a, 0, musictype.func_148634_b() / 2); } if (!this.field_147677_b.getSoundHandler().isSoundPlaying(this.field_147678_c)) { this.field_147678_c = null; this.field_147676_d = Math.min( MathHelper.getRandomIntegerInRange( this.field_147679_a, musictype.func_148634_b(), musictype.func_148633_c()), this.field_147676_d); } } if (this.field_147678_c == null && this.field_147676_d-- <= 0) { this.field_147678_c = PositionedSoundRecord.func_147673_a(musictype.getMusicTickerLocation()); this.field_147677_b.getSoundHandler().playSound(this.field_147678_c); this.field_147676_d = Integer.MAX_VALUE; } }
@SuppressWarnings("rawtypes") public static StructureBoundingBox func_74933_a( StructureComponentSaturnVillageStartPiece par0ComponentVillageStartPiece, List par1List, Random par2Random, int par3, int par4, int par5, int par6) { for (int var7 = 7 * MathHelper.getRandomIntegerInRange(par2Random, 3, 5); var7 >= 7; var7 -= 7) { final StructureBoundingBox var8 = StructureBoundingBox.getComponentToAddBoundingBox( par3, par4, par5, 0, 0, 0, 3, 3, var7, par6); if (StructureComponent.findIntersecting(par1List, var8) == null) { return var8; } } return null; }
@Override public PieceWeight getVillagePieceWeight(Random random, int i) { return new PieceWeight( ComponentVillageTavern.class, 18, MathHelper.getRandomIntegerInRange(random, 0 + i, 2 + i)); }
public void spawnActualHouse(World world, Random rand, StructureBoundingBox sbb) { this.fillWithBlocks(world, sbb, 1, 0, 1, 2, 0, 7, Blocks.farmland); this.fillWithBlocks(world, sbb, 4, 0, 1, 5, 0, 7, Blocks.farmland); this.fillWithBlocks(world, sbb, 7, 0, 1, 8, 0, 7, Blocks.farmland); this.fillWithBlocks(world, sbb, 10, 0, 1, 11, 0, 7, Blocks.farmland); this.fillWithBlocks(world, sbb, 0, 0, 0, 0, 0, 8, Blocks.log); this.fillWithBlocks(world, sbb, 6, 0, 0, 6, 0, 8, Blocks.log); this.fillWithBlocks(world, sbb, 12, 0, 0, 12, 0, 8, Blocks.log); this.fillWithBlocks(world, sbb, 1, 0, 0, 11, 0, 0, Blocks.log); this.fillWithBlocks(world, sbb, 1, 0, 8, 11, 0, 8, Blocks.log); this.fillWithBlocks(world, sbb, 3, 0, 1, 3, 0, 7, Blocks.water); this.fillWithBlocks(world, sbb, 9, 0, 1, 9, 0, 7, Blocks.water); for (int i = 1; i <= 7; ++i) { this.placeBlockAtCurrentPosition( world, this.getRandomCropType(rand), MathHelper.getRandomIntegerInRange(rand, 1, 7), 1, 1, i, sbb); this.placeBlockAtCurrentPosition( world, this.getRandomCropType(rand), MathHelper.getRandomIntegerInRange(rand, 1, 7), 2, 1, i, sbb); this.placeBlockAtCurrentPosition( world, this.getRandomCropType(rand), MathHelper.getRandomIntegerInRange(rand, 1, 7), 4, 1, i, sbb); this.placeBlockAtCurrentPosition( world, this.getRandomCropType(rand), MathHelper.getRandomIntegerInRange(rand, 1, 7), 5, 1, i, sbb); this.placeBlockAtCurrentPosition( world, this.getRandomCropType(rand), MathHelper.getRandomIntegerInRange(rand, 1, 7), 7, 1, i, sbb); this.placeBlockAtCurrentPosition( world, this.getRandomCropType(rand), MathHelper.getRandomIntegerInRange(rand, 1, 7), 8, 1, i, sbb); this.placeBlockAtCurrentPosition( world, this.getRandomCropType(rand), MathHelper.getRandomIntegerInRange(rand, 1, 7), 10, 1, i, sbb); this.placeBlockAtCurrentPosition( world, this.getRandomCropType(rand), MathHelper.getRandomIntegerInRange(rand, 1, 7), 11, 1, i, sbb); } }
@Override public boolean addComponentParts( World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) { if (this.averageGroundLevel < 0) { this.averageGroundLevel = this.getAverageGroundLevel(par1World, par3StructureBoundingBox); if (this.averageGroundLevel < 0) { return true; } this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + 7 - 1, 0); } this.fillWithBlocks( par1World, par3StructureBoundingBox, 0, 1, 0, 12, 4, 8, Blocks.air, Blocks.air, false); this.fillWithBlocks( par1World, par3StructureBoundingBox, 1, 0, 1, 2, 0, 7, Blocks.dirt, Blocks.dirt, false); this.fillWithBlocks( par1World, par3StructureBoundingBox, 4, 0, 1, 5, 0, 7, Blocks.dirt, Blocks.dirt, false); this.fillWithBlocks( par1World, par3StructureBoundingBox, 7, 0, 1, 8, 0, 7, Blocks.dirt, Blocks.dirt, false); this.fillWithBlocks( par1World, par3StructureBoundingBox, 10, 0, 1, 11, 0, 7, Blocks.dirt, Blocks.dirt, false); this.fillWithBlocks( par1World, par3StructureBoundingBox, 0, 0, 0, 0, 0, 8, Blocks.planks, Blocks.planks, false); this.fillWithBlocks( par1World, par3StructureBoundingBox, 6, 0, 0, 6, 0, 8, Blocks.planks, Blocks.planks, false); this.fillWithBlocks( par1World, par3StructureBoundingBox, 12, 0, 0, 12, 0, 8, Blocks.planks, Blocks.planks, false); this.fillWithBlocks( par1World, par3StructureBoundingBox, 1, 0, 0, 11, 0, 0, Blocks.planks, Blocks.planks, false); this.fillWithBlocks( par1World, par3StructureBoundingBox, 1, 0, 8, 11, 0, 8, Blocks.planks, Blocks.planks, false); this.fillWithBlocks( par1World, par3StructureBoundingBox, 3, 0, 1, 3, 0, 7, Blocks.flowing_water, Blocks.flowing_water, false); this.fillWithBlocks( par1World, par3StructureBoundingBox, 9, 0, 1, 9, 0, 7, Blocks.flowing_water, Blocks.flowing_water, false); int var4; for (var4 = 1; var4 <= 7; ++var4) { for (int i = 1; i < 12; i++) { if (i % 3 != 0) { if (par2Random.nextInt(3) == 0) { this.placeBlockAtCurrentPosition( par1World, Blocks.sapling, MathHelper.getRandomIntegerInRange(par2Random, 0, 2), i, 1, var4, par3StructureBoundingBox); } } } } for (var4 = 0; var4 < 9; ++var4) { for (int var5 = 0; var5 < 13; ++var5) { this.clearCurrentPositionBlocksUpwards(par1World, var5, 4, var4, par3StructureBoundingBox); this.func_151554_b(par1World, Blocks.dirt, 0, var5, -1, var4, par3StructureBoundingBox); } } return true; }
public StructureVillagePieceWeight getVillagePieceWeight(Random random, int i) { // TODO Auto-generated method stub return new StructureVillagePieceWeight( ComponentVillageHouseTurk.class, 4, MathHelper.getRandomIntegerInRange(random, 0, 1)); }
/** Called to update the entity's position/logic. */ public void onUpdate() { super.onUpdate(); if (this.fishPosRotationIncrements > 0) { double d7 = this.posX + (this.fishX - this.posX) / (double) this.fishPosRotationIncrements; double d8 = this.posY + (this.fishY - this.posY) / (double) this.fishPosRotationIncrements; double d9 = this.posZ + (this.fishZ - this.posZ) / (double) this.fishPosRotationIncrements; double d1 = MathHelper.wrapAngleTo180_double(this.fishYaw - (double) this.rotationYaw); this.rotationYaw = (float) ((double) this.rotationYaw + d1 / (double) this.fishPosRotationIncrements); this.rotationPitch = (float) ((double) this.rotationPitch + (this.fishPitch - (double) this.rotationPitch) / (double) this.fishPosRotationIncrements); --this.fishPosRotationIncrements; this.setPosition(d7, d8, d9); this.setRotation(this.rotationYaw, this.rotationPitch); } else { if (!this.worldObj.isRemote) { ItemStack itemstack = this.angler.getCurrentEquippedItem(); if (this.angler.isDead || !this.angler.isEntityAlive() || itemstack == null || itemstack.getItem() != Items.fishing_rod || this.getDistanceSqToEntity(this.angler) > 1024.0D) { this.setDead(); this.angler.fishEntity = null; return; } if (this.caughtEntity != null) { if (!this.caughtEntity.isDead) { this.posX = this.caughtEntity.posX; double d17 = (double) this.caughtEntity.height; this.posY = this.caughtEntity.getEntityBoundingBox().minY + d17 * 0.8D; this.posZ = this.caughtEntity.posZ; return; } this.caughtEntity = null; } } if (this.shake > 0) { --this.shake; } if (this.inGround) { if (this.worldObj.getBlockState(new BlockPos(this.xTile, this.yTile, this.zTile)).getBlock() == this.inTile) { ++this.ticksInGround; if (this.ticksInGround == 1200) { this.setDead(); } return; } this.inGround = false; this.motionX *= (double) (this.rand.nextFloat() * 0.2F); this.motionY *= (double) (this.rand.nextFloat() * 0.2F); this.motionZ *= (double) (this.rand.nextFloat() * 0.2F); this.ticksInGround = 0; this.ticksInAir = 0; } else { ++this.ticksInAir; } Vec3 vec31 = new Vec3(this.posX, this.posY, this.posZ); Vec3 vec3 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec31, vec3); vec31 = new Vec3(this.posX, this.posY, this.posZ); vec3 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); if (movingobjectposition != null) { vec3 = new Vec3( movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); } Entity entity = null; List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity( this, this.getEntityBoundingBox() .addCoord(this.motionX, this.motionY, this.motionZ) .expand(1.0D, 1.0D, 1.0D)); double d0 = 0.0D; for (int i = 0; i < list.size(); ++i) { Entity entity1 = (Entity) list.get(i); if (entity1.canBeCollidedWith() && (entity1 != this.angler || this.ticksInAir >= 5)) { float f = 0.3F; AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand((double) f, (double) f, (double) f); MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec31, vec3); if (movingobjectposition1 != null) { double d2 = vec31.squareDistanceTo(movingobjectposition1.hitVec); if (d2 < d0 || d0 == 0.0D) { entity = entity1; d0 = d2; } } } } if (entity != null) { movingobjectposition = new MovingObjectPosition(entity); } if (movingobjectposition != null) { if (movingobjectposition.entityHit != null) { if (movingobjectposition.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, this.angler), 0.0F)) { this.caughtEntity = movingobjectposition.entityHit; } } else { this.inGround = true; } } if (!this.inGround) { this.moveEntity(this.motionX, this.motionY, this.motionZ); float f5 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); this.rotationYaw = (float) (MathHelper.func_181159_b(this.motionX, this.motionZ) * 180.0D / Math.PI); for (this.rotationPitch = (float) (MathHelper.func_181159_b(this.motionY, (double) f5) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) {; } while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { this.prevRotationPitch += 360.0F; } while (this.rotationYaw - this.prevRotationYaw < -180.0F) { this.prevRotationYaw -= 360.0F; } while (this.rotationYaw - this.prevRotationYaw >= 180.0F) { this.prevRotationYaw += 360.0F; } this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; float f6 = 0.92F; if (this.onGround || this.isCollidedHorizontally) { f6 = 0.5F; } int j = 5; double d10 = 0.0D; for (int k = 0; k < j; ++k) { AxisAlignedBB axisalignedbb1 = this.getEntityBoundingBox(); double d3 = axisalignedbb1.maxY - axisalignedbb1.minY; double d4 = axisalignedbb1.minY + d3 * (double) k / (double) j; double d5 = axisalignedbb1.minY + d3 * (double) (k + 1) / (double) j; AxisAlignedBB axisalignedbb2 = new AxisAlignedBB( axisalignedbb1.minX, d4, axisalignedbb1.minZ, axisalignedbb1.maxX, d5, axisalignedbb1.maxZ); if (this.worldObj.isAABBInMaterial(axisalignedbb2, Material.water)) { d10 += 1.0D / (double) j; } } if (!this.worldObj.isRemote && d10 > 0.0D) { WorldServer worldserver = (WorldServer) this.worldObj; int l = 1; BlockPos blockpos = (new BlockPos(this)).up(); if (this.rand.nextFloat() < 0.25F && this.worldObj.canLightningStrike(blockpos)) { l = 2; } if (this.rand.nextFloat() < 0.5F && !this.worldObj.canSeeSky(blockpos)) { --l; } if (this.ticksCatchable > 0) { --this.ticksCatchable; if (this.ticksCatchable <= 0) { this.ticksCaughtDelay = 0; this.ticksCatchableDelay = 0; } } else if (this.ticksCatchableDelay > 0) { this.ticksCatchableDelay -= l; if (this.ticksCatchableDelay <= 0) { this.motionY -= 0.20000000298023224D; this.playSound( "random.splash", 0.25F, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F); float f8 = (float) MathHelper.floor_double(this.getEntityBoundingBox().minY); worldserver.spawnParticle( EnumParticleTypes.WATER_BUBBLE, this.posX, (double) (f8 + 1.0F), this.posZ, (int) (1.0F + this.width * 20.0F), (double) this.width, 0.0D, (double) this.width, 0.20000000298023224D, new int[0]); worldserver.spawnParticle( EnumParticleTypes.WATER_WAKE, this.posX, (double) (f8 + 1.0F), this.posZ, (int) (1.0F + this.width * 20.0F), (double) this.width, 0.0D, (double) this.width, 0.20000000298023224D, new int[0]); this.ticksCatchable = MathHelper.getRandomIntegerInRange(this.rand, 10, 30); } else { this.fishApproachAngle = (float) ((double) this.fishApproachAngle + this.rand.nextGaussian() * 4.0D); float f7 = this.fishApproachAngle * 0.017453292F; float f10 = MathHelper.sin(f7); float f11 = MathHelper.cos(f7); double d13 = this.posX + (double) (f10 * (float) this.ticksCatchableDelay * 0.1F); double d15 = (double) ((float) MathHelper.floor_double(this.getEntityBoundingBox().minY) + 1.0F); double d16 = this.posZ + (double) (f11 * (float) this.ticksCatchableDelay * 0.1F); Block block1 = worldserver .getBlockState(new BlockPos((int) d13, (int) d15 - 1, (int) d16)) .getBlock(); if (block1 == Blocks.water || block1 == Blocks.flowing_water) { if (this.rand.nextFloat() < 0.15F) { worldserver.spawnParticle( EnumParticleTypes.WATER_BUBBLE, d13, d15 - 0.10000000149011612D, d16, 1, (double) f10, 0.1D, (double) f11, 0.0D, new int[0]); } float f3 = f10 * 0.04F; float f4 = f11 * 0.04F; worldserver.spawnParticle( EnumParticleTypes.WATER_WAKE, d13, d15, d16, 0, (double) f4, 0.01D, (double) (-f3), 1.0D, new int[0]); worldserver.spawnParticle( EnumParticleTypes.WATER_WAKE, d13, d15, d16, 0, (double) (-f4), 0.01D, (double) f3, 1.0D, new int[0]); } } } else if (this.ticksCaughtDelay > 0) { this.ticksCaughtDelay -= l; float f1 = 0.15F; if (this.ticksCaughtDelay < 20) { f1 = (float) ((double) f1 + (double) (20 - this.ticksCaughtDelay) * 0.05D); } else if (this.ticksCaughtDelay < 40) { f1 = (float) ((double) f1 + (double) (40 - this.ticksCaughtDelay) * 0.02D); } else if (this.ticksCaughtDelay < 60) { f1 = (float) ((double) f1 + (double) (60 - this.ticksCaughtDelay) * 0.01D); } if (this.rand.nextFloat() < f1) { float f9 = MathHelper.randomFloatClamp(this.rand, 0.0F, 360.0F) * 0.017453292F; float f2 = MathHelper.randomFloatClamp(this.rand, 25.0F, 60.0F); double d12 = this.posX + (double) (MathHelper.sin(f9) * f2 * 0.1F); double d14 = (double) ((float) MathHelper.floor_double(this.getEntityBoundingBox().minY) + 1.0F); double d6 = this.posZ + (double) (MathHelper.cos(f9) * f2 * 0.1F); Block block = worldserver .getBlockState(new BlockPos((int) d12, (int) d14 - 1, (int) d6)) .getBlock(); if (block == Blocks.water || block == Blocks.flowing_water) { worldserver.spawnParticle( EnumParticleTypes.WATER_SPLASH, d12, d14, d6, 2 + this.rand.nextInt(2), 0.10000000149011612D, 0.0D, 0.10000000149011612D, 0.0D, new int[0]); } } if (this.ticksCaughtDelay <= 0) { this.fishApproachAngle = MathHelper.randomFloatClamp(this.rand, 0.0F, 360.0F); this.ticksCatchableDelay = MathHelper.getRandomIntegerInRange(this.rand, 20, 80); } } else { this.ticksCaughtDelay = MathHelper.getRandomIntegerInRange(this.rand, 100, 900); this.ticksCaughtDelay -= EnchantmentHelper.getLureModifier(this.angler) * 20 * 5; } if (this.ticksCatchable > 0) { this.motionY -= (double) (this.rand.nextFloat() * this.rand.nextFloat() * this.rand.nextFloat()) * 0.2D; } } double d11 = d10 * 2.0D - 1.0D; this.motionY += 0.03999999910593033D * d11; if (d10 > 0.0D) { f6 = (float) ((double) f6 * 0.9D); this.motionY *= 0.8D; } this.motionX *= (double) f6; this.motionY *= (double) f6; this.motionZ *= (double) f6; this.setPosition(this.posX, this.posY, this.posZ); } } }
@Override public int getExpDrop(IBlockAccess world, int meta, int fortune) { return MathHelper.getRandomIntegerInRange(BlockList.blockRandom, 1, 6); }
/** Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { if (!super.attackEntityFrom(par1DamageSource, par2)) { return false; } else { EntityLivingBase entitylivingbase = this.getAttackTarget(); if (entitylivingbase == null && this.getEntityToAttack() instanceof EntityLivingBase) { entitylivingbase = (EntityLivingBase) this.getEntityToAttack(); } if (entitylivingbase == null && par1DamageSource.getEntity() instanceof EntityLivingBase) { entitylivingbase = (EntityLivingBase) par1DamageSource.getEntity(); } int i = MathHelper.floor_double(this.posX); int j = MathHelper.floor_double(this.posY); int k = MathHelper.floor_double(this.posZ); SummonAidEvent summonAid = ForgeEventFactory.fireZombieSummonAid( this, worldObj, i, j, k, entitylivingbase, this.getEntityAttribute(field_110186_bp).getAttributeValue()); if (summonAid.getResult() == Result.DENY) { return true; } else if (summonAid.getResult() == Result.ALLOW || entitylivingbase != null && this.worldObj.difficultySetting >= 3 && (double) this.rand.nextFloat() < this.getEntityAttribute(field_110186_bp).getAttributeValue()) { EntityZombie entityzombie; if (summonAid.customSummonedAid != null && summonAid.getResult() == Result.ALLOW) { entityzombie = summonAid.customSummonedAid; } else { entityzombie = new EntityZombie(this.worldObj); } for (int l = 0; l < 50; ++l) { int i1 = i + MathHelper.getRandomIntegerInRange(this.rand, 7, 40) * MathHelper.getRandomIntegerInRange(this.rand, -1, 1); int j1 = j + MathHelper.getRandomIntegerInRange(this.rand, 7, 40) * MathHelper.getRandomIntegerInRange(this.rand, -1, 1); int k1 = k + MathHelper.getRandomIntegerInRange(this.rand, 7, 40) * MathHelper.getRandomIntegerInRange(this.rand, -1, 1); if (this.worldObj.doesBlockHaveSolidTopSurface(i1, j1 - 1, k1) && this.worldObj.getBlockLightValue(i1, j1, k1) < 10) { entityzombie.setPosition((double) i1, (double) j1, (double) k1); if (this.worldObj.checkNoEntityCollision(entityzombie.boundingBox) && this.worldObj .getCollidingBoundingBoxes(entityzombie, entityzombie.boundingBox) .isEmpty() && !this.worldObj.isAnyLiquid(entityzombie.boundingBox)) { this.worldObj.spawnEntityInWorld(entityzombie); if (entitylivingbase != null) entityzombie.setAttackTarget(entitylivingbase); entityzombie.onSpawnWithEgg((EntityLivingData) null); this.getEntityAttribute(field_110186_bp) .applyModifier( new AttributeModifier( "Zombie reinforcement caller charge", -0.05000000074505806D, 0)); entityzombie .getEntityAttribute(field_110186_bp) .applyModifier( new AttributeModifier( "Zombie reinforcement callee charge", -0.05000000074505806D, 0)); break; } } } } return true; } }
@Override public int getExpDrop(IBlockAccess world, int p_149690_5_, int p_149690_7_) { return MathHelper.getRandomIntegerInRange(rand, 0, 2); }