pryingtuna85649

grass block

Jun 18th, 2014
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.73 KB | None | 0 0
  1. package com.wizardofoz.basic.block;
  2.  
  3. import java.util.Random;
  4.  
  5. import net.minecraft.block.Block;
  6. import net.minecraft.block.BlockGrass;
  7. import net.minecraft.block.IGrowable;
  8. import net.minecraft.block.material.Material;
  9. import net.minecraft.client.renderer.texture.IIconRegister;
  10. import net.minecraft.creativetab.CreativeTabs;
  11. import net.minecraft.init.Blocks;
  12. import net.minecraft.item.Item;
  13. import net.minecraft.util.IIcon;
  14. import net.minecraft.world.ColorizerGrass;
  15. import net.minecraft.world.IBlockAccess;
  16. import net.minecraft.world.World;
  17.  
  18. import org.apache.logging.log4j.LogManager;
  19. import org.apache.logging.log4j.Logger;
  20.  
  21. import com.wizardofoz.basic.Gillikins;
  22. import com.wizardofoz.basic.Munchkins;
  23. import com.wizardofoz.basic.OzMod;
  24. import com.wizardofoz.basic.Quadlings;
  25. import com.wizardofoz.basic.Winkies;
  26.  
  27. import cpw.mods.fml.relauncher.Side;
  28. import cpw.mods.fml.relauncher.SideOnly;
  29.  
  30. public class GrassBlock extends Block implements IGrowable {
  31.  
  32. private static final Logger logger = LogManager.getLogger();
  33. @SideOnly(Side.CLIENT)
  34. private IIcon field_149991_b;
  35. @SideOnly(Side.CLIENT)
  36. private IIcon field_149993_M;
  37. @SideOnly(Side.CLIENT)
  38. private IIcon field_149994_N;
  39. private static final String __OBFID = "CL_00000251";
  40.  
  41. public GrassBlock(Material material) {
  42. super(Material.grass);
  43. this.setTickRandomly(true);
  44. this.setCreativeTab(OzMod.OzTab);
  45. //this.getItemDropped(lightOpacity, null, lightOpacity);
  46.  
  47. }
  48.  
  49. /**
  50. * Gets the block's texture. Args: side, meta
  51. */
  52. @SideOnly(Side.CLIENT)
  53. public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
  54. return p_149691_1_ == 1 ? this.field_149991_b : (p_149691_1_ == 0 ? Blocks.dirt.getBlockTextureFromSide(p_149691_1_) : this.blockIcon);
  55. }
  56.  
  57. /**
  58. * Ticks the block if it's been scheduled
  59. */
  60. public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) {
  61. if (!p_149674_1_.isRemote) {
  62. if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) < 4 && p_149674_1_.getBlockLightOpacity(p_149674_2_, p_149674_3_ + 1, p_149674_4_) > 2) {
  63. p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.dirt);
  64. }
  65.  
  66. else if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9) {
  67. for (int l = 0; l < 4; ++l) {
  68. int i1 = p_149674_2_ + p_149674_5_.nextInt(3) - 1;
  69. int j1 = p_149674_3_ + p_149674_5_.nextInt(5) - 3;
  70. int k1 = p_149674_4_ + p_149674_5_.nextInt(3) - 1;
  71. Block block = p_149674_1_.getBlock(i1, j1 + 1, k1);
  72.  
  73. if (p_149674_1_.getBlock(i1, j1, k1) == Blocks.dirt && p_149674_1_.getBlockMetadata(i1, j1, k1) == 0 && p_149674_1_.getBlockLightValue(i1, j1 + 1, k1) >= 4 && p_149674_1_.getBlockLightOpacity(i1, j1 + 1, k1) <= 2) {
  74. p_149674_1_.setBlock(i1, j1, k1, Blocks.grass);
  75. }
  76. }
  77. }
  78. }
  79. }
  80.  
  81. //public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
  82. // return Blocks.dirt.getItemDropped(0, p_149650_2_, p_149650_3_);
  83. //}
  84.  
  85. //public Item getItemFromBlock(Block block) {
  86. // return getItemFromBlock(OzBlocks.DirtBlock);
  87. //change Item.getItemFromBlock?
  88. //}
  89.  
  90. public boolean func_149851_a(World p_149851_1_, int p_149851_2_, int p_149851_3_, int p_149851_4_, boolean p_149851_5_) {
  91. return true;
  92. }
  93.  
  94. public boolean func_149852_a(World p_149852_1_, Random p_149852_2_, int p_149852_3_, int p_149852_4_, int p_149852_5_) {
  95. return true;
  96. }
  97.  
  98. @SideOnly(Side.CLIENT)
  99. public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) {
  100. if (p_149673_5_ == 1) {
  101. return this.field_149991_b;
  102. }
  103. else if (p_149673_5_ == 0) {
  104. return Blocks.dirt.getBlockTextureFromSide(p_149673_5_);
  105. }
  106. else {
  107. Material material = p_149673_1_.getBlock(p_149673_2_, p_149673_3_ + 1, p_149673_4_).getMaterial();
  108. return material != Material.snow && material != Material.craftedSnow ? this.blockIcon : this.field_149993_M;
  109. }
  110. }
  111.  
  112. @SideOnly(Side.CLIENT)
  113. public void registerBlockIcons(IIconRegister p_149651_1_) {
  114. this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side");
  115. this.field_149991_b = p_149651_1_.registerIcon(this.getTextureName() + "_top");
  116. this.field_149993_M = p_149651_1_.registerIcon(this.getTextureName() + "_side_snowed");
  117. this.field_149994_N = p_149651_1_.registerIcon(this.getTextureName() + "_side_overlay");
  118. }
  119.  
  120. @SideOnly(Side.CLIENT)
  121. public int getBlockColor() {
  122. double d0 = 0.5D;
  123. double d1 = 1.0D;
  124. return ColorizerGrass.getGrassColor(d0, d1);
  125. }
  126.  
  127. /**
  128. * Returns the color this block should be rendered. Used by leaves.
  129. */
  130.  
  131. // @SideOnly(Side.CLIENT)
  132. // public int getRenderColor(int p_149741_1_) {
  133.  
  134. // return this.getBlockColor();
  135.  
  136. // }
  137.  
  138. /**
  139. * Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called
  140. * when first determining what to render.
  141. */
  142.  
  143. // @SideOnly(Side.CLIENT)
  144. // public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) {
  145.  
  146. // int l = 0;
  147. // int i1 = 0;
  148. // int j1 = 0;
  149.  
  150. // for (int k1 = -1; k1 <= 1; ++k1) {
  151.  
  152. // for (int l1 = -1; l1 <= 1; ++l1) {
  153.  
  154. // int i2 = p_149720_1_.getBiomeGenForCoords(p_149720_2_ + l1, p_149720_4_ + k1).getBiomeGrassColor(p_149720_2_ + l1, p_149720_3_, p_149720_4_ + k1);
  155. // l += (i2 & 16711680) >> 16;
  156. // i1 += (i2 & 65280) >> 8;
  157. // j1 += i2 & 255;
  158. // }
  159. // }
  160.  
  161. // return (l / 9 & 255) << 16 | (i1 / 9 & 255) << 8 | j1 / 9 & 255;
  162. // }
  163.  
  164. @SideOnly(Side.CLIENT)
  165. public static BlockGrass getIconSideOverlay() {
  166.  
  167. return Blocks.grass;
  168. }
  169.  
  170. public void func_149853_b(World p_149853_1_, Random p_149853_2_, int p_149853_3_, int p_149853_4_, int p_149853_5_) {
  171.  
  172. int l = 0;
  173.  
  174. while (l < 128) {
  175.  
  176. int i1 = p_149853_3_;
  177. int j1 = p_149853_4_ + 1;
  178. int k1 = p_149853_5_;
  179. int l1 = 0;
  180.  
  181. while (true) {
  182.  
  183. if (l1 < l / 16) {
  184.  
  185. i1 += p_149853_2_.nextInt(3) - 1;
  186. j1 += (p_149853_2_.nextInt(3) - 1) * p_149853_2_.nextInt(3) / 2;
  187. k1 += p_149853_2_.nextInt(3) - 1;
  188.  
  189. if (p_149853_1_.getBlock(i1, j1 - 1, k1) == Blocks.grass && !p_149853_1_.getBlock(i1, j1, k1).isNormalCube()) {
  190.  
  191. ++l1;
  192. continue;
  193. }
  194. }
  195. else if (p_149853_1_.getBlock(i1, j1, k1).getMaterial() == Material.air) {
  196.  
  197. if (p_149853_2_.nextInt(8) != 0)
  198. {
  199. if (Blocks.tallgrass.canBlockStay(p_149853_1_, i1, j1, k1))
  200. {
  201. p_149853_1_.setBlock(i1, j1, k1, Blocks.tallgrass, 1, 3);
  202. }
  203. }
  204. else
  205. {
  206. p_149853_1_.getBiomeGenForCoords(i1, k1).plantFlower(p_149853_1_, p_149853_2_, i1, j1, k1);
  207. }
  208. }
  209.  
  210. ++l;
  211. break;
  212. }
  213. }
  214. }
  215.  
  216. }
Advertisement
Add Comment
Please, Sign In to add comment