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


Java ItemStack.canDestroy方法代码示例

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


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

示例1: isDrawBlockOutline

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private boolean isDrawBlockOutline()
{
    if (!this.drawBlockOutline)
    {
        return false;
    }
    else
    {
        Entity entity = this.mc.getRenderViewEntity();
        boolean flag = entity instanceof EntityPlayer && !this.mc.gameSettings.hideGUI;

        if (flag && !((EntityPlayer)entity).capabilities.allowEdit)
        {
            ItemStack itemstack = ((EntityPlayer)entity).getCurrentEquippedItem();

            if (this.mc.objectMouseOver != null && this.mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
            {
                BlockPos blockpos = this.mc.objectMouseOver.getBlockPos();
                Block block = this.mc.theWorld.getBlockState(blockpos).getBlock();

                if (this.mc.playerController.getCurrentGameType() == WorldSettings.GameType.SPECTATOR)
                {
                    flag = block.hasTileEntity() && this.mc.theWorld.getTileEntity(blockpos) instanceof IInventory;
                }
                else
                {
                    flag = itemstack != null && (itemstack.canDestroy(block) || itemstack.canPlaceOn(block));
                }
            }
        }

        return flag;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:35,代码来源:EntityRenderer.java

示例2: isDrawBlockOutline

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private boolean isDrawBlockOutline()
{
    if (!this.drawBlockOutline)
    {
        return false;
    }
    else
    {
        Entity entity = this.mc.getRenderViewEntity();
        boolean flag = entity instanceof EntityPlayer && !this.mc.gameSettings.hideGUI;

        if (flag && !((EntityPlayer)entity).capabilities.allowEdit)
        {
            ItemStack itemstack = ((EntityPlayer)entity).getCurrentEquippedItem();

            if (this.mc.objectMouseOver != null && this.mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
            {
                BlockPos blockpos = this.mc.objectMouseOver.getBlockPos();
                IBlockState iblockstate = this.mc.theWorld.getBlockState(blockpos);
                Block block = iblockstate.getBlock();

                if (this.mc.playerController.getCurrentGameType() == WorldSettings.GameType.SPECTATOR)
                {
                    flag = ReflectorForge.blockHasTileEntity(iblockstate) && this.mc.theWorld.getTileEntity(blockpos) instanceof IInventory;
                }
                else
                {
                    flag = itemstack != null && (itemstack.canDestroy(block) || itemstack.canPlaceOn(block));
                }
            }
        }

        return flag;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:36,代码来源:EntityRenderer.java

示例3: isDrawBlockOutline

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private boolean isDrawBlockOutline() {
	if (!this.drawBlockOutline) {
		return false;
	} else {
		Entity entity = this.mc.getRenderViewEntity();
		boolean flag = entity instanceof EntityPlayer && !this.mc.gameSettings.hideGUI;

		if (flag && !((EntityPlayer) entity).capabilities.allowEdit) {
			ItemStack itemstack = ((EntityPlayer) entity).getCurrentEquippedItem();

			if (this.mc.objectMouseOver != null
					&& this.mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
				BlockPos blockpos = this.mc.objectMouseOver.getBlockPos();
				Block block = this.mc.theWorld.getBlockState(blockpos).getBlock();

				if (this.mc.playerController.getCurrentGameType() == WorldSettings.GameType.SPECTATOR) {
					boolean flag1;

					if (Reflector.ForgeBlock_hasTileEntity.exists()) {
						IBlockState iblockstate = this.mc.theWorld.getBlockState(blockpos);
						flag1 = Reflector.callBoolean(block, Reflector.ForgeBlock_hasTileEntity,
								new Object[] { iblockstate });
					} else {
						flag1 = block.hasTileEntity();
					}

					flag = flag1 && this.mc.theWorld.getTileEntity(blockpos) instanceof IInventory;
				} else {
					flag = itemstack != null && (itemstack.canDestroy(block) || itemstack.canPlaceOn(block));
				}
			}
		}

		return flag;
	}
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:37,代码来源:EntityRenderer.java

示例4: isDrawBlockOutline

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private boolean isDrawBlockOutline()
{
    if (!this.drawBlockOutline)
    {
        return false;
    }
    else
    {
        Entity entity = this.mc.getRenderViewEntity();
        boolean flag = entity instanceof EntityPlayer && !this.mc.gameSettings.hideGUI;

        if (flag && !((EntityPlayer)entity).capabilities.allowEdit)
        {
            ItemStack itemstack = ((EntityPlayer)entity).getHeldItemMainhand();

            if (this.mc.objectMouseOver != null && this.mc.objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK)
            {
                BlockPos blockpos = this.mc.objectMouseOver.getBlockPos();
                Block block = this.mc.theWorld.getBlockState(blockpos).getBlock();

                if (this.mc.playerController.getCurrentGameType() == GameType.SPECTATOR)
                {
                    flag = block.hasTileEntity(this.mc.theWorld.getBlockState(blockpos)) && this.mc.theWorld.getTileEntity(blockpos) instanceof IInventory;
                }
                else
                {
                    flag = itemstack != null && (itemstack.canDestroy(block) || itemstack.canPlaceOn(block));
                }
            }
        }

        return flag;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:35,代码来源:EntityRenderer.java

示例5: isDrawBlockOutline

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private boolean isDrawBlockOutline()
{
    if (!this.drawBlockOutline)
    {
        return false;
    }
    else
    {
        Entity entity = this.mc.getRenderViewEntity();
        boolean flag = entity instanceof EntityPlayer && !this.mc.gameSettings.hideGUI;

        if (flag && !((EntityPlayer)entity).capabilities.allowEdit)
        {
            ItemStack itemstack = ((EntityPlayer)entity).getHeldItemMainhand();

            if (this.mc.objectMouseOver != null && this.mc.objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK)
            {
                BlockPos blockpos = this.mc.objectMouseOver.getBlockPos();
                IBlockState iblockstate = this.mc.world.getBlockState(blockpos);
                Block block = iblockstate.getBlock();

                if (this.mc.playerController.getCurrentGameType() == GameType.SPECTATOR)
                {
                    flag = ReflectorForge.blockHasTileEntity(iblockstate) && this.mc.world.getTileEntity(blockpos) instanceof IInventory;
                }
                else
                {
                    flag = !itemstack.func_190926_b() && (itemstack.canDestroy(block) || itemstack.canPlaceOn(block));
                }
            }
        }

        return flag;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:36,代码来源:EntityRenderer.java

示例6: tryHarvestBlock

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Attempts to harvest a block
 */
public boolean tryHarvestBlock(BlockPos pos)
{
    if (this.gameType.isCreative() && !this.thisPlayerMP.getHeldItemMainhand().func_190926_b() && this.thisPlayerMP.getHeldItemMainhand().getItem() instanceof ItemSword)
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = this.theWorld.getBlockState(pos);
        TileEntity tileentity = this.theWorld.getTileEntity(pos);
        Block block = iblockstate.getBlock();

        if ((block instanceof BlockCommandBlock || block instanceof BlockStructure) && !this.thisPlayerMP.canUseCommandBlock())
        {
            this.theWorld.notifyBlockUpdate(pos, iblockstate, iblockstate, 3);
            return false;
        }
        else
        {
            if (this.gameType.isAdventure())
            {
                if (this.gameType == GameType.SPECTATOR)
                {
                    return false;
                }

                if (!this.thisPlayerMP.isAllowEdit())
                {
                    ItemStack itemstack = this.thisPlayerMP.getHeldItemMainhand();

                    if (itemstack.func_190926_b())
                    {
                        return false;
                    }

                    if (!itemstack.canDestroy(block))
                    {
                        return false;
                    }
                }
            }

            this.theWorld.playEvent(this.thisPlayerMP, 2001, pos, Block.getStateId(iblockstate));
            boolean flag1 = this.removeBlock(pos);

            if (this.isCreative())
            {
                this.thisPlayerMP.connection.sendPacket(new SPacketBlockChange(this.theWorld, pos));
            }
            else
            {
                ItemStack itemstack1 = this.thisPlayerMP.getHeldItemMainhand();
                ItemStack itemstack2 = itemstack1.func_190926_b() ? ItemStack.field_190927_a : itemstack1.copy();
                boolean flag = this.thisPlayerMP.canHarvestBlock(iblockstate);

                if (!itemstack1.func_190926_b())
                {
                    itemstack1.onBlockDestroyed(this.theWorld, iblockstate, pos, this.thisPlayerMP);
                }

                if (flag1 && flag)
                {
                    iblockstate.getBlock().harvestBlock(this.theWorld, this.thisPlayerMP, pos, iblockstate, tileentity, itemstack2);
                }
            }

            return flag1;
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:74,代码来源:PlayerInteractionManager.java

示例7: tryHarvestBlock

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Attempts to harvest a block
 */
public boolean tryHarvestBlock(BlockPos pos)
{
    if (this.gameType.isCreative() && this.thisPlayerMP.getHeldItem() != null && this.thisPlayerMP.getHeldItem().getItem() instanceof ItemSword)
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = this.theWorld.getBlockState(pos);
        TileEntity tileentity = this.theWorld.getTileEntity(pos);

        if (this.gameType.isAdventure())
        {
            if (this.gameType == WorldSettings.GameType.SPECTATOR)
            {
                return false;
            }

            if (!this.thisPlayerMP.isAllowEdit())
            {
                ItemStack itemstack = this.thisPlayerMP.getCurrentEquippedItem();

                if (itemstack == null)
                {
                    return false;
                }

                if (!itemstack.canDestroy(iblockstate.getBlock()))
                {
                    return false;
                }
            }
        }

        this.theWorld.playAuxSFXAtEntity(this.thisPlayerMP, 2001, pos, Block.getStateId(iblockstate));
        boolean flag1 = this.removeBlock(pos);

        if (this.isCreative())
        {
            this.thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(this.theWorld, pos));
        }
        else
        {
            ItemStack itemstack1 = this.thisPlayerMP.getCurrentEquippedItem();
            boolean flag = this.thisPlayerMP.canHarvestBlock(iblockstate.getBlock());

            if (itemstack1 != null)
            {
                itemstack1.onBlockDestroyed(this.theWorld, iblockstate.getBlock(), pos, this.thisPlayerMP);

                if (itemstack1.stackSize == 0)
                {
                    this.thisPlayerMP.destroyCurrentEquippedItem();
                }
            }

            if (flag1 && flag)
            {
                iblockstate.getBlock().harvestBlock(this.theWorld, this.thisPlayerMP, pos, iblockstate, tileentity);
            }
        }

        return flag1;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:69,代码来源:ItemInWorldManager.java

示例8: clickBlock

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Called when the player is hitting a block with an item.
 */
public boolean clickBlock(BlockPos loc, EnumFacing face)
{
    if (this.currentGameType.isAdventure())
    {
        if (this.currentGameType == GameType.SPECTATOR)
        {
            return false;
        }

        if (!this.mc.thePlayer.isAllowEdit())
        {
            ItemStack itemstack = this.mc.thePlayer.getHeldItemMainhand();

            if (itemstack == null)
            {
                return false;
            }

            if (!itemstack.canDestroy(this.mc.theWorld.getBlockState(loc).getBlock()))
            {
                return false;
            }
        }
    }

    if (!this.mc.theWorld.getWorldBorder().contains(loc))
    {
        return false;
    }
    else
    {
        if (this.currentGameType.isCreative())
        {
            this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, loc, face));
            if (!net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.mc.thePlayer, loc, face, net.minecraftforge.common.ForgeHooks.rayTraceEyeHitVec(this.mc.thePlayer, getBlockReachDistance() + 1)).isCanceled())
            clickBlockCreative(this.mc, this, loc, face);
            this.blockHitDelay = 5;
        }
        else if (!this.isHittingBlock || !this.isHittingPosition(loc))
        {
            if (this.isHittingBlock)
            {
                this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, this.currentBlock, face));
            }

            this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, loc, face));
            net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock event = net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.mc.thePlayer, loc, face, net.minecraftforge.common.ForgeHooks.rayTraceEyeHitVec(this.mc.thePlayer, getBlockReachDistance() + 1));

            IBlockState iblockstate = this.mc.theWorld.getBlockState(loc);
            boolean flag = iblockstate.getMaterial() != Material.AIR;

            if (flag && this.curBlockDamageMP == 0.0F)
            {
                if (event.getUseBlock() != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY)
                iblockstate.getBlock().onBlockClicked(this.mc.theWorld, loc, this.mc.thePlayer);
            }
            if (event.getUseItem() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return true;
            if (flag && iblockstate.getPlayerRelativeBlockHardness(this.mc.thePlayer, this.mc.thePlayer.worldObj, loc) >= 1.0F)
            {
                this.onPlayerDestroyBlock(loc);
            }
            else
            {
                this.isHittingBlock = true;
                this.currentBlock = loc;
                this.currentItemHittingBlock = this.mc.thePlayer.getHeldItemMainhand();
                this.curBlockDamageMP = 0.0F;
                this.stepSoundTickCounter = 0.0F;
                this.mc.theWorld.sendBlockBreakProgress(this.mc.thePlayer.getEntityId(), this.currentBlock, (int)(this.curBlockDamageMP * 10.0F) - 1);
            }
        }

        return true;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:79,代码来源:PlayerControllerMP.java

示例9: clickBlock

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Called when the player is hitting a block with an item.
 */
public boolean clickBlock(BlockPos loc, EnumFacing face)
{
    if (this.currentGameType.isAdventure())
    {
        if (this.currentGameType == WorldSettings.GameType.SPECTATOR)
        {
            return false;
        }

        if (!this.mc.thePlayer.isAllowEdit())
        {
            Block block = this.mc.theWorld.getBlockState(loc).getBlock();
            ItemStack itemstack = this.mc.thePlayer.getCurrentEquippedItem();

            if (itemstack == null)
            {
                return false;
            }

            if (!itemstack.canDestroy(block))
            {
                return false;
            }
        }
    }

    if (!this.mc.theWorld.getWorldBorder().contains(loc))
    {
        return false;
    }
    else
    {
        if (this.currentGameType.isCreative())
        {
            this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, loc, face));
            clickBlockCreative(this.mc, this, loc, face);
            this.blockHitDelay = 5;
        }
        else if (!this.isHittingBlock || !this.isHittingPosition(loc))
        {
            if (this.isHittingBlock)
            {
                this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, this.currentBlock, face));
            }

            this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, loc, face));
            Block block1 = this.mc.theWorld.getBlockState(loc).getBlock();
            boolean flag = block1.getMaterial() != Material.air;

            if (flag && this.curBlockDamageMP == 0.0F)
            {
                block1.onBlockClicked(this.mc.theWorld, loc, this.mc.thePlayer);
            }

            if (flag && block1.getPlayerRelativeBlockHardness(this.mc.thePlayer, this.mc.thePlayer.worldObj, loc) >= 1.0F)
            {
                this.onPlayerDestroyBlock(loc, face);
            }
            else
            {
                this.isHittingBlock = true;
                this.currentBlock = loc;
                this.currentItemHittingBlock = this.mc.thePlayer.getHeldItem();
                this.curBlockDamageMP = 0.0F;
                this.stepSoundTickCounter = 0.0F;
                this.mc.theWorld.sendBlockBreakProgress(this.mc.thePlayer.getEntityId(), this.currentBlock, (int)(this.curBlockDamageMP * 10.0F) - 1);
            }
        }

        return true;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:76,代码来源:PlayerControllerMP.java

示例10: onBlockClicked

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * If not creative, it calls sendBlockBreakProgress until the block is broken first. tryHarvestBlock can also be the
 * result of this call.
 */
public void onBlockClicked(BlockPos pos, EnumFacing side)
{
    if (this.isCreative())
    {
        if (!this.theWorld.extinguishFire((EntityPlayer)null, pos, side))
        {
            this.tryHarvestBlock(pos);
        }
    }
    else
    {
        Block block = this.theWorld.getBlockState(pos).getBlock();

        if (this.gameType.isAdventure())
        {
            if (this.gameType == WorldSettings.GameType.SPECTATOR)
            {
                return;
            }

            if (!this.thisPlayerMP.isAllowEdit())
            {
                ItemStack itemstack = this.thisPlayerMP.getCurrentEquippedItem();

                if (itemstack == null)
                {
                    return;
                }

                if (!itemstack.canDestroy(block))
                {
                    return;
                }
            }
        }

        this.theWorld.extinguishFire((EntityPlayer)null, pos, side);
        this.initialDamage = this.curblockDamage;
        float f = 1.0F;

        if (block.getMaterial() != Material.air)
        {
            block.onBlockClicked(this.theWorld, pos, this.thisPlayerMP);
            f = block.getPlayerRelativeBlockHardness(this.thisPlayerMP, this.thisPlayerMP.worldObj, pos);
        }

        if (block.getMaterial() != Material.air && f >= 1.0F)
        {
            this.tryHarvestBlock(pos);
        }
        else
        {
            this.isDestroyingBlock = true;
            this.field_180240_f = pos;
            int i = (int)(f * 10.0F);
            this.theWorld.sendBlockBreakProgress(this.thisPlayerMP.getEntityId(), pos, i);
            this.durabilityRemainingOnBlock = i;
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:65,代码来源:ItemInWorldManager.java

示例11: onPlayerDestroyBlock

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Called when a player completes the destruction of a block
 */
public boolean onPlayerDestroyBlock(BlockPos pos, EnumFacing side)
{
    if (this.currentGameType.isAdventure())
    {
        if (this.currentGameType == WorldSettings.GameType.SPECTATOR)
        {
            return false;
        }

        if (!this.mc.thePlayer.isAllowEdit())
        {
            Block block = this.mc.theWorld.getBlockState(pos).getBlock();
            ItemStack itemstack = this.mc.thePlayer.getCurrentEquippedItem();

            if (itemstack == null)
            {
                return false;
            }

            if (!itemstack.canDestroy(block))
            {
                return false;
            }
        }
    }

    if (this.currentGameType.isCreative() && this.mc.thePlayer.getHeldItem() != null && this.mc.thePlayer.getHeldItem().getItem() instanceof ItemSword)
    {
        return false;
    }
    else
    {
        World world = this.mc.theWorld;
        IBlockState iblockstate = world.getBlockState(pos);
        Block block1 = iblockstate.getBlock();

        if (block1.getMaterial() == Material.air)
        {
            return false;
        }
        else
        {
            world.playAuxSFX(2001, pos, Block.getStateId(iblockstate));
            boolean flag = world.setBlockToAir(pos);

            if (flag)
            {
                block1.onBlockDestroyedByPlayer(world, pos, iblockstate);
            }

            this.currentBlock = new BlockPos(this.currentBlock.getX(), -1, this.currentBlock.getZ());

            if (!this.currentGameType.isCreative())
            {
                ItemStack itemstack1 = this.mc.thePlayer.getCurrentEquippedItem();

                if (itemstack1 != null)
                {
                    itemstack1.onBlockDestroyed(world, block1, pos, this.mc.thePlayer);

                    if (itemstack1.stackSize == 0)
                    {
                        this.mc.thePlayer.destroyCurrentEquippedItem();
                    }
                }
            }

            return flag;
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:75,代码来源:PlayerControllerMP.java

示例12: onPlayerDestroyBlock

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public boolean onPlayerDestroyBlock(BlockPos pos)
{
    if (this.currentGameType.isAdventure())
    {
        if (this.currentGameType == GameType.SPECTATOR)
        {
            return false;
        }

        if (!this.mc.thePlayer.isAllowEdit())
        {
            ItemStack itemstack = this.mc.thePlayer.getHeldItemMainhand();

            if (itemstack == null)
            {
                return false;
            }

            if (!itemstack.canDestroy(this.mc.theWorld.getBlockState(pos).getBlock()))
            {
                return false;
            }
        }
    }

    ItemStack stack = mc.thePlayer.getHeldItemMainhand();
    if (stack != null && stack.getItem() != null && stack.getItem().onBlockStartBreak(stack, pos, mc.thePlayer))
    {
        return false;
    }

    if (this.currentGameType.isCreative() && this.mc.thePlayer.getHeldItemMainhand() != null && this.mc.thePlayer.getHeldItemMainhand().getItem() instanceof ItemSword)
    {
        return false;
    }
    else
    {
        World world = this.mc.theWorld;
        IBlockState iblockstate = world.getBlockState(pos);
        Block block = iblockstate.getBlock();

        if ((block instanceof BlockCommandBlock || block instanceof BlockStructure) && !this.mc.thePlayer.canUseCommandBlock())
        {
            return false;
        }
        else if (iblockstate.getMaterial() == Material.AIR)
        {
            return false;
        }
        else
        {
            world.playEvent(2001, pos, Block.getStateId(iblockstate));

            this.currentBlock = new BlockPos(this.currentBlock.getX(), -1, this.currentBlock.getZ());

            if (!this.currentGameType.isCreative())
            {
                ItemStack itemstack1 = this.mc.thePlayer.getHeldItemMainhand();

                if (itemstack1 != null)
                {
                    itemstack1.onBlockDestroyed(world, iblockstate, pos, this.mc.thePlayer);

                    if (itemstack1.stackSize <= 0)
                    {
                        net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this.mc.thePlayer, itemstack1, EnumHand.MAIN_HAND);
                        this.mc.thePlayer.setHeldItem(EnumHand.MAIN_HAND, (ItemStack)null);
                    }
                }
            }

            boolean flag = block.removedByPlayer(iblockstate, world, pos, mc.thePlayer, false);

            if (flag)
            {
                block.onBlockDestroyedByPlayer(world, pos, iblockstate);
            }
            return flag;
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:82,代码来源:PlayerControllerMP.java

示例13: clickBlock

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Called when the player is hitting a block with an item.
 */
public boolean clickBlock(BlockPos loc, EnumFacing face)
{
    if (this.currentGameType.isAdventure())
    {
        if (this.currentGameType == GameType.SPECTATOR)
        {
            return false;
        }

        if (!this.mc.player.isAllowEdit())
        {
            ItemStack itemstack = this.mc.player.getHeldItemMainhand();

            if (itemstack.func_190926_b())
            {
                return false;
            }

            if (!itemstack.canDestroy(this.mc.world.getBlockState(loc).getBlock()))
            {
                return false;
            }
        }
    }

    if (!this.mc.world.getWorldBorder().contains(loc))
    {
        return false;
    }
    else
    {
        if (this.currentGameType.isCreative())
        {
            this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, loc, face));
            clickBlockCreative(this.mc, this, loc, face);
            this.blockHitDelay = 5;
        }
        else if (!this.isHittingBlock || !this.isHittingPosition(loc))
        {
            if (this.isHittingBlock)
            {
                this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, this.currentBlock, face));
            }

            this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, loc, face));
            IBlockState iblockstate = this.mc.world.getBlockState(loc);
            boolean flag = iblockstate.getMaterial() != Material.AIR;

            if (flag && this.curBlockDamageMP == 0.0F)
            {
                iblockstate.getBlock().onBlockClicked(this.mc.world, loc, this.mc.player);
            }

            if (flag && iblockstate.getPlayerRelativeBlockHardness(this.mc.player, this.mc.player.world, loc) >= 1.0F)
            {
                this.onPlayerDestroyBlock(loc);
            }
            else
            {
                this.isHittingBlock = true;
                this.currentBlock = loc;
                this.currentItemHittingBlock = this.mc.player.getHeldItemMainhand();
                this.curBlockDamageMP = 0.0F;
                this.stepSoundTickCounter = 0.0F;
                this.mc.world.sendBlockBreakProgress(this.mc.player.getEntityId(), this.currentBlock, (int)(this.curBlockDamageMP * 10.0F) - 1);
            }
        }

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

示例14: onBlockClicked

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * If not creative, it calls sendBlockBreakProgress until the block is broken first. tryHarvestBlock can also be the
 * result of this call.
 */
public void onBlockClicked(BlockPos pos, EnumFacing side)
{
    if (this.isCreative())
    {
        if (!this.theWorld.extinguishFire((EntityPlayer)null, pos, side))
        {
            this.tryHarvestBlock(pos);
        }
    }
    else
    {
        IBlockState iblockstate = this.theWorld.getBlockState(pos);
        Block block = iblockstate.getBlock();

        if (this.gameType.isAdventure())
        {
            if (this.gameType == GameType.SPECTATOR)
            {
                return;
            }

            if (!this.thisPlayerMP.isAllowEdit())
            {
                ItemStack itemstack = this.thisPlayerMP.getHeldItemMainhand();

                if (itemstack.func_190926_b())
                {
                    return;
                }

                if (!itemstack.canDestroy(block))
                {
                    return;
                }
            }
        }

        this.theWorld.extinguishFire((EntityPlayer)null, pos, side);
        this.initialDamage = this.curblockDamage;
        float f = 1.0F;

        if (iblockstate.getMaterial() != Material.AIR)
        {
            block.onBlockClicked(this.theWorld, pos, this.thisPlayerMP);
            f = iblockstate.getPlayerRelativeBlockHardness(this.thisPlayerMP, this.thisPlayerMP.world, pos);
        }

        if (iblockstate.getMaterial() != Material.AIR && f >= 1.0F)
        {
            this.tryHarvestBlock(pos);
        }
        else
        {
            this.isDestroyingBlock = true;
            this.destroyPos = pos;
            int i = (int)(f * 10.0F);
            this.theWorld.sendBlockBreakProgress(this.thisPlayerMP.getEntityId(), pos, i);
            this.durabilityRemainingOnBlock = i;
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:66,代码来源:PlayerInteractionManager.java


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