Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
- {
- if (worldIn.isRemote)
- return false;
- if (playerIn.getHeldItem(hand) == null)
- {
- IBlockState newState;
- switch(state.getValue(BlockBookcaseMulti.TYPE))
- {
- // 2/3 full
- case two3:
- newState = state.withProperty(TYPE, EnumBookshelf.two2);
- break;
- // 1/3 full
- case two2:
- newState = state.withProperty(TYPE, EnumBookshelf.one1);
- break;
- //Empty
- default:
- // Can't empty an empty bookcase
- return false;
- }
- worldIn.setBlockState(pos, newState);
- playerIn.inventory.addItemStackToInventory(new ItemStack(Items.BOOK));
- return true;
- }
- ItemStack book = new ItemStack(Items.BOOK);
- if (playerIn.getHeldItemMainhand() == book)
- {
- IBlockState newState;
- switch (state.getValue(BlockBookcaseMulti.TYPE))
- {
- case one1:
- newState = state.withProperty(TYPE, EnumBookshelf.two2);
- break;
- case two2:
- newState = state.withProperty(TYPE, EnumBookshelf.two3);
- break;
- case two3:
- newState = Blocks.BOOKSHELF.getDefaultState();
- break;
- default:
- // For completeness
- return false;
- }
- worldIn.setBlockState(pos, newState);
- --heldItem.stackSize;
- return true;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement