Advertisement
Eragonn14900

Untitled

Nov 28th, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. //Change Meta
  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 stacktosubtract = new ItemStack(Items.BOOK);
  5. ItemStack stacktoadd = new ItemStack(Items.BOOK);
  6. //Change from empty to partially filled
  7. if (IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.one1) != null)
  8. {
  9. System.out.println("hi");
  10.  
  11. if(heldItem.getItem() == Items.BOOK)
  12. {
  13. System.out.println("changed into 1");
  14. worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(TYPE, EnumBookshelf.two2));
  15. --stacktosubtract.stackSize;
  16. return true;
  17. }
  18.  
  19. }
  20.  
  21. //Change from 1/3 to 2/3 filled
  22. if (IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.two2) != null)
  23. {
  24. if(heldItem.getItem() == Items.BOOK)
  25. {
  26. System.out.println("changed into 2");
  27. worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(TYPE, EnumBookshelf.two3));
  28. --stacktosubtract.stackSize;
  29. return true;
  30. }
  31. }
  32.  
  33. //Change from 2/3 to filled
  34. if (IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.two3) != null)
  35. {
  36. if(heldItem.getItem() == Items.BOOK)
  37. {
  38. System.out.println("changed into 3");
  39. worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(TYPE, EnumBookshelf.three1));
  40. --stacktosubtract.stackSize;
  41. return true;
  42. }
  43. }
  44.  
  45. //Change from 2/3 to filled
  46. if (IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.two3) != null)
  47. {
  48. if(heldItem.getItem() == Items.BOOK)
  49. {
  50. System.out.println("changed into 3");
  51. worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(TYPE, EnumBookshelf.three1));
  52. --stacktosubtract.stackSize;
  53. return true;
  54. }
  55. }
  56.  
  57. //Change from filled to 2/3
  58. if (IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.three1) != null)
  59. {
  60. if(heldItem.getItem() == null)
  61. {
  62. worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(TYPE, EnumBookshelf.two3));
  63. playerIn.inventory.addItemStackToInventory(stacktoadd);
  64. return true;
  65. }
  66. }
  67.  
  68. //Change from 2/3 to 1/3
  69. if (IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.two3) != null)
  70. {
  71. if(heldItem.getItem() == null)
  72. {
  73. worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(TYPE, EnumBookshelf.two2));
  74. playerIn.inventory.addItemStackToInventory(stacktoadd);
  75. return true;
  76. }
  77. }
  78.  
  79. //Change from 1/3 to empty
  80. if (IntegratedBlocks.bookcases.getDefaultState().withProperty(BlockBookcaseMulti.TYPE, EnumBookshelf.two2) != null)
  81. {
  82. if(heldItem.getItem() == null)
  83. {
  84. worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(TYPE, EnumBookshelf.one1));
  85. playerIn.inventory.addItemStackToInventory(stacktoadd);
  86. return true;
  87. }
  88. }
  89.  
  90. else
  91. {
  92. worldIn.setBlockToAir(pos);
  93. return true;
  94. }
  95. return true;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement