Search in sources :

Example 1 with PacketHackingBlockFinish

use of pneumaticCraft.common.network.PacketHackingBlockFinish in project PneumaticCraft by MineMaarten.

the class CommonHUDHandler method handleHacking.

private void handleHacking(EntityPlayer player) {
    if (hackedBlock != null) {
        IHackableBlock hackableBlock = HackableHandler.getHackableForCoord(hackedBlock, player);
        if (hackableBlock != null) {
            if (++hackTime >= hackableBlock.getHackTime(hackedBlock.world, hackedBlock.x, hackedBlock.y, hackedBlock.z, player)) {
                hackableBlock.onHackFinished(player.worldObj, hackedBlock.x, hackedBlock.y, hackedBlock.z, player);
                PneumaticCraft.proxy.getHackTickHandler().trackBlock(hackedBlock, hackableBlock);
                NetworkHandler.sendToAllAround(new PacketHackingBlockFinish(hackedBlock), player.worldObj);
                setHackedBlock(null);
            }
        } else {
            setHackedBlock(null);
        }
    } else if (hackedEntity != null) {
        IHackableEntity hackableEntity = HackableHandler.getHackableForEntity(hackedEntity, player);
        if (hackableEntity != null) {
            if (++hackTime >= hackableEntity.getHackTime(hackedEntity, player)) {
                hackableEntity.onHackFinished(hackedEntity, player);
                PneumaticCraft.proxy.getHackTickHandler().trackEntity(hackedEntity, hackableEntity);
                NetworkHandler.sendToAllAround(new PacketHackingEntityFinish(hackedEntity), new NetworkRegistry.TargetPoint(hackedEntity.worldObj.provider.dimensionId, hackedEntity.posX, hackedEntity.posY, hackedEntity.posZ, 64));
                setHackedEntity(null);
            }
        } else {
            setHackedEntity(null);
        }
    }
}
Also used : PacketHackingBlockFinish(pneumaticCraft.common.network.PacketHackingBlockFinish) IHackableBlock(pneumaticCraft.api.client.pneumaticHelmet.IHackableBlock) IHackableEntity(pneumaticCraft.api.client.pneumaticHelmet.IHackableEntity) PacketHackingEntityFinish(pneumaticCraft.common.network.PacketHackingEntityFinish)

Aggregations

IHackableBlock (pneumaticCraft.api.client.pneumaticHelmet.IHackableBlock)1 IHackableEntity (pneumaticCraft.api.client.pneumaticHelmet.IHackableEntity)1 PacketHackingBlockFinish (pneumaticCraft.common.network.PacketHackingBlockFinish)1 PacketHackingEntityFinish (pneumaticCraft.common.network.PacketHackingEntityFinish)1