@Override public void updateTick(World world, int x, int y, int z, Random rand) { if (world.isRemote) return; int meta = world.getBlockMetadata(x, y, z); l: if (meta != 0) { ForgeDirection dir = ForgeDirection.getOrientation(meta - 1); if (world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ).equals(this)) if (world.getBlockMetadata(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ) == meta) return; else break l; TileEntity te = world.getTileEntity(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); if (te instanceof IFactoryLaserSource && ((IFactoryLaserSource) te).canFormBeamFrom(dir)) return; world.setBlockMetadataWithNotify(x, y, z, 0, 0); } Block upperId = world.getBlock(x, y + 1, z); if (!upperId.equals(this) && !(world.getTileEntity(x, y + 1, z) instanceof TileEntityLaserDrill)) { world.setBlockToAir(x, y, z); return; } Block lowerId = world.getBlock(x, y - 1, z); if ((!lowerId.equals(this) || world.getBlockMetadata(x, y - 1, z) != 0) && TileEntityLaserDrill.canReplaceBlock(lowerId, world, x, y - 1, z)) { world.setBlock(x, y - 1, z, this); } }
/** Called whenever an entity is walking on top of this block. Args: world, x, y, z, entity */ public void onEntityWalking(World var1, int var2, int var3, int var4, Entity var5) { if (var5 instanceof EntityPlayer) { var1.playSoundEffect( (double) ((float) var2 + 0.5F), (double) ((float) var3 + 0.5F), (double) ((float) var4 + 0.5F), "aemisc.activateTrap", 1.0F, 1.0F); int var6 = MathHelper.floor_double((double) var2); int var7 = MathHelper.floor_double((double) var3); int var8 = MathHelper.floor_double((double) var4); if (!var1.isRemote) { switch (var1.getBlockMetadata(var2, var3, var4)) { case 0: EntitySentry var9 = new EntitySentry(var1); var9.setPosition((double) var6 + 0.5D, (double) var7 + 1.5D, (double) var8 + 0.5D); var1.spawnEntityInWorld(var9); case 1: } } var1.setBlock( var2, var3, var4, AetherBlocks.LockedDungeonStone.blockID, var1.getBlockMetadata(var2, var3, var4), 2); } }
public void addCollisionBoxesToList( World world, int x, int y, int z, AxisAlignedBB axisAlignedBB, List list, Entity entity) { if (world.getBlockMetadata(x, y, z) == 0) { this.setBlockBounds(0F, 0F, 0F, 1F, 0.5F, 1F); super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); this.setBlockBounds(1F, 0F, 0F, 0.5F, 1F, 1F); super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 1F); } if (world.getBlockMetadata(x, y, z) == 1) { this.setBlockBounds(0F, 0F, 0F, 1F, 0.5F, 1F); super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); this.setBlockBounds(1F, 0F, 0F, 0.5F, 1F, 1F); super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 1F); } if (world.getBlockMetadata(x, y, z) == 2) { this.setBlockBounds(0F, 0F, 0F, 1F, 0.5F, 1F); super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); this.setBlockBounds(1F, 0F, 0F, 0.5F, 1F, 1F); super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 1F); } if (world.getBlockMetadata(x, y, z) == 3) { this.setBlockBounds(0F, 0F, 0F, 1F, 0.5F, 1F); super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); this.setBlockBounds(1F, 0F, 0F, 0.5F, 1F, 1F); super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 1F); } }
private boolean func_150094_e( World p_150094_1_, int p_150094_2_, int p_150094_3_, int p_150094_4_) { int l = p_150094_1_.getBlockMetadata(p_150094_2_, p_150094_3_, p_150094_4_); int i1 = l; if (l > 0) { for (int j1 = 0; j1 <= 3; ++j1) { int k1 = 1 << j1; if ((l & k1) != 0 && !this.func_150093_a( p_150094_1_.getBlock( p_150094_2_ + Direction.offsetX[j1], p_150094_3_, p_150094_4_ + Direction.offsetZ[j1])) && (p_150094_1_.getBlock(p_150094_2_, p_150094_3_ + 1, p_150094_4_) != this || (p_150094_1_.getBlockMetadata(p_150094_2_, p_150094_3_ + 1, p_150094_4_) & k1) == 0)) { i1 &= ~k1; } } } if (i1 == 0 && !this.func_150093_a(p_150094_1_.getBlock(p_150094_2_, p_150094_3_ + 1, p_150094_4_))) { return false; } else { if (i1 != l) { p_150094_1_.setBlockMetadataWithNotify(p_150094_2_, p_150094_3_, p_150094_4_, i1, 2); } return true; } }
public boolean feed() { World world = worldObj; int x = xCoord; int y = yCoord; int z = zCoord; int id = world.getBlockId(x, y - 1, z); int meta = world.getBlockMetadata(x, y - 1, z); TileEntity tile = world.getBlockTileEntity(x, y - 1, z); if (tile instanceof Feedable) { if (((Feedable) tile).feedIn(inv[3])) { inv[3] = inv[2]; inv[2] = inv[1]; inv[1] = inv[0]; id = world.getBlockId(x, y + 1, z); meta = world.getBlockMetadata(x, y + 1, z); tile = world.getBlockTileEntity(x, y + 1, z); if (tile instanceof Feedable) { inv[0] = ((Feedable) tile).feedOut(); } else inv[0] = null; } } this.collapseInventory(); 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 */ @Override 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.isBlockSolidOnSide(par2 - 1, par3, par4, EAST, true) && var6 == 1) { var7 = true; } if (!par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST, true) && var6 == 2) { var7 = true; } if (!par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH, true) && var6 == 3) { var7 = true; } if (!par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH, 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.setBlock(par2, par3, par4, 0); } } }
/** Attempt to displace the block at (x, y, z), return true if it was displaced. */ @Override public boolean displaceIfPossible(World world, int x, int y, int z) { int bId = world.getBlockId(x, y, z); if (bId == 0) { return true; } if (bId == blockID) { return false; } if (displacementIds.containsKey(bId)) { if (displacementIds.get(bId)) { Block.blocksList[bId].dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); return true; } return false; } Material material = Block.blocksList[bId].blockMaterial; if (material.blocksMovement() || material == Material.water || material == Material.lava || material == Material.portal) { return false; } Block.blocksList[bId].dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); return true; }
@Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) { if (!canBlockStay(world, x, y, z)) { world.setBlockToAir(x, y, z); world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(this, 1))); } else if ((TEBloomery) world.getTileEntity(x, y, z) != null) { TEBloomery te = (TEBloomery) world.getTileEntity(x, y, z); ItemStack is = entityplayer.getCurrentEquippedItem(); if (is != null && (is.getItem() == TFCItems.FireStarter || is.getItem() == TFCItems.FlintSteel)) { if (te.canLight()) entityplayer.getCurrentEquippedItem().damageItem(1, entityplayer); } else { world.playAuxSFXAtEntity(entityplayer, 1003, x, y, z, 0); if (isOpen(world.getBlockMetadata(x, y, z))) world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) - 8, 3); else world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) + 8, 3); } } return true; }
/** * 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) { int l = getDirection(par1World.getBlockMetadata(par2, par3, par4)); par2 += Direction.offsetX[l]; par4 += Direction.offsetZ[l]; int i1 = par1World.getBlockId(par2, par3, par4); return i1 == Block.wood.blockID && BlockLog.limitToValidMetadata(par1World.getBlockMetadata(par2, par3, par4)) == 3; }
public void updateTick(World world, int i, int j, int k, Random random) { if (world.isRemote) { return; } super.updateTick(world, i, j, k, random); int md = world.getBlockMetadata(i, j, k); if (md % 8 == 0) { if (world.getBlockLightValue(i, j + 1, k) >= 9 && random.nextInt(120) == 0) { if ((md & 8) == 0) { world.setBlockMetadataWithNotify(i, j, k, md | 8); } else { growTree(world, i, j, k, random); } } } else if (md % 8 == 1 && random.nextInt(7) == 0) { if ((md & 8) == 0) { world.setBlockMetadataWithNotify(i, j, k, md | 8); int i1 = world.getBlockMetadata(i, j, k); System.out.println( (new StringBuilder()).append("Sapling metadata: ").append(i1).toString()); } else { growTree(world, i, j, k, random); System.out.println("Blood tree has grown"); } } else if (md % 8 == 2 && random.nextInt(10) == 0) { if ((md & 8) == 0) { world.setBlockMetadataWithNotify(i, j, k, md | 8); int i1 = world.getBlockMetadata(i, j, k); System.out.println( (new StringBuilder()).append("Sapling metadata: ").append(i1).toString()); } else { growTree(world, i, j, k, random); System.out.println("Eucalyptus tree has grown"); } } else if (md % 8 == 3 && random.nextInt(7) == 0) { if ((md & 8) == 0) { world.setBlockMetadataWithNotify(i, j, k, md | 8); int i1 = world.getBlockMetadata(i, j, k); System.out.println( (new StringBuilder()).append("Sapling metadata: ").append(i1).toString()); } else { growTree(world, i, j, k, random); System.out.println("Sakura tree has grown"); } } else if (md % 8 == 4 && random.nextInt(7) == 0) { if ((md & 8) == 0) { world.setBlockMetadataWithNotify(i, j, k, md | 8); int i1 = world.getBlockMetadata(i, j, k); System.out.println( (new StringBuilder()).append("Sapling metadata: ").append(i1).toString()); } else { growTree(world, i, j, k, random); System.out.println("White tree has grown"); } } }
protected boolean neighbourChanged(World world, int x, int y, int z, Block block) { if (canPlaceAt(world, x, y, z)) { int metadata = world.getBlockMetadata(x, y, z); boolean canSupport = true; if (!world.isSideSolid(x - 1, y, z, EAST, true) && metadata == 1) { canSupport = false; } else if (!world.isSideSolid(x + 1, y, z, WEST, true) && metadata == 2) { canSupport = false; } else if (!world.isSideSolid(x, y, z - 1, SOUTH, true) && metadata == 3) { canSupport = false; } else if (!world.isSideSolid(x, y, z + 1, NORTH, true) && metadata == 4) { canSupport = false; } else if (!isSolid(world, x, y - 1, z) && metadata == 5) { canSupport = false; } else if (!isSolid(world, x, y + 1, z) && metadata == 6) { canSupport = false; } if (!canSupport) { if (new Random().nextInt(9) == 0) { if (!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops") && !world.restoringBlockSnapshots) // do not drop items while restoring blockstates, // prevents item dupe { float f = 0.7F; double motionX = world.rand.nextFloat() * f + (1.0F - f) * 0.5D; double motionY = world.rand.nextFloat() * f + (1.0F - f) * 0.5D; double motionZ = world.rand.nextFloat() * f + (1.0F - f) * 0.5D; EntityItem entityitem = new EntityItem( world, x + motionX, y + motionY, z + motionZ, new ItemStack(TFBlocks.energonCrystal)); entityitem.delayBeforeCanPickup = 10; world.spawnEntityInWorld(entityitem); } } else { this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); } world.setBlockToAir(x, y, z); return true; } else { return false; } } else { return true; } }
@SideOnly(Side.CLIENT) public boolean func_150936_a( World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer, ItemStack par7ItemStack) { int i1 = par2; int j1 = par3; int k1 = par4; Block block = par1World.getBlock(par2, par3, par4); int l1 = par1World.getBlockMetadata(par2, par3, par4); int i2 = l1 & 7; boolean flag = (l1 & 8) != 0; if ((par5 == 1 && !flag || par5 == 0 && flag) && block == this.singleSlab && i2 == par7ItemStack.getItemDamage()) { return true; } else { if (par5 == 0) { --par3; } if (par5 == 1) { ++par3; } if (par5 == 2) { --par4; } if (par5 == 3) { ++par4; } if (par5 == 4) { --par2; } if (par5 == 5) { ++par2; } Block block1 = par1World.getBlock(par2, par3, par4); int j2 = par1World.getBlockMetadata(par2, par3, par4); i2 = j2 & 7; return block1 == this.singleSlab && i2 == par7ItemStack.getItemDamage() ? true : super.func_150936_a(par1World, i1, j1, k1, par5, par6EntityPlayer, par7ItemStack); } }
public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) { ItemStack stack = player.inventory.getCurrentItem(); if (stack != null && stack.getItem().itemID == ZapApples.jamBucket.itemID) { if (world.getBlockMetadata(x, y, z) == 0) { if (!world.isRemote) { world.setBlockMetadataWithNotify(x, y, z, 1); if (stack.stackSize > 1) { stack.stackSize--; } else { stack = null; } if (!player.capabilities.isCreativeMode) { player.inventory.setInventorySlotContents(player.inventory.currentItem, stack); } if (!player.inventory.addItemStackToInventory(new ItemStack(Item.bucketEmpty))) { player.dropPlayerItem(new ItemStack(Item.bucketEmpty)); } } } return true; } else if (stack != null && stack.getItem().itemID == Item.bucketEmpty.itemID) { if (world.getBlockMetadata(x, y, z) == 1) { if (!world.isRemote) { world.setBlockMetadataWithNotify(x, y, z, 0); if (stack != null && stack.stackSize > 1) { stack.stackSize--; } else { stack = null; } if (!player.capabilities.isCreativeMode) { player.inventory.setInventorySlotContents(player.inventory.currentItem, stack); } if (!player.inventory.addItemStackToInventory(new ItemStack(ZapApples.jamBucket))) { player.dropPlayerItem(new ItemStack(ZapApples.jamBucket)); } } } return true; } return false; }
@SideOnly(Side.CLIENT) public boolean func_150936_a( World p_150936_1_, int p_150936_2_, int p_150936_3_, int p_150936_4_, int p_150936_5_, EntityPlayer p_150936_6_, ItemStack p_150936_7_) { int i1 = p_150936_2_; int j1 = p_150936_3_; int k1 = p_150936_4_; Block block = p_150936_1_.getBlock(p_150936_2_, p_150936_3_, p_150936_4_); int l1 = p_150936_1_.getBlockMetadata(p_150936_2_, p_150936_3_, p_150936_4_); int i2 = l1 & 7; boolean flag = (l1 & 8) != 0; if ((p_150936_5_ == 1 && !flag || p_150936_5_ == 0 && flag) && block == this.field_150949_c && i2 == p_150936_7_.getItemDamage()) { return true; } else { if (p_150936_5_ == 0) { --p_150936_3_; } if (p_150936_5_ == 1) { ++p_150936_3_; } if (p_150936_5_ == 2) { --p_150936_4_; } if (p_150936_5_ == 3) { ++p_150936_4_; } if (p_150936_5_ == 4) { --p_150936_2_; } if (p_150936_5_ == 5) { ++p_150936_2_; } Block block1 = p_150936_1_.getBlock(p_150936_2_, p_150936_3_, p_150936_4_); int j2 = p_150936_1_.getBlockMetadata(p_150936_2_, p_150936_3_, p_150936_4_); i2 = j2 & 7; return block1 == this.field_150949_c && i2 == p_150936_7_.getItemDamage() ? true : super.func_150936_a(p_150936_1_, i1, j1, k1, p_150936_5_, p_150936_6_, p_150936_7_); } }
/** * Tries to add quicksand into this block. Returns the amount of quicksand meta that was added. * * @param world World of the block to flow into. * @param x X of the block to flow into. * @param y Y of the block to flow into. * @param z Z of the block to flow into. * @param flowAmount Amount of quicksand that should try to flow into this block. * @return True if the quicksand can flow into this block. */ public int flowIntoBlock(World world, int x, int y, int z, int flowAmount) { Block toFlowInto = world.getBlock(x, y, z); if (flowAmount > 0 && ((toFlowInto == BlockQuickSand.instance && world.getBlockMetadata(x, y, z) != 0) || world.isAirBlock(x, y, z))) { // Try to flow into this block; Calculate how much metadata to subtract from it. if (toFlowInto == Blocks.air) { if (debug) System.out.println( "Flowing into air block at x=" + x + ", y=" + y + ", z=" + z + ". Setting metadata to " + (16 - flowAmount)); world.setBlock(x, y, z, BlockQuickSand.instance, 16 - flowAmount, 3); return flowAmount; } else if (toFlowInto == BlockQuickSand.instance) { int emptyAmount = world.getBlockMetadata( x, y, z); // Amount of "air space" or empty space in the quicksand block. int finalFlowAmount = Math.min(emptyAmount, flowAmount); if (finalFlowAmount > 0) { if (debug) System.out.println( "Flowing into quicksand block at x=" + x + ", y=" + y + ", z=" + z + ". Setting metadata to " + (emptyAmount - finalFlowAmount)); world.setBlockMetadataWithNotify(x, y, z, emptyAmount - finalFlowAmount, 3); } return finalFlowAmount; } if (debug) System.out.println("How did I even get here?"); // Shouldn't ever reach this point. return 0; } else { // Can't flow into this block. // if(debug) System.out.println("Can't flow into a '" + world.getBlock(x, y, // z).getUnlocalizedName() + "' block with meta " + world.getBlockMetadata(x, y, z)); return 0; } }
/** Called when this EntityThrowable hits a block or entity. */ protected void onImpact(MovingObjectPosition var1) { int var2 = this.worldObj.getBlockId(var1.blockX, var1.blockY, var1.blockZ); int var3 = this.worldObj.getBlockMetadata(var1.blockX, var1.blockY, var1.blockZ); int x = var1.blockX; int y = var1.blockY; int z = var1.blockZ; if (status == 0) { // if (world.getBlockMaterial(x, y, z)== Material.water && world.getBlockMetadata(x,y,z) == // 0){ // world.setBlockToAir(x,y,z); // world.setBlock(x, y, z, Block.ice.blockID); // } // if (world.getBlockMaterial(x, y, z )== Material.lava && world.getBlockMetadata(x,y,z) == // 0){ // world.setBlockToAir(x,y,z); // world.setBlock(x, y, z, Block.stone.blockID); // } if (world.getBlockMaterial(x, y + 1, z) == Material.air && world.getBlockMaterial(x, y, z) != Material.snow && world.getBlockMaterial(x, y, z) != Material.ice) { world.setBlock(x, y + 1, z, Block.snow.blockID); } } else if (status == 1) { // if (world.getBlockMaterial(x, y, z )== Material.rock && world.getBlockMetadata(x,y,z) == // 0){ // world.setBlockToAir(x,y,z); // world.setBlock(x, y, z, Block.lavaStill.blockID); // } if (world.getBlockMaterial(x, y, z) == Material.ice && world.getBlockMetadata(x, y, z) == 0) { world.setBlockToAir(x, y, z); world.setBlock(x, y, z, Block.waterStill.blockID); } if (world.getBlockMaterial(x, y, z) == Material.snow && world.getBlockMetadata(x, y, z) == 0) { world.setBlockToAir(x, y, z); } } if (var1.entityHit != null) { var1.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, this.getThrower()), damage); if (status == 1) { var1.entityHit.setFire(20); } else if (status == 0 && var1.entityHit instanceof EntityLiving) { ((EntityLiving) var1.entityHit) .addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 60, 2)); } } if (!this.worldObj.isRemote) { this.setDead(); } }
/** Called upon block activation (right click on the block.) */ public boolean onBlockActivated( World world, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { if (par5EntityPlayer.getCurrentEquippedItem().itemID == this.blockID) { if (world.getBlockMetadata(par2, par3, par4) == 0 /*0 = Slab at bottom half*/) { if (par6 == 1 /*1 = top of the block*/) { if (!par5EntityPlayer.capabilities.isCreativeMode) { --par5EntityPlayer.getCurrentEquippedItem().stackSize; } world.playSoundEffect( (double) ((float) par2 + 0.5F), (double) ((float) par3 + 0.5F), (double) ((float) par4 + 0.5F), this.stepSound.getPlaceSound(), (this.stepSound.getVolume() + 1.0F) / 2.0F, this.stepSound.getPitch() * 0.8F); world.setBlock(par2, par3, par4, BOPBlocks.firDoubleSlab.blockID); return true; } } if (world.getBlockMetadata(par2, par3, par4) == 8 /*8 = Slab at top half*/) { if (par6 == 0 /*0 = bottom of the block*/) { if (!par5EntityPlayer.capabilities.isCreativeMode) { --par5EntityPlayer.getCurrentEquippedItem().stackSize; } world.playSoundEffect( (double) ((float) par2 + 0.5F), (double) ((float) par3 + 0.5F), (double) ((float) par4 + 0.5F), this.stepSound.getPlaceSound(), (this.stepSound.getVolume() + 1.0F) / 2.0F, this.stepSound.getPitch() * 0.8F); world.setBlock(par2, par3, par4, BOPBlocks.firDoubleSlab.blockID); return true; } } } return false; }
@Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer player, int side, float hitVecX, float hitVecY, float hitVecZ) { if (player.getCurrentEquippedItem() != null) { if (player.getCurrentEquippedItem().getDisplayName().toLowerCase().contains("hoe")) { if (world.getBlockMetadata(x, y, z) == 0) { Block farmland = KoentusBlocks.crystal_farmland; world.playSoundEffect( x + 0.5F, y + 0.5F, z + 0.5F, farmland.stepSound.getStepResourcePath(), (farmland.stepSound.getVolume() + 1.0F) / 2.0F, farmland.stepSound.getPitch() * 0.8F); if (!world.isRemote) { world.setBlock(x, y, z, farmland, 0, 2); } player.getCurrentEquippedItem().damageItem(1, player); } else if (world.getBlockMetadata(x, y, z) == 1) { Block farmland = this; world.playSoundEffect( x + 0.5F, y + 0.5F, z + 0.5F, farmland.stepSound.getStepResourcePath(), (farmland.stepSound.getVolume() + 1.0F) / 2.0F, farmland.stepSound.getPitch() * 0.8F); if (!world.isRemote) { world.setBlock(x, y, z, farmland, 0, 2); } player.getCurrentEquippedItem().damageItem(1, player); } return true; } else { return false; } } else { return false; } }
@Override public void updateTick(World world, int i, int j, int k, Random random) { if (j < 253) { if (world.getBlockId(i, j + 1, k) == 0) { world.setBlockAndMetadataWithNotify(i, j + 1, k, blockID, world.getBlockMetadata(i, j, k)); world.scheduleBlockUpdate(i, j + 1, k, blockID, 5); } } else if (world.getBlockMetadata(i, j, k) == 1) { world.setBlockMetadata(i, j, k, 0); world.setBlockAndMetadataWithNotify(i, j + 1, k, TooManyPlants.objs.blockpod.blockID, 1); world.setBlockWithNotify(i, j + 2, k, TooManyPlants.objs.blockpod.blockID); } }
@Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { if (player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() == TFCItems.Straw) { int meta = world.getBlockMetadata(x, y, z); if (world.getBlockMetadata(x, y, z) < 15) { if (player.capabilities.isCreativeMode) { world.setBlockMetadataWithNotify(x, y, z, 15, 2); } else { world.setBlockMetadataWithNotify(x, y, z, meta + 1, 2); } player.inventory.decrStackSize(player.inventory.currentItem, 1); return true; } } else { if (side == 1 && player.isSneaking()) { int offset = 0; /*if(world.getBlockId(x, y, z) != TFCBlocks.Pottery.blockID) { world.setBlock(x, y+1, z, TFCBlocks.Pottery.blockID); offset = 1; }*/ TileEntityPottery te = (TileEntityPottery) world.getBlockTileEntity(x, y + offset, z); if (hitX < 0.5 && hitZ < 0.5) { te.ejectItem(0); } else if (hitX > 0.5 && hitZ < 0.5) { te.ejectItem(1); } else if (hitX < 0.5 && hitZ > 0.5) { te.ejectItem(2); } else if (hitX > 0.5 && hitZ > 0.5) { te.ejectItem(3); } te.broadcastPacketInRange(te.createUpdatePacket()); } } } return false; }
@Override public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { if (!stack.hasTagCompound()) return false; World world = player.worldObj; final Block wood = world.getBlock(x, y, z); ; if (wood == null) { return super.onBlockStartBreak(stack, x, y, z, player); } if (wood.isWood(world, x, y, z) || wood.getMaterial() == Material.sponge) { int height = y; boolean foundTop = false; do { height++; Block block = world.getBlock(x, height, z); if (block != wood) { height--; foundTop = true; } } while (!foundTop); int numLeaves = 0; if (height - y < 50) { for (int xPos = x - 1; xPos <= x + 1; xPos++) { for (int yPos = height - 1; yPos <= height + 1; yPos++) { for (int zPos = z - 1; zPos <= z + 1; zPos++) { Block leaves = world.getBlock(xPos, yPos, zPos); if (leaves != null && leaves.isLeaves(world, xPos, yPos, zPos)) numLeaves++; } } } } NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); int meta = world.getBlockMetadata(x, y, z); if (numLeaves > 3) breakTree(world, x, y, z, stack, tags, wood, meta, player); else destroyWood(world, x, y, z, stack, tags, player); if (!world.isRemote) world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(wood) + (meta << 12)); } else if (wood.getMaterial() == Material.wood) { NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); int meta = world.getBlockMetadata(x, y, z); destroyWood(world, x, y, z, stack, tags, player); if (!world.isRemote) world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(wood) + (meta << 12)); } return super.onBlockStartBreak(stack, x, y, z, player); }
@SideOnly(Side.CLIENT) public void randomDisplayTick(World world, int i, int j, int k, Random random) { if (this == FABlockRegistry.mutantPlant) { if (world.getBlockMetadata(i, j, k) != 0) { int l = ((MathHelper.floor_double((double) (1 * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4; int q = 8 | l; world.spawnParticle( "blockcrack_" + Block.getIdFromBlock(FABlockRegistry.mutantPlant) + "_" + q, i + ((double) random.nextFloat()), j + ((double) random.nextFloat()), k + ((double) random.nextFloat()), 4.0D * ((double) random.nextFloat()), 0.5D, ((double) random.nextFloat()) * 4.0D); world.spawnParticle( "blockcrack_" + Block.getIdFromBlock(FABlockRegistry.mutantPlant) + "_" + q, i + ((double) random.nextFloat()), j + ((double) random.nextFloat()), k + ((double) random.nextFloat()), 4.0D * ((double) random.nextFloat()), 0.5D, ((double) random.nextFloat()) * 4.0D); world.spawnParticle( "blockcrack_" + Block.getIdFromBlock(FABlockRegistry.mutantPlant) + "_" + q, i + ((double) random.nextFloat()), j + ((double) random.nextFloat()), k + ((double) random.nextFloat()), 4.0D * ((double) random.nextFloat() - 0.5D), 0.5D, ((double) random.nextFloat() - 0.5D) * 4.0D); world.spawnParticle( "blockcrack_" + Block.getIdFromBlock(FABlockRegistry.mutantPlant) + "_" + q, i + ((double) random.nextFloat()), j + ((double) random.nextFloat()), k + ((double) random.nextFloat()), 4.0D * ((double) random.nextFloat() - 0.5D), 0.5D, ((double) random.nextFloat() - 0.5D) * 4.0D); } } if (this == FABlockRegistry.sarracina) { if (world.getBlockMetadata(i, j, k) == 0) { FossilFX.spawnParticle("flies", i + 0.7, j + 0.8, k + 0.6, 0.0D, 1.5D, 0.0D, 3); FossilFX.spawnParticle("flies", i + 0.7, j + 0.5, k, 0.0D, 1.5D, 0.0D, 2); FossilFX.spawnParticle("flies", i, j + 0.5, k + 0.5, 0.0D, 1.5D, 0.0D, 4); FossilFX.spawnParticle("flies", i + 0.3, j + 0.5, k + 0.9, 0.0D, 1.5D, 0.0D, 4); } } }
/** Ticks the block if it's been scheduled */ public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { if (!this.canBlockStay(par1World, par2, par3, par4)) { this.dropBlockAsItem( par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); par1World.setBlockToAir(par2, par3, par4); } else if (par1World.rand.nextInt(5) == 0) { int l = par1World.getBlockMetadata(par2, par3, par4); int i1 = func_72219_c(l); if (i1 < 2) { ++i1; par1World.setBlockMetadataWithNotify(par2, par3, par4, i1 << 2 | getDirection(l), 2); } } }
@Override public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); World world = player.worldObj; int bID = player.worldObj.getBlockId(x, y, z); int meta = world.getBlockMetadata(x, y, z); Block block = Block.blocksList[bID]; if (block == null || bID < 1) return false; int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); int shlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getSecondHarvestType()); if (hlvl <= tags.getInteger("HarvestLevel") && shlvl <= tags.getInteger("HarvestLevel2")) { boolean cancelHarvest = false; for (ActiveToolMod mod : TConstructRegistry.activeModifiers) { if (mod.beforeBlockBreak(this, stack, x, y, z, player)) cancelHarvest = true; } return cancelHarvest; } else { if (!player.capabilities.isCreativeMode) onBlockDestroyed(stack, world, bID, x, y, z, player); world.setBlockToAir(x, y, z); if (!world.isRemote) world.playAuxSFX(2001, x, y, z, bID + (meta << 12)); return true; } }
@Override public boolean onBlockActivated( World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, float subY, float subZ) { // Play the block break sound and spawn the block break particle effects worldIn.playAuxSFXAtEntity( player, 2001, x, y, z, Block.getIdFromBlock(this) + (worldIn.getBlockMetadata(x, y, z) << 12)); if (!worldIn.isRemote) { ItemStack itemStack = LootSpawns.RubbleMilitaryLoot.getOneItem( worldIn.rand); // Get a random item from the loot list dropBlockAsItem(worldIn, x, y, z, itemStack); // Drop it in the world worldIn.setBlockToAir(x, y, z); // Set this block to air } return true; }
@Override public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block par5) { int i1 = par1World.getBlockMetadata(par2, par3, par4); boolean flag = false; if (i1 == 0 && par1World.isSideSolid(par2, par3, par4 + 1, ForgeDirection.NORTH)) { flag = true; } if (i1 == 1 && par1World.isSideSolid(par2, par3, par4 - 1, ForgeDirection.SOUTH)) { flag = true; } if (i1 == 2 && par1World.isSideSolid(par2 + 1, par3, par4, ForgeDirection.WEST)) { flag = true; } if (i1 == 3 && par1World.isSideSolid(par2 - 1, par3, par4, ForgeDirection.EAST)) { flag = true; } if (!flag) { this.dropBlockAsItem(par1World, par2, par3, par4, i1, 0); par1World.setBlockToAir(par2, par3, par4); } super.onNeighborBlockChange(par1World, par2, par3, par4, par5); }
/** Returns the block hardness at a location. Args: world, x, y, z */ @Override public float getBlockHardness(World world, int x, int y, int z) { int meta = world.getBlockMetadata(x, y, z); if (subBlocks[meta] != null) return subBlocks[meta].getBlockHardness(); return 0; }
@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); } } } }
/** Called when the block is right clicked by the player */ @Override public boolean onMachineActivated( World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) { int metadata = par1World.getBlockMetadata(x, y, z); if (!par1World.isRemote) { if (metadata >= GCCoreBlockMachine.COMPRESSOR_METADATA) { par5EntityPlayer.openGui(GalacticraftCore.instance, -1, par1World, x, y, z); return true; } else if (metadata >= GCCoreBlockMachine.ELECTRIC_FURNACE_METADATA) { par5EntityPlayer.openGui(GalacticraftCore.instance, -1, par1World, x, y, z); return true; } else if (metadata >= GCCoreBlockMachine.STORAGE_MODULE_METADATA) { par5EntityPlayer.openGui(GalacticraftCore.instance, -1, par1World, x, y, z); return true; } else { par5EntityPlayer.openGui(GalacticraftCore.instance, -1, par1World, x, y, z); return true; } } return true; }
@Override public boolean canBlockStay(World world, int x, int y, int z) { if (world.isAirBlock(x, y, z)) return true; if (world.getTileEntity(x, y, z) instanceof TEBloomery) // Prevent ClassCastException { boolean flipped = false; int dir = world.getBlockMetadata(x, y, z) & 3; TEBloomery te = (TEBloomery) world.getTileEntity(x, y, z); if (te != null) flipped = te.isFlipped; if (checkStack(world, x, y, z, dir)) { if (checkVertical(world, x, y, z, flipped)) { if (checkHorizontal(world, x, y, z, flipped)) return true; } else if (te != null && !flipped) { this.tryFlip(world, x, y, z); flipped = te.isFlipped; if (checkVertical(world, x, y, z, flipped)) { if (checkHorizontal(world, x, y, z, flipped)) return true; } } } } return false; }