From 429107215f95bb9ae9e92c11fe0a6104ded952ee Mon Sep 17 00:00:00 2001 From: bdew Date: Sun, 10 May 2015 15:36:31 +0300 Subject: [PATCH] Allow fractional chances in config lootlists --- src/net/bdew/lib/recipes/lootlist/EntryLootList.scala | 4 ++-- src/net/bdew/lib/recipes/lootlist/LootListLoader.scala | 4 ++-- src/net/bdew/lib/recipes/lootlist/LootListParser.scala | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/net/bdew/lib/recipes/lootlist/EntryLootList.scala b/src/net/bdew/lib/recipes/lootlist/EntryLootList.scala index 1dd5f0b..b519b3c 100644 --- a/src/net/bdew/lib/recipes/lootlist/EntryLootList.scala +++ b/src/net/bdew/lib/recipes/lootlist/EntryLootList.scala @@ -14,10 +14,10 @@ import net.bdew.lib.recipes.gencfg.ConfigEntry /** * Allows definition of random-weighted loot/drop lists in config sections - * @param list List on (chance percent, stack reference) pairs, resolve to + * @param list List of (chance percent, stack reference) pairs, resolve to * real ItemStacks with LootListLoader.resolveLootList */ -case class EntryLootList(list: List[(Int, StackRef)]) extends ConfigEntry +case class EntryLootList(list: List[(Double, StackRef)]) extends ConfigEntry diff --git a/src/net/bdew/lib/recipes/lootlist/LootListLoader.scala b/src/net/bdew/lib/recipes/lootlist/LootListLoader.scala index b272403..0971bd8 100644 --- a/src/net/bdew/lib/recipes/lootlist/LootListLoader.scala +++ b/src/net/bdew/lib/recipes/lootlist/LootListLoader.scala @@ -19,8 +19,8 @@ import net.minecraftforge.oredict.OreDictionary * Loader mixin for loot lists */ trait LootListLoader extends GenericConfigLoader { - def resolveLootList(entry: EntryLootList): List[(Int, ItemStack)] = resolveLootList(entry.list) - def resolveLootList(list: List[(Int, StackRef)]) = + def resolveLootList(entry: EntryLootList): List[(Double, ItemStack)] = resolveLootList(entry.list) + def resolveLootList(list: List[(Double, StackRef)]) = (for ((chance, ref) <- list) yield { try { val itemStack = getConcreteStack(ref) diff --git a/src/net/bdew/lib/recipes/lootlist/LootListParser.scala b/src/net/bdew/lib/recipes/lootlist/LootListParser.scala index a9f53e4..cd12359 100644 --- a/src/net/bdew/lib/recipes/lootlist/LootListParser.scala +++ b/src/net/bdew/lib/recipes/lootlist/LootListParser.scala @@ -19,7 +19,7 @@ import net.bdew.lib.recipes.gencfg.GenericConfigParser * ) */ trait LootListParser extends GenericConfigParser { - def dropsEntry = (wholeNumber <~ "%") ~ spec ^^ { case n ~ s => (n.toInt, s) } + def dropsEntry = (decimalNumber <~ "%") ~ spec ^^ { case n ~ s => (n.toDouble, s) } def ceDrops = "DropsList" ~> "(" ~> dropsEntry.* <~ ")" ^^ EntryLootList override def cfgValue = ceDrops | super.cfgValue }