Search in sources :

Example 1 with PacketHackingBlockFinish

use of me.desht.pneumaticcraft.common.network.PacketHackingBlockFinish in project pnc-repressurized by TeamPneumatic.

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.pos, player)) {
                hackableBlock.onHackFinished(player.world, hackedBlock.pos, player);
                PneumaticCraftRepressurized.proxy.getHackTickHandler().trackBlock(hackedBlock, hackableBlock);
                NetworkHandler.sendToAllAround(new PacketHackingBlockFinish(hackedBlock), player.world);
                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);
                PneumaticCraftRepressurized.proxy.getHackTickHandler().trackEntity(hackedEntity, hackableEntity);
                NetworkHandler.sendToAllAround(new PacketHackingEntityFinish(hackedEntity), new NetworkRegistry.TargetPoint(hackedEntity.world.provider.getDimension(), hackedEntity.posX, hackedEntity.posY, hackedEntity.posZ, 64));
                setHackedEntity(null);
            }
        } else {
            setHackedEntity(null);
        }
    }
}
Also used : PacketHackingBlockFinish(me.desht.pneumaticcraft.common.network.PacketHackingBlockFinish) IHackableBlock(me.desht.pneumaticcraft.api.client.pneumaticHelmet.IHackableBlock) IHackableEntity(me.desht.pneumaticcraft.api.client.pneumaticHelmet.IHackableEntity) PacketHackingEntityFinish(me.desht.pneumaticcraft.common.network.PacketHackingEntityFinish)

Aggregations

IHackableBlock (me.desht.pneumaticcraft.api.client.pneumaticHelmet.IHackableBlock)1 IHackableEntity (me.desht.pneumaticcraft.api.client.pneumaticHelmet.IHackableEntity)1 PacketHackingBlockFinish (me.desht.pneumaticcraft.common.network.PacketHackingBlockFinish)1 PacketHackingEntityFinish (me.desht.pneumaticcraft.common.network.PacketHackingEntityFinish)1