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