001    package net.minecraft.block;
002    
003    import net.minecraft.block.material.Material;
004    import net.minecraft.tileentity.TileEntity;
005    import net.minecraft.world.World;
006    
007    public abstract class BlockContainer extends Block
008    {
009        protected BlockContainer(int par1, Material par2Material)
010        {
011            super(par1, par2Material);
012            this.isBlockContainer = true;
013        }
014    
015        protected BlockContainer(int par1, int par2, Material par3Material)
016        {
017            super(par1, par2, par3Material);
018            this.isBlockContainer = true;
019        }
020    
021        /**
022         * Called whenever the block is added into the world. Args: world, x, y, z
023         */
024        public void onBlockAdded(World par1World, int par2, int par3, int par4)
025        {
026            super.onBlockAdded(par1World, par2, par3, par4);
027            par1World.setBlockTileEntity(par2, par3, par4, this.createTileEntity(par1World, par1World.getBlockMetadata(par2, par3, par4)));
028        }
029    
030        /**
031         * ejects contained items into the world, and notifies neighbours of an update, as appropriate
032         */
033        public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
034        {
035            super.breakBlock(par1World, par2, par3, par4, par5, par6);
036            par1World.removeBlockTileEntity(par2, par3, par4);
037        }
038    
039        /**
040         * Returns a new instance of a block's tile entity class. Called on placing the block.
041         */
042        public abstract TileEntity createNewTileEntity(World var1);
043        
044    
045        public TileEntity createNewTileEntity(World world, int metadata)
046        {
047            return createNewTileEntity(world);
048        }
049    
050        /**
051         * Called when the block receives a BlockEvent - see World.addBlockEvent. By default, passes it on to the tile
052         * entity at this location. Args: world, x, y, z, blockID, EventID, event parameter
053         */
054        public void onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6)
055        {
056            super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6);
057            TileEntity var7 = par1World.getBlockTileEntity(par2, par3, par4);
058    
059            if (var7 != null)
060            {
061                var7.receiveClientEvent(par5, par6);
062            }
063        }
064    }