mirror of
https://github.com/GTNewHorizons/bdlib.git
synced 2026-11-19 03:49:36 +00:00
Allow fractional chances in config lootlists
This commit is contained in:
1 parent
0c60d596b6
commit
429107215f
3 files changed
+5
-5
No files matched your search
@@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user