Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Change Meta
- 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 stacktosubtract = new ItemStack(Items.BOOK);
- ItemStack stacktoadd = new ItemStack(Items.BOOK);
- //Change from empty to partially filled
- if (IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.one1) != null)
- {
- System.out.println("hi");
- if(heldItem.getItem() == Items.BOOK)
- {
- System.out.println("changed into 1");
- worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(TYPE, EnumBookshelf.two2));
- --stacktosubtract.stackSize;
- return true;
- }
- }
- //Change from 1/3 to 2/3 filled
- if (IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.two2) != null)
- {
- if(heldItem.getItem() == Items.BOOK)
- {
- System.out.println("changed into 2");
- worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(TYPE, EnumBookshelf.two3));
- --stacktosubtract.stackSize;
- return true;
- }
- }
- //Change from 2/3 to filled
- if (IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.two3) != null)
- {
- if(heldItem.getItem() == Items.BOOK)
- {
- System.out.println("changed into 3");
- worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(TYPE, EnumBookshelf.three1));
- --stacktosubtract.stackSize;
- return true;
- }
- }
- //Change from 2/3 to filled
- if (IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.two3) != null)
- {
- if(heldItem.getItem() == Items.BOOK)
- {
- System.out.println("changed into 3");
- worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(TYPE, EnumBookshelf.three1));
- --stacktosubtract.stackSize;
- return true;
- }
- }
- //Change from filled to 2/3
- if (IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.three1) != null)
- {
- if(heldItem.getItem() == null)
- {
- worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(TYPE, EnumBookshelf.two3));
- playerIn.inventory.addItemStackToInventory(stacktoadd);
- return true;
- }
- }
- //Change from 2/3 to 1/3
- if (IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.two3) != null)
- {
- if(heldItem.getItem() == null)
- {
- worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(TYPE, EnumBookshelf.two2));
- playerIn.inventory.addItemStackToInventory(stacktoadd);
- return true;
- }
- }
- //Change from 1/3 to empty
- if (IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.two2) != null)
- {
- if(heldItem.getItem() == null)
- {
- worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(TYPE, EnumBookshelf.one1));
- playerIn.inventory.addItemStackToInventory(stacktoadd);
- return true;
- }
- }
- else
- {
- worldIn.setBlockToAir(pos);
- return true;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement