Java 类net.minecraft.network.play.client.CPacketPlayerDigging 实例源码

项目:OreLogger    文件:BlockBreakHandler.java   
public void dissectPacket(Object msg) {
    if (!(msg instanceof CPacketPlayerDigging)) {
        return;
    }
    CPacketPlayerDigging packet = (CPacketPlayerDigging) msg;
    if (packet.getAction() != CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK) {
        // even though the name may suggest otherwise, STOP_DESTROY_BLOCK means the player successfully broke the block
        return;
    }
    // at this point we have confirmed that some kind of block was broken, so we check what kind. We can use forge
    // events for just any kind of interaction in general, but not for block breaks specificially, so we pull the item
    // the player used to mine and the block he mined from the interact event
    if (OreLogger.instance.getListener().getCachedMaterial() == Material.ROCK
            && OreLogger.instance.getListener().getCachedVariant() == 0) {
        // confirmed stone break
        sbCounter.breakOccured(OreLogger.instance.getListener().getCachedBlockPos());
    }

}
项目:Wurst-MC-1.12    文件:BlockUtils.java   
public static void breakBlockPacketSpam(BlockPos pos)
{
    Vec3d eyesPos = RotationUtils.getEyesPos();
    Vec3d posVec = new Vec3d(pos).addVector(0.5, 0.5, 0.5);
    double distanceSqPosVec = eyesPos.squareDistanceTo(posVec);

    for(EnumFacing side : EnumFacing.values())
    {
        Vec3d hitVec =
            posVec.add(new Vec3d(side.getDirectionVec()).scale(0.5));

        // check if side is facing towards player
        if(eyesPos.squareDistanceTo(hitVec) >= distanceSqPosVec)
            continue;

        // break block
        WConnection.sendPacket(new CPacketPlayerDigging(
            Action.START_DESTROY_BLOCK, pos, side));
        WConnection.sendPacket(
            new CPacketPlayerDigging(Action.STOP_DESTROY_BLOCK, pos, side));

        return;
    }
}
项目:CheataClientSrc    文件:Nuker.java   
@Override
public void onUpdate() {
    if(mc.thePlayer.capabilities.isCreativeMode){
        for(int x = -size; x < size + sizeOther; x++){
            for(int z = -size; z < size + sizeOther; z++){
                for(int y = -size; y < size + sizeOther; y++){
                    boolean shouldBreakBlock = true;
                    int blockX = (int) (mc.thePlayer.posX + x);
                    int blockY = (int) (mc.thePlayer.posY + y);
                    int blockZ = (int) (mc.thePlayer.posZ + z);
                    if (Block.getIdFromBlock(mc.theWorld.getBlockState(new BlockPos(blockX, blockY, blockZ)).getBlock()) != 0){
                        mc.thePlayer.sendQueue.addToSendQueue(new CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, new BlockPos(blockX, blockY, blockZ), EnumFacing.UP));
                    }
                }
            }
        }
    }
}
项目:CheataClientSrc    文件:InstantMine.java   
@Override
public void onUpdate() {
    BlockPos var1 = mc.objectMouseOver.getBlockPos();

    if (mc.theWorld.getBlockState(var1).getMaterial() == Material.air)
        return;
    if (mc.playerController.isHittingBlock)
        if (ncp
                && mc.gameSettings.keyBindAttack.isKeyDown())
            PacketUtils.sendPacket(new CPacketPlayerDigging(Action.STOP_DESTROY_BLOCK,
                    mc.objectMouseOver.getBlockPos(), EnumFacing.getHorizontal(-1)));
        else {
            PacketUtils.sendPacket(new CPacketPlayerDigging(Action.START_DESTROY_BLOCK,
                    mc.objectMouseOver.getBlockPos(), EnumFacing.getHorizontal(-1)));
            PacketUtils.sendPacket(new CPacketPlayerDigging(Action.STOP_DESTROY_BLOCK,
                    mc.objectMouseOver.getBlockPos(), EnumFacing.getHorizontal(-1)));
        }
}
项目:Wurst-MC-1.12    文件:BlockUtils.java   
public static void breakBlocksPacketSpam(Iterable<BlockPos> blocks)
{
    Vec3d eyesPos = RotationUtils.getEyesPos();

    for(BlockPos pos : blocks)
    {
        Vec3d posVec = new Vec3d(pos).addVector(0.5, 0.5, 0.5);
        double distanceSqPosVec = eyesPos.squareDistanceTo(posVec);

        for(EnumFacing side : EnumFacing.values())
        {
            Vec3d hitVec =
                posVec.add(new Vec3d(side.getDirectionVec()).scale(0.5));

            // check if side is facing towards player
            if(eyesPos.squareDistanceTo(hitVec) >= distanceSqPosVec)
                continue;

            // break block
            WConnection.sendPacket(new CPacketPlayerDigging(
                Action.START_DESTROY_BLOCK, pos, side));
            WConnection.sendPacket(new CPacketPlayerDigging(
                Action.STOP_DESTROY_BLOCK, pos, side));

            break;
        }
    }
}
项目:Zombe-Modpack    文件:EntityPlayerSP.java   
@Nullable

    /**
     * Drop one item out of the currently selected stack if {@code dropAll} is false. If {@code dropItem} is true the
     * entire stack is dropped.
     */
    public EntityItem dropItem(boolean dropAll)
    {
        CPacketPlayerDigging.Action cpacketplayerdigging$action = dropAll ? CPacketPlayerDigging.Action.DROP_ALL_ITEMS : CPacketPlayerDigging.Action.DROP_ITEM;
        this.connection.sendPacket(new CPacketPlayerDigging(cpacketplayerdigging$action, BlockPos.ORIGIN, EnumFacing.DOWN));
        return null;
    }
