irgendwas

Untitled

Sep 18th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.20 KB | None | 0 0
  1. public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
  2.     {
  3.         ItemStack itemstack = player.getHeldItem(hand);
  4.  
  5.         if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack))
  6.         {
  7.             IBlockState iblockstate = worldIn.getBlockState(pos);
  8.             Block block = iblockstate.getBlock();
  9.             BlockPos blockpos = pos;
  10.  
  11.             if ((facing != EnumFacing.UP || block != this.block) && !block.isReplaceable(worldIn, pos))
  12.             {
  13.                 blockpos = pos.offset(facing);
  14.                 iblockstate = worldIn.getBlockState(blockpos);
  15.                 block = iblockstate.getBlock();
  16.             }
  17.  
  18.             if (block == this.block)
  19.             {
  20.                 int i = ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue();
  21.  
  22.                 if (i < 8)
  23.                 {
  24.                     IBlockState iblockstate1 = iblockstate.withProperty(BlockSnow.LAYERS, Integer.valueOf(i + 1));
  25.                     AxisAlignedBB axisalignedbb = iblockstate1.getCollisionBoundingBox(worldIn, blockpos);
  26.  
  27.                     if (axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(blockpos)) && worldIn.setBlockState(blockpos, iblockstate1, 10))
  28.                     {
  29.                         SoundType soundtype = this.block.getSoundType(iblockstate1, worldIn, pos, player);
  30.                         worldIn.playSound(player, blockpos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
  31.  
  32.                         if (player instanceof EntityPlayerMP)
  33.                         {
  34.                             CriteriaTriggers.PLACED_BLOCK.trigger((EntityPlayerMP)player, pos, itemstack);
  35.                         }
  36.  
  37.                         itemstack.shrink(1);
  38.                         return EnumActionResult.SUCCESS;
  39.                     }
  40.                 }
  41.             }
  42.  
  43.             return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
  44.         }
  45.         else
  46.         {
  47.             return EnumActionResult.FAIL;
  48.         }
  49.     }
Advertisement
Add Comment
Please, Sign In to add comment