From b213c8189d776d2f320baae23233b10dad2af800 Mon Sep 17 00:00:00 2001 From: bdew Date: Sun, 15 Mar 2015 11:02:10 +0200 Subject: [PATCH] Fixed crash if BC Core and/or CoFH API is present but not the respective transport API --- src/net/bdew/gendustry/compat/PowerProxy.scala | 6 +++++- src/net/bdew/gendustry/compat/itempush/ItemPush.scala | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/net/bdew/gendustry/compat/PowerProxy.scala b/src/net/bdew/gendustry/compat/PowerProxy.scala index d95730d..28fb696 100644 --- a/src/net/bdew/gendustry/compat/PowerProxy.scala +++ b/src/net/bdew/gendustry/compat/PowerProxy.scala @@ -11,6 +11,7 @@ package net.bdew.gendustry.compat import java.util +import cpw.mods.fml.common.versioning.VersionParser import cpw.mods.fml.common.{Loader, ModAPIManager, ModContainer} import net.bdew.gendustry.Gendustry import net.bdew.gendustry.config.Tuning @@ -36,7 +37,10 @@ object PowerProxy { lazy val haveIC2 = haveModVersion(IC2_MOD_ID) lazy val haveTE = haveModVersion(TE_MOD_ID) - def haveModVersion(modId: String) = lookup.contains(modId) + def haveModVersion(modId: String) = { + val spec = VersionParser.parseVersionReference(modId) + lookup.contains(spec.getLabel) && spec.containsVersion(lookup(spec.getLabel).getProcessedVersion) + } def getModVersion(modId: String): String = { val cont = lookup.getOrElse(modId, return "NOT FOUND") diff --git a/src/net/bdew/gendustry/compat/itempush/ItemPush.scala b/src/net/bdew/gendustry/compat/itempush/ItemPush.scala index e4ae951..f7b7c68 100644 --- a/src/net/bdew/gendustry/compat/itempush/ItemPush.scala +++ b/src/net/bdew/gendustry/compat/itempush/ItemPush.scala @@ -19,8 +19,8 @@ object ItemPush { def init() { register(VanillaPush) - if (PowerProxy.haveModVersion("BuildCraftAPI|core")) register(BCPipePushProxy) - if (PowerProxy.haveTE) register(CofhConduitPushProxy) + if (PowerProxy.haveModVersion("BuildCraftAPI|transport@[3.0,)")) register(BCPipePushProxy) + if (PowerProxy.haveModVersion("CoFHAPI|transport")) register(CofhConduitPushProxy) } def register(p: ItemPushProxy) = proxies :+= p