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)
- {
- ItemStack stack = playerIn.getHeldItem(hand);
- ItemStack stacktoAdd = new ItemStack(Items.BOOK);
- final IBlockState set0 = IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.one1); // Empty
- final IBlockState set1 = IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.two2); // 1/3 full
- final IBlockState set2 = IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.two3); // 2/3 full
- final IBlockState set3 = IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.three1);// full
- if(stack != null && playerIn.getHeldItemMainhand().getItem() == Items.BOOK)
- {
- if (state.getValue(BlockBookcaseMulti.TYPE) == EnumBookshelf.one1)
- {
- if (worldIn.isRemote)
- {
- System.out.println("changed into +1");
- worldIn.setBlockState(pos, set1);
- --stack.stackSize;
- return true;
- }
- }
- if (state.getValue(BlockBookcaseMulti.TYPE) == EnumBookshelf.two2)
- {
- if (worldIn.isRemote)
- {
- System.out.println("changed into +2");
- worldIn.setBlockState(pos, set2);
- --stack.stackSize;
- }
- return true;
- }
- if (state.getValue(BlockBookcaseMulti.TYPE) == EnumBookshelf.two3)
- {
- if (worldIn.isRemote)
- {
- System.out.println("changed into +3");
- worldIn.setBlockState(pos, Blocks.BOOKSHELF.getDefaultState());
- --stack.stackSize;
- }
- return true;
- }
- }
- if(stack == null)
- {
- if (state.getValue(BlockBookcaseMulti.TYPE) == EnumBookshelf.two3)// 2/3 full
- {
- if (worldIn.isRemote)
- {
- System.out.println("changed back into -2");
- worldIn.setBlockState(pos, set1);
- playerIn.inventory.addItemStackToInventory(stacktoAdd);
- return true;
- }
- }
- if (state.getValue(BlockBookcaseMulti.TYPE) == EnumBookshelf.two2) //back to empty
- {
- if (worldIn.isRemote)
- {
- System.out.println("changed back into -1");
- worldIn.setBlockState(pos, set0);
- playerIn.inventory.addItemStackToInventory(stacktoAdd);
- return true;
- }
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement