ItemSalt.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:Bewitchment 作者:
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    final boolean flag = worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos);
    final BlockPos blockpos = flag ? pos : pos.offset(facing);

    ItemStack stack = playerIn.getHeldItem(hand);
    if (playerIn.canPlayerEdit(blockpos, facing, stack) && worldIn.mayPlace(worldIn.getBlockState(blockpos).getBlock(), blockpos, false, facing, playerIn) && ModBlocks.salt_barrier.canPlaceBlockAt(worldIn, blockpos)) {
        stack.shrink(1);
        worldIn.setBlockState(blockpos, ModBlocks.salt_barrier.getDefaultState());
        return EnumActionResult.SUCCESS;
    } else {
        return EnumActionResult.FAIL;
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号