Search in sources :

Example 6 with IHackableBlock

use of pneumaticCraft.api.client.pneumaticHelmet.IHackableBlock in project PneumaticCraft by MineMaarten.

the class PneumaticCraftAPIHandler method addHackable.

@Override
public void addHackable(Block block, Class<? extends IHackableBlock> iHackable) {
    if (block == null)
        throw new NullPointerException("Block is null!");
    if (iHackable == null)
        throw new NullPointerException("IHackableBlock is null!");
    if (Block.class.isAssignableFrom(iHackable)) {
        Log.warning("Blocks that implement IHackableBlock shouldn't be registered as hackable! Registering block: " + block.getLocalizedName());
    } else {
        try {
            IHackableBlock hackableBlock = iHackable.newInstance();
            if (hackableBlock.getId() != null)
                stringToBlockHackables.put(hackableBlock.getId(), iHackable);
            hackableBlocks.put(block, iHackable);
        } catch (InstantiationException e) {
            Log.error("Not able to register hackable block: " + iHackable.getName() + ". Does the class have a parameterless constructor?");
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            Log.error("Not able to register hackable block: " + iHackable.getName() + ". Is the class a public class?");
            e.printStackTrace();
        }
    }
}
Also used : IHackableBlock(pneumaticCraft.api.client.pneumaticHelmet.IHackableBlock)

Example 7 with IHackableBlock

use of pneumaticCraft.api.client.pneumaticHelmet.IHackableBlock in project PneumaticCraft by MineMaarten.

the class PacketHackingBlockFinish method handleClientSide.

@Override
public void handleClientSide(PacketHackingBlockFinish message, EntityPlayer player) {
    IHackableBlock hackableBlock = HackableHandler.getHackableForCoord(player.worldObj, message.x, message.y, message.z, player);
    if (hackableBlock != null) {
        hackableBlock.onHackFinished(player.worldObj, message.x, message.y, message.z, player);
        PneumaticCraft.proxy.getHackTickHandler().trackBlock(new WorldAndCoord(player.worldObj, message.x, message.y, message.z), hackableBlock);
        CommonHUDHandler.getHandlerForPlayer(player).setHackedBlock(null);
        player.worldObj.playSound(message.x, message.y, message.z, "PneumaticCraft:helmetHackFinish", 1.0F, 1.0F, false);
    }
}
Also used : IHackableBlock(pneumaticCraft.api.client.pneumaticHelmet.IHackableBlock) WorldAndCoord(pneumaticCraft.common.util.WorldAndCoord)

Aggregations

IHackableBlock (pneumaticCraft.api.client.pneumaticHelmet.IHackableBlock)7 WorldAndCoord (pneumaticCraft.common.util.WorldAndCoord)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Block (net.minecraft.block.Block)2 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 World (net.minecraft.world.World)1 IBlockTrackEntry (pneumaticCraft.api.client.pneumaticHelmet.IBlockTrackEntry)1 IHackableEntity (pneumaticCraft.api.client.pneumaticHelmet.IHackableEntity)1 PacketDescriptionPacketRequest (pneumaticCraft.common.network.PacketDescriptionPacketRequest)1 PacketHackingBlockFinish (pneumaticCraft.common.network.PacketHackingBlockFinish)1 PacketHackingEntityFinish (pneumaticCraft.common.network.PacketHackingEntityFinish)1