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 BlockCloth extends Block 013{ 014 @SideOnly(Side.CLIENT) 015 private Icon[] iconArray; 016 017 public BlockCloth() 018 { 019 super(35, Material.cloth); 020 this.setCreativeTab(CreativeTabs.tabBlock); 021 } 022 023 @SideOnly(Side.CLIENT) 024 025 /** 026 * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata 027 */ 028 public Icon getIcon(int par1, int par2) 029 { 030 return this.iconArray[par2 % this.iconArray.length]; 031 } 032 033 /** 034 * Determines the damage on the item the block drops. Used in cloth and wood. 035 */ 036 public int damageDropped(int par1) 037 { 038 return par1; 039 } 040 041 /** 042 * Takes a dye damage value and returns the block damage value to match 043 */ 044 public static int getBlockFromDye(int par0) 045 { 046 return ~par0 & 15; 047 } 048 049 /** 050 * Takes a block damage value and returns the dye damage value to match 051 */ 052 public static int getDyeFromBlock(int par0) 053 { 054 return ~par0 & 15; 055 } 056 057 @SideOnly(Side.CLIENT) 058 059 /** 060 * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) 061 */ 062 public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) 063 { 064 for (int j = 0; j < 16; ++j) 065 { 066 par3List.add(new ItemStack(par1, 1, j)); 067 } 068 } 069 070 @SideOnly(Side.CLIENT) 071 072 /** 073 * When this method is called, your block should register all the icons it needs with the given IconRegister. This 074 * is the only chance you get to register icons. 075 */ 076 public void registerIcons(IconRegister par1IconRegister) 077 { 078 this.iconArray = new Icon[16]; 079 080 for (int i = 0; i < this.iconArray.length; ++i) 081 { 082 this.iconArray[i] = par1IconRegister.registerIcon("cloth_" + i); 083 } 084 } 085}