001    package net.minecraft.src;
002    
003    import cpw.mods.fml.common.Side;
004    import cpw.mods.fml.common.asm.SideOnly;
005    
006    import java.util.ArrayList;
007    import java.util.List;
008    import java.util.Random;
009    
010    import net.minecraftforge.common.*;
011    import static net.minecraftforge.common.ForgeDirection.*;
012    
013    public class Block
014    {
015        protected static int[] blockFireSpreadSpeed = new int[4096];
016        protected static int[] blockFlammability = new int[4096];
017        protected String currentTexture = "/terrain.png";
018        public boolean isDefaultTexture = true;
019        
020        /**
021         * used as foreach item, if item.tab = current tab, display it on the screen
022         */
023        private CreativeTabs displayOnCreativeTab;
024        public static final StepSound soundPowderFootstep = new StepSound("stone", 1.0F, 1.0F);
025        public static final StepSound soundWoodFootstep = new StepSound("wood", 1.0F, 1.0F);
026        public static final StepSound soundGravelFootstep = new StepSound("gravel", 1.0F, 1.0F);
027        public static final StepSound soundGrassFootstep = new StepSound("grass", 1.0F, 1.0F);
028        public static final StepSound soundStoneFootstep = new StepSound("stone", 1.0F, 1.0F);
029        public static final StepSound soundMetalFootstep = new StepSound("stone", 1.0F, 1.5F);
030        public static final StepSound soundGlassFootstep = new StepSoundStone("stone", 1.0F, 1.0F);
031        public static final StepSound soundClothFootstep = new StepSound("cloth", 1.0F, 1.0F);
032        public static final StepSound soundSandFootstep = new StepSound("sand", 1.0F, 1.0F);
033        public static final StepSound soundSnowFootstep = new StepSound("snow", 1.0F, 1.0F);
034        public static final StepSound soundLadderFootstep = new StepSoundSand("ladder", 1.0F, 1.0F);
035        public static final StepSound soundAnvilFootstep = new StepSoundAnvil("anvil", 0.3F, 1.0F);
036    
037        /** List of ly/ff (BlockType) containing the already registered blocks. */
038        public static final Block[] blocksList = new Block[4096];
039    
040        /**
041         * An array of 4096 booleans corresponding to the result of the isOpaqueCube() method for each block ID
042         */
043        public static final boolean[] opaqueCubeLookup = new boolean[4096];
044    
045        /** How much light is subtracted for going through this block */
046        public static final int[] lightOpacity = new int[4096];
047    
048        /** Array of booleans that tells if a block can grass */
049        public static final boolean[] canBlockGrass = new boolean[4096];
050    
051        /** Amount of light emitted */
052        public static final int[] lightValue = new int[4096];
053        public static final boolean[] requiresSelfNotify = new boolean[4096];
054    
055        /**
056         * Flag if block ID should use the brightest neighbor light value as its own
057         */
058        public static boolean[] useNeighborBrightness = new boolean[4096];
059        public static final Block stone = (new BlockStone(1, 1)).setHardness(1.5F).setResistance(10.0F).setStepSound(soundStoneFootstep).setBlockName("stone");
060        public static final BlockGrass grass = (BlockGrass)(new BlockGrass(2)).setHardness(0.6F).setStepSound(soundGrassFootstep).setBlockName("grass");
061        public static final Block dirt = (new BlockDirt(3, 2)).setHardness(0.5F).setStepSound(soundGravelFootstep).setBlockName("dirt");
062        public static final Block cobblestone = (new Block(4, 16, Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(soundStoneFootstep).setBlockName("stonebrick").setCreativeTab(CreativeTabs.tabBlock);
063        public static final Block planks = (new BlockWood(5)).setHardness(2.0F).setResistance(5.0F).setStepSound(soundWoodFootstep).setBlockName("wood").setRequiresSelfNotify();
064        public static final Block sapling = (new BlockSapling(6, 15)).setHardness(0.0F).setStepSound(soundGrassFootstep).setBlockName("sapling").setRequiresSelfNotify();
065        public static final Block bedrock = (new Block(7, 17, Material.rock)).setBlockUnbreakable().setResistance(6000000.0F).setStepSound(soundStoneFootstep).setBlockName("bedrock").disableStats().setCreativeTab(CreativeTabs.tabBlock);
066        public static final Block waterMoving = (new BlockFlowing(8, Material.water)).setHardness(100.0F).setLightOpacity(3).setBlockName("water").disableStats().setRequiresSelfNotify();
067        public static final Block waterStill = (new BlockStationary(9, Material.water)).setHardness(100.0F).setLightOpacity(3).setBlockName("water").disableStats().setRequiresSelfNotify();
068        public static final Block lavaMoving = (new BlockFlowing(10, Material.lava)).setHardness(0.0F).setLightValue(1.0F).setLightOpacity(255).setBlockName("lava").disableStats().setRequiresSelfNotify();
069    
070        /** Stationary lava source block */
071        public static final Block lavaStill = (new BlockStationary(11, Material.lava)).setHardness(100.0F).setLightValue(1.0F).setLightOpacity(255).setBlockName("lava").disableStats().setRequiresSelfNotify();
072        public static final Block sand = (new BlockSand(12, 18)).setHardness(0.5F).setStepSound(soundSandFootstep).setBlockName("sand");
073        public static final Block gravel = (new BlockGravel(13, 19)).setHardness(0.6F).setStepSound(soundGravelFootstep).setBlockName("gravel");
074        public static final Block oreGold = (new BlockOre(14, 32)).setHardness(3.0F).setResistance(5.0F).setStepSound(soundStoneFootstep).setBlockName("oreGold");
075        public static final Block oreIron = (new BlockOre(15, 33)).setHardness(3.0F).setResistance(5.0F).setStepSound(soundStoneFootstep).setBlockName("oreIron");
076        public static final Block oreCoal = (new BlockOre(16, 34)).setHardness(3.0F).setResistance(5.0F).setStepSound(soundStoneFootstep).setBlockName("oreCoal");
077        public static final Block wood = (new BlockLog(17)).setHardness(2.0F).setStepSound(soundWoodFootstep).setBlockName("log").setRequiresSelfNotify();
078        public static final BlockLeaves leaves = (BlockLeaves)(new BlockLeaves(18, 52)).setHardness(0.2F).setLightOpacity(1).setStepSound(soundGrassFootstep).setBlockName("leaves").setRequiresSelfNotify();
079        public static final Block sponge = (new BlockSponge(19)).setHardness(0.6F).setStepSound(soundGrassFootstep).setBlockName("sponge");
080        public static final Block glass = (new BlockGlass(20, 49, Material.glass, false)).setHardness(0.3F).setStepSound(soundGlassFootstep).setBlockName("glass");
081        public static final Block oreLapis = (new BlockOre(21, 160)).setHardness(3.0F).setResistance(5.0F).setStepSound(soundStoneFootstep).setBlockName("oreLapis");
082        public static final Block blockLapis = (new Block(22, 144, Material.rock)).setHardness(3.0F).setResistance(5.0F).setStepSound(soundStoneFootstep).setBlockName("blockLapis").setCreativeTab(CreativeTabs.tabBlock);
083        public static final Block dispenser = (new BlockDispenser(23)).setHardness(3.5F).setStepSound(soundStoneFootstep).setBlockName("dispenser").setRequiresSelfNotify();
084        public static final Block sandStone = (new BlockSandStone(24)).setStepSound(soundStoneFootstep).setHardness(0.8F).setBlockName("sandStone").setRequiresSelfNotify();
085        public static final Block music = (new BlockNote(25)).setHardness(0.8F).setBlockName("musicBlock").setRequiresSelfNotify();
086        public static final Block bed = (new BlockBed(26)).setHardness(0.2F).setBlockName("bed").disableStats().setRequiresSelfNotify();
087        public static final Block railPowered = (new BlockRail(27, 179, true)).setHardness(0.7F).setStepSound(soundMetalFootstep).setBlockName("goldenRail").setRequiresSelfNotify();
088        public static final Block railDetector = (new BlockDetectorRail(28, 195)).setHardness(0.7F).setStepSound(soundMetalFootstep).setBlockName("detectorRail").setRequiresSelfNotify();
089        public static final Block pistonStickyBase = (new BlockPistonBase(29, 106, true)).setBlockName("pistonStickyBase").setRequiresSelfNotify();
090        public static final Block web = (new BlockWeb(30, 11)).setLightOpacity(1).setHardness(4.0F).setBlockName("web");
091        public static final BlockTallGrass tallGrass = (BlockTallGrass)(new BlockTallGrass(31, 39)).setHardness(0.0F).setStepSound(soundGrassFootstep).setBlockName("tallgrass");
092        public static final BlockDeadBush deadBush = (BlockDeadBush)(new BlockDeadBush(32, 55)).setHardness(0.0F).setStepSound(soundGrassFootstep).setBlockName("deadbush");
093        public static final Block pistonBase = (new BlockPistonBase(33, 107, false)).setBlockName("pistonBase").setRequiresSelfNotify();
094        public static final BlockPistonExtension pistonExtension = (BlockPistonExtension)(new BlockPistonExtension(34, 107)).setRequiresSelfNotify();
095        public static final Block cloth = (new BlockCloth()).setHardness(0.8F).setStepSound(soundClothFootstep).setBlockName("cloth").setRequiresSelfNotify();
096        public static final BlockPistonMoving pistonMoving = new BlockPistonMoving(36);
097        public static final BlockFlower plantYellow = (BlockFlower)(new BlockFlower(37, 13)).setHardness(0.0F).setStepSound(soundGrassFootstep).setBlockName("flower");
098        public static final BlockFlower plantRed = (BlockFlower)(new BlockFlower(38, 12)).setHardness(0.0F).setStepSound(soundGrassFootstep).setBlockName("rose");
099        public static final BlockFlower mushroomBrown = (BlockFlower)(new BlockMushroom(39, 29)).setHardness(0.0F).setStepSound(soundGrassFootstep).setLightValue(0.125F).setBlockName("mushroom");
100        public static final BlockFlower mushroomRed = (BlockFlower)(new BlockMushroom(40, 28)).setHardness(0.0F).setStepSound(soundGrassFootstep).setBlockName("mushroom");
101        public static final Block blockGold = (new BlockOreStorage(41, 23)).setHardness(3.0F).setResistance(10.0F).setStepSound(soundMetalFootstep).setBlockName("blockGold");
102        public static final Block blockSteel = (new BlockOreStorage(42, 22)).setHardness(5.0F).setResistance(10.0F).setStepSound(soundMetalFootstep).setBlockName("blockIron");
103    
104        /** stoneDoubleSlab */
105        public static final BlockHalfSlab stoneDoubleSlab = (BlockHalfSlab)(new BlockStep(43, true)).setHardness(2.0F).setResistance(10.0F).setStepSound(soundStoneFootstep).setBlockName("stoneSlab");
106    
107        /** stoneSingleSlab */
108        public static final BlockHalfSlab stoneSingleSlab = (BlockHalfSlab)(new BlockStep(44, false)).setHardness(2.0F).setResistance(10.0F).setStepSound(soundStoneFootstep).setBlockName("stoneSlab");
109        public static final Block brick = (new Block(45, 7, Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(soundStoneFootstep).setBlockName("brick").setCreativeTab(CreativeTabs.tabBlock);
110        public static final Block tnt = (new BlockTNT(46, 8)).setHardness(0.0F).setStepSound(soundGrassFootstep).setBlockName("tnt");
111        public static final Block bookShelf = (new BlockBookshelf(47, 35)).setHardness(1.5F).setStepSound(soundWoodFootstep).setBlockName("bookshelf");
112        public static final Block cobblestoneMossy = (new Block(48, 36, Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(soundStoneFootstep).setBlockName("stoneMoss").setCreativeTab(CreativeTabs.tabBlock);
113        public static final Block obsidian = (new BlockObsidian(49, 37)).setHardness(50.0F).setResistance(2000.0F).setStepSound(soundStoneFootstep).setBlockName("obsidian");
114        public static final Block torchWood = (new BlockTorch(50, 80)).setHardness(0.0F).setLightValue(0.9375F).setStepSound(soundWoodFootstep).setBlockName("torch").setRequiresSelfNotify();
115        public static final BlockFire fire = (BlockFire)(new BlockFire(51, 31)).setHardness(0.0F).setLightValue(1.0F).setStepSound(soundWoodFootstep).setBlockName("fire").disableStats();
116        public static final Block mobSpawner = (new BlockMobSpawner(52, 65)).setHardness(5.0F).setStepSound(soundMetalFootstep).setBlockName("mobSpawner").disableStats();
117        public static final Block stairCompactPlanks = (new BlockStairs(53, planks, 0)).setBlockName("stairsWood").setRequiresSelfNotify();
118        public static final Block chest = (new BlockChest(54)).setHardness(2.5F).setStepSound(soundWoodFootstep).setBlockName("chest").setRequiresSelfNotify();
119        public static final Block redstoneWire = (new BlockRedstoneWire(55, 164)).setHardness(0.0F).setStepSound(soundPowderFootstep).setBlockName("redstoneDust").disableStats().setRequiresSelfNotify();
120        public static final Block oreDiamond = (new BlockOre(56, 50)).setHardness(3.0F).setResistance(5.0F).setStepSound(soundStoneFootstep).setBlockName("oreDiamond");
121        public static final Block blockDiamond = (new BlockOreStorage(57, 24)).setHardness(5.0F).setResistance(10.0F).setStepSound(soundMetalFootstep).setBlockName("blockDiamond");
122        public static final Block workbench = (new BlockWorkbench(58)).setHardness(2.5F).setStepSound(soundWoodFootstep).setBlockName("workbench");
123        public static final Block crops = (new BlockCrops(59, 88)).setBlockName("crops");
124        public static final Block tilledField = (new BlockFarmland(60)).setHardness(0.6F).setStepSound(soundGravelFootstep).setBlockName("farmland").setRequiresSelfNotify();
125        public static final Block stoneOvenIdle = (new BlockFurnace(61, false)).setHardness(3.5F).setStepSound(soundStoneFootstep).setBlockName("furnace").setRequiresSelfNotify().setCreativeTab(CreativeTabs.tabDecorations);
126        public static final Block stoneOvenActive = (new BlockFurnace(62, true)).setHardness(3.5F).setStepSound(soundStoneFootstep).setLightValue(0.875F).setBlockName("furnace").setRequiresSelfNotify();
127        public static final Block signPost = (new BlockSign(63, TileEntitySign.class, true)).setHardness(1.0F).setStepSound(soundWoodFootstep).setBlockName("sign").disableStats().setRequiresSelfNotify();
128        public static final Block doorWood = (new BlockDoor(64, Material.wood)).setHardness(3.0F).setStepSound(soundWoodFootstep).setBlockName("doorWood").disableStats().setRequiresSelfNotify();
129        public static final Block ladder = (new BlockLadder(65, 83)).setHardness(0.4F).setStepSound(soundLadderFootstep).setBlockName("ladder").setRequiresSelfNotify();
130        public static final Block rail = (new BlockRail(66, 128, false)).setHardness(0.7F).setStepSound(soundMetalFootstep).setBlockName("rail").setRequiresSelfNotify();
131        public static final Block stairCompactCobblestone = (new BlockStairs(67, cobblestone, 0)).setBlockName("stairsStone").setRequiresSelfNotify();
132        public static final Block signWall = (new BlockSign(68, TileEntitySign.class, false)).setHardness(1.0F).setStepSound(soundWoodFootstep).setBlockName("sign").disableStats().setRequiresSelfNotify();
133        public static final Block lever = (new BlockLever(69, 96)).setHardness(0.5F).setStepSound(soundWoodFootstep).setBlockName("lever").setRequiresSelfNotify();
134        public static final Block pressurePlateStone = (new BlockPressurePlate(70, stone.blockIndexInTexture, EnumMobType.mobs, Material.rock)).setHardness(0.5F).setStepSound(soundStoneFootstep).setBlockName("pressurePlate").setRequiresSelfNotify();
135        public static final Block doorSteel = (new BlockDoor(71, Material.iron)).setHardness(5.0F).setStepSound(soundMetalFootstep).setBlockName("doorIron").disableStats().setRequiresSelfNotify();
136        public static final Block pressurePlatePlanks = (new BlockPressurePlate(72, planks.blockIndexInTexture, EnumMobType.everything, Material.wood)).setHardness(0.5F).setStepSound(soundWoodFootstep).setBlockName("pressurePlate").setRequiresSelfNotify();
137        public static final Block oreRedstone = (new BlockRedstoneOre(73, 51, false)).setHardness(3.0F).setResistance(5.0F).setStepSound(soundStoneFootstep).setBlockName("oreRedstone").setRequiresSelfNotify().setCreativeTab(CreativeTabs.tabBlock);
138        public static final Block oreRedstoneGlowing = (new BlockRedstoneOre(74, 51, true)).setLightValue(0.625F).setHardness(3.0F).setResistance(5.0F).setStepSound(soundStoneFootstep).setBlockName("oreRedstone").setRequiresSelfNotify();
139        public static final Block torchRedstoneIdle = (new BlockRedstoneTorch(75, 115, false)).setHardness(0.0F).setStepSound(soundWoodFootstep).setBlockName("notGate").setRequiresSelfNotify();
140        public static final Block torchRedstoneActive = (new BlockRedstoneTorch(76, 99, true)).setHardness(0.0F).setLightValue(0.5F).setStepSound(soundWoodFootstep).setBlockName("notGate").setRequiresSelfNotify().setCreativeTab(CreativeTabs.tabRedstone);
141        public static final Block stoneButton = (new BlockButton(77, stone.blockIndexInTexture, false)).setHardness(0.5F).setStepSound(soundStoneFootstep).setBlockName("button").setRequiresSelfNotify();
142        public static final Block snow = (new BlockSnow(78, 66)).setHardness(0.1F).setStepSound(soundSnowFootstep).setBlockName("snow").setRequiresSelfNotify().setLightOpacity(0);
143        public static final Block ice = (new BlockIce(79, 67)).setHardness(0.5F).setLightOpacity(3).setStepSound(soundGlassFootstep).setBlockName("ice");
144        public static final Block blockSnow = (new BlockSnowBlock(80, 66)).setHardness(0.2F).setStepSound(soundSnowFootstep).setBlockName("snow");
145        public static final Block cactus = (new BlockCactus(81, 70)).setHardness(0.4F).setStepSound(soundClothFootstep).setBlockName("cactus");
146        public static final Block blockClay = (new BlockClay(82, 72)).setHardness(0.6F).setStepSound(soundGravelFootstep).setBlockName("clay");
147        public static final Block reed = (new BlockReed(83, 73)).setHardness(0.0F).setStepSound(soundGrassFootstep).setBlockName("reeds").disableStats();
148        public static final Block jukebox = (new BlockJukeBox(84, 74)).setHardness(2.0F).setResistance(10.0F).setStepSound(soundStoneFootstep).setBlockName("jukebox").setRequiresSelfNotify();
149        public static final Block fence = (new BlockFence(85, 4)).setHardness(2.0F).setResistance(5.0F).setStepSound(soundWoodFootstep).setBlockName("fence");
150        public static final Block pumpkin = (new BlockPumpkin(86, 102, false)).setHardness(1.0F).setStepSound(soundWoodFootstep).setBlockName("pumpkin").setRequiresSelfNotify();
151        public static final Block netherrack = (new BlockNetherrack(87, 103)).setHardness(0.4F).setStepSound(soundStoneFootstep).setBlockName("hellrock");
152        public static final Block slowSand = (new BlockSoulSand(88, 104)).setHardness(0.5F).setStepSound(soundSandFootstep).setBlockName("hellsand");
153        public static final Block glowStone = (new BlockGlowStone(89, 105, Material.glass)).setHardness(0.3F).setStepSound(soundGlassFootstep).setLightValue(1.0F).setBlockName("lightgem");
154    
155        /** The purple teleport blocks inside the obsidian circle */
156        public static final BlockPortal portal = (BlockPortal)(new BlockPortal(90, 14)).setHardness(-1.0F).setStepSound(soundGlassFootstep).setLightValue(0.75F).setBlockName("portal");
157        public static final Block pumpkinLantern = (new BlockPumpkin(91, 102, true)).setHardness(1.0F).setStepSound(soundWoodFootstep).setLightValue(1.0F).setBlockName("litpumpkin").setRequiresSelfNotify();
158        public static final Block cake = (new BlockCake(92, 121)).setHardness(0.5F).setStepSound(soundClothFootstep).setBlockName("cake").disableStats().setRequiresSelfNotify();
159        public static final Block redstoneRepeaterIdle = (new BlockRedstoneRepeater(93, false)).setHardness(0.0F).setStepSound(soundWoodFootstep).setBlockName("diode").disableStats().setRequiresSelfNotify();
160        public static final Block redstoneRepeaterActive = (new BlockRedstoneRepeater(94, true)).setHardness(0.0F).setLightValue(0.625F).setStepSound(soundWoodFootstep).setBlockName("diode").disableStats().setRequiresSelfNotify();
161    
162        /**
163         * April fools secret locked chest, only spawns on new chunks on 1st April.
164         */
165        public static final Block lockedChest = (new BlockLockedChest(95)).setHardness(0.0F).setLightValue(1.0F).setStepSound(soundWoodFootstep).setBlockName("lockedchest").setTickRandomly(true).setRequiresSelfNotify();
166        public static final Block trapdoor = (new BlockTrapDoor(96, Material.wood)).setHardness(3.0F).setStepSound(soundWoodFootstep).setBlockName("trapdoor").disableStats().setRequiresSelfNotify();
167        public static final Block silverfish = (new BlockSilverfish(97)).setHardness(0.75F).setBlockName("monsterStoneEgg");
168        public static final Block stoneBrick = (new BlockStoneBrick(98)).setHardness(1.5F).setResistance(10.0F).setStepSound(soundStoneFootstep).setBlockName("stonebricksmooth");
169        public static final Block mushroomCapBrown = (new BlockMushroomCap(99, Material.wood, 142, 0)).setHardness(0.2F).setStepSound(soundWoodFootstep).setBlockName("mushroom").setRequiresSelfNotify();
170        public static final Block mushroomCapRed = (new BlockMushroomCap(100, Material.wood, 142, 1)).setHardness(0.2F).setStepSound(soundWoodFootstep).setBlockName("mushroom").setRequiresSelfNotify();
171        public static final Block fenceIron = (new BlockPane(101, 85, 85, Material.iron, true)).setHardness(5.0F).setResistance(10.0F).setStepSound(soundMetalFootstep).setBlockName("fenceIron");
172        public static final Block thinGlass = (new BlockPane(102, 49, 148, Material.glass, false)).setHardness(0.3F).setStepSound(soundGlassFootstep).setBlockName("thinGlass");
173        public static final Block melon = (new BlockMelon(103)).setHardness(1.0F).setStepSound(soundWoodFootstep).setBlockName("melon");
174        public static final Block pumpkinStem = (new BlockStem(104, pumpkin)).setHardness(0.0F).setStepSound(soundWoodFootstep).setBlockName("pumpkinStem").setRequiresSelfNotify();
175        public static final Block melonStem = (new BlockStem(105, melon)).setHardness(0.0F).setStepSound(soundWoodFootstep).setBlockName("pumpkinStem").setRequiresSelfNotify();
176        public static final Block vine = (new BlockVine(106)).setHardness(0.2F).setStepSound(soundGrassFootstep).setBlockName("vine").setRequiresSelfNotify();
177        public static final Block fenceGate = (new BlockFenceGate(107, 4)).setHardness(2.0F).setResistance(5.0F).setStepSound(soundWoodFootstep).setBlockName("fenceGate").setRequiresSelfNotify();
178        public static final Block stairsBrick = (new BlockStairs(108, brick, 0)).setBlockName("stairsBrick").setRequiresSelfNotify();
179        public static final Block stairsStoneBrickSmooth = (new BlockStairs(109, stoneBrick, 0)).setBlockName("stairsStoneBrickSmooth").setRequiresSelfNotify();
180        public static final BlockMycelium mycelium = (BlockMycelium)(new BlockMycelium(110)).setHardness(0.6F).setStepSound(soundGrassFootstep).setBlockName("mycel");
181        public static final Block waterlily = (new BlockLilyPad(111, 76)).setHardness(0.0F).setStepSound(soundGrassFootstep).setBlockName("waterlily");
182        public static final Block netherBrick = (new Block(112, 224, Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(soundStoneFootstep).setBlockName("netherBrick").setCreativeTab(CreativeTabs.tabBlock);
183        public static final Block netherFence = (new BlockFence(113, 224, Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(soundStoneFootstep).setBlockName("netherFence");
184        public static final Block stairsNetherBrick = (new BlockStairs(114, netherBrick, 0)).setBlockName("stairsNetherBrick").setRequiresSelfNotify();
185        public static final Block netherStalk = (new BlockNetherStalk(115)).setBlockName("netherStalk").setRequiresSelfNotify();
186        public static final Block enchantmentTable = (new BlockEnchantmentTable(116)).setHardness(5.0F).setResistance(2000.0F).setBlockName("enchantmentTable");
187        public static final Block brewingStand = (new BlockBrewingStand(117)).setHardness(0.5F).setLightValue(0.125F).setBlockName("brewingStand").setRequiresSelfNotify();
188        public static final Block cauldron = (new BlockCauldron(118)).setHardness(2.0F).setBlockName("cauldron").setRequiresSelfNotify();
189        public static final Block endPortal = (new BlockEndPortal(119, Material.portal)).setHardness(-1.0F).setResistance(6000000.0F);
190        public static final Block endPortalFrame = (new BlockEndPortalFrame(120)).setStepSound(soundGlassFootstep).setLightValue(0.125F).setHardness(-1.0F).setBlockName("endPortalFrame").setRequiresSelfNotify().setResistance(6000000.0F).setCreativeTab(CreativeTabs.tabDecorations);
191        public static final Block whiteStone = (new Block(121, 175, Material.rock)).setHardness(3.0F).setResistance(15.0F).setStepSound(soundStoneFootstep).setBlockName("whiteStone").setCreativeTab(CreativeTabs.tabBlock);
192        public static final Block dragonEgg = (new BlockDragonEgg(122, 167)).setHardness(3.0F).setResistance(15.0F).setStepSound(soundStoneFootstep).setLightValue(0.125F).setBlockName("dragonEgg");
193        public static final Block redstoneLampIdle = (new BlockRedstoneLight(123, false)).setHardness(0.3F).setStepSound(soundGlassFootstep).setBlockName("redstoneLight").setCreativeTab(CreativeTabs.tabRedstone);
194        public static final Block redstoneLampActive = (new BlockRedstoneLight(124, true)).setHardness(0.3F).setStepSound(soundGlassFootstep).setBlockName("redstoneLight");
195        public static final BlockHalfSlab woodDoubleSlab = (BlockHalfSlab)(new BlockWoodSlab(125, true)).setHardness(2.0F).setResistance(5.0F).setStepSound(soundWoodFootstep).setBlockName("woodSlab");
196        public static final BlockHalfSlab woodSingleSlab = (BlockHalfSlab)(new BlockWoodSlab(126, false)).setHardness(2.0F).setResistance(5.0F).setStepSound(soundWoodFootstep).setBlockName("woodSlab");
197        public static final Block cocoaPlant = (new BlockCocoa(127)).setHardness(0.2F).setResistance(5.0F).setStepSound(soundWoodFootstep).setBlockName("cocoa").setRequiresSelfNotify();
198        public static final Block stairsSandStone = (new BlockStairs(128, sandStone, 0)).setBlockName("stairsSandStone").setRequiresSelfNotify();
199        public static final Block oreEmerald = (new BlockOre(129, 171)).setHardness(3.0F).setResistance(5.0F).setStepSound(soundStoneFootstep).setBlockName("oreEmerald");
200        public static final Block enderChest = (new BlockEnderChest(130)).setHardness(22.5F).setResistance(1000.0F).setStepSound(soundStoneFootstep).setBlockName("enderChest").setRequiresSelfNotify().setLightValue(0.5F);
201        public static final BlockTripWireSource tripWireSource = (BlockTripWireSource)(new BlockTripWireSource(131)).setBlockName("tripWireSource").setRequiresSelfNotify();
202        public static final Block tripWire = (new BlockTripWire(132)).setBlockName("tripWire").setRequiresSelfNotify();
203        public static final Block blockEmerald = (new BlockOreStorage(133, 25)).setHardness(5.0F).setResistance(10.0F).setStepSound(soundMetalFootstep).setBlockName("blockEmerald");
204        public static final Block stairsWoodSpruce = (new BlockStairs(134, planks, 1)).setBlockName("stairsWoodSpruce").setRequiresSelfNotify();
205        public static final Block stairsWoodBirch = (new BlockStairs(135, planks, 2)).setBlockName("stairsWoodBirch").setRequiresSelfNotify();
206        public static final Block stairsWoodJungle = (new BlockStairs(136, planks, 3)).setBlockName("stairsWoodJungle").setRequiresSelfNotify();
207        public static final Block commandBlock = (new BlockCommandBlock(137)).setBlockName("commandBlock");
208        public static final Block beacon = (new BlockBeacon(138)).setBlockName("beacon").setLightValue(1.0F);
209        public static final Block cobblestoneWall = (new BlockWall(139, cobblestone)).setBlockName("cobbleWall");
210        public static final Block flowerPot = (new BlockFlowerPot(140)).setHardness(0.0F).setStepSound(soundPowderFootstep).setBlockName("flowerPot");
211        public static final Block carrot = (new BlockCarrot(141)).setBlockName("carrots");
212        public static final Block potatoe = (new BlockPotato(142)).setBlockName("potatoes");
213        public static final Block woodenButton = (new BlockButton(143, planks.blockIndexInTexture, true)).setHardness(0.5F).setStepSound(soundWoodFootstep).setBlockName("button").setRequiresSelfNotify();
214        public static final Block skull = (new BlockSkull(144)).setHardness(1.0F).setStepSound(soundStoneFootstep).setBlockName("skull").setRequiresSelfNotify();
215        public static final Block anvil = (new BlockAnvil(145)).setHardness(5.0F).setStepSound(soundAnvilFootstep).setResistance(2000.0F).setBlockName("anvil").setRequiresSelfNotify();
216    
217        /**
218         * The index of the texture to be displayed for this block. May vary based on graphics settings. Mostly seems to
219         * come from terrain.png, and the index is 0-based (grass is 0).
220         */
221        public int blockIndexInTexture;
222    
223        /** ID of the block. */
224        public final int blockID;
225    
226        /** Indicates how many hits it takes to break a block. */
227        protected float blockHardness;
228    
229        /** Indicates the blocks resistance to explosions. */
230        protected float blockResistance;
231    
232        /**
233         * set to true when Block's constructor is called through the chain of super()'s. Note: Never used
234         */
235        protected boolean blockConstructorCalled;
236    
237        /**
238         * If this field is true, the block is counted for statistics (mined or placed)
239         */
240        protected boolean enableStats;
241    
242        /**
243         * Flags whether or not this block is of a type that needs random ticking. Ref-counted by ExtendedBlockStorage in
244         * order to broadly cull a chunk from the random chunk update list for efficiency's sake.
245         */
246        protected boolean needsRandomTick;
247    
248        /** true if the Block contains a Tile Entity */
249        protected boolean isBlockContainer;
250    
251        /** minimum X for the block bounds (local coordinates) */
252        protected double minX;
253    
254        /** minimum Y for the block bounds (local coordinates) */
255        protected double minY;
256    
257        /** minimum Z for the block bounds (local coordinates) */
258        protected double minZ;
259    
260        /** maximum X for the block bounds (local coordinates) */
261        protected double maxX;
262    
263        /** maximum Y for the block bounds (local coordinates) */
264        protected double maxY;
265    
266        /** maximum Z for the block bounds (local coordinates) */
267        protected double maxZ;
268    
269        /** Sound of stepping on the block */
270        public StepSound stepSound;
271        public float blockParticleGravity;
272    
273        /** Block material definition. */
274        public final Material blockMaterial;
275    
276        /**
277         * Determines how much velocity is maintained while moving on top of this block
278         */
279        public float slipperiness;
280        private String blockName;
281    
282        public Block(int par1, Material par2Material)
283        {
284            this.blockConstructorCalled = true;
285            this.enableStats = true;
286            this.stepSound = soundPowderFootstep;
287            this.blockParticleGravity = 1.0F;
288            this.slipperiness = 0.6F;
289    
290            if (blocksList[par1] != null)
291            {
292                throw new IllegalArgumentException("Slot " + par1 + " is already occupied by " + blocksList[par1] + " when adding " + this);
293            }
294            else
295            {
296                this.blockMaterial = par2Material;
297                blocksList[par1] = this;
298                this.blockID = par1;
299                this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
300                opaqueCubeLookup[par1] = this.isOpaqueCube();
301                lightOpacity[par1] = this.isOpaqueCube() ? 255 : 0;
302                canBlockGrass[par1] = !par2Material.getCanBlockGrass();
303            }
304            isDefaultTexture = (getTextureFile() != null && getTextureFile().equalsIgnoreCase("/terrain.png"));
305        }
306    
307        /**
308         * Blocks with this attribute will not notify all near blocks when it's metadata change. The default behavior is
309         * always notify every neightbor block when anything changes.
310         */
311        public Block setRequiresSelfNotify()
312        {
313            requiresSelfNotify[this.blockID] = true;
314            return this;
315        }
316    
317        /**
318         * This method is called on a block after all other blocks gets already created. You can use it to reference and
319         * configure something on the block that needs the others ones.
320         */
321        protected void initializeBlock() {}
322    
323        public Block(int par1, int par2, Material par3Material)
324        {
325            this(par1, par3Material);
326            this.blockIndexInTexture = par2;
327        }
328    
329        /**
330         * Sets the footstep sound for the block. Returns the object for convenience in constructing.
331         */
332        public Block setStepSound(StepSound par1StepSound)
333        {
334            this.stepSound = par1StepSound;
335            return this;
336        }
337    
338        /**
339         * Sets how much light is blocked going through this block. Returns the object for convenience in constructing.
340         */
341        public Block setLightOpacity(int par1)
342        {
343            lightOpacity[this.blockID] = par1;
344            return this;
345        }
346    
347        /**
348         * Sets the amount of light emitted by a block from 0.0f to 1.0f (converts internally to 0-15). Returns the object
349         * for convenience in constructing.
350         */
351        public Block setLightValue(float par1)
352        {
353            lightValue[this.blockID] = (int)(15.0F * par1);
354            return this;
355        }
356    
357        /**
358         * Sets the the blocks resistance to explosions. Returns the object for convenience in constructing.
359         */
360        public Block setResistance(float par1)
361        {
362            this.blockResistance = par1 * 3.0F;
363            return this;
364        }
365    
366        public static boolean isNormalCube(int par0)
367        {
368            Block var1 = blocksList[par0];
369            return var1 == null ? false : var1.blockMaterial.isOpaque() && var1.renderAsNormalBlock();
370        }
371    
372        /**
373         * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
374         */
375        public boolean renderAsNormalBlock()
376        {
377            return true;
378        }
379    
380        public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
381        {
382            return !this.blockMaterial.blocksMovement();
383        }
384    
385        /**
386         * The type of render function that is called for this block
387         */
388        public int getRenderType()
389        {
390            return 0;
391        }
392    
393        /**
394         * Sets how many hits it takes to break a block.
395         */
396        public Block setHardness(float par1)
397        {
398            this.blockHardness = par1;
399    
400            if (this.blockResistance < par1 * 5.0F)
401            {
402                this.blockResistance = par1 * 5.0F;
403            }
404    
405            return this;
406        }
407    
408        /**
409         * This method will make the hardness of the block equals to -1, and the block is indestructible.
410         */
411        public Block setBlockUnbreakable()
412        {
413            this.setHardness(-1.0F);
414            return this;
415        }
416    
417        /**
418         * Returns the block hardness at a location. Args: world, x, y, z
419         */
420        public float getBlockHardness(World par1World, int par2, int par3, int par4)
421        {
422            return this.blockHardness;
423        }
424    
425        /**
426         * Sets whether this block type will receive random update ticks
427         */
428        public Block setTickRandomly(boolean par1)
429        {
430            this.needsRandomTick = par1;
431            return this;
432        }
433    
434        /**
435         * Returns whether or not this block is of a type that needs random ticking. Called for ref-counting purposes by
436         * ExtendedBlockStorage in order to broadly cull a chunk from the random chunk update list for efficiency's sake.
437         */
438        public boolean getTickRandomly()
439        {
440            return this.needsRandomTick;
441        }
442    
443        @Deprecated //Forge: New Metadata sensitive version.
444        public boolean hasTileEntity()
445        {
446            return hasTileEntity(0);
447        }
448    
449        /**
450         * Sets the bounds of the block.  minX, minY, minZ, maxX, maxY, maxZ
451         */
452        public final void setBlockBounds(float par1, float par2, float par3, float par4, float par5, float par6)
453        {
454            this.minX = (double)par1;
455            this.minY = (double)par2;
456            this.minZ = (double)par3;
457            this.maxX = (double)par4;
458            this.maxY = (double)par5;
459            this.maxZ = (double)par6;
460        }
461    
462        @SideOnly(Side.CLIENT)
463    
464        /**
465         * How bright to render this block based on the light its receiving. Args: iBlockAccess, x, y, z
466         */
467        public float getBlockBrightness(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
468        {
469            return par1IBlockAccess.getBrightness(par2, par3, par4, getLightValue(par1IBlockAccess, par2, par3, par4));
470        }
471    
472        @SideOnly(Side.CLIENT)
473    
474        /**
475         * Goes straight to getLightBrightnessForSkyBlocks for Blocks, does some fancy computing for Fluids
476         */
477        public int getMixedBrightnessForBlock(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
478        {
479            return par1IBlockAccess.getLightBrightnessForSkyBlocks(par2, par3, par4, getLightValue(par1IBlockAccess, par2, par3, par4));
480        }
481    
482        @SideOnly(Side.CLIENT)
483    
484        /**
485         * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
486         * coordinates.  Args: blockAccess, x, y, z, side
487         */
488        public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
489        {
490            return par5 == 0 && this.minY > 0.0D ? true : (par5 == 1 && this.maxY < 1.0D ? true : (par5 == 2 && this.minZ > 0.0D ? true : (par5 == 3 && this.maxZ < 1.0D ? true : (par5 == 4 && this.minX > 0.0D ? true : (par5 == 5 && this.maxX < 1.0D ? true : !par1IBlockAccess.isBlockOpaqueCube(par2, par3, par4))))));
491        }
492    
493        /**
494         * Returns Returns true if the given side of this block type should be rendered (if it's solid or not), if the
495         * adjacent block is at the given coordinates. Args: blockAccess, x, y, z, side
496         */
497        public boolean isBlockSolid(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
498        {
499            return par1IBlockAccess.getBlockMaterial(par2, par3, par4).isSolid();
500        }
501    
502        @SideOnly(Side.CLIENT)
503    
504        /**
505         * Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
506         */
507        public int getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
508        {
509            return this.getBlockTextureFromSideAndMetadata(par5, par1IBlockAccess.getBlockMetadata(par2, par3, par4));
510        }
511    
512        /**
513         * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
514         */
515        public int getBlockTextureFromSideAndMetadata(int par1, int par2)
516        {
517            return this.getBlockTextureFromSide(par1);
518        }
519    
520        /**
521         * Returns the block texture based on the side being looked at.  Args: side
522         */
523        public int getBlockTextureFromSide(int par1)
524        {
525            return this.blockIndexInTexture;
526        }
527    
528        /**
529         * if the specified block is in the given AABB, add its collision bounding box to the given list
530         */
531        public void addCollidingBlockToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
532        {
533            AxisAlignedBB var8 = this.getCollisionBoundingBoxFromPool(par1World, par2, par3, par4);
534    
535            if (var8 != null && par5AxisAlignedBB.intersectsWith(var8))
536            {
537                par6List.add(var8);
538            }
539        }
540    
541        @SideOnly(Side.CLIENT)
542    
543        /**
544         * Returns the bounding box of the wired rectangular prism to render.
545         */
546        public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
547        {
548            return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double)par2 + this.minX, (double)par3 + this.minY, (double)par4 + this.minZ, (double)par2 + this.maxX, (double)par3 + this.maxY, (double)par4 + this.maxZ);
549        }
550    
551        /**
552         * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
553         * cleared to be reused)
554         */
555        public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
556        {
557            return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double)par2 + this.minX, (double)par3 + this.minY, (double)par4 + this.minZ, (double)par2 + this.maxX, (double)par3 + this.maxY, (double)par4 + this.maxZ);
558        }
559    
560        /**
561         * Is this block (a) opaque and (b) a full 1m cube?  This determines whether or not to render the shared face of two
562         * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
563         */
564        public boolean isOpaqueCube()
565        {
566            return true;
567        }
568    
569        /**
570         * Returns whether this block is collideable based on the arguments passed in Args: blockMetaData, unknownFlag
571         */
572        public boolean canCollideCheck(int par1, boolean par2)
573        {
574            return this.isCollidable();
575        }
576    
577        /**
578         * Returns if this block is collidable (only used by Fire). Args: x, y, z
579         */
580        public boolean isCollidable()
581        {
582            return true;
583        }
584    
585        /**
586         * Ticks the block if it's been scheduled
587         */
588        public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {}
589    
590        @SideOnly(Side.CLIENT)
591    
592        /**
593         * A randomly called display update to be able to add particles or other items for display
594         */
595        public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {}
596    
597        /**
598         * Called right before the block is destroyed by a player.  Args: world, x, y, z, metaData
599         */
600        public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) {}
601    
602        /**
603         * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
604         * their own) Args: x, y, z, neighbor blockID
605         */
606        public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {}
607    
608        /**
609         * How many world ticks before ticking
610         */
611        public int tickRate()
612        {
613            return 10;
614        }
615    
616        /**
617         * Called whenever the block is added into the world. Args: world, x, y, z
618         */
619        public void onBlockAdded(World par1World, int par2, int par3, int par4) {}
620    
621        /**
622         * ejects contained items into the world, and notifies neighbours of an update, as appropriate
623         */
624        public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) {}
625    
626        /**
627         * Returns the quantity of items to drop on block destruction.
628         */
629        public int quantityDropped(Random par1Random)
630        {
631            return 1;
632        }
633    
634        /**
635         * Returns the ID of the items to drop on destruction.
636         */
637        public int idDropped(int par1, Random par2Random, int par3)
638        {
639            return this.blockID;
640        }
641    
642        /**
643         * Gets the hardness of block at the given coordinates in the given world, relative to the ability of the given
644         * EntityPlayer.
645         */
646        public float getPlayerRelativeBlockHardness(EntityPlayer par1EntityPlayer, World par2World, int par3, int par4, int par5)
647        {
648            return ForgeHooks.blockStrength(this, par1EntityPlayer, par2World, par3, par4, par5);
649        }
650    
651        /**
652         * Drops the specified block items
653         */
654        public final void dropBlockAsItem(World par1World, int par2, int par3, int par4, int par5, int par6)
655        {
656            this.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, 1.0F, par6);
657        }
658    
659        /**
660         * Drops the block items with a specified chance of dropping the specified items
661         */
662        public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
663        {
664            if (!par1World.isRemote)
665            {
666                ArrayList<ItemStack> items = getBlockDropped(par1World, par2, par3, par4, par5, par7);
667    
668                for (ItemStack item : items)
669                {
670                    if (par1World.rand.nextFloat() <= par6)
671                    {
672                        this.dropBlockAsItem_do(par1World, par2, par3, par4, item);
673                    }
674                }
675            }
676        }
677    
678        /**
679         * Spawns EntityItem in the world for the given ItemStack if the world is not remote.
680         */
681        protected void dropBlockAsItem_do(World par1World, int par2, int par3, int par4, ItemStack par5ItemStack)
682        {
683            if (!par1World.isRemote && par1World.getGameRules().getGameRuleBooleanValue("doTileDrops"))
684            {
685                float var6 = 0.7F;
686                double var7 = (double)(par1World.rand.nextFloat() * var6) + (double)(1.0F - var6) * 0.5D;
687                double var9 = (double)(par1World.rand.nextFloat() * var6) + (double)(1.0F - var6) * 0.5D;
688                double var11 = (double)(par1World.rand.nextFloat() * var6) + (double)(1.0F - var6) * 0.5D;
689                EntityItem var13 = new EntityItem(par1World, (double)par2 + var7, (double)par3 + var9, (double)par4 + var11, par5ItemStack);
690                var13.delayBeforeCanPickup = 10;
691                par1World.spawnEntityInWorld(var13);
692            }
693        }
694    
695        /**
696         * called by spawner, ore, redstoneOre blocks
697         */
698        protected void dropXpOnBlockBreak(World par1World, int par2, int par3, int par4, int par5)
699        {
700            if (!par1World.isRemote)
701            {
702                while (par5 > 0)
703                {
704                    int var6 = EntityXPOrb.getXPSplit(par5);
705                    par5 -= var6;
706                    par1World.spawnEntityInWorld(new EntityXPOrb(par1World, (double)par2 + 0.5D, (double)par3 + 0.5D, (double)par4 + 0.5D, var6));
707                }
708            }
709        }
710    
711        /**
712         * Determines the damage on the item the block drops. Used in cloth and wood.
713         */
714        public int damageDropped(int par1)
715        {
716            return 0;
717        }
718    
719        /**
720         * Returns how much this block can resist explosions from the passed in entity.
721         */
722        public float getExplosionResistance(Entity par1Entity)
723        {
724            return this.blockResistance / 5.0F;
725        }
726    
727        /**
728         * Ray traces through the blocks collision from start vector to end vector returning a ray trace hit. Args: world,
729         * x, y, z, startVec, endVec
730         */
731        public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3)
732        {
733            this.setBlockBoundsBasedOnState(par1World, par2, par3, par4);
734            par5Vec3 = par5Vec3.addVector((double)(-par2), (double)(-par3), (double)(-par4));
735            par6Vec3 = par6Vec3.addVector((double)(-par2), (double)(-par3), (double)(-par4));
736            Vec3 var7 = par5Vec3.getIntermediateWithXValue(par6Vec3, this.minX);
737            Vec3 var8 = par5Vec3.getIntermediateWithXValue(par6Vec3, this.maxX);
738            Vec3 var9 = par5Vec3.getIntermediateWithYValue(par6Vec3, this.minY);
739            Vec3 var10 = par5Vec3.getIntermediateWithYValue(par6Vec3, this.maxY);
740            Vec3 var11 = par5Vec3.getIntermediateWithZValue(par6Vec3, this.minZ);
741            Vec3 var12 = par5Vec3.getIntermediateWithZValue(par6Vec3, this.maxZ);
742    
743            if (!this.isVecInsideYZBounds(var7))
744            {
745                var7 = null;
746            }
747    
748            if (!this.isVecInsideYZBounds(var8))
749            {
750                var8 = null;
751            }
752    
753            if (!this.isVecInsideXZBounds(var9))
754            {
755                var9 = null;
756            }
757    
758            if (!this.isVecInsideXZBounds(var10))
759            {
760                var10 = null;
761            }
762    
763            if (!this.isVecInsideXYBounds(var11))
764            {
765                var11 = null;
766            }
767    
768            if (!this.isVecInsideXYBounds(var12))
769            {
770                var12 = null;
771            }
772    
773            Vec3 var13 = null;
774    
775            if (var7 != null && (var13 == null || par5Vec3.squareDistanceTo(var7) < par5Vec3.squareDistanceTo(var13)))
776            {
777                var13 = var7;
778            }
779    
780            if (var8 != null && (var13 == null || par5Vec3.squareDistanceTo(var8) < par5Vec3.squareDistanceTo(var13)))
781            {
782                var13 = var8;
783            }
784    
785            if (var9 != null && (var13 == null || par5Vec3.squareDistanceTo(var9) < par5Vec3.squareDistanceTo(var13)))
786            {
787                var13 = var9;
788            }
789    
790            if (var10 != null && (var13 == null || par5Vec3.squareDistanceTo(var10) < par5Vec3.squareDistanceTo(var13)))
791            {
792                var13 = var10;
793            }
794    
795            if (var11 != null && (var13 == null || par5Vec3.squareDistanceTo(var11) < par5Vec3.squareDistanceTo(var13)))
796            {
797                var13 = var11;
798            }
799    
800            if (var12 != null && (var13 == null || par5Vec3.squareDistanceTo(var12) < par5Vec3.squareDistanceTo(var13)))
801            {
802                var13 = var12;
803            }
804    
805            if (var13 == null)
806            {
807                return null;
808            }
809            else
810            {
811                byte var14 = -1;
812    
813                if (var13 == var7)
814                {
815                    var14 = 4;
816                }
817    
818                if (var13 == var8)
819                {
820                    var14 = 5;
821                }
822    
823                if (var13 == var9)
824                {
825                    var14 = 0;
826                }
827    
828                if (var13 == var10)
829                {
830                    var14 = 1;
831                }
832    
833                if (var13 == var11)
834                {
835                    var14 = 2;
836                }
837    
838                if (var13 == var12)
839                {
840                    var14 = 3;
841                }
842    
843                return new MovingObjectPosition(par2, par3, par4, var14, var13.addVector((double)par2, (double)par3, (double)par4));
844            }
845        }
846    
847        /**
848         * Checks if a vector is within the Y and Z bounds of the block.
849         */
850        private boolean isVecInsideYZBounds(Vec3 par1Vec3)
851        {
852            return par1Vec3 == null ? false : par1Vec3.yCoord >= this.minY && par1Vec3.yCoord <= this.maxY && par1Vec3.zCoord >= this.minZ && par1Vec3.zCoord <= this.maxZ;
853        }
854    
855        /**
856         * Checks if a vector is within the X and Z bounds of the block.
857         */
858        private boolean isVecInsideXZBounds(Vec3 par1Vec3)
859        {
860            return par1Vec3 == null ? false : par1Vec3.xCoord >= this.minX && par1Vec3.xCoord <= this.maxX && par1Vec3.zCoord >= this.minZ && par1Vec3.zCoord <= this.maxZ;
861        }
862    
863        /**
864         * Checks if a vector is within the X and Y bounds of the block.
865         */
866        private boolean isVecInsideXYBounds(Vec3 par1Vec3)
867        {
868            return par1Vec3 == null ? false : par1Vec3.xCoord >= this.minX && par1Vec3.xCoord <= this.maxX && par1Vec3.yCoord >= this.minY && par1Vec3.yCoord <= this.maxY;
869        }
870    
871        /**
872         * Called upon the block being destroyed by an explosion
873         */
874        public void onBlockDestroyedByExplosion(World par1World, int par2, int par3, int par4) {}
875    
876        @SideOnly(Side.CLIENT)
877    
878        /**
879         * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha
880         */
881        public int getRenderBlockPass()
882        {
883            return 0;
884        }
885    
886        /**
887         * checks to see if you can place this block can be placed on that side of a block: BlockLever overrides
888         */
889        public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int par5)
890        {
891            return this.canPlaceBlockAt(par1World, par2, par3, par4);
892        }
893    
894        /**
895         * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
896         */
897        public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
898        {
899            int var5 = par1World.getBlockId(par2, par3, par4);
900            return var5 == 0 || blocksList[var5].blockMaterial.isGroundCover();
901        }
902    
903        /**
904         * Called upon block activation (right click on the block.)
905         */
906        public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
907        {
908            return false;
909        }
910    
911        /**
912         * Called whenever an entity is walking on top of this block. Args: world, x, y, z, entity
913         */
914        public void onEntityWalking(World par1World, int par2, int par3, int par4, Entity par5Entity) {}
915    
916        public int func_85104_a(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
917        {
918            return par9;
919        }
920    
921        /**
922         * Called when the block is clicked by a player. Args: x, y, z, entityPlayer
923         */
924        public void onBlockClicked(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) {}
925    
926        /**
927         * Can add to the passed in vector for a movement vector to be applied to the entity. Args: x, y, z, entity, vec3d
928         */
929        public void velocityToAddToEntity(World par1World, int par2, int par3, int par4, Entity par5Entity, Vec3 par6Vec3) {}
930    
931        /**
932         * Updates the blocks bounds based on its current state. Args: world, x, y, z
933         */
934        public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {}
935    
936        /**
937         * returns the block bounderies minX value
938         */
939        public final double getBlockBoundsMinX()
940        {
941            return this.minX;
942        }
943    
944        /**
945         * returns the block bounderies maxX value
946         */
947        public final double getBlockBoundsMaxX()
948        {
949            return this.maxX;
950        }
951    
952        /**
953         * returns the block bounderies minY value
954         */
955        public final double getBlockBoundsMinY()
956        {
957            return this.minY;
958        }
959    
960        /**
961         * returns the block bounderies maxY value
962         */
963        public final double getBlockBoundsMaxY()
964        {
965            return this.maxY;
966        }
967    
968        /**
969         * returns the block bounderies minZ value
970         */
971        public final double getBlockBoundsMinZ()
972        {
973            return this.minZ;
974        }
975    
976        /**
977         * returns the block bounderies maxZ value
978         */
979        public final double getBlockBoundsMaxZ()
980        {
981            return this.maxZ;
982        }
983    
984        @SideOnly(Side.CLIENT)
985        public int getBlockColor()
986        {
987            return 16777215;
988        }
989    
990        @SideOnly(Side.CLIENT)
991    
992        /**
993         * Returns the color this block should be rendered. Used by leaves.
994         */
995        public int getRenderColor(int par1)
996        {
997            return 16777215;
998        }
999    
1000        @SideOnly(Side.CLIENT)
1001    
1002        /**
1003         * Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called
1004         * when first determining what to render.
1005         */
1006        public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
1007        {
1008            return 16777215;
1009        }
1010    
1011        /**
1012         * Is this block powering the block on the specified side
1013         */
1014        public boolean isPoweringTo(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
1015        {
1016            return false;
1017        }
1018    
1019        /**
1020         * Can this block provide power. Only wire currently seems to have this change based on its state.
1021         */
1022        public boolean canProvidePower()
1023        {
1024            return false;
1025        }
1026    
1027        /**
1028         * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
1029         */
1030        public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) {}
1031    
1032        /**
1033         * Is this block indirectly powering the block on the specified side
1034         */
1035        public boolean isIndirectlyPoweringTo(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
1036        {
1037            return false;
1038        }
1039    
1040        /**
1041         * Sets the block's bounds for rendering it as an item
1042         */
1043        public void setBlockBoundsForItemRender() {}
1044    
1045        /**
1046         * Called when the player destroys a block with an item that can harvest it. (i, j, k) are the coordinates of the
1047         * block and l is the block's subtype/damage.
1048         */
1049        public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6)
1050        {
1051            par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1);
1052            par2EntityPlayer.addExhaustion(0.025F);
1053    
1054            if (this.canSilkHarvest(par1World, par2EntityPlayer, par3, par4, par5, par6) && EnchantmentHelper.getSilkTouchModifier(par2EntityPlayer))
1055            {
1056                ItemStack var8 = this.createStackedBlock(par6);
1057    
1058                if (var8 != null)
1059                {
1060                    this.dropBlockAsItem_do(par1World, par3, par4, par5, var8);
1061                }
1062            }
1063            else
1064            {
1065                int var7 = EnchantmentHelper.getFortuneModifier(par2EntityPlayer);
1066                this.dropBlockAsItem(par1World, par3, par4, par5, par6, var7);
1067            }
1068        }
1069    
1070        /**
1071         * Return true if a player with Silk Touch can harvest this block directly, and not its normal drops.
1072         */
1073        protected boolean canSilkHarvest()
1074        {
1075            return this.renderAsNormalBlock() && !this.isBlockContainer;
1076        }
1077    
1078        /**
1079         * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage
1080         * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null.
1081         */
1082        protected ItemStack createStackedBlock(int par1)
1083        {
1084            int var2 = 0;
1085    
1086            if (this.blockID >= 0 && this.blockID < Item.itemsList.length && Item.itemsList[this.blockID].getHasSubtypes())
1087            {
1088                var2 = par1;
1089            }
1090    
1091            return new ItemStack(this.blockID, 1, var2);
1092        }
1093    
1094        /**
1095         * Returns the usual quantity dropped by the block plus a bonus of 1 to 'i' (inclusive).
1096         */
1097        public int quantityDroppedWithBonus(int par1, Random par2Random)
1098        {
1099            return this.quantityDropped(par2Random);
1100        }
1101    
1102        /**
1103         * Can this block stay at this position.  Similar to canPlaceBlockAt except gets checked often with plants.
1104         */
1105        public boolean canBlockStay(World par1World, int par2, int par3, int par4)
1106        {
1107            return true;
1108        }
1109    
1110        /**
1111         * Called when the block is placed in the world.
1112         */
1113        public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving) {}
1114    
1115        public void func_85105_g(World par1World, int par2, int par3, int par4, int par5) {}
1116    
1117        /**
1118         * set name of block from language file
1119         */
1120        public Block setBlockName(String par1Str)
1121        {
1122            this.blockName = "tile." + par1Str;
1123            return this;
1124        }
1125    
1126        /**
1127         * gets the localized version of the name of this block using StatCollector.translateToLocal. Used for the statistic
1128         * page.
1129         */
1130        public String translateBlockName()
1131        {
1132            return StatCollector.translateToLocal(this.getBlockName() + ".name");
1133        }
1134    
1135        public String getBlockName()
1136        {
1137            return this.blockName;
1138        }
1139    
1140        /**
1141         * Called when the block receives a BlockEvent - see World.addBlockEvent. By default, passes it on to the tile
1142         * entity at this location. Args: world, x, y, z, blockID, EventID, event parameter
1143         */
1144        public void onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6) {}
1145    
1146        /**
1147         * Return the state of blocks statistics flags - if the block is counted for mined and placed.
1148         */
1149        public boolean getEnableStats()
1150        {
1151            return this.enableStats;
1152        }
1153    
1154        /**
1155         * Disable statistics for the block, the block will no count for mined or placed.
1156         */
1157        protected Block disableStats()
1158        {
1159            this.enableStats = false;
1160            return this;
1161        }
1162    
1163        /**
1164         * Returns the mobility information of the block, 0 = free, 1 = can't push but can move over, 2 = total immobility
1165         * and stop pistons
1166         */
1167        public int getMobilityFlag()
1168        {
1169            return this.blockMaterial.getMaterialMobility();
1170        }
1171    
1172        @SideOnly(Side.CLIENT)
1173    
1174        /**
1175         * Returns the default ambient occlusion value based on block opacity
1176         */
1177        public float getAmbientOcclusionLightValue(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
1178        {
1179            return par1IBlockAccess.isBlockNormalCube(par2, par3, par4) ? 0.2F : 1.0F;
1180        }
1181    
1182        /**
1183         * Block's chance to react to an entity falling on it.
1184         */
1185        public void onFallenUpon(World par1World, int par2, int par3, int par4, Entity par5Entity, float par6) {}
1186    
1187        @SideOnly(Side.CLIENT)
1188    
1189        /**
1190         * only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
1191         */
1192        public int idPicked(World par1World, int par2, int par3, int par4)
1193        {
1194            return this.blockID;
1195        }
1196    
1197        /**
1198         * Get the block's damage value (for use with pick block).
1199         */
1200        public int getDamageValue(World par1World, int par2, int par3, int par4)
1201        {
1202            return this.damageDropped(par1World.getBlockMetadata(par2, par3, par4));
1203        }
1204    
1205        @SideOnly(Side.CLIENT)
1206    
1207        /**
1208         * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
1209         */
1210        public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
1211        {
1212            par3List.add(new ItemStack(par1, 1, 0));
1213        }
1214    
1215        /**
1216         * Sets the CreativeTab to display this block on.
1217         */
1218        public Block setCreativeTab(CreativeTabs par1CreativeTabs)
1219        {
1220            this.displayOnCreativeTab = par1CreativeTabs;
1221            return this;
1222        }
1223    
1224        /**
1225         * Called when the block is attempted to be harvested
1226         */
1227        public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) {}
1228    
1229        @SideOnly(Side.CLIENT)
1230    
1231        /**
1232         * Returns the CreativeTab to display the given block on.
1233         */
1234        public CreativeTabs getCreativeTabToDisplayOn()
1235        {
1236            return this.displayOnCreativeTab;
1237        }
1238    
1239        /**
1240         * Called when this block is set (with meta data).
1241         */
1242        public void onSetBlockIDWithMetaData(World par1World, int par2, int par3, int par4, int par5) {}
1243    
1244        /**
1245         * currently only used by BlockCauldron to incrament meta-data during rain
1246         */
1247        public void fillWithRain(World par1World, int par2, int par3, int par4) {}
1248    
1249        @SideOnly(Side.CLIENT)
1250        public boolean func_82505_u_()
1251        {
1252            return false;
1253        }
1254    
1255        public boolean func_82506_l()
1256        {
1257            return true;
1258        }
1259    
1260        public boolean func_85103_a(Explosion par1Explosion)
1261        {
1262            return true;
1263        }
1264    
1265        static
1266        {
1267            Item.itemsList[cloth.blockID] = (new ItemCloth(cloth.blockID - 256)).setItemName("cloth");
1268            Item.itemsList[wood.blockID] = (new ItemMultiTextureTile(wood.blockID - 256, wood, BlockLog.woodType)).setItemName("log");
1269            Item.itemsList[planks.blockID] = (new ItemMultiTextureTile(planks.blockID - 256, planks, BlockWood.woodType)).setItemName("wood");
1270            Item.itemsList[silverfish.blockID] = (new ItemMultiTextureTile(silverfish.blockID - 256, silverfish, BlockSilverfish.silverfishStoneTypes)).setItemName("monsterStoneEgg");
1271            Item.itemsList[stoneBrick.blockID] = (new ItemMultiTextureTile(stoneBrick.blockID - 256, stoneBrick, BlockStoneBrick.STONE_BRICK_TYPES)).setItemName("stonebricksmooth");
1272            Item.itemsList[sandStone.blockID] = (new ItemMultiTextureTile(sandStone.blockID - 256, sandStone, BlockSandStone.SAND_STONE_TYPES)).setItemName("sandStone");
1273            Item.itemsList[stoneSingleSlab.blockID] = (new ItemSlab(stoneSingleSlab.blockID - 256, stoneSingleSlab, stoneDoubleSlab, false)).setItemName("stoneSlab");
1274            Item.itemsList[stoneDoubleSlab.blockID] = (new ItemSlab(stoneDoubleSlab.blockID - 256, stoneSingleSlab, stoneDoubleSlab, true)).setItemName("stoneSlab");
1275            Item.itemsList[woodSingleSlab.blockID] = (new ItemSlab(woodSingleSlab.blockID - 256, woodSingleSlab, woodDoubleSlab, false)).setItemName("woodSlab");
1276            Item.itemsList[woodDoubleSlab.blockID] = (new ItemSlab(woodDoubleSlab.blockID - 256, woodSingleSlab, woodDoubleSlab, true)).setItemName("woodSlab");
1277            Item.itemsList[sapling.blockID] = (new ItemMultiTextureTile(sapling.blockID - 256, sapling, BlockSapling.WOOD_TYPES)).setItemName("sapling");
1278            Item.itemsList[leaves.blockID] = (new ItemLeaves(leaves.blockID - 256)).setItemName("leaves");
1279            Item.itemsList[vine.blockID] = new ItemColored(vine.blockID - 256, false);
1280            Item.itemsList[tallGrass.blockID] = (new ItemColored(tallGrass.blockID - 256, true)).setBlockNames(new String[] {"shrub", "grass", "fern"});
1281            Item.itemsList[waterlily.blockID] = new ItemLilyPad(waterlily.blockID - 256);
1282            Item.itemsList[pistonBase.blockID] = new ItemPiston(pistonBase.blockID - 256);
1283            Item.itemsList[pistonStickyBase.blockID] = new ItemPiston(pistonStickyBase.blockID - 256);
1284            Item.itemsList[cobblestoneWall.blockID] = (new ItemMultiTextureTile(cobblestoneWall.blockID - 256, cobblestoneWall, BlockWall.types)).setItemName("cobbleWall");
1285            Item.itemsList[anvil.blockID] = (new ItemAnvilBlock(anvil)).setItemName("anvil");
1286    
1287            for (int var0 = 0; var0 < 256; ++var0)
1288            {
1289                if (blocksList[var0] != null)
1290                {
1291                    if (Item.itemsList[var0] == null)
1292                    {
1293                        Item.itemsList[var0] = new ItemBlock(var0 - 256);
1294                        blocksList[var0].initializeBlock();
1295                    }
1296    
1297                    boolean var1 = false;
1298    
1299                    if (var0 > 0 && blocksList[var0].getRenderType() == 10)
1300                    {
1301                        var1 = true;
1302                    }
1303    
1304                    if (var0 > 0 && blocksList[var0] instanceof BlockHalfSlab)
1305                    {
1306                        var1 = true;
1307                    }
1308    
1309                    if (var0 == tilledField.blockID)
1310                    {
1311                        var1 = true;
1312                    }
1313    
1314                    if (canBlockGrass[var0])
1315                    {
1316                        var1 = true;
1317                    }
1318    
1319                    if (lightOpacity[var0] == 0)
1320                    {
1321                        var1 = true;
1322                    }
1323    
1324                    useNeighborBrightness[var0] = var1;
1325                }
1326            }
1327    
1328            canBlockGrass[0] = true;
1329            StatList.initBreakableStats();
1330        }
1331            
1332        /* =================================================== FORGE START =====================================*/    
1333        /**
1334         * Get a light value for this block, normal ranges are between 0 and 15
1335         * 
1336         * @param world The current world
1337         * @param x X Position
1338         * @param y Y position
1339         * @param z Z position
1340         * @return The light value
1341         */
1342        public int getLightValue(IBlockAccess world, int x, int y, int z) 
1343        {
1344            return lightValue[blockID];
1345        }
1346    
1347        /**
1348         * Checks if a player or entity can use this block to 'climb' like a ladder.
1349         * 
1350         * @param world The current world
1351         * @param x X Position
1352         * @param y Y position
1353         * @param z Z position
1354         * @return True if the block should act like a ladder
1355         */
1356        public boolean isLadder(World world, int x, int y, int z) 
1357        {
1358            return false;
1359        }
1360        
1361        /**
1362         * Return true if the block is a normal, solid cube.  This
1363         * determines indirect power state, entity ejection from blocks, and a few
1364         * others.
1365         * 
1366         * @param world The current world
1367         * @param x X Position
1368         * @param y Y position
1369         * @param z Z position
1370         * @return True if the block is a full cube
1371         */
1372        public boolean isBlockNormalCube(World world, int x, int y, int z) 
1373        {
1374            return blockMaterial.isOpaque() && renderAsNormalBlock();
1375        }
1376    
1377        /**
1378         * Checks if the block is a solid face on the given side, used by placement logic.
1379         * 
1380         * @param world The current world
1381         * @param x X Position
1382         * @param y Y position
1383         * @param z Z position
1384         * @param side The side to check
1385         * @return True if the block is solid on the specified side.
1386         */
1387        public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) 
1388        {
1389            int meta = world.getBlockMetadata(x, y, z);
1390            if (this instanceof BlockHalfSlab)
1391            {
1392                return (((meta & 8) == 8 && (side == UP)) || isOpaqueCube());
1393            }
1394            else if (this instanceof BlockFarmland)
1395            {
1396                return (side != DOWN && side != UP);
1397            }
1398            else if (this instanceof BlockStairs)
1399            {
1400                boolean flipped = ((meta & 4) != 0);
1401                return ((meta & 3) + side.ordinal() == 5) || (side == UP && flipped);
1402            }
1403            return isBlockNormalCube(world, x, y, z);
1404        }
1405    
1406        /**
1407         * Determines if a new block can be replace the space occupied by this one,
1408         * Used in the player's placement code to make the block act like water, and lava.
1409         * 
1410         * @param world The current world
1411         * @param x X Position
1412         * @param y Y position
1413         * @param z Z position
1414         * @return True if the block is replaceable by another block
1415         */
1416        public boolean isBlockReplaceable(World world, int x, int y, int z) 
1417        {
1418            return false;
1419        }
1420    
1421        /**
1422         * Determines if this block should set fire and deal fire damage
1423         * to entities coming into contact with it.
1424         * 
1425         * @param world The current world
1426         * @param x X Position
1427         * @param y Y position
1428         * @param z Z position
1429         * @return True if the block should deal damage
1430         */
1431        public boolean isBlockBurning(World world, int x, int y, int z) 
1432        {
1433            return false;
1434        }
1435        
1436        /**
1437         * Determines this block should be treated as an air block
1438         * by the rest of the code. This method is primarily
1439         * useful for creating pure logic-blocks that will be invisible 
1440         * to the player and otherwise interact as air would.
1441         * 
1442         * @param world The current world
1443         * @param x X Position
1444         * @param y Y position
1445         * @param z Z position
1446         * @return True if the block considered air
1447         */
1448        public boolean isAirBlock(World world, int x, int y, int z) 
1449        {
1450            return false;
1451        }
1452    
1453        /**
1454         * Determines if the player can harvest this block, obtaining it's drops when the block is destroyed.
1455         * 
1456         * @param player The player damaging the block, may be null
1457         * @param meta The block's current metadata
1458         * @return True to spawn the drops
1459         */
1460        public boolean canHarvestBlock(EntityPlayer player, int meta) 
1461        {
1462            return ForgeHooks.canHarvestBlock(this, player, meta);
1463        }
1464    
1465        /**
1466         * Called when a player removes a block.  This is responsible for
1467         * actually destroying the block, and the block is intact at time of call.
1468         * This is called regardless of whether the player can harvest the block or
1469         * not.  
1470         * 
1471         * Return true if the block is actually destroyed.
1472         *
1473         * Note: When used in multiplayer, this is called on both client and
1474         * server sides!
1475         * 
1476         * @param world The current world
1477         * @param player The player damaging the block, may be null
1478         * @param x X Position
1479         * @param y Y position
1480         * @param z Z position
1481         * @return True if the block is actually destroyed.
1482         */
1483        public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) 
1484        {
1485            return world.setBlockWithNotify(x, y, z, 0);
1486        }
1487    
1488        /**
1489         * Called when a new CreativeContainer is opened, populate the list 
1490         * with all of the items for this block you want a player in creative mode
1491         * to have access to.
1492         * 
1493         * @param itemList The list of items to display on the creative inventory.
1494         */
1495        public void addCreativeItems(ArrayList itemList)
1496        {           
1497        }
1498            
1499        /**
1500         * Chance that fire will spread and consume this block.
1501         * 300 being a 100% chance, 0, being a 0% chance.
1502         * 
1503         * @param world The current world
1504         * @param x The blocks X position
1505         * @param y The blocks Y position
1506         * @param z The blocks Z position
1507         * @param metadata The blocks current metadata
1508         * @param face The face that the fire is coming from
1509         * @return A number ranging from 0 to 300 relating used to determine if the block will be consumed by fire
1510         */
1511        public int getFlammability(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face)
1512        {
1513            return blockFlammability[blockID];
1514        }
1515        
1516        /**
1517         * Called when fire is updating, checks if a block face can catch fire.
1518         * 
1519         * 
1520         * @param world The current world
1521         * @param x The blocks X position
1522         * @param y The blocks Y position
1523         * @param z The blocks Z position
1524         * @param metadata The blocks current metadata
1525         * @param face The face that the fire is coming from
1526         * @return True if the face can be on fire, false otherwise.
1527         */
1528        public boolean isFlammable(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face)
1529        {
1530            return getFlammability(world, x, y, z, metadata, face) > 0;
1531        }
1532        
1533        /**
1534         * Called when fire is updating on a neighbor block.
1535         * The higher the number returned, the faster fire will spread around this block.
1536         * 
1537         * @param world The current world
1538         * @param x The blocks X position
1539         * @param y The blocks Y position
1540         * @param z The blocks Z position
1541         * @param metadata The blocks current metadata
1542         * @param face The face that the fire is coming from
1543         * @return A number that is used to determine the speed of fire growth around the block
1544         */
1545        public int getFireSpreadSpeed(World world, int x, int y, int z, int metadata, ForgeDirection face)
1546        {
1547            return blockFireSpreadSpeed[blockID];
1548        }
1549        
1550        /**
1551         * Currently only called by fire when it is on top of this block.
1552         * Returning true will prevent the fire from naturally dying during updating.
1553         * Also prevents firing from dying from rain.
1554         * 
1555         * @param world The current world
1556         * @param x The blocks X position
1557         * @param y The blocks Y position
1558         * @param z The blocks Z position
1559         * @param metadata The blocks current metadata
1560         * @param side The face that the fire is coming from
1561         * @return True if this block sustains fire, meaning it will never go out.
1562         */
1563        public boolean isFireSource(World world, int x, int y, int z, int metadata, ForgeDirection side)
1564        {
1565            if (blockID == Block.netherrack.blockID && side == UP)
1566            {
1567                    return true;
1568            }
1569            if ((world.provider instanceof WorldProviderEnd) && blockID == Block.bedrock.blockID && side == UP)
1570            {
1571                    return true;
1572            }
1573            return false;
1574        }
1575    
1576        /**
1577         * Called by BlockFire to setup the burn values of vanilla blocks.
1578         * @param id The block id
1579         * @param encouragement How much the block encourages fire to spread
1580         * @param flammability how easy a block is to catch fire
1581         */
1582        public static void setBurnProperties(int id, int encouragement, int flammability)
1583        {
1584            blockFireSpreadSpeed[id] = encouragement;
1585            blockFlammability[id] = flammability;
1586        }
1587    
1588        /**
1589         * Called throughout the code as a replacement for block instanceof BlockContainer
1590         * Moving this to the Block base class allows for mods that wish to extend vinella 
1591         * blocks, and also want to have a tile entity on that block, may.
1592         * 
1593         * Return true from this function to specify this block has a tile entity.
1594         * 
1595         * @param metadata Metadata of the current block
1596         * @return True if block has a tile entity, false otherwise
1597         */
1598        public boolean hasTileEntity(int metadata)
1599        {
1600            return isBlockContainer;
1601        }
1602        
1603        /**
1604         * Called throughout the code as a replacement for BlockContainer.getBlockEntity
1605         * Return the same thing you would from that function.
1606         * This will fall back to BlockContainer.getBlockEntity if this block is a BlockContainer.
1607         * 
1608         * @param metadata The Metadata of the current block
1609         * @return A instance of a class extending TileEntity
1610         */
1611        public TileEntity createTileEntity(World world, int metadata)
1612        {
1613            if (this instanceof BlockContainer)
1614            {
1615                return ((BlockContainer)this).createNewTileEntity(world, metadata);
1616            }
1617            return null;
1618        }    
1619        
1620        /**
1621         * Metadata and fortune sensitive version, this replaces the old (int meta, Random rand)
1622         * version in 1.1. 
1623         * 
1624         * @param meta Blocks Metadata
1625         * @param fortune Current item fortune level
1626         * @param random Random number generator
1627         * @return The number of items to drop
1628         */
1629        public int quantityDropped(int meta, int fortune, Random random)
1630        {
1631            return quantityDroppedWithBonus(fortune, random);
1632        }
1633        
1634        /**
1635         * This returns a complete list of items dropped from this block.
1636         * 
1637         * @param world The current world
1638         * @param x X Position
1639         * @param y Y Position
1640         * @param z Z Position
1641         * @param metadata Current metadata
1642         * @param fortune Breakers fortune level
1643         * @return A ArrayList containing all items this block drops
1644         */
1645        public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int metadata, int fortune)
1646        {
1647            ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
1648            
1649            int count = quantityDropped(metadata, fortune, world.rand);
1650            for(int i = 0; i < count; i++)
1651            {
1652                int id = idDropped(metadata, world.rand, 0);
1653                if (id > 0)
1654                {
1655                    ret.add(new ItemStack(id, 1, damageDropped(metadata)));
1656                }
1657            }
1658            return ret;
1659        }
1660        
1661        /**
1662         * Return true from this function if the player with silk touch can harvest this block directly, and not it's normal drops.
1663         * 
1664         * @param world The world
1665         * @param player The player doing the harvesting
1666         * @param x X Position
1667         * @param y Y Position
1668         * @param z Z Position
1669         * @param metadata The metadata
1670         * @return True if the block can be directly harvested using silk touch
1671         */
1672        public boolean canSilkHarvest(World world, EntityPlayer player, int x, int y, int z, int metadata)
1673        {
1674            if (this instanceof BlockGlass || this instanceof BlockEnderChest)
1675            {
1676                return true;
1677            }
1678            return renderAsNormalBlock() && !hasTileEntity(metadata);
1679        }
1680        
1681        /**
1682         * Determines if a specified mob type can spawn on this block, returning false will 
1683         * prevent any mob from spawning on the block.
1684         * 
1685         * @param type The Mob Category Type
1686         * @param world The current world
1687         * @param x The X Position
1688         * @param y The Y Position
1689         * @param z The Z Position
1690         * @return True to allow a mob of the specified category to spawn, false to prevent it.
1691         */
1692        public boolean canCreatureSpawn(EnumCreatureType type, World world, int x, int y, int z) 
1693        {
1694            int meta = world.getBlockMetadata(x, y, z);
1695            if (this instanceof BlockStep)
1696            {
1697                if (MinecraftForge.SPAWNER_ALLOW_ON_INVERTED)
1698                {
1699                    return (((meta & 8) == 8) || isOpaqueCube());   
1700                }
1701                else
1702                {
1703                    return isNormalCube(this.blockID);
1704                }
1705            }
1706            else if (this instanceof BlockStairs)
1707            {
1708                if (MinecraftForge.SPAWNER_ALLOW_ON_INVERTED)
1709                {
1710                    return ((meta & 4) != 0);
1711                }
1712                else
1713                {
1714                    return isNormalCube(this.blockID);
1715                }
1716            }
1717            return isBlockSolidOnSide(world, x, y, z, UP);
1718        }
1719        
1720        /**
1721         * Determines if this block is classified as a Bed, Allowing 
1722         * players to sleep in it, though the block has to specifically 
1723         * perform the sleeping functionality in it's activated event.
1724         * 
1725         * @param world The current world
1726         * @param x X Position
1727         * @param y Y Position
1728         * @param z Z Position
1729         * @param player The player or camera entity, null in some cases.
1730         * @return True to treat this as a bed
1731         */
1732        public boolean isBed(World world, int x, int y, int z, EntityLiving player)
1733        {
1734            return blockID == Block.bed.blockID;
1735        }
1736        
1737        /**
1738         * Returns the position that the player is moved to upon 
1739         * waking up, or respawning at the bed.
1740         * 
1741         * @param world The current world
1742         * @param x X Position
1743         * @param y Y Position
1744         * @param z Z Position
1745         * @param player The player or camera entity, null in some cases.
1746         * @return The spawn position
1747         */
1748        public ChunkCoordinates getBedSpawnPosition(World world, int x, int y, int z, EntityPlayer player)
1749        {
1750            return BlockBed.getNearestEmptyChunkCoordinates(world, x, y, z, 0);
1751        }
1752    
1753        /**
1754         * Called when a user either starts or stops sleeping in the bed.
1755         *  
1756         * @param world The current world
1757         * @param x X Position
1758         * @param y Y Position
1759         * @param z Z Position
1760         * @param player The player or camera entity, null in some cases.
1761         * @param occupied True if we are occupying the bed, or false if they are stopping use of the bed
1762         */
1763        public void setBedOccupied(World world, int x, int y, int z, EntityPlayer player, boolean occupied)
1764        {
1765            BlockBed.setBedOccupied(world,  x, y, z, occupied);        
1766        }
1767    
1768        /**
1769         * Returns the direction of the block. Same values that 
1770         * are returned by BlockDirectional
1771         * 
1772         * @param world The current world
1773         * @param x X Position
1774         * @param y Y Position
1775         * @param z Z Position
1776         * @return Bed direction
1777         */
1778        public int getBedDirection(IBlockAccess world, int x, int y, int z) 
1779        {
1780            return BlockBed.getDirection(world.getBlockMetadata(x,  y, z));
1781        }
1782        
1783        /**
1784         * Determines if the current block is the foot half of the bed.
1785         * 
1786         * @param world The current world
1787         * @param x X Position
1788         * @param y Y Position
1789         * @param z Z Position
1790         * @return True if the current block is the foot side of a bed.
1791         */
1792        public boolean isBedFoot(IBlockAccess world, int x, int y, int z)
1793        {
1794            return BlockBed.isBlockHeadOfBed(world.getBlockMetadata(x,  y, z));
1795        }
1796        
1797        /**
1798         * Called when a leaf should start its decay process.
1799         * 
1800         * @param world The current world
1801         * @param x X Position
1802         * @param y Y Position
1803         * @param z Z Position
1804         */
1805        public void beginLeavesDecay(World world, int x, int y, int z){}
1806        
1807        /**
1808         * Determines if this block can prevent leaves connected to it from decaying.
1809         * 
1810         * @param world The current world
1811         * @param x X Position
1812         * @param y Y Position
1813         * @param z Z Position
1814         * @return true if the presence this block can prevent leaves from decaying.
1815         */
1816        public boolean canSustainLeaves(World world, int x, int y, int z)
1817        {
1818            return false;
1819        }
1820        
1821        /**
1822         * Determines if this block is considered a leaf block, used to apply the leaf decay and generation system.
1823         * 
1824         * @param world The current world
1825         * @param x X Position
1826         * @param y Y Position
1827         * @param z Z Position
1828         * @return true if this block is considered leaves.
1829         */
1830        public boolean isLeaves(World world, int x, int y, int z)
1831        {
1832            return false;
1833        }
1834        
1835        /**
1836         * Used during tree growth to determine if newly generated leaves can replace this block.
1837         * 
1838         * @param world The current world
1839         * @param x X Position
1840         * @param y Y Position
1841         * @param z Z Position
1842         * @return true if this block can be replaced by growing leaves.
1843         */
1844        public boolean canBeReplacedByLeaves(World world, int x, int y, int z)
1845        {
1846            return !Block.opaqueCubeLookup[this.blockID];
1847        }
1848        
1849        /**
1850         * 
1851         * @param world The current world
1852         * @param x X Position
1853         * @param y Y Position
1854         * @param z Z Position
1855         * @return  true if the block is wood (logs)
1856         */
1857        public boolean isWood(World world, int x, int y, int z)
1858        {
1859             return false;
1860        }
1861        
1862        /**
1863         * Determines if the current block is replaceable by Ore veins during world generation.
1864         * 
1865         * @param world The current world
1866         * @param x X Position
1867         * @param y Y Position
1868         * @param z Z Position
1869         * @return True to allow this block to be replaced by a ore
1870         */
1871        public boolean isGenMineableReplaceable(World world, int x, int y, int z)
1872        {
1873            return blockID == stone.blockID;
1874        }
1875    
1876        /**
1877         * Grabs the current texture file used for this block
1878         */
1879        public String getTextureFile()
1880        {
1881            return currentTexture;
1882        }
1883    
1884        /**
1885         * Sets the current texture file for this block, used when rendering.
1886         * Default is "/terrain.png"
1887         * 
1888         * @param texture The texture file
1889         */
1890        public void setTextureFile(String texture)
1891        {
1892            currentTexture = texture;
1893            isDefaultTexture = false;
1894        }
1895        
1896    
1897        /**
1898         * Location sensitive version of getExplosionRestance
1899         * 
1900         * @param par1Entity The entity that caused the explosion
1901         * @param world The current world
1902         * @param x X Position
1903         * @param y Y Position
1904         * @param z Z Position
1905         * @param explosionX Explosion source X Position
1906         * @param explosionY Explosion source X Position
1907         * @param explosionZ Explosion source X Position
1908         * @return The amount of the explosion absorbed.
1909         */
1910        public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
1911        {
1912            return getExplosionResistance(par1Entity);
1913        }
1914    
1915        /**
1916         * Determine if this block can make a redstone connection on the side provided,
1917         * Useful to control which sides are inputs and outputs for redstone wires.
1918         * 
1919         * Side:
1920         *  -1: UP
1921         *   0: NORTH
1922         *   1: EAST
1923         *   2: SOUTH
1924         *   3: WEST
1925         *
1926         * @param world The current world
1927         * @param x X Position
1928         * @param y Y Position
1929         * @param z Z Position
1930         * @param side The side that is trying to make the connection
1931         * @return True to make the connection
1932         */
1933        public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side)
1934        {
1935            return Block.blocksList[blockID].canProvidePower() && side != -1;
1936        }
1937        
1938        /**
1939         * Determines if a torch can be placed on the top surface of this block.
1940         * Useful for creating your own block that torches can be on, such as fences.
1941         * 
1942         * @param world The current world
1943         * @param x X Position
1944         * @param y Y Position
1945         * @param z Z Position
1946         * @return True to allow the torch to be placed
1947         */
1948        public boolean canPlaceTorchOnTop(World world, int x, int y, int z)
1949        {
1950            if (world.doesBlockHaveSolidTopSurface(x, y, z))
1951            {
1952                return true;
1953            }
1954            else
1955            {
1956                int id = world.getBlockId(x, y, z);
1957                return id == Block.fence.blockID || id == Block.netherFence.blockID || id == Block.glass.blockID || id == Block.cobblestoneWall.blockID;
1958            }
1959        }
1960        
1961    
1962        /**
1963         * Determines if this block should render in this pass.
1964         * 
1965         * @param pass The pass in question
1966         * @return True to render
1967         */
1968        public boolean canRenderInPass(int pass)
1969        {
1970            return pass == getRenderBlockPass();
1971        }
1972    
1973        /**
1974         * Called when a user uses the creative pick block button on this block
1975         * 
1976         * @param target The full target the player is looking at
1977         * @return A ItemStack to add to the player's inventory, Null if nothing should be added.
1978         */
1979        public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
1980        {
1981            int id = idPicked(world, x, y, z);
1982            
1983            if (id == 0)
1984            {
1985                return null;
1986            }
1987    
1988            Item item = Item.itemsList[id];
1989            if (item == null)
1990            {
1991                return null;
1992            }
1993    
1994            return new ItemStack(id, 1, getDamageValue(world, x, y, z));
1995        }
1996    
1997        /**
1998         * Used by getTopSolidOrLiquidBlock while placing biome decorations, villages, etc
1999         * Also used to determine if the player can spawn on this block.
2000         * 
2001         * @return False to disallow spawning
2002         */
2003        public boolean isBlockFoliage(World world, int x, int y, int z)
2004        {
2005            return false;
2006        }
2007    
2008        /**
2009         * Spawn a digging particle effect in the world, this is a wrapper 
2010         * around EffectRenderer.addBlockHitEffects to allow the block more 
2011         * control over the particles. Useful when you have entirely different
2012         * texture sheets for different sides/locations in the world.
2013         * 
2014         * @param world The current world
2015         * @param target The target the player is looking at {x/y/z/side/sub}
2016         * @param effectRenderer A reference to the current effect renderer.
2017         * @return True to prevent vanilla digging particles form spawning.
2018         */
2019        @SideOnly(Side.CLIENT)
2020        public boolean addBlockHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer)
2021        {
2022            return false;
2023        }
2024    
2025        /**
2026         * Spawn particles for when the block is destroyed. Due to the nature 
2027         * of how this is invoked, the x/y/z locations are not always guaranteed 
2028         * to host your block. So be sure to do proper sanity checks before assuming
2029         * that the location is this block.
2030         * 
2031         * @param world The current world
2032         * @param x X position to spawn the particle
2033         * @param y Y position to spawn the particle
2034         * @param z Z position to spawn the particle
2035         * @param meta The metadata for the block before it was destroyed.
2036         * @param effectRenderer A reference to the current effect renderer.
2037         * @return True to prevent vanilla break particles from spawning.
2038         */
2039        @SideOnly(Side.CLIENT)
2040        public boolean addBlockDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer effectRenderer)
2041        {
2042            return false;
2043        }
2044    
2045        /**
2046         * Determines if this block can support the passed in plant, allowing it to be planted and grow.
2047         * Some examples:
2048         *   Reeds check if its a reed, or if its sand/dirt/grass and adjacent to water
2049         *   Cacti checks if its a cacti, or if its sand
2050         *   Nether types check for soul sand
2051         *   Crops check for tilled soil
2052         *   Caves check if it's a colid surface
2053         *   Plains check if its grass or dirt
2054         *   Water check if its still water
2055         *   
2056         * @param world The current world
2057         * @param x X Position
2058         * @param y Y Position
2059         * @param z Z position
2060         * @param direction The direction relative to the given position the plant wants to be, typically its UP
2061         * @param plant The plant that wants to check
2062         * @return True to allow the plant to be planted/stay.
2063         */
2064        public boolean canSustainPlant(World world, int x, int y, int z, ForgeDirection direction, IPlantable plant)
2065        {
2066            int plantID = plant.getPlantID(world, x, y + 1, z);
2067            EnumPlantType plantType = plant.getPlantType(world, x, y + 1, z);
2068    
2069            if (plantID == cactus.blockID && blockID == cactus.blockID)
2070            {
2071                return true;
2072            }
2073    
2074            if (plantID == reed.blockID && blockID == reed.blockID)
2075            {
2076                return true;
2077            }
2078    
2079            if (plant instanceof BlockFlower && ((BlockFlower)plant).canThisPlantGrowOnThisBlockID(blockID))
2080            {
2081                return true;
2082            }
2083    
2084            switch (plantType)
2085            {
2086                case Desert: return blockID == sand.blockID;
2087                case Nether: return blockID == slowSand.blockID;
2088                case Crop:   return blockID == tilledField.blockID;
2089                case Cave:   return isBlockSolidOnSide(world, x, y, z, UP);
2090                case Plains: return blockID == grass.blockID || blockID == dirt.blockID;
2091                case Water:  return world.getBlockMaterial(x, y, z) == Material.water && world.getBlockMetadata(x, y, z) == 0;
2092                case Beach:
2093                    boolean isBeach = (blockID == Block.grass.blockID || blockID == Block.dirt.blockID || blockID == Block.sand.blockID);
2094                    boolean hasWater = (world.getBlockMaterial(x - 1, y - 1, z    ) == Material.water || 
2095                                        world.getBlockMaterial(x + 1, y - 1, z    ) == Material.water || 
2096                                        world.getBlockMaterial(x,     y - 1, z - 1) == Material.water ||
2097                                        world.getBlockMaterial(x,     y - 1, z + 1) == Material.water);
2098                    return isBeach && hasWater;
2099            }
2100    
2101            return false;
2102        }
2103    
2104        /**
2105         * Checks if this soil is fertile, typically this means that growth rates 
2106         * of plants on this soil will be slightly sped up.
2107         * Only vanilla case is tilledField when it is within range of water.
2108         * 
2109         * @param world The current world
2110         * @param x X Position
2111         * @param y Y Position
2112         * @param z Z position
2113         * @return True if the soil should be considered fertile.
2114         */
2115        public boolean isFertile(World world, int x, int y, int z)
2116        {
2117            if (blockID == tilledField.blockID)
2118            {
2119                return world.getBlockMetadata(x, y, z) > 0;
2120            }
2121    
2122            return false;
2123        }
2124        
2125        /**
2126         * Location aware and overrideable version of the lightOpacity array,
2127         * return the number to subtract from the light value when it passes through this block.
2128         * 
2129         * This is not guaranteed to have the tile entity in place before this is called, so it is
2130         * Recommended that you have your tile entity call relight after being placed if you
2131         * rely on it for light info.
2132         * 
2133         * @param world The current world
2134         * @param x X Position
2135         * @param y Y Position
2136         * @param z Z position
2137         * @return The amount of light to block, 0 for air, 255 for fully opaque.
2138         */
2139        public int getLightOpacity(World world, int x, int y, int z)
2140        {
2141            return lightOpacity[blockID];
2142        }
2143    
2144        /**
2145         * Determines if this block is destroyed when a ender dragon tries to fly through it.
2146         * The block will be set to 0, nothing will drop.
2147         * 
2148         * @param world The current world
2149         * @param x X Position
2150         * @param y Y Position
2151         * @param z Z position
2152         * @return True to allow the ender dragon to destroy this block
2153         */
2154        public boolean canDragonDestroy(World world, int x, int y, int z)
2155        {
2156            return blockID != obsidian.blockID && blockID != whiteStone.blockID && blockID != bedrock.blockID;
2157        }
2158    
2159        /**
2160         * Determines if this block can be used as the base of a beacon.
2161         * 
2162         * @param world The current world
2163         * @param x X Position
2164         * @param y Y Position
2165         * @param z Z position
2166         * @param beaconX Beacons X Position
2167         * @param beaconY Beacons Y Position
2168         * @param beaconZ Beacons Z Position
2169         * @return True, to support the beacon, and make it active with this block.
2170         */
2171        public boolean isBeaconBase(World worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ)
2172        {
2173            return (blockID == blockEmerald.blockID || blockID == blockGold.blockID || blockID == blockDiamond.blockID || blockID == blockSteel.blockID);
2174        }
2175    }