Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
- {
- ItemStack itemstack = player.getHeldItem(hand);
- if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack))
- {
- IBlockState iblockstate = worldIn.getBlockState(pos);
- Block block = iblockstate.getBlock();
- BlockPos blockpos = pos;
- if ((facing != EnumFacing.UP || block != this.block) && !block.isReplaceable(worldIn, pos))
- {
- blockpos = pos.offset(facing);
- iblockstate = worldIn.getBlockState(blockpos);
- block = iblockstate.getBlock();
- }
- if (block == this.block)
- {
- int i = ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue();
- if (i < 8)
- {
- IBlockState iblockstate1 = iblockstate.withProperty(BlockSnow.LAYERS, Integer.valueOf(i + 1));
- AxisAlignedBB axisalignedbb = iblockstate1.getCollisionBoundingBox(worldIn, blockpos);
- if (axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(blockpos)) && worldIn.setBlockState(blockpos, iblockstate1, 10))
- {
- SoundType soundtype = this.block.getSoundType(iblockstate1, worldIn, pos, player);
- worldIn.playSound(player, blockpos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
- if (player instanceof EntityPlayerMP)
- {
- CriteriaTriggers.PLACED_BLOCK.trigger((EntityPlayerMP)player, pos, itemstack);
- }
- itemstack.shrink(1);
- return EnumActionResult.SUCCESS;
- }
- }
- }
- return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
- }
- else
- {
- return EnumActionResult.FAIL;
- }
- }
Add Comment
Please, Sign In to add comment