Eragonn14900

Untitled

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