本文整理汇总了Java中net.minecraft.client.entity.EntityPlayerSP.canUseCommandBlock方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayerSP.canUseCommandBlock方法的具体用法?Java EntityPlayerSP.canUseCommandBlock怎么用?Java EntityPlayerSP.canUseCommandBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.client.entity.EntityPlayerSP
的用法示例。
在下文中一共展示了EntityPlayerSP.canUseCommandBlock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processRightClickBlock
import net.minecraft.client.entity.EntityPlayerSP; //导入方法依赖的package包/类
public EnumActionResult processRightClickBlock(EntityPlayerSP player, WorldClient worldIn, BlockPos stack, EnumFacing pos, Vec3d facing, EnumHand vec)
{
this.syncCurrentPlayItem();
ItemStack itemstack = player.getHeldItem(vec);
float f = (float)(facing.xCoord - (double)stack.getX());
float f1 = (float)(facing.yCoord - (double)stack.getY());
float f2 = (float)(facing.zCoord - (double)stack.getZ());
boolean flag = false;
if (!this.mc.world.getWorldBorder().contains(stack))
{
return EnumActionResult.FAIL;
}
else
{
if (this.currentGameType != GameType.SPECTATOR)
{
IBlockState iblockstate = worldIn.getBlockState(stack);
if ((!player.isSneaking() || player.getHeldItemMainhand().func_190926_b() && player.getHeldItemOffhand().func_190926_b()) && iblockstate.getBlock().onBlockActivated(worldIn, stack, iblockstate, player, vec, pos, f, f1, f2))
{
flag = true;
}
if (!flag && itemstack.getItem() instanceof ItemBlock)
{
ItemBlock itemblock = (ItemBlock)itemstack.getItem();
if (!itemblock.canPlaceBlockOnSide(worldIn, stack, pos, player, itemstack))
{
return EnumActionResult.FAIL;
}
}
}
this.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(stack, pos, vec, f, f1, f2));
if (!flag && this.currentGameType != GameType.SPECTATOR)
{
if (itemstack.func_190926_b())
{
return EnumActionResult.PASS;
}
else if (player.getCooldownTracker().hasCooldown(itemstack.getItem()))
{
return EnumActionResult.PASS;
}
else
{
if (itemstack.getItem() instanceof ItemBlock && !player.canUseCommandBlock())
{
Block block = ((ItemBlock)itemstack.getItem()).getBlock();
if (block instanceof BlockCommandBlock || block instanceof BlockStructure)
{
return EnumActionResult.FAIL;
}
}
if (this.currentGameType.isCreative())
{
int i = itemstack.getMetadata();
int j = itemstack.func_190916_E();
EnumActionResult enumactionresult = itemstack.onItemUse(player, worldIn, stack, vec, pos, f, f1, f2);
itemstack.setItemDamage(i);
itemstack.func_190920_e(j);
return enumactionresult;
}
else
{
return itemstack.onItemUse(player, worldIn, stack, vec, pos, f, f1, f2);
}
}
}
else
{
return EnumActionResult.SUCCESS;
}
}
}