项目:Zombe-Modpack    文件:PlayerControllerMP.java   
/**
 * Resets current block damage and isHittingBlock
 */
public void resetBlockRemoving()
{
    if (this.isHittingBlock)
    {
        this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, this.currentBlock, EnumFacing.DOWN));
        //-ZMod-----------------------------------------------------------
        ZHandle.handle("afterBlockDig");
        //----------------------------------------------------------------
        this.isHittingBlock = false;
        this.curBlockDamageMP = 0.0F;
        this.mc.world.sendBlockBreakProgress(this.mc.player.getEntityId(), this.currentBlock, -1);
        this.mc.player.resetCooldown();
    }
}
项目:EMC    文件:ICPacketDig.java   
public static CPacketPlayerDigging.Action getAction(IDigAction action) {
    if (action.equals(IDigAction.START_DESTROY_BLOCK)) {
        return CPacketPlayerDigging.Action.START_DESTROY_BLOCK;
    } else if (action.equals(IDigAction.STOP_DESTROY_BLOCK)) {
        return CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK;
    }
    return null;
}
项目:Backmemed    文件:EntityPlayerSP.java   
@Nullable

    /**
     * Drop one item out of the currently selected stack if {@code dropAll} is false. If {@code dropItem} is true the
     * entire stack is dropped.
     */
    public EntityItem dropItem(boolean dropAll)
    {
        CPacketPlayerDigging.Action cpacketplayerdigging$action = dropAll ? CPacketPlayerDigging.Action.DROP_ALL_ITEMS : CPacketPlayerDigging.Action.DROP_ITEM;
        this.connection.sendPacket(new CPacketPlayerDigging(cpacketplayerdigging$action, BlockPos.ORIGIN, EnumFacing.DOWN));
        return null;
    }
项目:Backmemed    文件:PlayerControllerMP.java   
/**
 * Resets current block damage and isHittingBlock
 */
public void resetBlockRemoving()
{
    if (this.isHittingBlock)
    {
        this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, this.currentBlock, EnumFacing.DOWN));
        this.isHittingBlock = false;
        this.curBlockDamageMP = 0.0F;
        this.mc.world.sendBlockBreakProgress(this.mc.player.getEntityId(), this.currentBlock, -1);
        this.mc.player.resetCooldown();
    }
}
项目:CustomWorldGen    文件:EntityPlayerSP.java   
/**
 * Drop one item out of the currently selected stack if {@code dropAll} is false. If {@code dropItem} is true the
 * entire stack is dropped.
 */
@Nullable
public EntityItem dropItem(boolean dropAll)
{
    CPacketPlayerDigging.Action cpacketplayerdigging$action = dropAll ? CPacketPlayerDigging.Action.DROP_ALL_ITEMS : CPacketPlayerDigging.Action.DROP_ITEM;
    this.connection.sendPacket(new CPacketPlayerDigging(cpacketplayerdigging$action, BlockPos.ORIGIN, EnumFacing.DOWN));
    return null;
}
项目:CustomWorldGen    文件:PlayerControllerMP.java   
/**
 * Resets current block damage and field_78778_j
 */
public void resetBlockRemoving()
{
    if (this.isHittingBlock)
    {
        this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, this.currentBlock, EnumFacing.DOWN));
        this.isHittingBlock = false;
        this.curBlockDamageMP = 0.0F;
        this.mc.theWorld.sendBlockBreakProgress(this.mc.thePlayer.getEntityId(), this.currentBlock, -1);
        this.mc.thePlayer.resetCooldown();
    }
}
项目:SettlerCraft    文件:MessageSettlerDigging.java   
public MessageSettlerDigging(EntitySettler settler, CPacketPlayerDigging.Action action, EnumFacing face, BlockPos pos) {
    this();
    this.settler = settler;
    this.action = action;
    this.face = face;
    this.pos = pos;
}
项目:SettlerCraft    文件:SettlerInteractionController.java   
public boolean leftClickBlock(BlockPos pos, EnumFacing side, Vec3d hit) {
    if (!this.getSettler().getWorld().getWorldBorder().contains(pos)
            || SettlerCraft.instance.getMinecraftServer().isBlockProtected(this.getWorld(), pos, this.getFakePlayer())) {
        return true;
    } else {
        if (!this.isHittingBlock || !this.isHittingPosition(pos)) {
            if (this.isHittingBlock) {
                new MessageSettlerDigging(this.getSettler(), CPacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, side, this.currentBlock).sendToAll();
            }
            new MessageSettlerDigging(this.getSettler(), CPacketPlayerDigging.Action.START_DESTROY_BLOCK, side, pos).sendToAll();
            PlayerInteractEvent.LeftClickBlock event = ForgeHooks.onLeftClickBlock(this.getFakePlayer(), pos, side, hit);
            IBlockState state = this.getWorld().getBlockState(pos);
            boolean flag = state.getMaterial() != Material.AIR;
            if (flag && this.curBlockDamageMP == 0.0F) {
                if (event.getUseBlock() != Event.Result.DENY)
                    state.getBlock().onBlockClicked(this.getWorld(), pos, this.getFakePlayer());
            }
            if (event.getUseItem() == Event.Result.DENY) return true;
            if (flag && state.getPlayerRelativeBlockHardness(this.getFakePlayer(), this.getWorld(), pos) >= 1.0F) {
                this.onPlayerDestroyBlock();
            } else {
                this.isHittingBlock = true;
                this.currentBlock = pos;
                this.currentItemHittingBlock = this.getSettler().getHeldItemMainhand();
                this.curBlockDamageMP = 0.0F;
                //this.stepSoundTickCounter = 0.0F;
                this.getWorld().sendBlockBreakProgress(this.getSettler().getEntityId(), this.currentBlock, (int)(this.curBlockDamageMP * 10.0F) - 1);
            }
        }
        return true;
    }
}
项目:ExpandedRailsMod    文件:EntityPlayerSP.java   
/**
 * Drop one item out of the currently selected stack if {@code dropAll} is false. If {@code dropItem} is true the
 * entire stack is dropped.
 */
@Nullable
public EntityItem dropItem(boolean dropAll)
{
    CPacketPlayerDigging.Action cpacketplayerdigging$action = dropAll ? CPacketPlayerDigging.Action.DROP_ALL_ITEMS : CPacketPlayerDigging.Action.DROP_ITEM;
    this.connection.sendPacket(new CPacketPlayerDigging(cpacketplayerdigging$action, BlockPos.ORIGIN, EnumFacing.DOWN));
    return null;
}
项目:ExpandedRailsMod    文件:PlayerControllerMP.java   
/**
 * Resets current block damage and field_78778_j
 */
public void resetBlockRemoving()
{
    if (this.isHittingBlock)
    {
        this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, this.currentBlock, EnumFacing.DOWN));
        this.isHittingBlock = false;
        this.curBlockDamageMP = 0.0F;
        this.mc.theWorld.sendBlockBreakProgress(this.mc.thePlayer.getEntityId(), this.currentBlock, -1);
        this.mc.thePlayer.resetCooldown();
    }
}
项目:Zombe-Modpack    文件:PlayerControllerMP.java   
public void onStoppedUsingItem(EntityPlayer playerIn)
{
    this.syncCurrentPlayItem();
    this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
    playerIn.stopActiveHand();
}
项目:EMC    文件:IInventory.java   
public static void swapHands() {
    Minecraft.getMinecraft().player.connection.sendPacket(new CPacketPlayerDigging(
            CPacketPlayerDigging.Action.SWAP_HELD_ITEMS, BlockPos.ORIGIN, EnumFacing.DOWN));
}
项目:EMC    文件:ICPacketDig.java   
public ICPacketDig(IDigAction action, IBlockPos pos, IEnumFacing facing) {
    super(new CPacketPlayerDigging(getAction(action), pos.getPos(), IEnumFacing.getFacing(facing)));
}
项目:Backmemed    文件:PlayerControllerMP.java   
/**
 * 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;
    }
}
项目:Backmemed    文件:PlayerControllerMP.java   
public boolean onPlayerDamageBlock(BlockPos posBlock, EnumFacing directionFacing)
{
    this.syncCurrentPlayItem();

    if (this.blockHitDelay > 0)
    {
        --this.blockHitDelay;
        return true;
    }
    else if (this.currentGameType.isCreative() && this.mc.world.getWorldBorder().contains(posBlock))
    {
        this.blockHitDelay = 5;
        this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, posBlock, directionFacing));
        clickBlockCreative(this.mc, this, posBlock, directionFacing);
        return true;
    }
    else if (this.isHittingPosition(posBlock))
    {
        IBlockState iblockstate = this.mc.world.getBlockState(posBlock);
        Block block = iblockstate.getBlock();

        if (iblockstate.getMaterial() == Material.AIR)
        {
            this.isHittingBlock = false;
            return false;
        }
        else
        {
            this.curBlockDamageMP += iblockstate.getPlayerRelativeBlockHardness(this.mc.player, this.mc.player.world, posBlock);

            if (this.stepSoundTickCounter % 4.0F == 0.0F)
            {
                SoundType soundtype = block.getSoundType();
                this.mc.getSoundHandler().playSound(new PositionedSoundRecord(soundtype.getHitSound(), SoundCategory.NEUTRAL, (soundtype.getVolume() + 1.0F) / 8.0F, soundtype.getPitch() * 0.5F, posBlock));
            }

            ++this.stepSoundTickCounter;

            if (this.curBlockDamageMP >= 1.0F)
            {
                this.isHittingBlock = false;
                this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, posBlock, directionFacing));
                this.onPlayerDestroyBlock(posBlock);
                this.curBlockDamageMP = 0.0F;
                this.stepSoundTickCounter = 0.0F;
                this.blockHitDelay = 5;
            }

            this.mc.world.sendBlockBreakProgress(this.mc.player.getEntityId(), this.currentBlock, (int)(this.curBlockDamageMP * 10.0F) - 1);
            return true;
        }
    }
    else
    {
        return this.clickBlock(posBlock, directionFacing);
    }
}
项目:Backmemed    文件:PlayerControllerMP.java   
public void onStoppedUsingItem(EntityPlayer playerIn)
{
    this.syncCurrentPlayItem();
    this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
    playerIn.stopActiveHand();
}
项目:CustomWorldGen    文件:PlayerControllerMP.java   
/**
 * 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;
    }
}
项目:CustomWorldGen    文件:PlayerControllerMP.java   
public boolean onPlayerDamageBlock(BlockPos posBlock, EnumFacing directionFacing)
{
    this.syncCurrentPlayItem();

    if (this.blockHitDelay > 0)
    {
        --this.blockHitDelay;
        return true;
    }
    else if (this.currentGameType.isCreative() && this.mc.theWorld.getWorldBorder().contains(posBlock))
    {
        this.blockHitDelay = 5;
        this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, posBlock, directionFacing));
        clickBlockCreative(this.mc, this, posBlock, directionFacing);
        return true;
    }
    else if (this.isHittingPosition(posBlock))
    {
        IBlockState iblockstate = this.mc.theWorld.getBlockState(posBlock);
        Block block = iblockstate.getBlock();

        if (iblockstate.getMaterial() == Material.AIR)
        {
            this.isHittingBlock = false;
            return false;
        }
        else
        {
            this.curBlockDamageMP += iblockstate.getPlayerRelativeBlockHardness(this.mc.thePlayer, this.mc.thePlayer.worldObj, posBlock);

            if (this.stepSoundTickCounter % 4.0F == 0.0F)
            {
                SoundType soundtype = block.getSoundType(iblockstate, mc.theWorld, posBlock, mc.thePlayer);
                this.mc.getSoundHandler().playSound(new PositionedSoundRecord(soundtype.getHitSound(), SoundCategory.NEUTRAL, (soundtype.getVolume() + 1.0F) / 8.0F, soundtype.getPitch() * 0.5F, posBlock));
            }

            ++this.stepSoundTickCounter;

            if (this.curBlockDamageMP >= 1.0F)
            {
                this.isHittingBlock = false;
                this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, posBlock, directionFacing));
                this.onPlayerDestroyBlock(posBlock);
                this.curBlockDamageMP = 0.0F;
                this.stepSoundTickCounter = 0.0F;
                this.blockHitDelay = 5;
            }

            this.mc.theWorld.sendBlockBreakProgress(this.mc.thePlayer.getEntityId(), this.currentBlock, (int)(this.curBlockDamageMP * 10.0F) - 1);
            return true;
        }
    }
    else
    {
        return this.clickBlock(posBlock, directionFacing);
    }
}
项目:CustomWorldGen    文件:PlayerControllerMP.java   
public void onStoppedUsingItem(EntityPlayer playerIn)
{
    this.syncCurrentPlayItem();
    this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
    playerIn.stopActiveHand();
}
项目:CrystalMod    文件:FakeNetHandlerPlayServer.java   
@Override
public void processPlayerDigging(CPacketPlayerDigging p_147345_1_) {
}
项目:CrystalMod    文件:BlockUtil.java   
public static void breakExtraBlock(ItemStack stack, World world, EntityPlayer player, BlockPos pos, BlockPos refPos) {
    if(world.isAirBlock(pos)) {
        return;
    }
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();

    if(!ToolUtil.isToolEffective(stack, state)) {
        return;
    }

    IBlockState refState = world.getBlockState(refPos);
    float refStrength = ForgeHooks.blockStrength(refState, player, world, refPos);
    float strength = ForgeHooks.blockStrength(state, player, world, pos);

    if(!ForgeHooks.canHarvestBlock(block, player, world, pos) || refStrength / strength > 10f) {
        return;
    }

    if(player.capabilities.isCreativeMode) {
        block.onBlockHarvested(world, pos, state, player);
        if(block.removedByPlayer(state, world, pos, player, false)) {
            block.onBlockDestroyedByPlayer(world, pos, state);
        }

        if(!world.isRemote) {
            CrystalModNetwork.sendMCPacket(player, new SPacketBlockChange(world, pos));
        }
        return;
    }

    stack.onBlockDestroyed(world, state, pos, player);

    if(!world.isRemote) {
        int xp = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP) player).interactionManager.getGameType(), (EntityPlayerMP) player, pos);
        if(xp == -1) {
            return;
        }


        TileEntity tileEntity = world.getTileEntity(pos);
        if(block.removedByPlayer(state, world, pos, player, true))
        {
            block.onBlockDestroyedByPlayer(world, pos, state);
            block.harvestBlock(world, player, pos, state, tileEntity, stack);
            block.dropXpOnBlockBreak(world, pos, xp);
        }

        CrystalModNetwork.sendMCPacket(player, new SPacketBlockChange(world, pos));
    }
    else {
        Minecraft.getMinecraft();
        world.playBroadcastSound(2001, pos, Block.getStateId(state));
        if(block.removedByPlayer(state, world, pos, player, true)) {
            block.onBlockDestroyedByPlayer(world, pos, state);
        }
        stack.onBlockDestroyed(world, state, pos, player);

        if(ItemStackTools.getStackSize(stack) == 0 && stack == player.getHeldItemMainhand()) {
            ForgeEventFactory.onPlayerDestroyItem(player, stack, EnumHand.MAIN_HAND);
            player.setHeldItem(EnumHand.MAIN_HAND, ItemStackTools.getEmptyStack());
        }

        Minecraft.getMinecraft().getConnection().sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, pos, Minecraft
                .getMinecraft().objectMouseOver.sideHit));
    }
}
项目:Cyclic    文件:ItemMattock.java   
/**
 * <<<< made with some help from Tinkers Construct and Spark's Hammers
 * https://github.com/thebrightspark/SparksHammers/blob/b84bd178fe2bbe47b13a89ef9435b20f09e429a4/src/main/java/com/brightspark/sparkshammers/util/CommonUtils.java and
 * https://github.com/SlimeKnights/TinkersConstruct
 */
