Advertisement
Guest User

sugaaar

a guest
May 23rd, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
  2. {
  3. IBlockState iblockstate = worldIn.getBlockState(pos);
  4. Block block = iblockstate.getBlock();
  5.  
  6. if (block == Blocks.snow_layer && ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue() < 1)
  7. {
  8. side = EnumFacing.UP;
  9. }
  10. else if (!block.isReplaceable(worldIn, pos))
  11. {
  12. pos = pos.offset(side);
  13. }
  14.  
  15. if (!playerIn.canPlayerEdit(pos, side, stack))
  16. {
  17. return false;
  18. }
  19. else if (stack.stackSize == 0)
  20. {
  21. return false;
  22. }
  23. else
  24. {
  25. if (worldIn.canBlockBePlaced(this.block, pos, false, side, (Entity)null, stack))
  26. {
  27. IBlockState iblockstate1 = this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, 0, playerIn);
  28.  
  29. if (worldIn.setBlockState(pos, iblockstate1, 3))
  30. {
  31. iblockstate1 = worldIn.getBlockState(pos);
  32.  
  33. if (iblockstate1.getBlock() == this.block)
  34. {
  35. ItemBlock.setTileEntityNBT(worldIn, pos, stack);
  36. iblockstate1.getBlock().onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack);
  37. }
  38.  
  39. worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F);
  40. --stack.stackSize;
  41. return true;
  42. }
  43. }
  44.  
  45. return false;
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement