Advertisement
ThatGamerBlue2

Untitled

Oct 30th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. protected static float getGrowthChance(Block blockIn, World worldIn, BlockPos pos)
  2. {
  3. float f = 1.0F;
  4. BlockPos blockpos = pos.down();
  5.  
  6. for (int i = -1; i <= 1; ++i)
  7. {
  8. for (int j = -1; j <= 1; ++j)
  9. {
  10. float f1 = 0.0F;
  11. IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j));
  12.  
  13. if (iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, blockpos.add(i, 0, j), net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable)blockIn))
  14. {
  15. f1 = 1.0F;
  16.  
  17. if (iblockstate.getBlock().isFertile(worldIn, blockpos.add(i, 0, j)))
  18. {
  19. f1 = 3.0F;
  20. }
  21. }
  22.  
  23. if (i != 0 || j != 0)
  24. {
  25. f1 /= 4.0F;
  26. }
  27.  
  28. f += f1;
  29. }
  30. }
  31.  
  32. BlockPos blockpos1 = pos.north();
  33. BlockPos blockpos2 = pos.south();
  34. BlockPos blockpos3 = pos.west();
  35. BlockPos blockpos4 = pos.east();
  36. boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock() || blockIn == worldIn.getBlockState(blockpos4).getBlock();
  37. boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock() || blockIn == worldIn.getBlockState(blockpos2).getBlock();
  38.  
  39. if (flag && flag1)
  40. {
  41. f /= 2.0F;
  42. }
  43. else
  44. {
  45. boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.south()).getBlock() || blockIn == worldIn.getBlockState(blockpos3.south()).getBlock();
  46.  
  47. if (flag2)
  48. {
  49. f /= 2.0F;
  50. }
  51. }
  52.  
  53. return f;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement