Search in sources :

Example 1 with BlockTuple

use of micdoodle8.mods.galacticraft.api.vector.BlockTuple in project Galacticraft by micdoodle8.

the class TickHandlerClient method registerDetectableBlocks.

public static void registerDetectableBlocks(boolean logging) {
    ClientProxyCore.detectableBlocks.clear();
    for (final String s : ConfigManagerCore.detectableIDs) {
        BlockTuple bt = ConfigManagerCore.stringToBlock(s, "External Detectable IDs", logging);
        if (bt == null) {
            continue;
        }
        int meta = bt.meta;
        if (meta == -1) {
            meta = 0;
        }
        boolean flag = false;
        for (BlockMetaList blockMetaList : ClientProxyCore.detectableBlocks) {
            if (blockMetaList.getBlock() == bt.block) {
                if (!blockMetaList.getMetaList().contains(meta)) {
                    blockMetaList.getMetaList().add(meta);
                }
                flag = true;
                break;
            }
        }
        if (!flag) {
            List<Integer> metaList = Lists.newArrayList();
            metaList.add(meta);
            ClientProxyCore.detectableBlocks.add(new BlockMetaList(bt.block, metaList));
        }
    }
}
Also used : BlockMetaList(micdoodle8.mods.galacticraft.core.wrappers.BlockMetaList) BlockTuple(micdoodle8.mods.galacticraft.api.vector.BlockTuple) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint)

Example 2 with BlockTuple

use of micdoodle8.mods.galacticraft.api.vector.BlockTuple in project Galacticraft by micdoodle8.

the class ConfigManagerCore method stringToBlock.

public static BlockTuple stringToBlock(String s, String caller, boolean logging) {
    int lastColon = s.lastIndexOf(':');
    int meta = -1;
    String name;
    if (lastColon > 0) {
        try {
            meta = Integer.parseInt(s.substring(lastColon + 1, s.length()));
        } catch (NumberFormatException ex) {
        }
    }
    if (meta == -1) {
        name = s;
    } else {
        name = s.substring(0, lastColon);
    }
    Block block = Block.getBlockFromName(name);
    if (block == null) {
        Item item = (Item) Item.itemRegistry.getObject(new ResourceLocation(name));
        if (item instanceof ItemBlock) {
            block = ((ItemBlock) item).block;
        }
        if (block == null) {
            if (logging) {
                GCLog.severe("[config] " + caller + ": unrecognised block name '" + s + "'.");
            }
            return null;
        }
    }
    try {
        Integer.parseInt(name);
        String bName = (String) GameData.getBlockRegistry().getNameForObject(block).toString();
        if (logging) {
            GCLog.info("[config] " + caller + ": the use of numeric IDs is discouraged, please use " + bName + " instead of " + name);
        }
    } catch (NumberFormatException ex) {
    }
    if (Blocks.air == block) {
        if (logging) {
            GCLog.info("[config] " + caller + ": not a good idea to specify air, skipping that!");
        }
        return null;
    }
    return new BlockTuple(block, meta);
}
Also used : Item(net.minecraft.item.Item) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemBlock(net.minecraft.item.ItemBlock) BlockTuple(micdoodle8.mods.galacticraft.api.vector.BlockTuple)

Aggregations

BlockTuple (micdoodle8.mods.galacticraft.api.vector.BlockTuple)2 BlockMetaList (micdoodle8.mods.galacticraft.core.wrappers.BlockMetaList)1 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)1 Block (net.minecraft.block.Block)1 Item (net.minecraft.item.Item)1 ItemBlock (net.minecraft.item.ItemBlock)1 ResourceLocation (net.minecraft.util.ResourceLocation)1