@Override
public boolean onBlockStartBreak(ItemStack stack, BlockPos posHit, EntityPlayer player) {
  RayTraceResult ray = rayTrace(player.getEntityWorld(), player, false);
  if (ray == null) {
    return super.onBlockStartBreak(stack, posHit, player);
  }
  EnumFacing sideHit = ray.sideHit;
  World world = player.getEntityWorld();
  //use the shape builder to get region
  List<BlockPos> shape;
  if (sideHit == EnumFacing.UP || sideHit == EnumFacing.DOWN) {
    shape = UtilShape.squareHorizontalHollow(posHit, RADIUS);
  }
  else if (sideHit == EnumFacing.EAST || sideHit == EnumFacing.WEST) {
    shape = UtilShape.squareVerticalZ(posHit, RADIUS);
  }
  else {//has to be NORTHSOUTH
    shape = UtilShape.squareVerticalX(posHit, RADIUS);
  }
  for (BlockPos posCurrent : shape) {
    //first we validate
    if (posHit.equals(posCurrent)) {
      continue;
    }
    if (super.onBlockStartBreak(stack, new BlockPos(posCurrent), player)) {
      continue;
    }
    IBlockState bsCurrent = world.getBlockState(posCurrent);
    if (world.isAirBlock(posCurrent)) {
      continue;
    }
    if (!mats.contains(bsCurrent.getMaterial())) {
      continue;
    }
    Block blockCurrent = bsCurrent.getBlock();
    if (!ForgeHooks.canHarvestBlock(blockCurrent, player, world, posCurrent)
        || bsCurrent.getBlock().canEntityDestroy(bsCurrent, world, posCurrent, player) == false
        || bsCurrent.getBlock().getBlockHardness(bsCurrent, world, posCurrent) < 0) {
      continue;
    }
    //then we destroy
    stack.onBlockDestroyed(world, bsCurrent, posCurrent, player);
    if (world.isRemote) {//C
      world.playEvent(2001, posCurrent, Block.getStateId(bsCurrent));
      if (blockCurrent.removedByPlayer(bsCurrent, world, posCurrent, player, true)) {
        blockCurrent.onBlockDestroyedByPlayer(world, posCurrent, bsCurrent);
      }
      stack.onBlockDestroyed(world, bsCurrent, posCurrent, player);//update tool damage
      if (stack.getCount() == 0 && stack == player.getHeldItemMainhand()) {
        ForgeEventFactory.onPlayerDestroyItem(player, stack, EnumHand.MAIN_HAND);
        player.setHeldItem(EnumHand.MAIN_HAND, null);
      }
      Minecraft.getMinecraft().getConnection().sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, posCurrent, Minecraft.getMinecraft().objectMouseOver.sideHit));
    }
    else if (player instanceof EntityPlayerMP) {//Server side, so this works
      EntityPlayerMP mp = (EntityPlayerMP) player;
      int xpGivenOnDrop = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP) player).interactionManager.getGameType(), (EntityPlayerMP) player, posCurrent);
      if (xpGivenOnDrop >= 0) {
        if (blockCurrent.removedByPlayer(bsCurrent, world, posCurrent, player, true)) {
          TileEntity tile = world.getTileEntity(posCurrent);
          blockCurrent.onBlockDestroyedByPlayer(world, posCurrent, bsCurrent);
          blockCurrent.harvestBlock(world, player, posCurrent, bsCurrent, tile, stack);
          blockCurrent.dropXpOnBlockBreak(world, posCurrent, xpGivenOnDrop);
        }
        mp.connection.sendPacket(new SPacketBlockChange(world, posCurrent));
      }
    }
  }
  return super.onBlockStartBreak(stack, posHit, player);
}
项目:ClockworkPhase2    文件:ClientProxy.java   
@Override
public void sendBlockDestroyPacket(BlockPos pos) {
    //noinspection ConstantConditions
    Minecraft.getMinecraft().getConnection().sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, pos, Minecraft.getMinecraft().objectMouseOver.sideHit));
}
项目:ExpandedRailsMod    文件:PlayerControllerMP.java   
/**
 * 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;
    }
}
项目:ExpandedRailsMod    文件:PlayerControllerMP.java   
public boolean onPlayerDamageBlock(BlockPos posBlock, EnumFacing directionFacing)
{
    this.syncCurrentPlayItem();

    if (this.blockHitDelay > 0)
    {
        --this.blockHitDelay;
        return true;
    }
    else if (this.currentGameType.isCreative() && this.mc.theWorld.getWorldBorder().contains(posBlock))
    {
        this.blockHitDelay = 5;
        this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, posBlock, directionFacing));
        clickBlockCreative(this.mc, this, posBlock, directionFacing);
        return true;
    }
    else if (this.isHittingPosition(posBlock))
    {
        IBlockState iblockstate = this.mc.theWorld.getBlockState(posBlock);
        Block block = iblockstate.getBlock();

        if (iblockstate.getMaterial() == Material.AIR)
        {
            this.isHittingBlock = false;
            return false;
        }
        else
        {
            this.curBlockDamageMP += iblockstate.getPlayerRelativeBlockHardness(this.mc.thePlayer, this.mc.thePlayer.worldObj, posBlock);

            if (this.stepSoundTickCounter % 4.0F == 0.0F)
            {
                SoundType soundtype = block.getSoundType(iblockstate, mc.theWorld, posBlock, mc.thePlayer);
                this.mc.getSoundHandler().playSound(new PositionedSoundRecord(soundtype.getHitSound(), SoundCategory.NEUTRAL, (soundtype.getVolume() + 1.0F) / 8.0F, soundtype.getPitch() * 0.5F, posBlock));
            }

            ++this.stepSoundTickCounter;

            if (this.curBlockDamageMP >= 1.0F)
            {
                this.isHittingBlock = false;
                this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, posBlock, directionFacing));
                this.onPlayerDestroyBlock(posBlock);
                this.curBlockDamageMP = 0.0F;
                this.stepSoundTickCounter = 0.0F;
                this.blockHitDelay = 5;
            }

            this.mc.theWorld.sendBlockBreakProgress(this.mc.thePlayer.getEntityId(), this.currentBlock, (int)(this.curBlockDamageMP * 10.0F) - 1);
            return true;
        }
    }
    else
    {
        return this.clickBlock(posBlock, directionFacing);
    }
}
项目:ExpandedRailsMod    文件:PlayerControllerMP.java   
public void onStoppedUsingItem(EntityPlayer playerIn)
{
    this.syncCurrentPlayItem();
    this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
    playerIn.stopActiveHand();
}
项目:EnderIO    文件:FakeNetHandlerPlayServer.java   
@Override
public void processPlayerDigging(@Nonnull CPacketPlayerDigging p_147345_1_) {
}
项目:DankNull    文件:NetServerHandlerFake.java   
@Override
public void processPlayerDigging(CPacketPlayerDigging packetIn) {

}
项目:Backmemed    文件:INetHandlerPlayServer.java   
/**
 * Processes the player initiating/stopping digging on a particular spot, as well as a player dropping items?. (0:
 * initiated, 1: reinitiated, 2? , 3-4 drop item (respectively without or with player control), 5: stopped; x,y,z,
 * side clicked on;)
 */
void processPlayerDigging(CPacketPlayerDigging packetIn);
项目:CustomWorldGen    文件:INetHandlerPlayServer.java   
/**
 * Processes the player initiating/stopping digging on a particular spot, as well as a player dropping items?. (0:
 * initiated, 1: reinitiated, 2? , 3-4 drop item (respectively without or with player control), 5: stopped; x,y,z,
 * side clicked on;)
 */
void processPlayerDigging(CPacketPlayerDigging packetIn);