Advertisement
Eragonn14900

Untitled

Dec 5th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 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(stack != null && playerIn.getHeldItemMainhand().getItem() == Items.BOOK)
  13. {
  14. if (state.getValue(BlockBookcaseMulti.TYPE) == EnumBookshelf.one1)
  15. {
  16. if (worldIn.isRemote)
  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. if (worldIn.isRemote)
  27. {
  28. System.out.println("changed into +2");
  29. worldIn.setBlockState(pos, set2);
  30. --stack.stackSize;
  31. return true;
  32. }
  33. }
  34. if (state.getValue(BlockBookcaseMulti.TYPE) == EnumBookshelf.two3)
  35. {
  36. if (worldIn.isRemote)
  37. {
  38. System.out.println("changed into +3");
  39. worldIn.setBlockState(pos, Blocks.BOOKSHELF.getDefaultState());
  40. --stack.stackSize;
  41. return true;
  42. }
  43. }
  44. }
  45. if(stack == null)
  46. {
  47. if (state.getValue(BlockBookcaseMulti.TYPE) == EnumBookshelf.two3)// 2/3 full
  48. {
  49. if (worldIn.isRemote)
  50. {
  51. System.out.println("changed back into -2");
  52. worldIn.setBlockState(pos, set1);
  53. playerIn.inventory.addItemStackToInventory(stacktoAdd);
  54. return true;
  55. }
  56. }
  57. if (state.getValue(BlockBookcaseMulti.TYPE) == EnumBookshelf.two2) //back to empty
  58. {
  59. if (worldIn.isRemote)
  60. {
  61. System.out.println("changed back into -1");
  62. worldIn.setBlockState(pos, set0);
  63. playerIn.inventory.addItemStackToInventory(stacktoAdd);
  64. return true;
  65. }
  66. }
  67. }
  68.  
  69. return false;
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement