Eragonn14900

Untitled

Dec 5th, 2016
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. @Override
  2. public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
  3. {
  4. ItemStack stack = playerIn.getHeldItem(hand);
  5. ItemStack stacktoAdd = new ItemStack(Items.BOOK);
  6.  
  7. final IBlockState set0 = IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.one1); // Empty
  8. final IBlockState set1 = IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.two2); // 1/3 full
  9. final IBlockState set2 = IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.two3); // 2/3 full
  10. final IBlockState set3 = IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.three1);// full
  11.  
  12. if (!worldIn.isRemote)
  13. {
  14. if(stack != null && playerIn.getHeldItemMainhand().getItem() == Items.BOOK)
  15. {
  16. if (state.getValue(BlockBookcaseMulti.TYPE) == EnumBookshelf.one1)
  17. {
  18. System.out.println("changed into +1");
  19. worldIn.setBlockState(pos, set1);
  20. --stack.stackSize;
  21. return true;
  22.  
  23. }
  24. if (state.getValue(BlockBookcaseMulti.TYPE) == EnumBookshelf.two2)
  25. {
  26. System.out.println("changed into +2");
  27. worldIn.setBlockState(pos, set2);
  28. --stack.stackSize;
  29. return true;
  30. }
  31. if (state.getValue(BlockBookcaseMulti.TYPE) == EnumBookshelf.two3)
  32. {
  33. System.out.println("changed into +3");
  34. worldIn.setBlockState(pos, Blocks.BOOKSHELF.getDefaultState());
  35. --stack.stackSize;
  36. return true;
  37. }
  38. }
  39.  
  40. if (stack == null && state.getValue(BlockBookcaseMulti.TYPE) == EnumBookshelf.two3)// 2/3 full
  41. {
  42. System.out.println("changed back into -2");
  43. worldIn.setBlockState(pos, set1);
  44. playerIn.inventory.addItemStackToInventory(stacktoAdd);
  45. return true;
  46. }
  47. if (stack == null && state.getValue(BlockBookcaseMulti.TYPE) == EnumBookshelf.two2) //back to empty
  48. {
  49. System.out.println("changed back into -1");
  50. worldIn.setBlockState(pos, set0);
  51. playerIn.inventory.addItemStackToInventory(stacktoAdd);
  52. return true;
  53. }
  54. else
  55. {
  56. return false;
  57. }
  58. }
  59. else
  60. {
  61. return false;
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment