@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;
}
}
ItemSalt.java 文件源码
java
阅读 25
收藏 0
点赞 0
评论 0
项目:Bewitchment
作者:
评论列表
文章目录