From 47a28c97f7c8eea99d47aa9b446c3f65e10c6bd7 Mon Sep 17 00:00:00 2001 From: bdew Date: Tue, 28 Jul 2015 11:11:40 +0300 Subject: [PATCH] more work on drops for custom hives --- example_configs/hives.cfg | 5 +++++ src/net/bdew/gendustry/config/loader/ParserHives.scala | 2 +- src/net/bdew/gendustry/custom/CustomHives.scala | 8 +++++++- src/net/bdew/gendustry/custom/hives/HiveDrop.scala | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/example_configs/hives.cfg b/example_configs/hives.cfg index 3fb3056..6e35fbc 100644 --- a/example_configs/hives.cfg +++ b/example_configs/hives.cfg @@ -21,6 +21,11 @@ HiveGen Test { // hive ID - must be unique, determines block name NextTo Air // At least 1 block next to hive must be air Replace Replaceable // Spawn instead of air or "replaceable" material blocks (plants, etc.) + Drops { + 90% "forestry.speciesIndustrious" (10% ignoble) + I:Forestry:beeCombs @ 0 + 3% "forestry.speciesValiant" + I:Forestry:beeCombs @ 1 + } + // Visual settings // Texture must be provided by a mod or a resource pack // Texture will default to gendustry:beehives/{id}/{top|side} if not specified diff --git a/src/net/bdew/gendustry/config/loader/ParserHives.scala b/src/net/bdew/gendustry/config/loader/ParserHives.scala index ffec3db..f8e095a 100644 --- a/src/net/bdew/gendustry/config/loader/ParserHives.scala +++ b/src/net/bdew/gendustry/config/loader/ParserHives.scala @@ -24,7 +24,7 @@ trait ParserHives extends RecipeParser with GenericConfigParser { private def intRange = int ~ ("-" ~> int) ^^ { case a ~ b => (a, b) } private def hiveDropEntry = - (int <~ "%") ~ str ~ (int <~ "%" <~ "ignoble").? ~ ("+" ~> spec).* ^^ { case chance ~ uid ~ ignoble ~ drops => HiveDropEntry(chance, uid, ignoble.getOrElse(0) / 100F, drops) } + (int <~ "%") ~ str ~ ("(" ~> int <~ "%" <~ "ignoble" <~ ")").? ~ ("+" ~> spec).* ^^ { case chance ~ uid ~ ignoble ~ drops => HiveDropEntry(chance, uid, ignoble.getOrElse(0) / 100F, drops) } private def hiveDefStatement = ( "YLevel" ~> int ~ "-" ~ int ^^ { case min ~ a ~ max => HDYRange(min, max) } diff --git a/src/net/bdew/gendustry/custom/CustomHives.scala b/src/net/bdew/gendustry/custom/CustomHives.scala index da87d92..a256496 100644 --- a/src/net/bdew/gendustry/custom/CustomHives.scala +++ b/src/net/bdew/gendustry/custom/CustomHives.scala @@ -26,6 +26,7 @@ import net.minecraftforge.oredict.OreDictionary object CustomHives { var definitions = List.empty[CSHiveDefinition] + var blocks = Map.empty[CSHiveDefinition, BeeHive] def registerHiveDefinition(definition: CSHiveDefinition): Unit = { definitions :+= definition @@ -42,6 +43,7 @@ object CustomHives { color = color, lightLevel = lightLevel )) + blocks += definition -> block Gendustry.logDebug("Registered hive block: %s", block) } @@ -155,9 +157,13 @@ object CustomHives { Gendustry.logDebug("Registering hive definition: %s", hive) HiveManager.hiveRegistry.registerHive("Gendustry:" + definition.id, hive) + + blocks(definition).hive = Some(hive) } } - definitions = List.empty // clear definitions + // clear data that's no longer needed + definitions = List.empty + blocks = Map.empty } } diff --git a/src/net/bdew/gendustry/custom/hives/HiveDrop.scala b/src/net/bdew/gendustry/custom/hives/HiveDrop.scala index a4a0a17..a9ce27d 100644 --- a/src/net/bdew/gendustry/custom/hives/HiveDrop.scala +++ b/src/net/bdew/gendustry/custom/hives/HiveDrop.scala @@ -36,7 +36,7 @@ case class HiveDrop(chance: Int, species: IAlleleBeeSpecies, ignobleShare: Float override def getAdditional(world: World, x: Int, y: Int, z: Int, fortune: Int): util.Collection[ItemStack] = { import scala.collection.JavaConversions._ - additional + additional.map(_.copy()) } override def getChance(world: World, x: Int, y: Int, z: Int): Int = chance