private void checkForHarden(World world, int i, int j, int k) { Material material = blockMaterial; Material material1 = Material.water; if (material == Material.water) { material1 = Material.lava; } boolean flag = false; if (flag || world.getBlockMaterial(i, j, k - 1) == material1) { flag = true; } if (flag || world.getBlockMaterial(i, j, k + 1) == material1) { flag = true; } if (flag || world.getBlockMaterial(i - 1, j, k) == material1) { flag = true; } if (flag || world.getBlockMaterial(i + 1, j, k) == material1) { flag = true; } if (flag || world.getBlockMaterial(i, j + 1, k) == material1) { flag = true; } if (flag) { if (material == Material.lava) { world.setBlockWithNotify(i, j, k, Block.obsidian.blockID); } else { world.setBlockWithNotify(i, j, k, Block.cobblestone.blockID); } } }
/** Dispense the specified stack, play the dispense sound and spawn particles. */ public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { EnumFacing var3 = EnumFacing.func_82600_a(par1IBlockSource.func_82620_h()); World var4 = par1IBlockSource.getWorld(); double var5 = par1IBlockSource.getX() + (double) ((float) var3.func_82601_c() * 1.125F); double var7 = par1IBlockSource.getY(); double var9 = par1IBlockSource.getZ() + (double) ((float) var3.func_82599_e() * 1.125F); int var11 = par1IBlockSource.getXInt() + var3.func_82601_c(); int var12 = par1IBlockSource.getYInt(); int var13 = par1IBlockSource.getZInt() + var3.func_82599_e(); Material var14 = var4.getBlockMaterial(var11, var12, var13); double var15; if (Material.water.equals(var14)) { var15 = 1.0D; } else { if (!Material.air.equals(var14) || !Material.water.equals(var4.getBlockMaterial(var11, var12 - 1, var13))) { return this.defaultItemDispenseBehavior.dispense(par1IBlockSource, par2ItemStack); } var15 = 0.0D; } EntityBoat var17 = new EntityBoat(var4, var5, var7 + var15, var9); var4.spawnEntityInWorld(var17); par2ItemStack.splitStack(1); return par2ItemStack; }
/** Returns whether or not the specified creature type can spawn at the specified location. */ public static boolean canCreatureTypeSpawnAtLocation( EnumCreatureType par0EnumCreatureType, World par1World, int par2, int par3, int par4) { if (par0EnumCreatureType.getCreatureMaterial() == Material.water) { return par1World.getBlockMaterial(par2, par3, par4).isLiquid() && !par1World.isBlockNormalCube(par2, par3 + 1, par4); } else { int i = par1World.getBlockId(par2, par3 - 1, par4); return Block.isNormalCube(i) && i != Block.bedrock.blockID && !par1World.isBlockNormalCube(par2, par3, par4) && !par1World.getBlockMaterial(par2, par3, par4).isLiquid() && !par1World.isBlockNormalCube(par2, par3 + 1, par4); } }
/** Attempts to place the liquid contained inside the bucket. */ public boolean tryPlaceContainedLiquid( World par1World, double par2, double par4, double par6, int par8, int par9, int par10) { if (this.isFull <= 0) { return false; } else if (!par1World.isAirBlock(par8, par9, par10) && par1World.getBlockMaterial(par8, par9, par10).isSolid()) { return false; } else { if (par1World.provider.isHellWorld && this.isFull == Block.waterMoving.blockID) { par1World.playSoundEffect( par2 + 0.5D, par4 + 0.5D, par6 + 0.5D, "random.fizz", 0.5F, 2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F); for (int var11 = 0; var11 < 8; ++var11) { par1World.spawnParticle( "largesmoke", (double) par8 + Math.random(), (double) par9 + Math.random(), (double) par10 + Math.random(), 0.0D, 0.0D, 0.0D); } } else { par1World.setBlock(par8, par9, par10, this.isFull, 0, 3); } return true; } }
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { MovingObjectPosition movingobjectposition = func_40402_a(world, entityplayer, true); if (movingobjectposition == null) { return itemstack; } if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) { int i = movingobjectposition.blockX; int j = movingobjectposition.blockY; int k = movingobjectposition.blockZ; if (!world.canMineBlock(entityplayer, i, j, k)) { return itemstack; } if (!entityplayer.canPlayerEdit(i, j, k)) { return itemstack; } if (world.getBlockMaterial(i, j, k) == Material.water) { itemstack.stackSize--; if (itemstack.stackSize <= 0) { return new ItemStack(Item.potion); } if (!entityplayer.inventory.addItemStackToInventory(new ItemStack(Item.potion))) { entityplayer.dropPlayerItem(new ItemStack(Item.potion.shiftedIndex, 1, 0)); } } } return itemstack; }
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { MovingObjectPosition movingobjectposition = func_40402_a(world, entityplayer, true); if (movingobjectposition == null) { return itemstack; } if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) { int i = movingobjectposition.blockX; int j = movingobjectposition.blockY; int k = movingobjectposition.blockZ; if (!world.canMineBlock(entityplayer, i, j, k)) { return itemstack; } if (!entityplayer.func_35190_e(i, j, k)) { return itemstack; } if (world.getBlockMaterial(i, j, k) == Material.water && world.getBlockMetadata(i, j, k) == 0 && world.isAirBlock(i, j + 1, k)) { world.setBlockWithNotify(i, j + 1, k, Block.waterlily.blockID); if (!entityplayer.capabilities.depleteBuckets) { itemstack.stackSize--; } } } return itemstack; }
public void onNeighborBlockChange(World world, int i, int j, int k, int l) { super.onNeighborBlockChange(world, i, j, k, l); Material material = world.getBlockMaterial(i, j + 1, k); if (material.isSolid()) { world.setBlockWithNotify(i, j, k, Block.dirt.blockID); } }
/** * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed * (coordinates passed are their own) Args: x, y, z, neighbor blockID */ public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) { super.onNeighborBlockChange(par1World, par2, par3, par4, par5); Material material = par1World.getBlockMaterial(par2, par3 + 1, par4); if (material.isSolid()) { par1World.setBlockWithNotify(par2, par3, par4, Block.dirt.blockID); } }
/** * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z */ @Override public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) { if (!par1World.getBlockMaterial(par2, par3 - 1, par4).isSolid()) { return false; } else { return super.canPlaceBlockAt(par1World, par2, par3, par4); } }
public boolean canPlaceBlockAt(World world, int i, int j, int k) { if (world.getBlockId(i, j - 1, k) == blockID) { return false; } if (!world.getBlockMaterial(i, j - 1, k).isSolid()) { return false; } else { return super.canPlaceBlockAt(world, i, j, k); } }
private boolean liquidCanDisplaceBlock(World world, int i, int j, int k) { Material material = world.getBlockMaterial(i, j, k); if (material == blockMaterial) { return false; } if (material == Material.lava) { return false; } else { return !blockBlocksFlow(world, i, j, k); } }
/** * Forces lava to check to see if it is colliding with water, and then decide what it should * harden to. */ private void checkForHarden(World par1World, int par2, int par3, int par4) { if (par1World.getBlockId(par2, par3, par4) == this.blockID) { if (this.blockMaterial == Material.lava) { boolean var5 = false; if (var5 || par1World.getBlockMaterial(par2, par3, par4 - 1) == Material.water) { var5 = true; } if (var5 || par1World.getBlockMaterial(par2, par3, par4 + 1) == Material.water) { var5 = true; } if (var5 || par1World.getBlockMaterial(par2 - 1, par3, par4) == Material.water) { var5 = true; } if (var5 || par1World.getBlockMaterial(par2 + 1, par3, par4) == Material.water) { var5 = true; } if (var5 || par1World.getBlockMaterial(par2, par3 + 1, par4) == Material.water) { var5 = true; } if (var5) { int var6 = par1World.getBlockMetadata(par2, par3, par4); if (var6 == 0) { par1World.setBlockWithNotify(par2, par3, par4, Block.obsidian.blockID); } else if (var6 <= 4) { par1World.setBlockWithNotify(par2, par3, par4, Block.cobblestone.blockID); } this.triggerLavaMixEffects(par1World, par2, par3, par4); } } } }
/** returns true if there's water nearby (x-4 to x+4, y to y+1, k-4 to k+4) */ private boolean isWaterNearby(World par1World, int par2, int par3, int par4) { for (int i = par2 - 4; i <= par2 + 4; i++) { for (int j = par3; j <= par3 + 1; j++) { for (int k = par4 - 4; k <= par4 + 4; k++) { if (par1World.getBlockMaterial(i, j, k) == Material.water) { return true; } } } } return false; }
private boolean isWaterNearby(World world, int i, int j, int k) { for (int l = i - 4; l <= i + 4; l++) { for (int i1 = j; i1 <= j + 1; i1++) { for (int j1 = k - 4; j1 <= k + 4; j1++) { if (world.getBlockMaterial(l, i1, j1) == Material.water) { return true; } } } } return false; }
/** * Returns a boolean array indicating which flow directions are optimal based on each direction's * calculated flow cost. Each array index corresponds to one of the four cardinal directions. A * value of true indicates the direction is optimal. */ private boolean[] getOptimalFlowDirections(World par1World, int par2, int par3, int par4) { int var5; int var6; for (var5 = 0; var5 < 4; ++var5) { this.flowCost[var5] = 1000; var6 = par2; int var8 = par4; if (var5 == 0) { var6 = par2 - 1; } if (var5 == 1) { ++var6; } if (var5 == 2) { var8 = par4 - 1; } if (var5 == 3) { ++var8; } if (!this.blockBlocksFlow(par1World, var6, par3, var8) && (par1World.getBlockMaterial(var6, par3, var8) != this.blockMaterial || par1World.getBlockMetadata(var6, par3, var8) != 0)) { if (this.blockBlocksFlow(par1World, var6, par3 - 1, var8)) { this.flowCost[var5] = this.calculateFlowCost(par1World, var6, par3, var8, 1, var5); } else { this.flowCost[var5] = 0; } } } var5 = this.flowCost[0]; for (var6 = 1; var6 < 4; ++var6) { if (this.flowCost[var6] < var5) { var5 = this.flowCost[var6]; } } for (var6 = 0; var6 < 4; ++var6) { this.isOptimalFlowDirection[var6] = this.flowCost[var6] == var5; } return this.isOptimalFlowDirection; }
/** * calculateFlowCost(World world, int x, int y, int z, int accumulatedCost, int * previousDirectionOfFlow) - Used to determine the path of least resistance, this method returns * the lowest possible flow cost for the direction of flow indicated. Each necessary horizontal * flow adds to the flow cost. */ private int calculateFlowCost(World par1World, int par2, int par3, int par4, int par5, int par6) { int var7 = 1000; for (int var8 = 0; var8 < 4; ++var8) { if ((var8 != 0 || par6 != 1) && (var8 != 1 || par6 != 0) && (var8 != 2 || par6 != 3) && (var8 != 3 || par6 != 2)) { int var9 = par2; int var11 = par4; if (var8 == 0) { var9 = par2 - 1; } if (var8 == 1) { ++var9; } if (var8 == 2) { var11 = par4 - 1; } if (var8 == 3) { ++var11; } if (!this.blockBlocksFlow(par1World, var9, par3, var11) && (par1World.getBlockMaterial(var9, par3, var11) != this.blockMaterial || par1World.getBlockMetadata(var9, par3, var11) != 0)) { if (!this.blockBlocksFlow(par1World, var9, par3 - 1, var11)) { return par5; } if (par5 < 4) { int var12 = this.calculateFlowCost(par1World, var9, par3, var11, par5 + 1, var8); if (var12 < var7) { var7 = var12; } } } } } return var7; }
private boolean[] getOptimalFlowDirections(World world, int i, int j, int k) { for (int l = 0; l < 4; l++) { flowCost[l] = 1000; int j1 = i; int i2 = j; int j2 = k; if (l == 0) { j1--; } if (l == 1) { j1++; } if (l == 2) { j2--; } if (l == 3) { j2++; } if (blockBlocksFlow(world, j1, i2, j2) || world.getBlockMaterial(j1, i2, j2) == blockMaterial && world.getBlockMetadata(j1, i2, j2) == 0) { continue; } if (!blockBlocksFlow(world, j1, i2 - 1, j2)) { flowCost[l] = 0; } else { flowCost[l] = calculateFlowCost(world, j1, i2, j2, 1, l); } } int i1 = flowCost[0]; for (int k1 = 1; k1 < 4; k1++) { if (flowCost[k1] < i1) { i1 = flowCost[k1]; } } for (int l1 = 0; l1 < 4; l1++) { isOptimalFlowDirection[l1] = flowCost[l1] == i1; } return isOptimalFlowDirection; }
private int calculateFlowCost(World world, int i, int j, int k, int l, int i1) { int j1 = 1000; for (int k1 = 0; k1 < 4; k1++) { if (k1 == 0 && i1 == 1 || k1 == 1 && i1 == 0 || k1 == 2 && i1 == 3 || k1 == 3 && i1 == 2) { continue; } int l1 = i; int i2 = j; int j2 = k; if (k1 == 0) { l1--; } if (k1 == 1) { l1++; } if (k1 == 2) { j2--; } if (k1 == 3) { j2++; } if (blockBlocksFlow(world, l1, i2, j2) || world.getBlockMaterial(l1, i2, j2) == blockMaterial && world.getBlockMetadata(l1, i2, j2) == 0) { continue; } if (!blockBlocksFlow(world, l1, i2 - 1, j2)) { return l; } if (l >= 4) { continue; } int k2 = calculateFlowCost(world, l1, i2, j2, l + 1, k1); if (k2 < j1) { j1 = k2; } } return j1; }
/** * 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) { MovingObjectPosition var4 = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); if (var4 == null) { return par1ItemStack; } else { if (var4.typeOfHit == EnumMovingObjectType.TILE) { int var5 = var4.blockX; int var6 = var4.blockY; int var7 = var4.blockZ; if (!par2World.canMineBlock(par3EntityPlayer, var5, var6, var7)) { return par1ItemStack; } if (!par3EntityPlayer.canPlayerEdit(var5, var6, var7)) { return par1ItemStack; } if (par2World.getBlockMaterial(var5, var6, var7) == Material.water) { --par1ItemStack.stackSize; if (par1ItemStack.stackSize <= 0) { return new ItemStack(Item.potion); } if (!par3EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Item.potion))) { par3EntityPlayer.dropPlayerItem(new ItemStack(Item.potion.shiftedIndex, 1, 0)); } } } return par1ItemStack; } }
/** * Returns the amount of fluid decay at the coordinates, or -1 if the block at the coordinates is * not the same material as the fluid. */ protected int getFlowDecay(World par1World, int par2, int par3, int par4) { return par1World.getBlockMaterial(par2, par3, par4) == this.blockMaterial ? par1World.getBlockMetadata(par2, par3, par4) : -1; }
/** The main spawning algorithm, spawns three random creatures of types in the subclass array */ public static final int performSpawning(World par0World, boolean par1, boolean par2) { if (!par1 && !par2) { return 0; } else { eligibleChunksForSpawning.clear(); int var3; int var6; for (var3 = 0; var3 < par0World.playerEntities.size(); ++var3) { EntityPlayer var4 = (EntityPlayer) par0World.playerEntities.get(var3); int var5 = MathHelper.floor_double(var4.posX / 16.0D); var6 = MathHelper.floor_double(var4.posZ / 16.0D); byte var7 = 8; for (int var8 = -var7; var8 <= var7; ++var8) { for (int var9 = -var7; var9 <= var7; ++var9) { boolean var10 = var8 == -var7 || var8 == var7 || var9 == -var7 || var9 == var7; ChunkCoordIntPair var11 = new ChunkCoordIntPair(var8 + var5, var9 + var6); if (!var10) { eligibleChunksForSpawning.put(var11, Boolean.valueOf(false)); } else if (!eligibleChunksForSpawning.containsKey(var11)) { eligibleChunksForSpawning.put(var11, Boolean.valueOf(true)); } } } } var3 = 0; ChunkCoordinates var31 = par0World.getSpawnPoint(); EnumCreatureType[] var32 = EnumCreatureType.values(); var6 = var32.length; for (int var33 = 0; var33 < var6; ++var33) { EnumCreatureType var34 = var32[var33]; if ((!var34.getPeacefulCreature() || par2) && (var34.getPeacefulCreature() || par1) && par0World.countEntities(var34.getCreatureClass()) <= var34.getMaxNumberOfCreature() * eligibleChunksForSpawning.size() / 256) { Iterator var35 = eligibleChunksForSpawning.keySet().iterator(); label108: while (var35.hasNext()) { ChunkCoordIntPair var37 = (ChunkCoordIntPair) var35.next(); if (!((Boolean) eligibleChunksForSpawning.get(var37)).booleanValue()) { ChunkPosition var36 = getRandomSpawningPointInChunk(par0World, var37.chunkXPos, var37.chunkZPos); int var12 = var36.x; int var13 = var36.y; int var14 = var36.z; if (!par0World.isBlockNormalCube(var12, var13, var14) && par0World.getBlockMaterial(var12, var13, var14) == var34.getCreatureMaterial()) { int var15 = 0; int var16 = 0; while (var16 < 3) { int var17 = var12; int var18 = var13; int var19 = var14; byte var20 = 6; SpawnListEntry var21 = null; int var22 = 0; while (true) { if (var22 < 4) { label101: { var17 += par0World.rand.nextInt(var20) - par0World.rand.nextInt(var20); var18 += par0World.rand.nextInt(1) - par0World.rand.nextInt(1); var19 += par0World.rand.nextInt(var20) - par0World.rand.nextInt(var20); if (canCreatureTypeSpawnAtLocation(var34, par0World, var17, var18, var19)) { float var23 = (float) var17 + 0.5F; float var24 = (float) var18; float var25 = (float) var19 + 0.5F; if (par0World.getClosestPlayer( (double) var23, (double) var24, (double) var25, 24.0D) == null) { float var26 = var23 - (float) var31.posX; float var27 = var24 - (float) var31.posY; float var28 = var25 - (float) var31.posZ; float var29 = var26 * var26 + var27 * var27 + var28 * var28; if (var29 >= 576.0F) { if (var21 == null) { var21 = par0World.getRandomMob(var34, var17, var18, var19); if (var21 == null) { break label101; } } EntityLiving var38; try { var38 = (EntityLiving) var21 .entityClass .getConstructor(new Class[] {World.class}) .newInstance(new Object[] {par0World}); } catch (Exception var30) { var30.printStackTrace(); return var3; } var38.setLocationAndAngles( (double) var23, (double) var24, (double) var25, par0World.rand.nextFloat() * 360.0F, 0.0F); if (var38.getCanSpawnHere()) { ++var15; par0World.spawnEntityInWorld(var38); creatureSpecificInit(var38, par0World, var23, var24, var25); if (var15 >= var38.getMaxSpawnedInChunk()) { continue label108; } } var3 += var15; } } } ++var22; continue; } } ++var16; break; } } } } } } } return var3; } }
/** 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; if (this.blockMaterial == Material.water) { if (par5Random.nextInt(10) == 0) { var6 = par1World.getBlockMetadata(par2, par3, par4); if (var6 <= 0 || var6 >= 8) { par1World.spawnParticle( "suspended", (double) ((float) par2 + par5Random.nextFloat()), (double) ((float) par3 + par5Random.nextFloat()), (double) ((float) par4 + par5Random.nextFloat()), 0.0D, 0.0D, 0.0D); } } for (var6 = 0; var6 < 0; ++var6) { int var7 = par5Random.nextInt(4); int var8 = par2; int var9 = par4; if (var7 == 0) { var8 = par2 - 1; } if (var7 == 1) { ++var8; } if (var7 == 2) { var9 = par4 - 1; } if (var7 == 3) { ++var9; } if (par1World.getBlockMaterial(var8, par3, var9) == Material.air && (par1World.getBlockMaterial(var8, par3 - 1, var9).blocksMovement() || par1World.getBlockMaterial(var8, par3 - 1, var9).isLiquid())) { float var10 = 0.0625F; double var11 = (double) ((float) par2 + par5Random.nextFloat()); double var13 = (double) ((float) par3 + par5Random.nextFloat()); double var15 = (double) ((float) par4 + par5Random.nextFloat()); if (var7 == 0) { var11 = (double) ((float) par2 - var10); } if (var7 == 1) { var11 = (double) ((float) (par2 + 1) + var10); } if (var7 == 2) { var15 = (double) ((float) par4 - var10); } if (var7 == 3) { var15 = (double) ((float) (par4 + 1) + var10); } double var17 = 0.0D; double var19 = 0.0D; if (var7 == 0) { var17 = (double) (-var10); } if (var7 == 1) { var17 = (double) var10; } if (var7 == 2) { var19 = (double) (-var10); } if (var7 == 3) { var19 = (double) var10; } par1World.spawnParticle("splash", var11, var13, var15, var17, 0.0D, var19); } } } if (this.blockMaterial == Material.water && par5Random.nextInt(64) == 0) { var6 = par1World.getBlockMetadata(par2, par3, par4); if (var6 > 0 && var6 < 8) { par1World.playSound( (double) ((float) par2 + 0.5F), (double) ((float) par3 + 0.5F), (double) ((float) par4 + 0.5F), "liquid.water", par5Random.nextFloat() * 0.25F + 0.75F, par5Random.nextFloat() * 1.0F + 0.5F); } } double var21; double var23; double var22; if (this.blockMaterial == Material.lava && par1World.getBlockMaterial(par2, par3 + 1, par4) == Material.air && !par1World.isBlockOpaqueCube(par2, par3 + 1, par4)) { if (par5Random.nextInt(100) == 0) { var21 = (double) ((float) par2 + par5Random.nextFloat()); var22 = (double) par3 + this.maxY; var23 = (double) ((float) par4 + par5Random.nextFloat()); par1World.spawnParticle("lava", var21, var22, var23, 0.0D, 0.0D, 0.0D); par1World.playSound( var21, var22, var23, "liquid.lavapop", 0.2F + par5Random.nextFloat() * 0.2F, 0.9F + par5Random.nextFloat() * 0.15F); } if (par5Random.nextInt(200) == 0) { par1World.playSound( (double) par2, (double) par3, (double) par4, "liquid.lava", 0.2F + par5Random.nextFloat() * 0.2F, 0.9F + par5Random.nextFloat() * 0.15F); } } if (par5Random.nextInt(10) == 0 && par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && !par1World.getBlockMaterial(par2, par3 - 2, par4).blocksMovement()) { var21 = (double) ((float) par2 + par5Random.nextFloat()); var22 = (double) par3 - 1.05D; var23 = (double) ((float) par4 + par5Random.nextFloat()); if (this.blockMaterial == Material.water) { par1World.spawnParticle("dripWater", var21, var22, var23, 0.0D, 0.0D, 0.0D); } else { par1World.spawnParticle("dripLava", var21, var22, var23, 0.0D, 0.0D, 0.0D); } } }
public boolean canBlockStay(World world, int i, int j, int k) { return world.getBlockMaterial(i, j - 1, k).isSolid(); }
/** * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z */ public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) { int var5 = par1World.getBlockId(par2, par3 - 1, par4); return var5 != 0 && (var5 == Block.leaves.blockID || Block.blocksList[var5].isOpaqueCube()) ? par1World.getBlockMaterial(par2, par3 - 1, par4).blocksMovement() : false; }
/** * Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with * plants. */ public boolean canBlockStay(World par1World, int par2, int par3, int par4) { return par1World.getBlockMaterial(par2, par3 - 1, par4).isSolid(); }
/** Ticks the block if it's been scheduled */ public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { int var6 = this.getFlowDecay(par1World, par2, par3, par4); byte var7 = 1; if (this.blockMaterial == Material.lava && !par1World.provider.isHellWorld) { var7 = 2; } boolean var8 = true; int var9 = this.tickRate(par1World); int var11; if (var6 > 0) { byte var10 = -100; this.numAdjacentSources = 0; int var13 = this.getSmallestFlowDecay(par1World, par2 - 1, par3, par4, var10); var13 = this.getSmallestFlowDecay(par1World, par2 + 1, par3, par4, var13); var13 = this.getSmallestFlowDecay(par1World, par2, par3, par4 - 1, var13); var13 = this.getSmallestFlowDecay(par1World, par2, par3, par4 + 1, var13); var11 = var13 + var7; if (var11 >= 8 || var13 < 0) { var11 = -1; } if (this.getFlowDecay(par1World, par2, par3 + 1, par4) >= 0) { int var12 = this.getFlowDecay(par1World, par2, par3 + 1, par4); if (var12 >= 8) { var11 = var12; } else { var11 = var12 + 8; } } if (this.numAdjacentSources >= 2 && this.blockMaterial == Material.water) { if (par1World.getBlockMaterial(par2, par3 - 1, par4).isSolid()) { var11 = 0; } else if (par1World.getBlockMaterial(par2, par3 - 1, par4) == this.blockMaterial && par1World.getBlockMetadata(par2, par3 - 1, par4) == 0) { var11 = 0; } } if (this.blockMaterial == Material.lava && var6 < 8 && var11 < 8 && var11 > var6 && par5Random.nextInt(4) != 0) { var9 *= 4; } if (var11 == var6) { if (var8) { this.updateFlow(par1World, par2, par3, par4); } } else { var6 = var11; if (var11 < 0) { par1World.setBlockToAir(par2, par3, par4); } else { par1World.setBlockMetadata(par2, par3, par4, var11, 2); par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, var9); par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID); } } } else { this.updateFlow(par1World, par2, par3, par4); } if (this.liquidCanDisplaceBlock(par1World, par2, par3 - 1, par4)) { if (this.blockMaterial == Material.lava && par1World.getBlockMaterial(par2, par3 - 1, par4) == Material.water) { par1World.setBlock(par2, par3 - 1, par4, Block.stone.blockID); this.triggerLavaMixEffects(par1World, par2, par3 - 1, par4); return; } if (var6 >= 8) { this.flowIntoBlock(par1World, par2, par3 - 1, par4, var6); } else { this.flowIntoBlock(par1World, par2, par3 - 1, par4, var6 + 8); } } else if (var6 >= 0 && (var6 == 0 || this.blockBlocksFlow(par1World, par2, par3 - 1, par4))) { boolean[] var14 = this.getOptimalFlowDirections(par1World, par2, par3, par4); var11 = var6 + var7; if (var6 >= 8) { var11 = 1; } if (var11 >= 8) { return; } if (var14[0]) { this.flowIntoBlock(par1World, par2 - 1, par3, par4, var11); } if (var14[1]) { this.flowIntoBlock(par1World, par2 + 1, par3, par4, var11); } if (var14[2]) { this.flowIntoBlock(par1World, par2, par3, par4 - 1, var11); } if (var14[3]) { this.flowIntoBlock(par1World, par2, par3, par4 + 1, var11); } } }
/** Returns true if the block at the coordinates can be displaced by the liquid. */ private boolean liquidCanDisplaceBlock(World par1World, int par2, int par3, int par4) { Material var5 = par1World.getBlockMaterial(par2, par3, par4); return var5 == this.blockMaterial ? false : (var5 == Material.lava ? false : !this.blockBlocksFlow(par1World, par2, par3, par4)); }
public boolean generate(World world, Random random, int i, int j, int k) { i -= 8; for (k -= 8; j > 0 && world.isAirBlock(i, j, k); j--) {} j -= 4; boolean aflag[] = new boolean[2048]; int l = random.nextInt(4) + 4; for (int i1 = 0; i1 < l; i1++) { double d = random.nextDouble() * 6D + 3D; double d1 = random.nextDouble() * 4D + 2D; double d2 = random.nextDouble() * 6D + 3D; double d3 = random.nextDouble() * (16D - d - 2D) + 1.0D + d / 2D; double d4 = random.nextDouble() * (8D - d1 - 4D) + 2D + d1 / 2D; double d5 = random.nextDouble() * (16D - d2 - 2D) + 1.0D + d2 / 2D; for (int j4 = 1; j4 < 15; j4++) { for (int k4 = 1; k4 < 15; k4++) { for (int l4 = 1; l4 < 7; l4++) { double d6 = ((double) j4 - d3) / (d / 2D); double d7 = ((double) l4 - d4) / (d1 / 2D); double d8 = ((double) k4 - d5) / (d2 / 2D); double d9 = d6 * d6 + d7 * d7 + d8 * d8; if (d9 < 1.0D) { aflag[(j4 * 16 + k4) * 8 + l4] = true; } } } } } for (int j1 = 0; j1 < 16; j1++) { for (int j2 = 0; j2 < 16; j2++) { for (int j3 = 0; j3 < 8; j3++) { boolean flag = !aflag[(j1 * 16 + j2) * 8 + j3] && (j1 < 15 && aflag[((j1 + 1) * 16 + j2) * 8 + j3] || j1 > 0 && aflag[((j1 - 1) * 16 + j2) * 8 + j3] || j2 < 15 && aflag[(j1 * 16 + (j2 + 1)) * 8 + j3] || j2 > 0 && aflag[(j1 * 16 + (j2 - 1)) * 8 + j3] || j3 < 7 && aflag[(j1 * 16 + j2) * 8 + (j3 + 1)] || j3 > 0 && aflag[(j1 * 16 + j2) * 8 + (j3 - 1)]); if (!flag) { continue; } Material material = world.getBlockMaterial(i + j1, j + j3, k + j2); if (j3 >= 4 && material.getIsLiquid()) { return false; } if (j3 < 4 && !material.isSolid() && world.getBlockId(i + j1, j + j3, k + j2) != field_15005_a) { return false; } } } } for (int k1 = 0; k1 < 16; k1++) { for (int k2 = 0; k2 < 16; k2++) { for (int k3 = 0; k3 < 8; k3++) { if (aflag[(k1 * 16 + k2) * 8 + k3]) { world.setBlock(i + k1, j + k3, k + k2, k3 < 4 ? field_15005_a : 0); } } } } for (int l1 = 0; l1 < 16; l1++) { for (int l2 = 0; l2 < 16; l2++) { for (int l3 = 4; l3 < 8; l3++) { if (aflag[(l1 * 16 + l2) * 8 + l3] && world.getBlockId(i + l1, (j + l3) - 1, k + l2) == Block.dirt.blockID && world.getSavedLightValue(EnumSkyBlock.Sky, i + l1, j + l3, k + l2) > 0) { world.setBlock(i + l1, (j + l3) - 1, k + l2, Block.grass.blockID); } } } } if (Block.blocksList[field_15005_a].blockMaterial == Material.lava) { for (int i2 = 0; i2 < 16; i2++) { for (int i3 = 0; i3 < 16; i3++) { for (int i4 = 0; i4 < 8; i4++) { boolean flag1 = !aflag[(i2 * 16 + i3) * 8 + i4] && (i2 < 15 && aflag[((i2 + 1) * 16 + i3) * 8 + i4] || i2 > 0 && aflag[((i2 - 1) * 16 + i3) * 8 + i4] || i3 < 15 && aflag[(i2 * 16 + (i3 + 1)) * 8 + i4] || i3 > 0 && aflag[(i2 * 16 + (i3 - 1)) * 8 + i4] || i4 < 7 && aflag[(i2 * 16 + i3) * 8 + (i4 + 1)] || i4 > 0 && aflag[(i2 * 16 + i3) * 8 + (i4 - 1)]); if (flag1 && (i4 < 4 || random.nextInt(2) != 0) && world.getBlockMaterial(i + i2, j + i4, k + i3).isSolid()) { world.setBlock(i + i2, j + i4, k + i3, Block.stone.blockID); } } } } } return true; }
/** * 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) { float var4 = 1.0F; double var5 = par3EntityPlayer.prevPosX + (par3EntityPlayer.posX - par3EntityPlayer.prevPosX) * (double) var4; double var7 = par3EntityPlayer.prevPosY + (par3EntityPlayer.posY - par3EntityPlayer.prevPosY) * (double) var4 + 1.62D - (double) par3EntityPlayer.yOffset; double var9 = par3EntityPlayer.prevPosZ + (par3EntityPlayer.posZ - par3EntityPlayer.prevPosZ) * (double) var4; boolean var11 = this.isFull == 0; MovingObjectPosition var12 = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, var11); if (var12 == null) { return par1ItemStack; } else { if (var12.typeOfHit == EnumMovingObjectType.TILE) { int var13 = var12.blockX; int var14 = var12.blockY; int var15 = var12.blockZ; if (!par2World.canMineBlock(par3EntityPlayer, var13, var14, var15)) { return par1ItemStack; } if (this.isFull == 0) { if (!par3EntityPlayer.canPlayerEdit(var13, var14, var15, var12.sideHit, par1ItemStack)) { return par1ItemStack; } if (par2World.getBlockMaterial(var13, var14, var15) == Material.water && par2World.getBlockMetadata(var13, var14, var15) == 0) { par2World.setBlockToAir(var13, var14, var15); if (par3EntityPlayer.capabilities.isCreativeMode) { return par1ItemStack; } if (--par1ItemStack.stackSize <= 0) { return new ItemStack(Item.bucketWater); } if (!par3EntityPlayer.inventory.addItemStackToInventory( new ItemStack(Item.bucketWater))) { par3EntityPlayer.dropPlayerItem(new ItemStack(Item.bucketWater.itemID, 1, 0)); } return par1ItemStack; } if (par2World.getBlockMaterial(var13, var14, var15) == Material.lava && par2World.getBlockMetadata(var13, var14, var15) == 0) { par2World.setBlockToAir(var13, var14, var15); if (par3EntityPlayer.capabilities.isCreativeMode) { return par1ItemStack; } if (--par1ItemStack.stackSize <= 0) { return new ItemStack(Item.bucketLava); } if (!par3EntityPlayer.inventory.addItemStackToInventory( new ItemStack(Item.bucketLava))) { par3EntityPlayer.dropPlayerItem(new ItemStack(Item.bucketLava.itemID, 1, 0)); } return par1ItemStack; } } else { if (this.isFull < 0) { return new ItemStack(Item.bucketEmpty); } if (var12.sideHit == 0) { --var14; } if (var12.sideHit == 1) { ++var14; } if (var12.sideHit == 2) { --var15; } if (var12.sideHit == 3) { ++var15; } if (var12.sideHit == 4) { --var13; } if (var12.sideHit == 5) { ++var13; } if (!par3EntityPlayer.canPlayerEdit(var13, var14, var15, var12.sideHit, par1ItemStack)) { return par1ItemStack; } if (this.tryPlaceContainedLiquid(par2World, var5, var7, var9, var13, var14, var15) && !par3EntityPlayer.capabilities.isCreativeMode) { return new ItemStack(Item.bucketEmpty); } } } else if (this.isFull == 0 && var12.entityHit instanceof EntityCow) { return new ItemStack(Item.bucketMilk); } return par1ItemStack; } }
public void updateTick(World world, int i, int j, int k, Random random) { int l = getFlowDecay(world, i, j, k); byte byte0 = 1; if (blockMaterial == Material.lava && !world.worldProvider.isHellWorld) { byte0 = 2; } boolean flag = true; if (l > 0) { int i1 = -100; numAdjacentSources = 0; i1 = getSmallestFlowDecay(world, i - 1, j, k, i1); i1 = getSmallestFlowDecay(world, i + 1, j, k, i1); i1 = getSmallestFlowDecay(world, i, j, k - 1, i1); i1 = getSmallestFlowDecay(world, i, j, k + 1, i1); int j1 = i1 + byte0; if (j1 >= 8 || i1 < 0) { j1 = -1; } if (getFlowDecay(world, i, j + 1, k) >= 0) { int l1 = getFlowDecay(world, i, j + 1, k); if (l1 >= 8) { j1 = l1; } else { j1 = l1 + 8; } } if (numAdjacentSources >= 2 && blockMaterial == Material.water) { if (world.getBlockMaterial(i, j - 1, k).isSolid()) { j1 = 0; } else if (world.getBlockMaterial(i, j - 1, k) == blockMaterial && world.getBlockMetadata(i, j, k) == 0) { j1 = 0; } } if (blockMaterial == Material.lava && l < 8 && j1 < 8 && j1 > l && random.nextInt(4) != 0) { j1 = l; flag = false; } if (j1 != l) { l = j1; if (l < 0) { world.setBlockWithNotify(i, j, k, 0); } else { world.setBlockMetadataWithNotify(i, j, k, l); world.scheduleBlockUpdate(i, j, k, blockID, tickRate()); world.notifyBlocksOfNeighborChange(i, j, k, blockID); } } else if (flag) { func_30003_j(world, i, j, k); } } else { func_30003_j(world, i, j, k); } if (liquidCanDisplaceBlock(world, i, j - 1, k)) { if (l >= 8) { world.setBlockAndMetadataWithNotify(i, j - 1, k, blockID, l); } else { world.setBlockAndMetadataWithNotify(i, j - 1, k, blockID, l + 8); } } else if (l >= 0 && (l == 0 || blockBlocksFlow(world, i, j - 1, k))) { boolean aflag[] = getOptimalFlowDirections(world, i, j, k); int k1 = l + byte0; if (l >= 8) { k1 = 1; } if (k1 >= 8) { return; } if (aflag[0]) { flowIntoBlock(world, i - 1, j, k, k1); } if (aflag[1]) { flowIntoBlock(world, i + 1, j, k, k1); } if (aflag[2]) { flowIntoBlock(world, i, j, k - 1, k1); } if (aflag[3]) { flowIntoBlock(world, i, j, k + 1, k1); } } }