protected void setBlockMode(World world, int x, int y, int z) { if (world.isRemote) return; TileEntity ent = world.getTileEntity(x, y, z); int habCount = 0; if (ent instanceof TileEntityFlickerHabitat) { TileEntityFlickerHabitat hab = (TileEntityFlickerHabitat) ent; for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { Block block = world.getBlock(x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ); TileEntity te = world.getTileEntity( x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ); if (block == BlocksCommonProxy.elementalAttuner && te != null && te instanceof TileEntityFlickerHabitat) { TileEntityFlickerHabitat foundHab = (TileEntityFlickerHabitat) te; if (foundHab.isUpgrade() == false) { habCount++; if (habCount == 1) { hab.setUpgrade(true, direction); } else { world.func_147480_a(x, y, z, true); } } else { world.func_147480_a(x, y, z, true); } } } } }
/** Called when the block is attempted to be harvested */ public void onBlockHarvested(World world, int x, int y, int z, int i, EntityPlayer f) { if (func_149887_c(i)) { if (world.getBlock(x, y - 1, z) == this) { if (!f.capabilities.isCreativeMode) { int i1 = world.getBlockMetadata(x, y - 1, z); int j1 = func_149890_d(i1); if (j1 != 3 && j1 != 2) { world.func_147480_a(x, y - 1, z, true); } else { if (!world.isRemote && f.getCurrentEquippedItem() != null && f.getCurrentEquippedItem().getItem() == Items.shears) { this.func_149886_b(world, x, y, z, i1, f); } world.setBlockToAir(x, y - 1, z); } } else { world.setBlockToAir(x, y - 1, z); } } } else if (f.capabilities.isCreativeMode && world.getBlock(x, y + 1, z) == this) { world.setBlock(x, y + 1, z, Blocks.air, 0, 2); } super.onBlockHarvested(world, x, y, z, i, f); }
@Override public void onNeighborBlockChange(World world, int x, int y, int z, Block neighborBlockID) { if (world.isRemote) return; TileEntity te = world.getTileEntity(x, y, z); if (te instanceof TileEntityFlickerHabitat) { TileEntityFlickerHabitat hab = (TileEntityFlickerHabitat) te; if (hab.isUpgrade()) { int habCount = 0; for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { te = world.getTileEntity( x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ); if (te != null && te instanceof TileEntityFlickerHabitat) { TileEntityFlickerHabitat foundHab = (TileEntityFlickerHabitat) te; if (foundHab.isUpgrade() == false) { habCount++; if (habCount == 1) { } else { world.func_147480_a(x, y, z, true); } } else { world.func_147480_a(x, y, z, true); } } } if (habCount == 0) { world.func_147480_a(x, y, z, true); } } else { hab.scanForNearbyUpgrades(); if (!hab.isUpgrade()) { hab.scanForNearbyUpgrades(); } } } }
@Override public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { try { TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileSignalFoundation) { TileSignalFoundation structure = (TileSignalFoundation) tile; if (structure.getSignalType().needsSupport() && !world.isSideSolid(x, y - 1, z, ForgeDirection.UP)) world.func_147480_a(x, y, z, true); else structure.onNeighborBlockChange(block); } } catch (StackOverflowError error) { Game.logThrowable(Level.ERROR, "Error in BlockSignalBase.onNeighborBlockChange()", 10, error); throw error; } }
@Override public void breakBlock(World world, int x, int y, int z, Block oldBlockID, int oldMetadata) { TileEntityFlickerHabitat habitat = (TileEntityFlickerHabitat) world.getTileEntity(x, y, z); // if there is no habitat at the location break out if (habitat == null) return; // if the habitat has a flicker throw it on the ground if (habitat.hasFlicker()) { Random rand = new Random(); ItemStack stack = habitat.getStackInSlot(0); float offsetX = rand.nextFloat() * 0.8F + 0.1F; float offsetY = rand.nextFloat() * 0.8F + 0.1F; float offsetZ = rand.nextFloat() * 0.8F + 0.1F; float force = 0.05F; EntityItem entityItem = new EntityItem(world, x + offsetX, y + offsetY, z + offsetZ, stack); entityItem.motionX = (float) rand.nextGaussian() * force; entityItem.motionY = (float) rand.nextGaussian() * force + 0.2F; entityItem.motionZ = (float) rand.nextGaussian() * force; world.spawnEntityInWorld(entityItem); } if (!habitat.isUpgrade()) { for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { TileEntity te = world.getTileEntity( x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ); if (te != null && te instanceof TileEntityFlickerHabitat) { TileEntityFlickerHabitat upgHab = (TileEntityFlickerHabitat) te; if (upgHab.isUpgrade()) { world.func_147480_a( x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ, true); world.setTileEntity( x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ, null); } } } } super.breakBlock(world, x, y, z, oldBlockID, oldMetadata); return; }
@Override public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { try { TileEntity tile = world.getTileEntity(x, y, z); if ((tile instanceof TileDigitalReceiverBox)) { TileDigitalReceiverBox structure = (TileDigitalReceiverBox) tile; if ((structure.getSignalType().needsSupport()) && (!world.isSideSolid(x, y - 1, z, ForgeDirection.UP)) && !(Mods.isLoaded(Mods.OpenComputers) && world.getTileEntity(x, y - 1, z) instanceof Environment)) { world.func_147480_a(x, y, z, true); } else { structure.onNeighborBlockChange(block); } } } catch (StackOverflowError error) { Computronics.log.error("Error in BlockDigitalReceiverBox.onNeighborBlockChange()"); throw error; } }
/** Attempts to place the liquid contained inside the bucket. */ public boolean tryPlaceContainedLiquid(World world, int x, int y, int z) { if (this.isFull == Blocks.air) { return false; } else { Material material = world.getBlock(x, y, z).getMaterial(); boolean flag = !material.isSolid(); if (!world.isAirBlock(x, y, z) && !flag) { return false; } else { if (world.provider.isHellWorld && this.isFull == Blocks.flowing_water) { world.playSoundEffect( x + 0.5F, y + 0.5F, z + 0.5F, "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); for (int l = 0; l < 8; ++l) { world.spawnParticle( "largesmoke", x + Math.random(), y + Math.random(), z + Math.random(), 0.0D, 0.0D, 0.0D); } } else { if (!world.isRemote && flag && !material.isLiquid()) { world.func_147480_a(x, y, z, true); } world.setBlock(x, y, z, this.isFull, 0, 3); } return true; } } }
/** * Drop some kinetic dust in the world * * @param world * @param x * @param y * @param z * @param amount */ public void makeKineticDust(World world, int x, int y, int z, int amount) { world.func_147480_a(x, y, z, false); // Destroy block world.spawnEntityInWorld( new EntityItem(world, x, y, z, new ItemStack(KinetiCraft2Items.netherKineticDust, amount))); }