BlockBase.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package me.km.blocks;
  2. import me.km.KajetansMod;
  3. import net.minecraft.block.*;
  4. import net.minecraft.block.material.MapColor;
  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.math.BlockPos;
  11. import net.minecraft.world.IBlockAccess;
  12. import net.minecraft.world.World;
  13. public class BlockBase extends Block implements IBlockBase
  14. {
  15. protected String name;
  16. private SoundType type;
  17. private MapColor mapColor;
  18. public BlockBase(Material material, String name, String local)
  19. {
  20. super(material);
  21. this.name = name;
  22. this.setRegistryName(name);
  23. super.setUnlocalizedName(local);
  24. super.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
  25. this.type = super.getSoundType();
  26. this.mapColor = blockMapColor;
  27. }
  28. public BlockBase setMapColor(MapColor mapColor)
  29. {
  30. this.mapColor = mapColor;
  31. return this;
  32. }
  33. @Override
  34. public MapColor getMapColor(IBlockState state, IBlockAccess worldIn, BlockPos pos)
  35. {
  36. return this.mapColor;
  37. }
  38. @Override
  39. public void registerItemModel(Item itemBlock)
  40. {
  41. KajetansMod.proxy.registerItemRenderer(itemBlock, 0, name);
  42. }
  43. @Override
  44. public BlockBase setCreativeTab(CreativeTabs tab)
  45. {
  46. super.setCreativeTab(tab);
  47. return this;
  48. }
  49. @Override
  50. public BlockBase setSoundType(SoundType sound)
  51. {
  52. this.type = sound;
  53. return this;
  54. }
  55. @Override
  56. public SoundType getSoundType(IBlockState state, World world, BlockPos pos, Entity entity)
  57. {
  58. return type;
  59. }
  60. }