BlockTallGrass.java 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package me.km.blocks;
  2. import me.km.items.ModItems;
  3. import net.minecraft.block.SoundType;
  4. import net.minecraft.block.state.IBlockState;
  5. import net.minecraft.entity.Entity;
  6. import net.minecraft.item.ItemStack;
  7. import net.minecraft.util.NonNullList;
  8. import net.minecraft.util.math.BlockPos;
  9. import net.minecraft.world.IBlockAccess;
  10. import net.minecraft.world.World;
  11. public class BlockTallGrass extends net.minecraft.block.BlockTallGrass
  12. {
  13. private final SoundType type;
  14. public BlockTallGrass()
  15. {
  16. super.setHardness(0);
  17. type = SoundType.PLANT;
  18. }
  19. @Override
  20. public SoundType getSoundType(IBlockState state, World world, BlockPos pos, Entity entity)
  21. {
  22. return type;
  23. }
  24. @Override
  25. public NonNullList<ItemStack> getDrops(IBlockAccess w, BlockPos pos, IBlockState state, int fortune)
  26. {
  27. int rand = RANDOM.nextInt(8);
  28. if(rand <= 3)
  29. {
  30. return NonNullList.withSize(1, new ItemStack(ModItems.hayBundle));
  31. }
  32. else if(RANDOM.nextInt(8) == 4)
  33. {
  34. ItemStack seed = net.minecraftforge.common.ForgeHooks.getGrassSeed(RANDOM, fortune);
  35. if(!seed.isEmpty())
  36. {
  37. return NonNullList.withSize(1, seed);
  38. }
  39. }
  40. return NonNullList.create();
  41. }
  42. }