001package net.minecraft.block; 002 003import cpw.mods.fml.relauncher.Side; 004import cpw.mods.fml.relauncher.SideOnly; 005import java.util.List; 006import net.minecraft.block.material.Material; 007import net.minecraft.client.renderer.texture.IconRegister; 008import net.minecraft.creativetab.CreativeTabs; 009import net.minecraft.item.ItemStack; 010import net.minecraft.util.Icon; 011 012public class BlockWood extends Block 013{ 014 /** The type of tree this block came from. */ 015 public static final String[] woodType = new String[] {"oak", "spruce", "birch", "jungle"}; 016 public static final String[] woodTextureTypes = new String[] {"wood", "wood_spruce", "wood_birch", "wood_jungle"}; 017 @SideOnly(Side.CLIENT) 018 private Icon[] iconArray; 019 020 public BlockWood(int par1) 021 { 022 super(par1, Material.wood); 023 this.setCreativeTab(CreativeTabs.tabBlock); 024 } 025 026 @SideOnly(Side.CLIENT) 027 028 /** 029 * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata 030 */ 031 public Icon getBlockTextureFromSideAndMetadata(int par1, int par2) 032 { 033 if (par2 < 0 || par2 >= this.iconArray.length) 034 { 035 par2 = 0; 036 } 037 038 return this.iconArray[par2]; 039 } 040 041 /** 042 * Determines the damage on the item the block drops. Used in cloth and wood. 043 */ 044 public int damageDropped(int par1) 045 { 046 return par1; 047 } 048 049 @SideOnly(Side.CLIENT) 050 051 /** 052 * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) 053 */ 054 public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) 055 { 056 par3List.add(new ItemStack(par1, 1, 0)); 057 par3List.add(new ItemStack(par1, 1, 1)); 058 par3List.add(new ItemStack(par1, 1, 2)); 059 par3List.add(new ItemStack(par1, 1, 3)); 060 } 061 062 @SideOnly(Side.CLIENT) 063 064 /** 065 * When this method is called, your block should register all the icons it needs with the given IconRegister. This 066 * is the only chance you get to register icons. 067 */ 068 public void registerIcons(IconRegister par1IconRegister) 069 { 070 this.iconArray = new Icon[woodTextureTypes.length]; 071 072 for (int i = 0; i < this.iconArray.length; ++i) 073 { 074 this.iconArray[i] = par1IconRegister.registerIcon(woodTextureTypes[i]); 075 } 076 } 077}