Advertisement
hassansyyid

Untitled

Nov 11th, 2015
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. package io.github.hsyyid.wilsonsmp.blocks;
  2.  
  3. import io.github.hsyyid.wilsonsmp.tileentities.TileEntityReadableBookshelf;
  4. import net.minecraft.block.Block;
  5. import net.minecraft.block.material.Material;
  6. import net.minecraft.block.state.IBlockState;
  7. import net.minecraft.entity.player.EntityPlayer;
  8. import net.minecraft.tileentity.TileEntity;
  9. import net.minecraft.util.BlockPos;
  10. import net.minecraft.util.EnumFacing;
  11. import net.minecraft.world.World;
  12.  
  13. public class BlockReadableBookshelf extends Block
  14. {
  15.     public BlockReadableBookshelf()
  16.     {
  17.         super(Material.wood);
  18.     }
  19.  
  20.     @Override
  21.     public boolean hasTileEntity(IBlockState state)
  22.     {
  23.         return true;
  24.     }
  25.  
  26.     @Override
  27.     public TileEntity createTileEntity(World world, IBlockState state)
  28.     {
  29.         return new TileEntityReadableBookshelf();
  30.     }
  31.  
  32.     @Override
  33.     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
  34.     {
  35.         TileEntity tileEntity = world.getTileEntity(pos);
  36.  
  37.         if (tileEntity != null && tileEntity instanceof TileEntityReadableBookshelf)
  38.         {
  39.             TileEntityReadableBookshelf tileEntityBookshelf = (TileEntityReadableBookshelf) tileEntity;
  40.  
  41.             if (!playerIn.isSneaking())
  42.             {
  43.                 tileEntityBookshelf.openGui(playerIn);
  44.             }
  45.         }
  46.  
  47.         return true;
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement