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