    001    package net.minecraft.block;
    002
    003    import cpw.mods.fml.relauncher.Side;
    004    import cpw.mods.fml.relauncher.SideOnly;
    005    import java.util.List;
    006    import java.util.Random;
    007    import net.minecraft.block.material.Material;
    008    import net.minecraft.creativetab.CreativeTabs;
    009    import net.minecraft.item.ItemStack;
    010    import net.minecraft.world.World;
    011
    012    public class BlockLog extends Block
    013    {
    014        /** The type of tree this log came from. */
    015        public static final String[] woodType = new String[] {"oak", "spruce", "birch", "jungle"};
    016
    017        protected BlockLog(int par1)
    018        {
    019            super(par1, Material.wood);
    020            this.blockIndexInTexture = 20;
    021            this.setCreativeTab(CreativeTabs.tabBlock);
    022        }
    023
    024        /**
    025         * The type of render function that is called for this block
    026         */
    027        public int getRenderType()
    028        {
    029            return 31;
    030        }
    031
    032        /**
    033         * Returns the quantity of items to drop on block destruction.
    034         */
    035        public int quantityDropped(Random par1Random)
    036        {
    037            return 1;
    038        }
    039
    040        /**
    041         * Returns the ID of the items to drop on destruction.
    042         */
    043        public int idDropped(int par1, Random par2Random, int par3)
    044        {
    045            return Block.wood.blockID;
    046        }
    047
    048        /**
    049         * ejects contained items into the world, and notifies neighbours of an update, as appropriate
    050         */
    051        public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
    052        {
    053            byte var7 = 4;
    054            int var8 = var7 + 1;
    055
    056            if (par1World.checkChunksExist(par2 - var8, par3 - var8, par4 - var8, par2 + var8, par3 + var8, par4 + var8))
    057            {
    058                for (int var9 = -var7; var9 <= var7; ++var9)
    059                {
    060                    for (int var10 = -var7; var10 <= var7; ++var10)
    061                    {
    062                        for (int var11 = -var7; var11 <= var7; ++var11)
    063                        {
    064                            int var12 = par1World.getBlockId(par2 + var9, par3 + var10, par4 + var11);
    065
    066                            if (Block.blocksList[var12] != null)
    067                            {
    068                                Block.blocksList[var12].beginLeavesDecay(par1World, par2 + var9, par3 + var10, par4 + var11);
    069                            }
    070                        }
    071                    }
    072                }
    073            }
    074        }
    075
    076        public int func_85104_a(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
    077        {
    078            int var10 = par9 & 3;
    079            byte var11 = 0;
    080
    081            switch (par5)
    082            {
    083                case 0:
    084                case 1:
    085                    var11 = 0;
    086                    break;
    087                case 2:
    088                case 3:
    089                    var11 = 8;
    090                    break;
    091                case 4:
    092                case 5:
    093                    var11 = 4;
    094            }
    095
    096            return var10 | var11;
    097        }
    098
    099        /**
    100         * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
    101         */
    102        public int getBlockTextureFromSideAndMetadata(int par1, int par2)
    103        {
    104            int var3 = par2 & 12;
    105            int var4 = par2 & 3;
    106            return var3 == 0 && (par1 == 1 || par1 == 0) ? 21 : (var3 == 4 && (par1 == 5 || par1 == 4) ? 21 : (var3 == 8 && (par1 == 2 || par1 == 3) ? 21 : (var4 == 1 ? 116 : (var4 == 2 ? 117 : (var4 == 3 ? 153 : 20)))));
    107        }
    108
    109        /**
    110         * Determines the damage on the item the block drops. Used in cloth and wood.
    111         */
    112        public int damageDropped(int par1)
    113        {
    114            return par1 & 3;
    115        }
    116
    117        /**
    118         * returns a number between 0 and 3
    119         */
    120        public static int limitToValidMetadata(int par0)
    121        {
    122            return par0 & 3;
    123        }
    124
    125        @SideOnly(Side.CLIENT)
    126
    127        /**
    128         * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
    129         */
    130        public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
    131        {
    132            par3List.add(new ItemStack(par1, 1, 0));
    133            par3List.add(new ItemStack(par1, 1, 1));
    134            par3List.add(new ItemStack(par1, 1, 2));
    135            par3List.add(new ItemStack(par1, 1, 3));
    136        }
    137
    138        /**
    139         * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage
    140         * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null.
    141         */
    142        protected ItemStack createStackedBlock(int par1)
    143        {
    144            return new ItemStack(this.blockID, 1, limitToValidMetadata(par1));
    145        }
    146
    147        @Override
    148        public boolean canSustainLeaves(World world, int x, int y, int z)
    149        {
    150            return true;
    151        }
    152
    153        @Override
    154        public boolean isWood(World world, int x, int y, int z)
    155        {
    156            return true;
    157        }
    158    }