diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 80e03c99c..794a2b4c8 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -1063,25 +1063,25 @@ opencomputers { # in case of a number it has to be the potion ID. Add any potion effects # to make use of here, since they will all be disabled by default. potionWhitelist: [ - "potion.moveSpeed", - "potion.digSpeed", - "potion.damageBoost", - "potion.jump", - "potion.resistance", - "potion.fireResistance", - "potion.waterBreathing", - "potion.nightVision", - "potion.absorption", + "speed", + "haste", + "strength", + "jump_boost", + "resistance", + "fire_resistance", + "water_breathing", + "night_vision", + "absorption", - "potion.blindness", - "potion.confusion", - "potion.digSlowDown", - "potion.harm", - "potion.hunger", - "potion.moveSlowdown", - "potion.poison", - "potion.weakness", - "potion.wither" + "blindness", + "nausea", + "mining_fatigue", + "instant_damage", + "hunger", + "slowness", + "poison", + "weakness", + "wither" ] # How much damage the hungry behavior should deal to the player when the diff --git a/src/main/scala/li/cil/oc/Settings.scala b/src/main/scala/li/cil/oc/Settings.scala index 3328b8825..32da921ef 100644 --- a/src/main/scala/li/cil/oc/Settings.scala +++ b/src/main/scala/li/cil/oc/Settings.scala @@ -372,7 +372,7 @@ class Settings(val config: Config) { val nanomachinesCommandRange = config.getDouble("nanomachines.commandRange") max 0 val nanomachineMagnetRange = config.getDouble("nanomachines.magnetRange") max 0 val nanomachineDisintegrationRange = config.getInt("nanomachines.disintegrationRange") max 0 - val nanomachinePotionWhitelist = config.getStringList("nanomachines.potionWhitelist") + val nanomachinePotionWhitelist = config.getAnyRefList("nanomachines.potionWhitelist") val nanomachinesHungryDamage = config.getDouble("nanomachines.hungryDamage").toFloat max 0 val nanomachinesHungryEnergyRestored = config.getDouble("nanomachines.hungryEnergyRestored") max 0 @@ -513,6 +513,10 @@ object Settings { // Upgrading to version 1.5.20, changed relay delay default. VersionRange.createFromVersionSpec("[0.0, 1.5.20)") -> Array( "switch.relayDelayUpgrade" + ), + // Potion whitelist was fixed in 1.6.2. + VersionRange.createFromVersionSpec("[0.0, 1.6.2)") -> Array( + "nanomachines.potionWhitelist" ) ) diff --git a/src/main/scala/li/cil/oc/common/nanomachines/provider/PotionProvider.scala b/src/main/scala/li/cil/oc/common/nanomachines/provider/PotionProvider.scala index fd79e93a6..7b1283abe 100644 --- a/src/main/scala/li/cil/oc/common/nanomachines/provider/PotionProvider.scala +++ b/src/main/scala/li/cil/oc/common/nanomachines/provider/PotionProvider.scala @@ -16,7 +16,15 @@ object PotionProvider extends ScalaProvider("c29e4eec-5a46-479a-9b3d-ad0f06da784 // Lazy to give other mods a chance to register their potions. lazy val PotionWhitelist = filterPotions(Settings.get.nanomachinePotionWhitelist) - def filterPotions(list: Iterable[String]) = list.map(Potion.getPotionFromResourceLocation).filter(_ != null).toSet + def filterPotions[T](list: Iterable[T]) = { + list.map { + case name: String => Option(Potion.getPotionFromResourceLocation(name)) + case id: java.lang.Number => Option(Potion.getPotionById(id.intValue())) + case _ => None + }.collect { + case Some(potion) => potion + }.toSet + } def isPotionEligible(potion: Potion) = potion != null && PotionWhitelist.contains(potion) @@ -27,14 +35,14 @@ object PotionProvider extends ScalaProvider("c29e4eec-5a46-479a-9b3d-ad0f06da784 override def writeBehaviorToNBT(behavior: Behavior, nbt: NBTTagCompound): Unit = { behavior match { case potionBehavior: PotionBehavior => - nbt.setInteger("potionId", Potion.getIdFromPotion(potionBehavior.potion)) + nbt.setString("potionId", Potion.REGISTRY.getNameForObject(potionBehavior.potion).toString) case _ => // Shouldn't happen, ever. } } override def readBehaviorFromNBT(player: EntityPlayer, nbt: NBTTagCompound) = { - val potionId = nbt.getInteger("potionId") - new PotionBehavior(Potion.getPotionById(potionId), player) + val potionId = nbt.getString("potionId") + new PotionBehavior(Potion.getPotionFromResourceLocation(potionId), player) } class PotionBehavior(val potion: Potion, player: EntityPlayer) extends AbstractBehavior(player) {