private void tryToFall(World world, int i, int j, int k) { int meta = world.getBlockMetadata(i, j, k); if (!BlockCollapsable.isNearSupport(world, i, j, k) && BlockCollapsable.canFallBelow(world, i, j - 1, k) && j >= 0) { byte byte0 = 32; if (fallInstantly || !world.checkChunksExist( i - byte0, j - byte0, k - byte0, i + byte0, j + byte0, k + byte0)) { world.setBlockWithNotify(i, j, k, 0); for (; canFallBelow(world, i, j - 1, k) && j > 0; j--) {} if (j > 0) { world.setBlockWithNotify(i, j, k, blockID); } } else if (!world.isRemote) { EntityFallingStone2 ent = new EntityFallingStone2( world, (float) i + 0.5F, (float) j + 0.5F, (float) k + 0.5F, blockID, meta, 0); world.spawnEntityInWorld(ent); Random R = new Random(i * j + k); world.playSoundAtEntity(ent, "fallingrockshort", 1.0F, 0.8F + (R.nextFloat() / 2)); } } }
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); } } }
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); } } } } }
/** * 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); boolean var7 = false; if (var6 == 2 && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, 2)) { var7 = true; } if (var6 == 3 && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, 3)) { var7 = true; } if (var6 == 4 && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, 4)) { var7 = true; } if (var6 == 5 && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, 5)) { var7 = true; } if (!var7) { this.dropBlockAsItem(par1World, par2, par3, par4, var6, 0); par1World.setBlockWithNotify(par2, par3, par4, 0); } super.onNeighborBlockChange(par1World, par2, par3, par4, par5); }
@Override public void onNeighborBlockChange(World world, int x, int y, int z, int par4) { /* Check that we are still on a solid block */ if (!world.isBlockSolidOnSide(x, y - 1, z, ForgeDirection.UP)) { this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); world.setBlockWithNotify(x, y, z, 0); } }
@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()); } } }
public void onEntityCollidedWithBlock( World par1World, int par2, int par3, int par4, Entity par5Entity) { if (par5Entity.posY > yaxis) { if (par5Entity instanceof EntityLiving && !par5Entity.isSprinting()) { this.dropBlockAsItem( par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); par1World.setBlockWithNotify(par2, par3, par4, 0); par1World.playAuxSFX(2002, par2, par3, par4, 0); } } }
@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); } }
@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); } }
@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; }
public ItemStack fillCustomBucket(World w, int i, int j, int k) { if (w.getBlockId(i, j, k) == Zoo.saltwaterStill.blockID || w.getBlockId(i, j, k) == Zoo.saltwaterMoving.blockID) { w.setBlockWithNotify(i, j, k, 0); EntityPlayer player = ModLoader.getMinecraftInstance().thePlayer; if (!player.capabilities.isCreativeMode) { return new ItemStack(this); } } return null; }
@Override public void updateBlockMetadata( World world, int i, int j, int k, int l, float something1, float something2, float something3) { int i1 = world.getBlockMetadata(i, j, k); int j1 = i1 & 8; i1 &= 7; i1 = -1; if (l == 1 && world.isBlockNormalCube(i, j - 1, k)) { i1 = 5 + world.rand.nextInt(2); } if (l == 2 && world.isBlockNormalCube(i, j, k + 1)) { i1 = 4; } if (l == 3 && world.isBlockNormalCube(i, j, k - 1)) { i1 = 3; } if (l == 4 && world.isBlockNormalCube(i + 1, j, k)) { i1 = 2; } if (l == 5 && world.isBlockNormalCube(i - 1, j, k)) { i1 = 1; } if (i1 == -1) { dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k), 0); world.setBlockWithNotify(i, j, k, 0); } else { System.out.println("metadata = " + (i1)); world.setBlockMetadataWithNotify(i, j, k, i1 + j1); } super.updateBlockMetadata(world, i, j, k, l, something1, something2, something3); }
protected void placeSpawnerAtCurrentPosition( World var1, Random var2, int var3, int var4, int var5, String var6, StructureBoundingBox var7) { int var8 = this.getXWithOffset(var3, var5); int var9 = this.getYWithOffset(var4); int var10 = this.getZWithOffset(var3, var5); if (var7.isVecInside(var8, var9, var10) && var1.getBlockId(var8, var9, var10) != Block.mobSpawner.blockID) { var1.setBlockWithNotify(var8, var9, var10, Block.mobSpawner.blockID); TileEntityMobSpawner var11 = (TileEntityMobSpawner) var1.getBlockTileEntity(var8, var9, var10); if (var11 != null) { var11.setMobID(var6); } } }
@Override public void onBlockPlaced(World world, int i, int j, int k, int l) { world.setBlockWithNotify(i, j + 1, k, mod_RocketScience.blockWarheadId); world.setBlockMetadata(i, j + 1, k, world.getBlockMetadata(i, j, k)); }
private void checkFlowerChange(World world, int x, int y, int z) { if (!canBlockStay(world, x, y, z)) { dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); world.setBlockWithNotify(x, y, z, 0); } }
/** Ticks the block if it's been scheduled */ @Override public void updateTick( final World par1World, final int par2, final int par3, final int par4, final 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 var10; if (var6 > 0) { final byte var9 = -100; this.numAdjacentSources = 0; int var12 = this.getSmallestFlowDecay(par1World, par2 - 1, par3, par4, var9); var12 = this.getSmallestFlowDecay(par1World, par2 + 1, par3, par4, var12); var12 = this.getSmallestFlowDecay(par1World, par2, par3, par4 - 1, var12); var12 = this.getSmallestFlowDecay(par1World, par2, par3, par4 + 1, var12); var10 = var12 + var7; if ((var10 >= 8) || (var12 < 0)) { var10 = -1; } if (this.getFlowDecay(par1World, par2, par3 + 1, par4) >= 0) { final int var11 = this.getFlowDecay(par1World, par2, par3 + 1, par4); if (var11 >= 8) { var10 = var11; } else { var10 = var11 + 8; } } if ((this.numAdjacentSources >= 2) && (this.blockMaterial == Material.water)) { if (par1World.getBlockMaterial(par2, par3 - 1, par4).isSolid()) { var10 = 0; } else if ((par1World.getBlockMaterial(par2, par3 - 1, par4) == this.blockMaterial) && (par1World.getBlockMetadata(par2, par3, par4) == 0)) { var10 = 0; } } if ((this.blockMaterial == Material.lava) && (var6 < 8) && (var10 < 8) && (var10 > var6) && (par5Random.nextInt(4) != 0)) { var10 = var6; var8 = false; } if (var10 == var6) { if (var8) { this.updateFlow(par1World, par2, par3, par4); } } else { var6 = var10; if (var10 < 0) { par1World.setBlockWithNotify(par2, par3, par4, 0); } else { par1World.setBlockMetadataWithNotify(par2, par3, par4, var10); par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate()); 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.setBlockWithNotify(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))) { final boolean[] var13 = this.getOptimalFlowDirections(par1World, par2, par3, par4); var10 = var6 + var7; if (var6 >= 8) { var10 = 1; } if (var10 >= 8) { return; } if (var13[0]) { this.flowIntoBlock(par1World, par2 - 1, par3, par4, var10); } if (var13[1]) { this.flowIntoBlock(par1World, par2 + 1, par3, par4, var10); } if (var13[2]) { this.flowIntoBlock(par1World, par2, par3, par4 - 1, var10); } if (var13[3]) { this.flowIntoBlock(par1World, par2, par3, par4 + 1, var10); } } }
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { float var4 = 1.0F; double var5 = player.prevPosX + (player.posX - player.prevPosX) * (double) var4; double var7 = player.prevPosY + (player.posY - player.prevPosY) * (double) var4 + 1.62D - (double) player.yOffset; double var9 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) var4; boolean var11 = this.isFull == 0; MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, var11); if (mop == null) { return itemstack; } if (mop.typeOfHit == EnumMovingObjectType.TILE) { int x = mop.blockX; int y = mop.blockY; int z = mop.blockZ; if (!world.canMineBlock(player, x, y, z)) { return itemstack; } if (isFull == 0) { int bID = world.getBlockId(x, y, z); if ((bID == Block.waterMoving.blockID || bID == Block.waterStill.blockID) && world.getBlockMetadata(x, y, z) == 0) { world.setBlockWithNotify(x, y, z, 0); return new ItemStack(mod_InfiTools.goldBucketWater); } if ((bID == Block.lavaMoving.blockID || bID == Block.lavaStill.blockID) && world.getBlockMetadata(x, y, z) == 0) { world.setBlockWithNotify(x, y, z, 0); return new ItemStack(mod_InfiTools.goldBucketLava); } if (bID == Block.sand.blockID) { world.setBlockWithNotify(x, y, z, 0); return new ItemStack(mod_InfiTools.goldBucketSand); } if (bID == Block.gravel.blockID) { world.setBlockWithNotify(x, y, z, 0); return new ItemStack(mod_InfiTools.goldBucketGravel); } } else { if (isFull < 0) { return new ItemStack(mod_InfiTools.goldBucketEmpty); } if (mop.sideHit == 0) { y--; } if (mop.sideHit == 1) { y++; } if (mop.sideHit == 2) { z--; } if (mop.sideHit == 3) { z++; } if (mop.sideHit == 4) { x--; } if (mop.sideHit == 5) { x++; } if (world.isAirBlock(x, y, z) || !world.getBlockMaterial(x, y, z).isSolid()) { if (world.worldProvider.isHellWorld && isFull == Block.waterMoving.blockID) { world.playSoundEffect( x + 0.5D, y + 0.5D, z + 0.5D, "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); for (int l = 0; l < 8; l++) { world.spawnParticle( "largesmoke", (double) x + Math.random(), (double) y + Math.random(), (double) z + Math.random(), 0.0D, 0.0D, 0.0D); } } else { world.setBlockAndMetadataWithNotify(x, y, z, isFull, 0); } return new ItemStack(mod_InfiTools.goldBucketEmpty); } } } else if (isFull == 0 && (mop.entityHit instanceof EntityCow)) { return new ItemStack(mod_InfiTools.goldBucketMilk); } return itemstack; }