/** * Spawns the ItemStack into the world. If it is a large stack it is broken down into smaller * stacks and spun out at different velocities. * * @param world * @param stack * @param x * @param y * @param z */ public static void spawnIntoWorld( final World world, final ItemStack stack, final double x, final double y, final double z) { if (stack == null) return; final float f = rand.nextFloat() * 0.8F + 0.1F; final float f1 = rand.nextFloat() * 0.8F + 0.1F; final float f2 = rand.nextFloat() * 0.8F + 0.1F; while (stack.stackSize > 0) { int j = rand.nextInt(21) + 10; if (j > stack.stackSize) { j = stack.stackSize; } stack.stackSize -= j; final EntityItem item = new EntityItem( world, x + f, y + f1, z + f2, new ItemStack(stack.getItem(), j, getItemDamage(stack))); if (stack.hasTagCompound()) { item.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy()); } world.spawnEntityInWorld(item); } }
@SideOnly(Side.CLIENT) /** A randomly called display update to be able to add particles or other items for display */ public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { int var6 = par1World.getBlockMetadata(par2, par3, par4); if (var6 > 0) { double var7 = (double) par2 + 0.5D + ((double) par5Random.nextFloat() - 0.5D) * 0.2D; double var9 = (double) ((float) par3 + 0.0625F); double var11 = (double) par4 + 0.5D + ((double) par5Random.nextFloat() - 0.5D) * 0.2D; float var13 = (float) var6 / 15.0F; float var14 = var13 * 0.6F + 0.4F; if (var6 == 0) { var14 = 0.0F; } float var15 = var13 * var13 * 0.7F - 0.5F; float var16 = var13 * var13 * 0.6F - 0.7F; if (var15 < 0.0F) { var15 = 0.0F; } if (var16 < 0.0F) { var16 = 0.0F; } par1World.spawnParticle( "reddust", var7, var9, var11, (double) var14, (double) var15, (double) var16); } }
@Override public synchronized void run() { try { // print header inputBuffer.put("<h>sysTime\tBattV\tCurrent\tDutyCycle\tCadence\tGenSpeed\tconst</h>"); inputBuffer.put("<u>s\tmillivolts\tmilliamps\tpercent\thz\thz\tconst</u>"); } catch (Exception ex) { } while (!quit) { counter++; float battV = rndGen.nextFloat() * 3 + 12; float current = rndGen.nextFloat() * 3 + -1001; float dutyCycle = rndGen.nextFloat() * 50 + 50; float cadence = rndGen.nextFloat() * (float) (.2) - (float) (.1); float genSpeed = rndGen.nextFloat() * 250 + 10000; try { Thread.sleep(100); inputBuffer.put( String.format( "<r>%.3f\t%.3f\t%.3f\t%.3f\t%.3f\t" + "%.3f\t%d</r>", (float) time / 1000.0, battV, current, dutyCycle, cadence, genSpeed, 5)); if (counter % 10 == 0) inputBuffer.put("<m>message at row " + counter + "</m>"); } catch (Exception e) { System.out.print("\nin testSerialInput\n"); } time += 100; } }
public void GiveAir(World world, int i, int j, int k) { int meta = world.getBlockMetadata(i, j, k); int x = blockMap[meta][0]; int z = blockMap[meta][1]; Random random = new Random(); float f = (float) i + x + 0.5F; float f1 = j + 0.1F + random.nextFloat() * 6F / 16F; float f2 = (float) k + z + 0.5F; float f3 = 0.82F; float f4 = random.nextFloat() * 0.6F; float f5 = random.nextFloat() * -0.6F; float f6 = random.nextFloat() * -0.6F; world.spawnParticle("smoke", f + f4 - 0.3F, f1, f2 + f5 + 0.3F, 0.0D, 0.0D, 0.0D); TileEntity te = world.getBlockTileEntity(i + x, j, k + z); TileEntity te2 = world.getBlockTileEntity(i + x, j - 1, k + z); TileEntityFireEntity tileentityfirepit = null; ; if (te != null && te instanceof TileEntityFireEntity) { tileentityfirepit = (TileEntityFireEntity) te; } else if (te2 != null && te2 instanceof TileEntityFireEntity) { tileentityfirepit = (TileEntityFireEntity) te2; } if (tileentityfirepit != null) { tileentityfirepit.receiveAirFromBellows(); } }
private void misoFuzzyGateTest(String gateClassName, int operationNo) { // run the node for testing RosRunner gate = runNode(gateClassName); RosRunner rr = runNode("org.hanns.logic.fuzzy.gates.MisoFuzzyGateTester"); MisoFuzzyGateTester mt = startMisoFuzzyGateTester(rr); ArrayList<Float> receivedData = new ArrayList<Float>(); ArrayList<Float[]> sentData = new ArrayList<Float[]>(50); float a = r.nextFloat(), b = r.nextFloat(); Float[] tmp = new Float[] {new Float(a), new Float(b)}; tmp[r.nextInt(2)] = new Float(0); // at least one value should be 0 at the beginning sentData.add(tmp.clone()); this.appendRandomData(sentData, 30, -1); this.appendRandomData(sentData, 10, 5); this.appendRandomData(sentData, 5, 100); for (int i = 0; i < sentData.size(); i++) { receivedData.add(mt.computeRemotely(sentData.get(i)[0], sentData.get(i)[1])); } System.out.println("Simulation ENDED, so checking data now!!!"); assertEquals(sentData.size(), receivedData.size()); this.testOperations(new FuzzyLogic(operationNo), sentData, receivedData); rr.stop(); gate.stop(); }
public void ejectContents() { float f3 = 0.05F; EntityItem entityitem; Random rand = new Random(); float f = rand.nextFloat() * 0.8F + 0.1F; float f1 = rand.nextFloat() * 2.0F + 0.4F; float f2 = rand.nextFloat() * 0.8F + 0.1F; for (int i = 0; i < getSizeInventory(); i++) { if (fireItemStacks[i] != null) { entityitem = new EntityItem(worldObj, xCoord + f, yCoord + f1, zCoord + f2, fireItemStacks[i]); entityitem.motionX = (float) rand.nextGaussian() * f3; entityitem.motionY = (float) rand.nextGaussian() * f3 + 0.2F; entityitem.motionZ = (float) rand.nextGaussian() * f3; worldObj.spawnEntityInWorld(entityitem); } } // charcoal if (this.charcoalCount > 0) { entityitem = new EntityItem( worldObj, xCoord + f, yCoord + f1, zCoord + f2, new ItemStack(TFCItems.Coal, charcoalCount, 1)); entityitem.motionX = (float) rand.nextGaussian() * f3; entityitem.motionY = (float) rand.nextGaussian() * f3 + 0.2F; entityitem.motionZ = (float) rand.nextGaussian() * f3; worldObj.spawnEntityInWorld(entityitem); } }
private void dropItems(World world, int x, int y, int z) { Random rand = new Random(); TileEntity tileEntity = world.getBlockTileEntity(x, y, z); if (!(tileEntity instanceof IInventory)) { return; } IInventory inventory = (IInventory) tileEntity; for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack item = inventory.getStackInSlot(i); if (item != null && item.stackSize > 0) { float rx = rand.nextFloat() * 0.8F + 0.1F; float ry = rand.nextFloat() * 0.8F + 0.1F; float rz = rand.nextFloat() * 0.8F + 0.1F; EntityItem entityItem = new EntityItem( world, x + rx, y + ry, z + rz, new ItemStack(item.itemID, item.stackSize, item.getItemDamage())); if (item.hasTagCompound()) { entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy()); } float factor = 0.05F; entityItem.motionX = rand.nextGaussian() * factor; entityItem.motionY = rand.nextGaussian() * factor + 0.2F; entityItem.motionZ = rand.nextGaussian() * factor; world.spawnEntityInWorld(entityItem); item.stackSize = 0; } } }
public void jolt() { Random r = new Random(); Vector v = new Vector(r.nextFloat() - 0.5f, r.nextFloat() - 0.5f, 0); v.normalize(); v.scale(0.1f); particle.applyForce(v); }
private void func_319_i(World world, int i, int j, int k) { Random random = world.rand; double d = 0.0625D; for (int l = 0; l < 6; l++) { double d1 = (float) i + random.nextFloat(); double d2 = (float) j + random.nextFloat(); double d3 = (float) k + random.nextFloat(); if (l == 0 && !world.isBlockOpaqueCube(i, j + 1, k)) { d2 = (double) (j + 1) + d; } if (l == 1 && !world.isBlockOpaqueCube(i, j - 1, k)) { d2 = (double) (j + 0) - d; } if (l == 2 && !world.isBlockOpaqueCube(i, j, k + 1)) { d3 = (double) (k + 1) + d; } if (l == 3 && !world.isBlockOpaqueCube(i, j, k - 1)) { d3 = (double) (k + 0) - d; } if (l == 4 && !world.isBlockOpaqueCube(i + 1, j, k)) { d1 = (double) (i + 1) + d; } if (l == 5 && !world.isBlockOpaqueCube(i - 1, j, k)) { d1 = (double) (i + 0) - d; } if (d1 < (double) i || d1 > (double) (i + 1) || d2 < 0.0D || d2 > (double) (j + 1) || d3 < (double) k || d3 > (double) (k + 1)) { world.spawnParticle("reddust", d1, d2, d3, 0.0D, 0.0D, 0.0D); } } }
@SideOnly(Side.CLIENT) @Override public void randomDisplayTick(World world, int x, int y, int z, Random rand) { if (isActive(world, x, y, z) && shouldDoWorkThisTick(world, x, y, z, 5)) { float startX = x + 1.0F; float startY = y + 0.85F; float startZ = z + 1.0F; for (int i = 0; i < 1; i++) { float xOffset = -0.2F - rand.nextFloat() * 0.6F; float yOffset = -0.1F + rand.nextFloat() * 0.2F; float zOffset = -0.2F - rand.nextFloat() * 0.6F; EntityFX fx = Minecraft.getMinecraft() .renderGlobal .doSpawnParticle( "spell", startX + xOffset, startY + yOffset, startZ + zOffset, 0.0D, 0.0D, 0.0D); if (fx != null) { fx.setRBGColorF(0.2f, 0.2f, 0.8f); fx.motionY *= 0.5f; } } } }
@Override public void updateEntity() { Random r = new Random(); int i = this.xCoord; int j = this.yCoord; int k = this.zCoord; World world = this.worldObj; count = count + 1; if (count % 1 == 0) { for (int num = 0; num < Particles.INTENSITY; num++) { double theta = r.nextDouble() * Math.PI * 2; double x = Math.cos(theta) * 1.5D; double z = Math.sin(theta) * 1.5D; AcceleratedParticle p = new AcceleratedParticle( world, i + 0.5 + x, j, k + 0.5 + z, -x / 7.5D, 1.5 / 10D, -z / 7.5D); p.setRBGColorF((0.5F + (r.nextFloat() / 2)), 0.0F, 1.0F); p.setParticleTextureIndex(3); Minecraft.getMinecraft().effectRenderer.addEffect(p); AcceleratedParticle l = new AcceleratedParticle( world, i + 0.5 + x, j + 3, k + 0.5 + z, -x / 7.5D, -(1.75 / 10D), -z / 7.5D); l.setRBGColorF((0.5F + (r.nextFloat() / 2)), 0.0F, 1.0F); l.setParticleTextureIndex(3); Minecraft.getMinecraft().effectRenderer.addEffect(l); } } }
@SideOnly(Side.CLIENT) public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { double d0 = (double) ((float) pos.getX() + 0.4F + rand.nextFloat() * 0.2F); double d1 = (double) ((float) pos.getY() + 0.7F + rand.nextFloat() * 0.3F); double d2 = (double) ((float) pos.getZ() + 0.4F + rand.nextFloat() * 0.2F); worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]); }
public void spawnBirds() { for (Vector2f coordinate : birdformations.getRandomBirdFormation( (random.nextFloat() * 1300) + 0, (random.nextFloat() * 420) + 0)) { sceneHandler.spawn(coordinate.getX(), coordinate.getY(), PBird.class); } }
private Color changeColor() { // Commands to change the colors of the two Yin Yangs randomly // to some other color return new Color( Color.HSBtoRGB( randomNumber.nextFloat(), randomNumber.nextFloat(), randomNumber.nextFloat())); }
/** * Rotate specified Bitmap by a random angle. The angle is either negative or positive, and * ranges, in degrees, from 2.5 to 8. After rotation a frame is overlaid on top of the rotated * image. * * <p>This method is not thread safe. * * @param bitmap The Bitmap to rotate and apply a frame onto. * @return A new Bitmap whose dimension are different from the original bitmap. */ static Bitmap rotateAndFrame(Bitmap bitmap) { final boolean positive = sRandom.nextFloat() >= 0.5f; final float angle = (ROTATION_ANGLE_MIN + sRandom.nextFloat() * ROTATION_ANGLE_EXTRA) * (positive ? 1.0f : -1.0f); final double radAngle = Math.toRadians(angle); final int bitmapWidth = bitmap.getWidth(); final int bitmapHeight = bitmap.getHeight(); final double cosAngle = Math.abs(Math.cos(radAngle)); final double sinAngle = Math.abs(Math.sin(radAngle)); final int strokedWidth = (int) (bitmapWidth + 2 * PHOTO_BORDER_WIDTH); final int strokedHeight = (int) (bitmapHeight + 2 * PHOTO_BORDER_WIDTH); final int width = (int) (strokedHeight * sinAngle + strokedWidth * cosAngle); final int height = (int) (strokedWidth * sinAngle + strokedHeight * cosAngle); final float x = (width - bitmapWidth) / 2.0f; final float y = (height - bitmapHeight) / 2.0f; final Bitmap decored = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(decored); canvas.rotate(angle, width / 2.0f, height / 2.0f); canvas.drawBitmap(bitmap, x, y, sPaint); canvas.drawRect(x, y, x + bitmapWidth, y + bitmapHeight, sStrokePaint); return decored; }
@Override public Power getPower() { Power power = new Power(); power.setVolts(random.nextFloat() * 10); power.setAmperes(random.nextFloat()); return power; }
@SideOnly(Side.CLIENT) public void randomDisplayTick(World world, int x, int y, int z, Random random) { if (this.isActive) { int l = world.getBlockMetadata(x, y, z); float f = (float) x + 0.5F; float f1 = (float) y + 0.0F + random.nextFloat() * 6.0F / 16.0F; float f2 = (float) z + 0.5F; float f3 = 0.52F; float f4 = random.nextFloat() * 0.6F - 0.3F; if (l == 4) { world.spawnParticle( "smoke", (double) (f - f3), (double) f1, (double) (f2 + f4), 0.0D, 0.0D, 0.0D); world.spawnParticle( "flame", (double) (f - f3), (double) f1, (double) (f2 + f4), 0.0D, 0.0D, 0.0D); } else if (l == 5) { world.spawnParticle( "smoke", (double) (f + f3), (double) f1, (double) (f2 + f4), 0.0D, 0.0D, 0.0D); world.spawnParticle( "flame", (double) (f + f3), (double) f1, (double) (f2 + f4), 0.0D, 0.0D, 0.0D); } else if (l == 2) { world.spawnParticle( "smoke", (double) (f + f4), (double) f1, (double) (f2 - f3), 0.0D, 0.0D, 0.0D); world.spawnParticle( "flame", (double) (f + f4), (double) f1, (double) (f2 - f3), 0.0D, 0.0D, 0.0D); } else if (l == 3) { world.spawnParticle( "smoke", (double) (f + f4), (double) f1, (double) (f2 + f3), 0.0D, 0.0D, 0.0D); world.spawnParticle( "flame", (double) (f + f4), (double) f1, (double) (f2 + f3), 0.0D, 0.0D, 0.0D); } } }
private void initOriginal() throws Exception { int size = 500000; float x; float y; float z; float a; Coord3d[] points = new Coord3d[size]; Color[] colors = new Color[size]; Random r = new Random(); r.setSeed(0); for (int i = 0; i < size; i++) { x = r.nextFloat() - 0.5f; y = r.nextFloat() - 0.5f; z = r.nextFloat() - 0.5f; points[i] = new Coord3d(x, y, z); a = 0.25f; colors[i] = new Color(x, y, z, a); } Scatter scatter = new Scatter(points, colors); chart = AWTChartComponentFactory.chart(Quality.Advanced, "newt"); chart.getScene().add(scatter); }
@Override public boolean puffSmoke( World world, int x, int y, int z, float num, float speedX, float speedY) { if (world.getBlockMetadata(x, y, z) > 0) return false; IChimney chimney = (IChimney) Block.blocksList[world.getBlockId(x, y, z)]; if (chimney == null) { return false; } Random rand = new Random(); if (Block.blocksList[world.getBlockId(x, y + 1, z)] instanceof IChimney) { IChimney chimney2 = (IChimney) Block.blocksList[world.getBlockId(x, y + 1, z)]; return chimney2.puffSmoke(world, x, y + 1, z, num, speedX, speedY); } for (int a = 0; a < 30 * num; a++) { if (!world.isBlockSolidOnSide(x, y + 1, z, ForgeDirection.DOWN)) world.spawnParticle( "largesmoke", x + 0.5F, y + 1, z + 0.5F, (rand.nextFloat() - 0.5F) / 6 * speedX, 0.065F * speedY, (rand.nextFloat() - 0.5F) / 6 * speedX); } return true; }
/** * Calculates how every traffic light should be switched Per node, per sign the waiting roadusers * are passed and per each roaduser the gain is calculated. * * @param The TLDecision is a tuple consisting of a traffic light and a reward (Q) value, for it * to be green * @see gld.algo.tlc.TLDecision */ public TLDecision[][] decideTLs() { int num_dec; int num_tld = tld.length; // Determine wheter it should be random or not boolean do_this_random = false; if (random_number.nextFloat() < random_chance) do_this_random = true; for (int i = 0; i < num_tld; i++) { num_dec = tld[i].length; for (int j = 0; j < num_dec; j++) { Sign currenttl = tld[i][j].getTL(); float gain = 0; Drivelane currentlane = currenttl.getLane(); int waitingsize = currentlane.getNumRoadusersWaiting(); ListIterator queue = currentlane.getQueue().listIterator(); if (!do_this_random) { for (; waitingsize > 0; waitingsize--) { Roaduser ru = (Roaduser) queue.next(); int pos = ru.getPosition(); Node destination = ru.getDestNode(); gain += q_table[currenttl.getId()][pos][destination.getId()][1] - q_table[currenttl.getId()][pos][destination.getId()][0]; // red - green } float q = gain; } else gain = random_number.nextFloat(); tld[i][j].setGain(gain); } } return tld; }
public void func_71862_a( World p_71862_1_, int p_71862_2_, int p_71862_3_, int p_71862_4_, Random p_71862_5_) { if (this.field_72130_a) { int var6 = p_71862_1_.func_72805_g(p_71862_2_, p_71862_3_, p_71862_4_); double var7 = (double) ((float) p_71862_2_ + 0.5F) + (double) (p_71862_5_.nextFloat() - 0.5F) * 0.2D; double var9 = (double) ((float) p_71862_3_ + 0.7F) + (double) (p_71862_5_.nextFloat() - 0.5F) * 0.2D; double var11 = (double) ((float) p_71862_4_ + 0.5F) + (double) (p_71862_5_.nextFloat() - 0.5F) * 0.2D; double var13 = 0.2199999988079071D; double var15 = 0.27000001072883606D; if (var6 == 1) { p_71862_1_.func_72869_a("reddust", var7 - var15, var9 + var13, var11, 0.0D, 0.0D, 0.0D); } else if (var6 == 2) { p_71862_1_.func_72869_a("reddust", var7 + var15, var9 + var13, var11, 0.0D, 0.0D, 0.0D); } else if (var6 == 3) { p_71862_1_.func_72869_a("reddust", var7, var9 + var13, var11 - var15, 0.0D, 0.0D, 0.0D); } else if (var6 == 4) { p_71862_1_.func_72869_a("reddust", var7, var9 + var13, var11 + var15, 0.0D, 0.0D, 0.0D); } else { p_71862_1_.func_72869_a("reddust", var7, var9, var11, 0.0D, 0.0D, 0.0D); } } }
public void breakBlock(World aWorld, int aX, int aY, int aZ, Block par5, int par6) { GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if ((tTileEntity instanceof IGregTechTileEntity)) { IGregTechTileEntity tGregTechTileEntity = (IGregTechTileEntity) tTileEntity; Random tRandom = new Random(); mTemporaryTileEntity.set(tGregTechTileEntity); for (int i = 0; i < tGregTechTileEntity.getSizeInventory(); i++) { ItemStack tItem = tGregTechTileEntity.getStackInSlot(i); if ((tItem != null) && (tItem.stackSize > 0) && (tGregTechTileEntity.isValidSlot(i))) { EntityItem tItemEntity = new EntityItem( aWorld, aX + tRandom.nextFloat() * 0.8F + 0.1F, aY + tRandom.nextFloat() * 0.8F + 0.1F, aZ + tRandom.nextFloat() * 0.8F + 0.1F, new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage())); if (tItem.hasTagCompound()) { tItemEntity .getEntityItem() .setTagCompound((NBTTagCompound) tItem.getTagCompound().copy()); } tItemEntity.motionX = (tRandom.nextGaussian() * 0.0500000007450581D); tItemEntity.motionY = (tRandom.nextGaussian() * 0.0500000007450581D + 0.2000000029802322D); tItemEntity.motionZ = (tRandom.nextGaussian() * 0.0500000007450581D); aWorld.spawnEntityInWorld(tItemEntity); tItem.stackSize = 0; tGregTechTileEntity.setInventorySlotContents(i, null); } } } super.breakBlock(aWorld, aX, aY, aZ, par5, par6); aWorld.removeTileEntity(aX, aY, aZ); }
/* Straight from InventoryHelper in vanilla code */ public static void spawnInWorld(World world, BlockPos pos, ItemStack itemStack) { float f = RANDOM.nextFloat() * 0.8F + 0.1F; float f1 = RANDOM.nextFloat() * 0.8F + 0.1F; float f2 = RANDOM.nextFloat() * 0.8F + 0.1F; while (itemStack.stackSize > 0) { int i = RANDOM.nextInt(21) + 10; if (i > itemStack.stackSize) i = itemStack.stackSize; itemStack.stackSize -= i; EntityItem entityitem = new EntityItem( world, pos.getX() + (double) f, pos.getY() + (double) f1, pos.getZ() + (double) f2, new ItemStack(itemStack.getItem(), i, itemStack.getMetadata())); if (itemStack.hasTagCompound()) entityitem .getEntityItem() .setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy()); float f3 = 0.05F; entityitem.motionX = RANDOM.nextGaussian() * (double) f3; entityitem.motionY = RANDOM.nextGaussian() * (double) f3 + 0.20000000298023224D; entityitem.motionZ = RANDOM.nextGaussian() * (double) f3; world.spawnEntityInWorld(entityitem); } }
protected void dropInventory(World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); if (!(tileEntity instanceof IInventory)) { return; } IInventory inventory = (IInventory) tileEntity; for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack itemStack = inventory.getStackInSlot(i); if (itemStack != null && itemStack.stackSize > 0) { Random rand = new Random(); float dX = rand.nextFloat() * 0.8F + 0.1F; float dY = rand.nextFloat() * 0.8F + 0.1F; float dZ = rand.nextFloat() * 0.8F + 0.1F; EntityItem entityItem = new EntityItem(world, x + dX, y + dY, z + dZ, itemStack.copy()); if (itemStack.hasTagCompound()) { entityItem .getEntityItem() .setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy()); } float factor = 0.05F; entityItem.motionX = rand.nextGaussian() * factor; entityItem.motionY = rand.nextGaussian() * factor + 0.2F; entityItem.motionZ = rand.nextGaussian() * factor; world.spawnEntityInWorld(entityItem); itemStack.stackSize = 0; } } }
@SubscribeEvent public void onClientTicket(ClientTickEvent evt) { if (evt.phase == TickEvent.Phase.END && Minecraft.getMinecraft().theWorld != null) { Random rnd = Minecraft.getMinecraft().theWorld.rand; float chance = 0.004f; if (VintageCraft.proxy.meteorShowerDuration > 0) { VintageCraft.proxy.meteorShowerDuration--; chance = 0.11f; } if (rnd.nextFloat() < chance && RenderSkyVC.shootingStars.size() < 35) { RenderSkyVC.shootingStars.add( new ShootingStar( rnd.nextFloat() * 300 - 150, rnd.nextFloat() * 300 - 150, rnd.nextFloat())); } for (Iterator<ShootingStar> iterator = RenderSkyVC.shootingStars.iterator(); iterator.hasNext(); ) { ShootingStar star = iterator.next(); star.tick(); if (star.isDead()) { // Remove the current element from the iterator and the list. iterator.remove(); } } } }
@Override public void randomDisplayTick(World world, int x, int y, int z, Random random) { if (random.nextInt(1) == 0) { world.spawnParticle( "smoke", x + random.nextFloat(), y + 1.1F, z + random.nextFloat(), 0.0D, 0.0D, 0.0D); } }
@Override public void randomDisplayTick(World par1World, int x, int y, int z, Random par5Random) { TileEntity tile = par1World.getBlockTileEntity(x, y, z); if (tile instanceof GCCoreTileEntityCoalGenerator) { GCCoreTileEntityCoalGenerator tileEntity = (GCCoreTileEntityCoalGenerator) tile; if (tileEntity.generateWatts > 0) { int metadata = par1World.getBlockMetadata(x, y, z); float var7 = x + 0.5F; float var8 = y + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F; float var9 = z + 0.5F; float var10 = 0.52F; float var11 = par5Random.nextFloat() * 0.6F - 0.3F; if (metadata == 3) { par1World.spawnParticle("smoke", var7 - var10, var8, var9 + var11, 0.0D, 0.0D, 0.0D); par1World.spawnParticle("flame", var7 - var10, var8, var9 + var11, 0.0D, 0.0D, 0.0D); } else if (metadata == 2) { par1World.spawnParticle("smoke", var7 + var10, var8, var9 + var11, 0.0D, 0.0D, 0.0D); par1World.spawnParticle("flame", var7 + var10, var8, var9 + var11, 0.0D, 0.0D, 0.0D); } else if (metadata == 1) { par1World.spawnParticle("smoke", var7 + var11, var8, var9 - var10, 0.0D, 0.0D, 0.0D); par1World.spawnParticle("flame", var7 + var11, var8, var9 - var10, 0.0D, 0.0D, 0.0D); } else if (metadata == 0) { par1World.spawnParticle("smoke", var7 + var11, var8, var9 + var10, 0.0D, 0.0D, 0.0D); par1World.spawnParticle("flame", var7 + var11, var8, var9 + var10, 0.0D, 0.0D, 0.0D); } } } }
/** A randomly called display update to be able to add particles or other items for display */ public void randomDisplayTick(World var1, int var2, int var3, int var4, Random var5) { super.randomDisplayTick(var1, var2, var3, var4, var5); for (int var6 = var2 - 2; var6 <= var2 + 2; ++var6) { for (int var7 = var4 - 2; var7 <= var4 + 2; ++var7) { if (var6 > var2 - 2 && var6 < var2 + 2 && var7 == var4 - 1) { var7 = var4 + 2; } if (var5.nextInt(16) == 0) { for (int var8 = var3; var8 <= var3 + 1; ++var8) { if (var1.getBlockId(var6, var8, var7) == Block.bookShelf.blockID) { if (!var1.isAirBlock((var6 - var2) / 2 + var2, var8, (var7 - var4) / 2 + var4)) { break; } var1.spawnParticle( "enchantmenttable", (double) var2 + 0.5D, (double) var3 + 2.0D, (double) var4 + 0.5D, (double) ((float) (var6 - var2) + var5.nextFloat()) - 0.5D, (double) ((float) (var8 - var3) - var5.nextFloat() - 1.0F), (double) ((float) (var7 - var4) + var5.nextFloat()) - 0.5D); } } } } } }
/** * Calculate the next alarm time for overdue reminders. * * <p>We schedule an alarm for after the due date (which could be in the past), with the exception * that if a reminder was recently issued, we move the alarm time to the near future. * * @param task * @return */ private long calculateNextOverdueReminder(Task task) { // Uses getNowValue() instead of DateUtilities.now() if (task.hasDueDate() && task.getFlag(Task.REMINDER_FLAGS, Task.NOTIFY_AFTER_DEADLINE)) { Date due = new Date(task.getValue(Task.DUE_DATE)); if (!task.hasDueTime()) { due.setHours(23); due.setMinutes(59); due.setSeconds(59); } long dueDateForOverdue = due.getTime(); long lastReminder = task.getValue(Task.REMINDER_LAST); if (dueDateForOverdue > getNowValue()) { return dueDateForOverdue + (long) ((0.5f + 2f * random.nextFloat()) * DateUtilities.ONE_HOUR); } if (lastReminder < dueDateForOverdue) { return getNowValue(); } if (getNowValue() - lastReminder < 6 * DateUtilities.ONE_HOUR) { return getNowValue() + (long) ((2.0f + task.getValue(Task.IMPORTANCE) + 6f * random.nextFloat()) * DateUtilities.ONE_HOUR); } return getNowValue(); } return NO_ALARM; }
@Override public void run() { Random r = new Random(); VoodooSequence = r.nextDouble(); initWelder(); while (true) { UpdateWelderValues ssv = new UpdateWelderValues(main, this); ssv.schedule(); SendWeldingDatapointsCommand cmd = new SendWeldingDatapointsCommand(main, this); cmd.schedule(); if (r.nextFloat() < 0.05) { // send a "test alarm" Alarm a = new Alarm(); a.setType(AlarmTypes.CHEESEBURGER_DROPPED); a.setErrorMessage("Someone dropped a cheeseburger on the circut board."); SendAlarmCommand sac = new SendAlarmCommand(main, a); sac.schedule(); } try { Thread.sleep((long) (r.nextFloat() * 10000)); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } int queuesize = XMPCommandRunner.getQueueSize(); if (queuesize > 100) { // maybe send alarm here? or will that clog up the queue even more? } } }