pryingtuna85649

dirt block

Jun 18th, 2014
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. package com.wizardofoz.basic.block;
  2.  
  3. import java.util.List;
  4.  
  5. import com.wizardofoz.basic.OzMod;
  6.  
  7. import cpw.mods.fml.relauncher.Side;
  8. import cpw.mods.fml.relauncher.SideOnly;
  9. import net.minecraft.block.Block;
  10. import net.minecraft.block.material.Material;
  11. import net.minecraft.client.renderer.texture.IIconRegister;
  12. import net.minecraft.creativetab.CreativeTabs;
  13. import net.minecraft.init.Blocks;
  14. import net.minecraft.item.Item;
  15. import net.minecraft.item.ItemStack;
  16. import net.minecraft.util.IIcon;
  17. import net.minecraft.world.IBlockAccess;
  18. import net.minecraft.world.World;
  19.  
  20. public class DirtBlock extends Block {
  21.  
  22. public static final String[] field_150009_a = new String[] {"default", "default", "podzol"};
  23. @SideOnly(Side.CLIENT)
  24. private IIcon field_150008_b;
  25. @SideOnly(Side.CLIENT)
  26. private IIcon field_150010_M;
  27. private static final String __OBFID = "CL_00000228";
  28.  
  29. public DirtBlock(Material p_i45394_1_) {
  30. super(Material.ground);
  31. this.setCreativeTab(CreativeTabs.tabBlock);
  32. this.setHardness(0.5F);
  33. this.setStepSound(soundTypeGravel);
  34.  
  35. }
  36.  
  37. /**
  38. * Gets the block's texture. Args: side, meta
  39. */
  40. @SideOnly(Side.CLIENT)
  41. public IIcon getIcon(int p_149691_1_, int p_149691_2_)
  42. {
  43. if (p_149691_2_ == 2)
  44. {
  45. if (p_149691_1_ == 1)
  46. {
  47. return this.field_150008_b;
  48. }
  49.  
  50. if (p_149691_1_ != 0)
  51. {
  52. return this.field_150010_M;
  53. }
  54. }
  55.  
  56. return this.blockIcon;
  57. }
  58.  
  59. /**
  60. * Determines the damage on the item the block drops. Used in cloth and wood.
  61. */
  62. public int damageDropped(int p_149692_1_)
  63. {
  64. return 0;
  65. }
  66.  
  67. @SideOnly(Side.CLIENT)
  68. public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_)
  69. {
  70. int i1 = p_149673_1_.getBlockMetadata(p_149673_2_, p_149673_3_, p_149673_4_);
  71.  
  72. if (i1 == 2)
  73. {
  74. if (p_149673_5_ == 1)
  75. {
  76. return this.field_150008_b;
  77. }
  78.  
  79. if (p_149673_5_ != 0)
  80. {
  81. Material material = p_149673_1_.getBlock(p_149673_2_, p_149673_3_ + 1, p_149673_4_).getMaterial();
  82.  
  83. if (material == Material.snow || material == Material.craftedSnow)
  84. {
  85. return Blocks.grass.getIcon(p_149673_1_, p_149673_2_, p_149673_3_, p_149673_4_, p_149673_5_);
  86. }
  87.  
  88. Block block = p_149673_1_.getBlock(p_149673_2_, p_149673_3_ + 1, p_149673_4_);
  89.  
  90. if (block != Blocks.dirt && block != Blocks.grass)
  91. {
  92. return this.field_150010_M;
  93. }
  94. }
  95. }
  96.  
  97. return this.blockIcon;
  98. }
  99.  
  100. /**
  101. * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage
  102. * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null.
  103. */
  104. protected ItemStack createStackedBlock(int p_149644_1_)
  105. {
  106. if (p_149644_1_ == 1)
  107. {
  108. p_149644_1_ = 0;
  109. }
  110.  
  111. return super.createStackedBlock(p_149644_1_);
  112. }
  113.  
  114. /**
  115. * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
  116. */
  117. @SideOnly(Side.CLIENT)
  118. public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_)
  119. {
  120. p_149666_3_.add(new ItemStack(this, 1, 0));
  121. p_149666_3_.add(new ItemStack(this, 1, 2));
  122. }
  123.  
  124. @SideOnly(Side.CLIENT)
  125. public void registerBlockIcons(IIconRegister p_149651_1_)
  126. {
  127. super.registerBlockIcons(p_149651_1_);
  128. this.field_150008_b = p_149651_1_.registerIcon(this.getTextureName() + "_" + "podzol_top");
  129. this.field_150010_M = p_149651_1_.registerIcon(this.getTextureName() + "_" + "podzol_side");
  130. }
  131.  
  132. /**
  133. * Get the block's damage value (for use with pick block).
  134. */
  135. public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_)
  136. {
  137. int l = p_149643_1_.getBlockMetadata(p_149643_2_, p_149643_3_, p_149643_4_);
  138.  
  139. if (l == 1)
  140. {
  141. l = 0;
  142. }
  143.  
  144. return l;
  145. }
  146.  
  147. }
Advertisement
Add Comment
Please, Sign In to add comment