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); } } }
/** If there is space to fall below will start this block falling */ private void tryToFall(World par1World, int par2, int par3, int par4) { if (canFallBelow(par1World, par2, par3 - 1, par4) && par3 >= 0) { byte var8 = 32; if (!fallInstantly && par1World.checkChunksExist( par2 - var8, par3 - var8, par4 - var8, par2 + var8, par3 + var8, par4 + var8)) { if (!par1World.isRemote) { EntityFallingSand var9 = new EntityFallingSand( par1World, (double) ((float) par2 + 0.5F), (double) ((float) par3 + 0.5F), (double) ((float) par4 + 0.5F), this.blockID, par1World.getBlockMetadata(par2, par3, par4)); this.onStartFalling(var9); par1World.spawnEntityInWorld(var9); } } else { par1World.setBlockWithNotify(par2, par3, par4, 0); while (canFallBelow(par1World, par2, par3 - 1, par4) && par3 > 0) { --par3; } if (par3 > 0) { par1World.setBlockWithNotify(par2, par3, par4, this.blockID); } } } }
public void updateTick(World world, int i, int j, int k, Random random) { if (world.isRemote) { return; } if (world.getBlockLightValue(i, j + 1, k) < 4 && Block.lightOpacity[world.getBlockId(i, j + 1, k)] > 2) { world.setBlockWithNotify(i, j, k, Block.dirt.blockID); } else if (world.getBlockLightValue(i, j + 1, k) >= 9) { for (int l = 0; l < 4; l++) { int i1 = (i + random.nextInt(3)) - 1; int j1 = (j + random.nextInt(5)) - 3; int k1 = (k + random.nextInt(3)) - 1; int l1 = world.getBlockId(i1, j1 + 1, k1); if (world.getBlockId(i1, j1, k1) == Block.dirt.blockID && world.getBlockLightValue(i1, j1 + 1, k1) >= 4 && Block.lightOpacity[l1] <= 2) { if (blockID == ZooDirts.savannah.blockID) { world.setBlockWithNotify(i1, j1, k1, ZooDirts.savannah.blockID); } if (blockID == ZooDirts.tropical.blockID) { world.setBlockWithNotify(i1, j1, k1, ZooDirts.tropical.blockID); } if (blockID == ZooDirts.coniferous.blockID) { world.setBlockWithNotify(i1, j1, k1, ZooDirts.coniferous.blockID); } if (blockID == ZooDirts.deciduous.blockID) { world.setBlockWithNotify(i1, j1, k1, ZooDirts.deciduous.blockID); } } } } }
/** * Called when the player destroys a block with an item that can harvest it. (i, j, k) are the * coordinates of the block and l is the block's subtype/damage. */ public void harvestBlock( World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) { int var7 = Item.snowball.itemID; this.dropBlockAsItem_do(par1World, par3, par4, par5, new ItemStack(var7, 1, 0)); par1World.setBlockWithNotify(par3, par4, par5, 0); par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1); }
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) { if (!par1World.isRemote && !this.canVineStay(par1World, par2, par3, par4)) { this.dropBlockAsItem( par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); par1World.setBlockWithNotify(par2, par3, par4, 0); } }
public void onBlockAdded(World world, int i, int j, int k) { super.onBlockAdded(world, i, j, k); if (world.isBlockIndirectlyGettingPowered(i, j, k)) { onBlockDestroyedByPlayer(world, i, j, k, 1); world.setBlockWithNotify(i, j, k, 0); } }
public boolean onBlockStartBreak( ItemStack itemstack, int x, int y, int z, EntityPlayer entityplayer) { World world = entityplayer.worldObj; if (world.isRemote) { return false; } int bID = world.getBlockId(x, y, z); int md = world.getBlockMetadata(x, y, z); boolean flag = true; boolean flag1 = true; if (headType == handleType) { flag = powers(itemstack, bID, x, y, z, world, entityplayer, md, headType); } else { if (random.nextInt(100) + 1 <= 80) { flag = powers(itemstack, bID, x, y, z, world, entityplayer, md, headType); } if (random.nextInt(100) + 1 <= 20) { flag1 = powers(itemstack, bID, x, y, z, world, entityplayer, md, handleType); } } if (!ForgeHooks.canHarvestBlock(Block.blocksList[bID], entityplayer, md)) { flag = false; } if (!flag || !flag1) { world.playAuxSFX(2001, x, y, z, bID + (md << 12)); world.setBlockWithNotify(x, y, z, 0); onBlockDestroyed(itemstack, bID, x, y, z, entityplayer); return true; } else { return false; } }
/** * 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) { int i = par1World.getBlockMetadata(par2, par3, par4); boolean flag = false; if (i == 2 && par1World.isBlockNormalCube(par2, par3, par4 + 1)) { flag = true; } if (i == 3 && par1World.isBlockNormalCube(par2, par3, par4 - 1)) { flag = true; } if (i == 4 && par1World.isBlockNormalCube(par2 + 1, par3, par4)) { flag = true; } if (i == 5 && par1World.isBlockNormalCube(par2 - 1, par3, par4)) { flag = true; } if (!flag) { dropBlockAsItem(par1World, par2, par3, par4, i, 0); par1World.setBlockWithNotify(par2, par3, par4, 0); } super.onNeighborBlockChange(par1World, par2, par3, par4, par5); }
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; }
/** * 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) { if (this.dropTorchIfCantStay(par1World, par2, par3, par4)) { int var6 = par1World.getBlockMetadata(par2, par3, par4); boolean var7 = false; if (!par1World.isBlockNormalCubeDefault(par2 - 1, par3, par4, true) && var6 == 1) { var7 = true; } if (!par1World.isBlockNormalCubeDefault(par2 + 1, par3, par4, true) && var6 == 2) { var7 = true; } if (!par1World.isBlockNormalCubeDefault(par2, par3, par4 - 1, true) && var6 == 3) { var7 = true; } if (!par1World.isBlockNormalCubeDefault(par2, par3, par4 + 1, true) && var6 == 4) { var7 = true; } if (!this.canPlaceTorchOn(par1World, par2, par3 - 1, par4) && var6 == 5) { var7 = true; } if (var7) { this.dropBlockAsItem( par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); par1World.setBlockWithNotify(par2, par3, par4, 0); } } }
/** Ticks the block if it's been scheduled */ public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { if (par1World.getSavedLightValue(EnumSkyBlock.Block, par2, par3, par4) > 11) { this.dropBlockAsItem( par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); par1World.setBlockWithNotify(par2, par3, par4, 0); } }
/** * 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); } }
public void onNeighborBlockChange(World world, int i, int j, int k, int l) { if (!world.isBlockOpaqueCube(i, j - 1, k) && !func_263_h(world, i, j, k)) { world.setBlockWithNotify(i, j, k, 0); return; } else { return; } }
public void onNeighborBlockChange(World world, int i, int j, int k, int l) { if (l > 0 && Block.blocksList[l].canProvidePower() && world.isBlockIndirectlyGettingPowered(i, j, k)) { onBlockDestroyedByPlayer(world, i, j, k, 1); world.setBlockWithNotify(i, j, k, 0); } }
/** * 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) { int i = par1World.getBlockMetadata(par2, par3, par4); if ((i & 8) != 0) { if (par1World.getBlockId(par2, par3 - 1, par4) != blockID) { par1World.setBlockWithNotify(par2, par3, par4, 0); } if (par5 > 0 && par5 != blockID) { onNeighborBlockChange(par1World, par2, par3 - 1, par4, par5); } } else { boolean flag = false; if (par1World.getBlockId(par2, par3 + 1, par4) != blockID) { par1World.setBlockWithNotify(par2, par3, par4, 0); flag = true; } if (!par1World.isBlockNormalCube(par2, par3 - 1, par4)) { par1World.setBlockWithNotify(par2, par3, par4, 0); flag = true; if (par1World.getBlockId(par2, par3 + 1, par4) == blockID) { par1World.setBlockWithNotify(par2, par3 + 1, par4, 0); } } if (flag) { if (!par1World.isRemote) { dropBlockAsItem(par1World, par2, par3, par4, i, 0); } } else { boolean flag1 = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4) || par1World.isBlockIndirectlyGettingPowered(par2, par3 + 1, par4); if ((flag1 || par5 > 0 && Block.blocksList[par5].canProvidePower() || par5 == 0) && par5 != blockID) { onPoweredBlockChange(par1World, par2, par3, par4, flag1); } } } }
/** * 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) { int var6 = par1World.getBlockMetadata(par2, par3, par4); if ((var6 & 8) != 0) { if (par1World.getBlockId(par2, par3 - 1, par4) != this.blockID) { par1World.setBlockWithNotify(par2, par3, par4, 0); } if (par5 > 0 && par5 != this.blockID) { this.onNeighborBlockChange(par1World, par2, par3 - 1, par4, par5); } } else { boolean var7 = false; if (par1World.getBlockId(par2, par3 + 1, par4) != this.blockID) { par1World.setBlockWithNotify(par2, par3, par4, 0); var7 = true; } if (!par1World.isBlockSolidOnSide(par2, par3 - 1, par4, 1)) { par1World.setBlockWithNotify(par2, par3, par4, 0); var7 = true; if (par1World.getBlockId(par2, par3 + 1, par4) == this.blockID) { par1World.setBlockWithNotify(par2, par3 + 1, par4, 0); } } if (var7) { if (!par1World.isRemote) { this.dropBlockAsItem(par1World, par2, par3, par4, var6, 0); } } else { boolean var8 = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4) || par1World.isBlockIndirectlyGettingPowered(par2, par3 + 1, par4); if ((var8 || par5 > 0 && Block.blocksList[par5].canProvidePower() || par5 == 0) && par5 != this.blockID) { this.onPoweredBlockChange(par1World, par2, par3, par4, var8); } } } }
public void updateTick(World world, int i, int j, int k, Random random) { if (random.nextInt(100) == 0) { int l = (i + random.nextInt(3)) - 1; int i1 = (j + random.nextInt(2)) - random.nextInt(2); int j1 = (k + random.nextInt(3)) - 1; if (world.isAirBlock(l, i1, j1) && canBlockStay(world, l, i1, j1)) { world.setBlockWithNotify(l, i1, j1, blockID); } } }
/** Checks if this snow block can stay at this location. */ private boolean canSnowStay(World par1World, int par2, int par3, int par4) { if (!this.canPlaceBlockAt(par1World, par2, par3, par4)) { this.dropBlockAsItem( par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); par1World.setBlockWithNotify(par2, par3, par4, 0); return false; } else { return true; } }
public void updateTick(World world, int i, int j, int k, Random random) { boolean flag = world.getBlockId(i, j - 1, k) == Block.bloodStone.blockID; int l = world.getBlockMetadata(i, j, k); if (l < 15) { world.setBlockMetadataWithNotify(i, j, k, l + 1); world.func_22136_c(i, j, k, blockID, tickRate()); } if (!flag && !func_263_h(world, i, j, k)) { if (!world.isBlockOpaqueCube(i, j - 1, k) || l > 3) { world.setBlockWithNotify(i, j, k, 0); } return; } if (!flag && !canBlockCatchFire(world, i, j - 1, k) && l == 15 && random.nextInt(4) == 0) { world.setBlockWithNotify(i, j, k, 0); return; } if (l % 2 == 0 && l > 2) { tryToCatchBlockOnFire(world, i + 1, j, k, 300, random); tryToCatchBlockOnFire(world, i - 1, j, k, 300, random); tryToCatchBlockOnFire(world, i, j - 1, k, 250, random); tryToCatchBlockOnFire(world, i, j + 1, k, 250, random); tryToCatchBlockOnFire(world, i, j, k - 1, 300, random); tryToCatchBlockOnFire(world, i, j, k + 1, 300, random); for (int i1 = i - 1; i1 <= i + 1; i1++) { for (int j1 = k - 1; j1 <= k + 1; j1++) { for (int k1 = j - 1; k1 <= j + 4; k1++) { if (i1 == i && k1 == j && j1 == k) { continue; } int l1 = 100; if (k1 > j + 1) { l1 += (k1 - (j + 1)) * 100; } int i2 = getChanceOfNeighborsEncouragingFire(world, i1, k1, j1); if (i2 > 0 && random.nextInt(l1) <= i2) { world.setBlockWithNotify(i1, k1, j1, blockID); } } } } } }
@Override public void updateTick(World world, int i, int j, int k, Random random) { if (world.getBlockMetadata(i, j, k) < 2) { if (random.nextInt(5) == 2) { world.setBlockWithNotify(i, j, k, 0); } else { world.scheduleBlockUpdate(i, j, k, blockID, tickRate()); } } }
@Override public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) { if (!par1World.isAirBlock(par3, par4, par5) || par1World.getBlockId(par3, par4 - 1, par5) != this.replaceID) { return false; } int i = par2Random.nextInt(32) + 6; int j = par2Random.nextInt(4) + 1; for (int k = par3 - j; k <= par3 + j; k++) { for (int i1 = par5 - j; i1 <= par5 + j; i1++) { int k1 = k - par3; int i2 = i1 - par5; if (k1 * k1 + i2 * i2 <= j * j + 1 && par1World.getBlockId(k, par4 - 1, i1) != this.replaceID) { return false; } } } for (int l = par4; l < par4 + i && l < 128; l++) { for (int j1 = par3 - j; j1 <= par3 + j; j1++) { for (int l1 = par5 - j; l1 <= par5 + j; l1++) { int j2 = j1 - par3; int k2 = l1 - par5; if (j2 * j2 + k2 * k2 <= j * j + 1) { par1World.setBlockWithNotify(j1, l, l1, Block.obsidian.blockID); } } } } EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(par1World); entityendercrystal.setLocationAndAngles( par3 + 0.5F, par4 + i, par5 + 0.5F, par2Random.nextFloat() * 360F, 0.0F); par1World.spawnEntityInWorld(entityendercrystal); par1World.setBlockWithNotify(par3, par4 + i, par5, Block.bedrock.blockID); return true; }
public void onNeighborBlockChange(World world, int i, int j, int k, int l) { boolean flag = false; if (!world.isBlockNormalCube(i, j - 1, k) && world.getBlockId(i, j - 1, k) != Block.fence.blockID) { flag = true; } if (flag) { dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k), 0); world.setBlockWithNotify(i, j, k, 0); } }
@Override public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) { int arg = world.getBlockMetadata(i, j, k); if (entityplayer != null && entityplayer.getCurrentEquippedItem() != null && (entityplayer.getCurrentEquippedItem().itemID == Ic2Items.wrench.itemID || entityplayer.getCurrentEquippedItem().itemID == Ic2Items.electricWrench.itemID)) { this.dropBlockAsItem(world, i, j, k, arg, 1); world.setBlockWithNotify(i, j, k, 0); world.setBlockWithNotify(i, j + 1, k, 0); return false; } if (arg == 12 || arg == 15 || arg == 0) { TileEntityMissile titty = (TileEntityMissile) world.getBlockTileEntity(i, j, k); titty.launch(entityplayer); } return false; }
private void eatCakeSlice(World world, int i, int j, int k, EntityPlayer entityplayer) { if (entityplayer.health < 20) { entityplayer.heal(3); int l = world.getBlockMetadata(i, j, k) + 1; if (l >= 6) { world.setBlockWithNotify(i, j, k, 0); } else { world.setBlockMetadataWithNotify(i, j, k, l); world.markBlockAsNeedsUpdate(i, j, k); } } }
@Override public void onBlockAdded(World world, int i, int j, int k) { super.onBlockAdded(world, i, j, k); if (world.isBlockIndirectlyGettingPowered(i, j, k) && world.getBlockMetadata(i, j, k) != 12 && world.getBlockMetadata(i, j, k) != 0 && world.getBlockMetadata(i, j, k) != 15) { onBlockDestroyedByExplosion(world, i, j, k); world.setBlockWithNotify(i, j, k, 0); } }
public void updateTick(World world, int i, int j, int k, Random random) { if (world.multiplayerWorld) { return; } if (world.getBlockLightValue(i, j + 1, k) < 4 && Block.lightOpacity[world.getBlockId(i, j + 1, k)] > 2) { world.setBlockWithNotify(i, j, k, Block.dirt.blockID); } else if (world.getBlockLightValue(i, j + 1, k) >= 9) { for (int l = 0; l < 4; l++) { int i1 = (i + random.nextInt(3)) - 1; int j1 = (j + random.nextInt(5)) - 3; int k1 = (k + random.nextInt(3)) - 1; int l1 = world.getBlockId(i1, j1 + 1, k1); if (world.getBlockId(i1, j1, k1) == Block.dirt.blockID && world.getBlockLightValue(i1, j1 + 1, k1) >= 4 && Block.lightOpacity[l1] <= 2) { world.setBlockWithNotify(i1, j1, k1, blockID); } } } }
@Override public void onNeighborBlockChange(World world, int i, int j, int k, int l) { if (l > 0 && Block.blocksList[l].canProvidePower() && world.isBlockIndirectlyGettingPowered(i, j, k) && world.getBlockMetadata(i, j, k) != 12 && world.getBlockMetadata(i, j, k) != 0 && world.getBlockMetadata(i, j, k) != 15) { onBlockDestroyedByExplosion(world, i, j, k); world.setBlockWithNotify(i, j, k, 0); } }
/** * 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); } } } }
public void onBlockAdded(World world, int i, int j, int k) { if (world.getBlockId(i, j - 1, k) == Block.obsidian.blockID && Block.portal.tryToCreatePortal(world, i, j, k)) { return; } if (!world.isBlockOpaqueCube(i, j - 1, k) && !func_263_h(world, i, j, k)) { world.setBlockWithNotify(i, j, k, 0); return; } else { world.func_22136_c(i, j, k, blockID, tickRate()); return; } }