001 package net.minecraft.block; 002 003 import cpw.mods.fml.relauncher.Side; 004 import cpw.mods.fml.relauncher.SideOnly; 005 import java.util.Random; 006 import net.minecraft.block.material.Material; 007 import net.minecraft.creativetab.CreativeTabs; 008 import net.minecraft.enchantment.EnchantmentHelper; 009 import net.minecraft.entity.player.EntityPlayer; 010 import net.minecraft.item.ItemStack; 011 import net.minecraft.stats.StatList; 012 import net.minecraft.world.EnumSkyBlock; 013 import net.minecraft.world.IBlockAccess; 014 import net.minecraft.world.World; 015 016 public class BlockIce extends BlockBreakable 017 { 018 public BlockIce(int par1, int par2) 019 { 020 super(par1, par2, Material.ice, false); 021 this.slipperiness = 0.98F; 022 this.setTickRandomly(true); 023 this.setCreativeTab(CreativeTabs.tabBlock); 024 } 025 026 @SideOnly(Side.CLIENT) 027 028 /** 029 * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha 030 */ 031 public int getRenderBlockPass() 032 { 033 return 1; 034 } 035 036 @SideOnly(Side.CLIENT) 037 038 /** 039 * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given 040 * coordinates. Args: blockAccess, x, y, z, side 041 */ 042 public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) 043 { 044 return super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, 1 - par5); 045 } 046 047 /** 048 * Called when the player destroys a block with an item that can harvest it. (i, j, k) are the coordinates of the 049 * block and l is the block's subtype/damage. 050 */ 051 public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) 052 { 053 par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1); 054 par2EntityPlayer.addExhaustion(0.025F); 055 056 if (this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(par2EntityPlayer)) 057 { 058 ItemStack var9 = this.createStackedBlock(par6); 059 060 if (var9 != null) 061 { 062 this.dropBlockAsItem_do(par1World, par3, par4, par5, var9); 063 } 064 } 065 else 066 { 067 if (par1World.provider.isHellWorld) 068 { 069 par1World.setBlockWithNotify(par3, par4, par5, 0); 070 return; 071 } 072 073 int var7 = EnchantmentHelper.getFortuneModifier(par2EntityPlayer); 074 this.dropBlockAsItem(par1World, par3, par4, par5, par6, var7); 075 Material var8 = par1World.getBlockMaterial(par3, par4 - 1, par5); 076 077 if (var8.blocksMovement() || var8.isLiquid()) 078 { 079 par1World.setBlockWithNotify(par3, par4, par5, Block.waterMoving.blockID); 080 } 081 } 082 } 083 084 /** 085 * Returns the quantity of items to drop on block destruction. 086 */ 087 public int quantityDropped(Random par1Random) 088 { 089 return 0; 090 } 091 092 /** 093 * Ticks the block if it's been scheduled 094 */ 095 public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) 096 { 097 if (par1World.getSavedLightValue(EnumSkyBlock.Block, par2, par3, par4) > 11 - Block.lightOpacity[this.blockID]) 098 { 099 if (par1World.provider.isHellWorld) 100 { 101 par1World.setBlockWithNotify(par2, par3, par4, 0); 102 return; 103 } 104 105 this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); 106 par1World.setBlockWithNotify(par2, par3, par4, Block.waterStill.blockID); 107 } 108 } 109 110 /** 111 * Returns the mobility information of the block, 0 = free, 1 = can't push but can move over, 2 = total immobility 112 * and stop pistons 113 */ 114 public int getMobilityFlag() 115 { 116 return 0; 117 } 118 }