BlockBase.java 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package me.km.blocks;
  2. import me.km.KajetansMod;
  3. import net.minecraft.block.*;
  4. import net.minecraft.block.material.Material;
  5. import net.minecraft.block.state.IBlockState;
  6. import net.minecraft.creativetab.CreativeTabs;
  7. import net.minecraft.entity.Entity;
  8. import net.minecraft.item.ItemBlock;
  9. import net.minecraft.util.math.BlockPos;
  10. import net.minecraft.world.World;
  11. public class BlockBase extends Block
  12. {
  13. protected String name;
  14. private SoundType type;
  15. public BlockBase(Material material, String name, String local)
  16. {
  17. super(material);
  18. this.name = name;
  19. this.setRegistryName(name);
  20. super.setUnlocalizedName(local);
  21. super.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
  22. this.type = super.getSoundType();
  23. }
  24. public void registerItemModel(ItemBlock itemBlock)
  25. {
  26. KajetansMod.proxy.registerItemRenderer(itemBlock, 0, name);
  27. }
  28. @Override
  29. public BlockBase setCreativeTab(CreativeTabs tab)
  30. {
  31. super.setCreativeTab(tab);
  32. return this;
  33. }
  34. @Override
  35. public BlockBase setSoundType(SoundType sound)
  36. {
  37. this.type = sound;
  38. return this;
  39. }
  40. @Override
  41. public SoundType getSoundType(IBlockState state, World world, BlockPos pos, Entity entity)
  42. {
  43. return type;
  44. }
  45. }