Advertisement
PSquishyP

BlockStonesChest

Nov 3rd, 2015
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. package noahc3.abilitystones.blocks;
  2.  
  3. import net.minecraft.block.BlockContainer;
  4. import net.minecraft.block.material.Material;
  5. import net.minecraft.block.state.IBlockState;
  6. import net.minecraft.entity.EntityLivingBase;
  7. import net.minecraft.entity.player.EntityPlayer;
  8. import net.minecraft.inventory.InventoryHelper;
  9. import net.minecraft.item.ItemStack;
  10. import net.minecraft.tileentity.TileEntity;
  11. import net.minecraft.util.BlockPos;
  12. import net.minecraft.util.EnumFacing;
  13. import net.minecraft.util.EnumWorldBlockLayer;
  14. import net.minecraft.world.World;
  15. import noahc3.abilitystones.AbilityStones;
  16. import noahc3.abilitystones.gui.ASGuiHandler;
  17. import noahc3.abilitystones.tileentity.StonesChestTileEntity;
  18.  
  19. public class BlockStonesChest extends BlockContainer
  20. {
  21.  
  22.  
  23. public BlockStonesChest(Material materialIn) {
  24. super(materialIn);
  25.  
  26. }
  27.  
  28. @Override
  29. public TileEntity createNewTileEntity(World worldIn, int meta) {
  30. return (TileEntity) new StonesChestTileEntity();
  31. }
  32.  
  33. @Override
  34. public EnumWorldBlockLayer getBlockLayer() {
  35.  
  36. return EnumWorldBlockLayer.CUTOUT;
  37. }
  38.  
  39. public boolean isOpaqueCube() {
  40.  
  41. return true;
  42. }
  43.  
  44. public int getRenderType()
  45. {
  46. return 3;
  47. }
  48.  
  49. @Override
  50. public void breakBlock(World world, BlockPos pos, IBlockState blockstate) {
  51. StonesChestTileEntity te = (StonesChestTileEntity) world.getTileEntity(pos);
  52. InventoryHelper.dropInventoryItems(world, pos, te);
  53. super.breakBlock(world, pos, blockstate);
  54. }
  55.  
  56.  
  57. @Override
  58. public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
  59. if (stack.hasDisplayName()) {
  60. ((StonesChestTileEntity) worldIn.getTileEntity(pos)).setCustomName(stack.getDisplayName());
  61. }
  62. }
  63.  
  64. @Override
  65. public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) {
  66. if (!world.isRemote) {
  67. player.openGui(AbilityStones.instance, ASGuiHandler.MOD_TILE_ENTITY_GUI, world, pos.getX(), pos.getY(), pos.getZ());
  68. }
  69. return true;
  70. }
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement