Guest User

Untitled

a guest
Feb 23rd, 2019
81
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.sm.FirstMod.blocks;
  2.  
  3. import com.sm.FirstMod.Main;
  4. import com.sm.FirstMod.blocks.tileentity.TileEntityFilingCabinet;
  5. import com.sm.FirstMod.init.ModBlocks;
  6. import com.sm.FirstMod.init.ModItems;
  7. import com.sm.FirstMod.util.Reference;
  8.  
  9. import net.minecraft.block.BlockContainer;
  10. import net.minecraft.block.SoundType;
  11. import net.minecraft.block.material.Material;
  12. import net.minecraft.block.state.IBlockState;
  13. import net.minecraft.entity.EntityLivingBase;
  14. import net.minecraft.entity.player.EntityPlayer;
  15. import net.minecraft.inventory.InventoryHelper;
  16. import net.minecraft.item.ItemBlock;
  17. import net.minecraft.item.ItemStack;
  18. import net.minecraft.tileentity.TileEntity;
  19. import net.minecraft.util.EnumBlockRenderType;
  20. import net.minecraft.util.EnumFacing;
  21. import net.minecraft.util.EnumHand;
  22. import net.minecraft.util.math.BlockPos;
  23. import net.minecraft.world.World;
  24.  
  25. public class FilingCabinet extends BlockContainer
  26. {
  27. public FilingCabinet(String name, Material materialIn)
  28. {
  29. super(materialIn);
  30. setUnlocalizedName(name);
  31. setRegistryName(name);
  32. setCreativeTab(Main.coaxiummod);
  33. setSoundType(SoundType.METAL);
  34. setHardness(11.5F);
  35. setResistance(28.0F);
  36. setHarvestLevel("pickaxe",1); //the stone pickaxe...
  37.  
  38. ModBlocks.BLOCKS.add(this);
  39. ModItems.ITEMS.add(new ItemBlock(this).setRegistryName(name));
  40. }
  41.  
  42. @Override
  43. public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
  44. {
  45. if(!worldIn.isRemote)
  46. {
  47. playerIn.openGui(Main.instance, Reference.FILING_CABINET_GUI, worldIn, pos.getX(), pos.getY(), pos.getZ());
  48. }
  49.  
  50. return true;
  51. }
  52.  
  53. @Override
  54. public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
  55. {
  56. TileEntityFilingCabinet tileentity = (TileEntityFilingCabinet)worldIn.getTileEntity(pos);
  57. InventoryHelper.dropInventoryItems(worldIn, pos, tileentity);
  58. super.breakBlock(worldIn, pos, state);
  59. }
  60.  
  61. @Override
  62. public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
  63. {
  64. if(stack.hasDisplayName())
  65. {
  66. TileEntity tileentity = worldIn.getTileEntity(pos);
  67.  
  68. if(tileentity instanceof TileEntityFilingCabinet)
  69. {
  70. ((TileEntityFilingCabinet)tileentity).setCustomName(stack.getDisplayName());
  71. }
  72. }
  73. }
  74.  
  75. @Override
  76. public TileEntity createNewTileEntity(World worldIn, int meta)
  77. {
  78. return new TileEntityFilingCabinet();
  79. }
  80.  
  81. @Override
  82. public EnumBlockRenderType getRenderType(IBlockState state)
  83. {
  84. //return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
  85. return EnumBlockRenderType.MODEL;
  86. }
  87.  
  88. @Override
  89. public boolean isFullBlock(IBlockState state)
  90. {
  91. return true;
  92. }
  93.  
  94. @Override
  95. public boolean isFullCube(IBlockState state)
  96. {
  97. return true;
  98. }
  99.  
  100. @Override
  101. public boolean isOpaqueCube(IBlockState state)
  102. {
  103. return false;
  104. }
  105.  
  106.  
  107.  
  108. }
RAW Paste Data