Advertisement
Eragonn14900

Untitled

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