Advertisement
Eragonn14900

Untitled

Dec 5th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 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. else
  24. {
  25. return false;
  26. }
  27. }
  28. if (state.getValue(BlockBookcaseMulti.TYPE) == EnumBookshelf.two2)
  29. {
  30. if (!worldIn.isRemote)
  31. {
  32. System.out.println("changed into +2");
  33. worldIn.setBlockState(pos, set2);
  34. --stack.stackSize;
  35. return true;
  36. }
  37. else
  38. {
  39. return false;
  40. }
  41. }
  42. if (state.getValue(BlockBookcaseMulti.TYPE) == EnumBookshelf.two3)
  43. {
  44. if (!worldIn.isRemote)
  45. {
  46. System.out.println("changed into +3");
  47. worldIn.setBlockState(pos, Blocks.BOOKSHELF.getDefaultState());
  48. --stack.stackSize;
  49. return true;
  50. }
  51. else
  52. {
  53. return false;
  54. }
  55. }
  56. else
  57. {
  58. return false;
  59. }
  60. }
  61. else if(stack == null)
  62. {
  63. if (state.getValue(BlockBookcaseMulti.TYPE) == EnumBookshelf.two3)// 2/3 full
  64. {
  65. if (!worldIn.isRemote)
  66. {
  67. System.out.println("changed back into -2");
  68. worldIn.setBlockState(pos, set1);
  69. playerIn.inventory.addItemStackToInventory(stacktoAdd);
  70. return true;
  71. }
  72. else
  73. {
  74. return false;
  75. }
  76. }
  77. if (state.getValue(BlockBookcaseMulti.TYPE) == EnumBookshelf.two2) //back to empty
  78. {
  79. if (!worldIn.isRemote)
  80. {
  81. System.out.println("changed back into -1");
  82. worldIn.setBlockState(pos, set0);
  83. playerIn.inventory.addItemStackToInventory(stacktoAdd);
  84. return true;
  85. }
  86. else
  87. {
  88. return false;
  89. }
  90. }
  91. else
  92. {
  93. return false;
  94. }
  95. }
  96. else
  97. {
  98. return false;
  99. }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement