当前位置: 首页>>代码示例>>Java>>正文


Java EntityPlayer.canUseCommandBlock方法代码示例

本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.canUseCommandBlock方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.canUseCommandBlock方法的具体用法?Java EntityPlayer.canUseCommandBlock怎么用?Java EntityPlayer.canUseCommandBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.player.EntityPlayer的用法示例。


在下文中一共展示了EntityPlayer.canUseCommandBlock方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: usedBy

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public boolean usedBy(EntityPlayer player)
{
    if (!player.canUseCommandBlock())
    {
        return false;
    }
    else
    {
        if (player.getEntityWorld().isRemote)
        {
            player.openEditStructure(this);
        }

        return true;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:TileEntityStructure.java

示例2: tryOpenEditCommandBlock

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public boolean tryOpenEditCommandBlock(EntityPlayer playerIn)
{
    if (!playerIn.canUseCommandBlock())
    {
        return false;
    }
    else
    {
        if (playerIn.getEntityWorld().isRemote)
        {
            playerIn.displayGuiEditCommandCart(this);
        }

        return true;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:CommandBlockBaseLogic.java

示例3: onBlockActivated

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (worldIn.isRemote) {
        return true;
    }
    if (!playerIn.canUseCommandBlock()) {
        return false;
    }
    ScriptyNetworkHandler.handleOpenRequest(pos, (EntityPlayerMP) playerIn);
    return true;
}
 
开发者ID:ScriptyMod,项目名称:Scripty,代码行数:12,代码来源:ScriptyBlock.java

示例4: onBlockActivated

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof TileEntityCommandBlock && playerIn.canUseCommandBlock())
    {
        playerIn.displayGuiCommandBlock((TileEntityCommandBlock)tileentity);
        return true;
    }
    else
    {
        return false;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:15,代码来源:BlockCommandBlock.java

示例5: onBlockActivated

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof TileEntityCommandBlock && playerIn.canUseCommandBlock())
    {
        playerIn.displayGuiCommandBlock((TileEntityCommandBlock)tileentity);
        return true;
    }
    else
    {
        return false;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:15,代码来源:BlockCommandBlock.java

示例6: rightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private boolean rightClick(BlockPos pos) {
    EnumFacing faceDir = ProgWidgetPlace.getDirForSides(((ISidedWidget) widget).getSides());
    EntityPlayer player = drone.getFakePlayer();
    World world = drone.world();
    ItemStack stack = player.getHeldItemMainhand();

    player.setPosition(pos.getX() + 0.5, pos.getY() + 0.5 - player.eyeHeight, pos.getZ() + 0.5);
    player.rotationPitch = faceDir.getFrontOffsetY() * -90;
    player.rotationYaw = PneumaticCraftUtils.getYawFromFacing(faceDir);

    float hitX = (float)(player.posX - pos.getX());
    float hitY = (float)(player.posY - pos.getY());
    float hitZ = (float)(player.posZ - pos.getZ());

    // this is adapted from PlayerInteractionManager#processRightClickBlock()
    try {
        PlayerInteractEvent.RightClickBlock event = ForgeHooks.onRightClickBlock(player, EnumHand.MAIN_HAND, pos, faceDir.getOpposite(),  ForgeHooks.rayTraceEyeHitVec(player, 2.0D));
        if (event.isCanceled() || event.getUseItem() == Event.Result.DENY) {
            return false;
        }

        EnumActionResult ret = stack.onItemUseFirst(player, world, pos, EnumHand.MAIN_HAND, faceDir, hitX, hitY, hitZ);
        if (ret != EnumActionResult.PASS) return false;

        boolean bypass = player.getHeldItemMainhand().doesSneakBypassUse(world, pos, player);
        EnumActionResult result = EnumActionResult.PASS;

        if (!player.isSneaking() || bypass || event.getUseBlock() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW) {
            IBlockState iblockstate = world.getBlockState(pos);
            if(event.getUseBlock() != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY)
                if (iblockstate.getBlock().onBlockActivated(world, pos, iblockstate, player, EnumHand.MAIN_HAND, faceDir, hitX, hitY, hitZ)) {
                    result = EnumActionResult.SUCCESS;
                }
        }

        if (stack.isEmpty() || player.getCooldownTracker().hasCooldown(stack.getItem())) {
            return false;
        }

        if (stack.getItem() instanceof ItemBlock && !player.canUseCommandBlock()) {
            Block block = ((ItemBlock)stack.getItem()).getBlock();
            if (block instanceof BlockCommandBlock || block instanceof BlockStructure) {
                return false;
            }
        }

        if (result != EnumActionResult.SUCCESS && event.getUseItem() != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY
                || result == EnumActionResult.SUCCESS && event.getUseItem() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW) {
            ItemStack copyBeforeUse = stack.copy();
            result = stack.onItemUse(player, world, pos, EnumHand.MAIN_HAND, faceDir, hitX, hitY, hitZ);
            if (result == EnumActionResult.PASS) {
                ActionResult<ItemStack> rightClickResult = stack.getItem().onItemRightClick(world, player, EnumHand.MAIN_HAND);
                player.setHeldItem(EnumHand.MAIN_HAND, rightClickResult.getResult());
            }
            if (player.getHeldItem(EnumHand.MAIN_HAND).isEmpty()) {
                net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, copyBeforeUse, EnumHand.MAIN_HAND);
            }
        }

        return false;
    } catch (Throwable e) {
        Log.error("DroneAIBlockInteract crashed! Stacktrace: ");
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:67,代码来源:DroneAIBlockInteract.java

示例7: setTileEntityNBT

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static boolean setTileEntityNBT(World worldIn, @Nullable EntityPlayer player, BlockPos pos, ItemStack stackIn)
{
    MinecraftServer minecraftserver = worldIn.getMinecraftServer();

    if (minecraftserver == null)
    {
        return false;
    }
    else
    {
        NBTTagCompound nbttagcompound = stackIn.getSubCompound("BlockEntityTag");

        if (nbttagcompound != null)
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity != null)
            {
                if (!worldIn.isRemote && tileentity.onlyOpsCanSetNbt() && (player == null || !player.canUseCommandBlock()))
                {
                    return false;
                }

                NBTTagCompound nbttagcompound1 = tileentity.writeToNBT(new NBTTagCompound());
                NBTTagCompound nbttagcompound2 = nbttagcompound1.copy();
                nbttagcompound1.merge(nbttagcompound);
                nbttagcompound1.setInteger("x", pos.getX());
                nbttagcompound1.setInteger("y", pos.getY());
                nbttagcompound1.setInteger("z", pos.getZ());

                if (!nbttagcompound1.equals(nbttagcompound2))
                {
                    tileentity.readFromNBT(nbttagcompound1);
                    tileentity.markDirty();
                    return true;
                }
            }
        }

        return false;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:43,代码来源:ItemBlock.java

示例8: processRightClickBlock

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public EnumActionResult processRightClickBlock(EntityPlayer player, World worldIn, ItemStack stack, EnumHand hand, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    if (this.gameType == GameType.SPECTATOR)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof ILockableContainer)
        {
            Block block1 = worldIn.getBlockState(pos).getBlock();
            ILockableContainer ilockablecontainer = (ILockableContainer)tileentity;

            if (ilockablecontainer instanceof TileEntityChest && block1 instanceof BlockChest)
            {
                ilockablecontainer = ((BlockChest)block1).getLockableContainer(worldIn, pos);
            }

            if (ilockablecontainer != null)
            {
                player.displayGUIChest(ilockablecontainer);
                return EnumActionResult.SUCCESS;
            }
        }
        else if (tileentity instanceof IInventory)
        {
            player.displayGUIChest((IInventory)tileentity);
            return EnumActionResult.SUCCESS;
        }

        return EnumActionResult.PASS;
    }
    else
    {
        if (!player.isSneaking() || player.getHeldItemMainhand().func_190926_b() && player.getHeldItemOffhand().func_190926_b())
        {
            IBlockState iblockstate = worldIn.getBlockState(pos);

            if (iblockstate.getBlock().onBlockActivated(worldIn, pos, iblockstate, player, hand, facing, hitX, hitY, hitZ))
            {
                return EnumActionResult.SUCCESS;
            }
        }

        if (stack.func_190926_b())
        {
            return EnumActionResult.PASS;
        }
        else if (player.getCooldownTracker().hasCooldown(stack.getItem()))
        {
            return EnumActionResult.PASS;
        }
        else
        {
            if (stack.getItem() instanceof ItemBlock && !player.canUseCommandBlock())
            {
                Block block = ((ItemBlock)stack.getItem()).getBlock();

                if (block instanceof BlockCommandBlock || block instanceof BlockStructure)
                {
                    return EnumActionResult.FAIL;
                }
            }

            if (this.isCreative())
            {
                int j = stack.getMetadata();
                int i = stack.func_190916_E();
                EnumActionResult enumactionresult = stack.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
                stack.setItemDamage(j);
                stack.func_190920_e(i);
                return enumactionresult;
            }
            else
            {
                return stack.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:79,代码来源:PlayerInteractionManager.java

示例9: setTileEntityNBT

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static boolean setTileEntityNBT(World worldIn, @Nullable EntityPlayer player, BlockPos pos, ItemStack stackIn)
{
    MinecraftServer minecraftserver = worldIn.getMinecraftServer();

    if (minecraftserver == null)
    {
        return false;
    }
    else
    {
        if (stackIn.hasTagCompound() && stackIn.getTagCompound().hasKey("BlockEntityTag", 10))
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity != null)
            {
                if (!worldIn.isRemote && tileentity.onlyOpsCanSetNbt() && (player == null || !player.canUseCommandBlock()))
                {
                    return false;
                }

                NBTTagCompound nbttagcompound = tileentity.writeToNBT(new NBTTagCompound());
                NBTTagCompound nbttagcompound1 = nbttagcompound.copy();
                NBTTagCompound nbttagcompound2 = (NBTTagCompound)stackIn.getTagCompound().getTag("BlockEntityTag");
                nbttagcompound.merge(nbttagcompound2);
                nbttagcompound.setInteger("x", pos.getX());
                nbttagcompound.setInteger("y", pos.getY());
                nbttagcompound.setInteger("z", pos.getZ());

                if (!nbttagcompound.equals(nbttagcompound1))
                {
                    tileentity.readFromNBT(nbttagcompound);
                    tileentity.markDirty();
                    return true;
                }
            }
        }

        return false;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:42,代码来源:ItemBlock.java


注:本文中的net.minecraft.entity.player.EntityPlayer.canUseCommandBlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。