Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SubscribeEvent //Turn Regular Bookcase into my partially empty one
- public void onPlayerClickEvent(RightClickBlock event)
- {
- EnumHand hand = event.getHand();
- ItemStack stacktoAdd = new ItemStack(Items.BOOK);
- ItemStack stack = event.getEntityPlayer().getHeldItem(hand);
- final IBlockState set2 = IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.two3); // 2/3 full
- if (!event.getWorld().isRemote)
- {
- if (event.getEntity() instanceof EntityPlayer)
- {
- //If Hand is empty //If Block is a bookshelf
- if (stack == null && event.getWorld().getBlockState(event.getPos()).getBlock() == Blocks.BOOKSHELF)
- {
- //Set block to 2/3 full bookcase
- event.getWorld().setBlockState(event.getPos(), set2);
- //Add Book to inventory
- event.getEntityPlayer().inventory.addItemStackToInventory(stacktoAdd);
- System.out.println("Hey i changed back");//Notify Console
- }
- if (stack != null && event.getWorld().getBlockState(event.getPos()).getBlock() == Blocks.BOOKSHELF)
- {
- //Cancel event if you have an item in your hand
- event.isCanceled();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment