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