BlockHay.java 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package me.km.blocks;
  2. import me.km.KajetansMod;
  3. import net.minecraft.block.BlockRotatedPillar;
  4. import net.minecraft.block.SoundType;
  5. import net.minecraft.block.material.Material;
  6. import net.minecraft.block.state.IBlockState;
  7. import net.minecraft.creativetab.CreativeTabs;
  8. import net.minecraft.entity.Entity;
  9. import net.minecraft.item.Item;
  10. import net.minecraft.util.EnumFacing;
  11. import net.minecraft.util.math.BlockPos;
  12. import net.minecraft.world.World;
  13. public class BlockHay extends BlockRotatedPillar implements IBlockBase
  14. {
  15. protected String name;
  16. private SoundType type;
  17. public BlockHay(String name, String local)
  18. {
  19. super(Material.GRASS);
  20. this.name = name;
  21. this.setRegistryName(name);
  22. super.setUnlocalizedName(local);
  23. super.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
  24. super.setHardness(0.5F);
  25. this.type = SoundType.PLANT;
  26. this.setDefaultState(this.blockState.getBaseState().withProperty(AXIS, EnumFacing.Axis.Y));
  27. }
  28. @Override
  29. public void onFallenUpon(World w, BlockPos pos, Entity ent, float fallDistance)
  30. {
  31. ent.fall(fallDistance, 0.2F);
  32. }
  33. @Override
  34. public void registerItemModel(Item itemBlock)
  35. {
  36. KajetansMod.proxy.registerItemRenderer(itemBlock, 0, name);
  37. }
  38. @Override
  39. public BlockHay setSoundType(SoundType sound)
  40. {
  41. this.type = sound;
  42. return this;
  43. }
  44. @Override
  45. public SoundType getSoundType(IBlockState state, World world, BlockPos pos, Entity entity)
  46. {
  47. return type;
  48. }
  49. }