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));
}
}
}
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);
}
Aggregations