mirror of
https://github.com/GTNewHorizons/gendustry.git
synced 2026-11-27 23:45:37 +00:00
Added mutation biome and block requirements option (closes #51)
This commit is contained in:
1 parent
f6d627547b
commit
69f5d9bb87
6 files changed
+64
-9
No files matched your search
@@ -68,7 +68,14 @@ centrifuge: S:gendustry:"HoneyComb.test", 10 cycles => {
|
||||
|
||||
|
||||
// Mutation
|
||||
// Requirements are optional and can be dropped
|
||||
// Valid requirements: "Req Temperature" and "Req Humidity", more will possibly be added later
|
||||
// Requirements are optional and can be dropped, or multiple listed together
|
||||
// Valid requirements:
|
||||
// Req Temperature [Icy|Cold|Normal|Warm|Hot|Hellish]
|
||||
// Req Humidity [Arid|Normal|Damp]
|
||||
// Req Biome <biomename>
|
||||
// Req Block B[:modid]:<blockname>[@meta]
|
||||
|
||||
mutation: 10% "forestry.speciesIndustrious" + "forestry.speciesDiligent" = "gendustry.bee.Test" Req Temperature Hot
|
||||
|
||||
mutation: 10% "forestry.speciesIndustrious" + "forestry.speciesDiligent" = "gendustry.bee.Test" Req Temperature Hot
|
||||
mutation: 10% "forestry.speciesIndustrious" + "forestry.speciesCommon" = "gendustry.bee.Test" Req Biome Hell
|
||||
mutation: 10% "forestry.speciesIndustrious" + "forestry.speciesCommon" = "gendustry.bee.Test" Req Block B:wool@1
|
||||
@@ -60,6 +60,7 @@ gendustry.upgrades.sealing.name=Seal Upgrade
|
||||
gendustry.upgrades.light.name=Light Upgrade
|
||||
gendustry.upgrades.sky.name=Open Sky Upgrade
|
||||
gendustry.upgrades.hell.name=Hell Emulation Upgrade
|
||||
gendustry.upgrades.winter.name=Winter Emulation Upgrade
|
||||
gendustry.upgrades.auto.name=Automation Upgrade
|
||||
gendustry.upgrades.humidifier.name=Humidifier Upgrade
|
||||
gendustry.upgrades.dryer.name=Dryer Upgrade
|
||||
@@ -195,6 +196,8 @@ gendustry.givesample.success=Given sample (Species=%s, Chromosome=%s, Allele=%s)
|
||||
# ==== MUTATION REQUIREMENTS ====
|
||||
gendustry.req.temperature=Requires temperature: %s
|
||||
gendustry.req.humidity=Requires humidity: %s
|
||||
gendustry.req.biome=Requires biome: %s
|
||||
gendustry.req.block=Requires block: %s
|
||||
|
||||
# ==== BEE SPECIES ====
|
||||
gendustry.bees.species.black=Black
|
||||
@@ -256,3 +259,4 @@ itemGroup.bdew.samples=Genetic Samples
|
||||
|
||||
#this will be moved to bdlib at some point
|
||||
bdlib.label.empty=Empty
|
||||
|
||||
@@ -63,8 +63,10 @@ class Parser extends RecipeParser with GenericConfigParser with LootListParser {
|
||||
|
||||
def mrTemperature = "Req" ~> "Temperature" ~> ident ^^ MReqTemperature
|
||||
def mrHumidity = "Req" ~> "Humidity" ~> ident ^^ MReqHumidity
|
||||
def mrBiome = "Req" ~> "Biome" ~> str ^^ MReqBiome
|
||||
def mrBlock = "Req" ~> "Block" ~> specBlock ^^ MReqBlock
|
||||
|
||||
def mutationReq = mrTemperature | mrHumidity
|
||||
def mutationReq = mrTemperature | mrHumidity | mrBiome | mrBlock
|
||||
|
||||
def stMutation = "secret".? ~ ("mutation" ~> ":") ~ (decimalNumber <~ "%") ~ str ~ "+" ~ str ~ "=" ~ str ~ mutationReq.* ^^ {
|
||||
case secret ~ mutation ~ chance ~ p1 ~ plus ~ p2 ~ eq ~ res ~ req =>
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
|
||||
package net.bdew.gendustry.config.loader
|
||||
|
||||
import net.bdew.lib.block.BlockRef
|
||||
import net.bdew.lib.recipes.gencfg.CfgEntry
|
||||
import net.bdew.lib.recipes.{CraftingStatement, DelayedStatement, StackRef}
|
||||
import net.bdew.lib.recipes.{StackBlock, CraftingStatement, DelayedStatement, StackRef}
|
||||
|
||||
case class FluidSpec(id: String, amount: Int)
|
||||
|
||||
@@ -56,3 +57,6 @@ case class MReqTemperature(temperature: String) extends MutationRequirement
|
||||
|
||||
case class MReqHumidity(humidity: String) extends MutationRequirement
|
||||
|
||||
case class MReqBlock(block: StackBlock) extends MutationRequirement
|
||||
|
||||
case class MReqBiome(biome: String) extends MutationRequirement
|
||||
@@ -13,18 +13,41 @@ import forestry.api.apiculture.{IAlleleBeeSpecies, IBeeHousing, IBeeMutation, IB
|
||||
import forestry.api.core.{EnumHumidity, EnumTemperature}
|
||||
import forestry.api.genetics.{AlleleManager, IAllele, IGenome}
|
||||
import net.bdew.lib.Misc
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.world.biome.BiomeGenBase
|
||||
|
||||
class BeeMutation(parent1: IAlleleBeeSpecies, parent2: IAlleleBeeSpecies, result: IAlleleBeeSpecies, chance: Float) extends IBeeMutation {
|
||||
|
||||
var reqTemperature = Option[EnumTemperature](null)
|
||||
var reqHumidity = Option[EnumHumidity](null)
|
||||
var reqBlock = Option[Block](null)
|
||||
var reqBlockMeta: Option[Int] = None
|
||||
var reqBiome = Option[BiomeGenBase](null)
|
||||
|
||||
def reqBiomeId = reqBiome map (_.biomeID)
|
||||
|
||||
// === IBeeMutation ===
|
||||
|
||||
def getBlockUnderHousing(h: IBeeHousing) =
|
||||
if (h.getYCoord > 0)
|
||||
h.getWorld.getBlock(h.getXCoord, h.getYCoord - 1, h.getZCoord)
|
||||
else null
|
||||
|
||||
def getBlockMetaUnderHousing(h: IBeeHousing) =
|
||||
if (h.getYCoord > 0)
|
||||
h.getWorld.getBlockMetadata(h.getXCoord, h.getYCoord - 1, h.getZCoord)
|
||||
else -1
|
||||
|
||||
def testReq[T](req: Option[T], v: T) = !req.isDefined || req.get == v
|
||||
|
||||
override def getChance(housing: IBeeHousing, allele0: IAllele, allele1: IAllele, genome0: IGenome, genome1: IGenome) =
|
||||
if (!((allele0 == parent1 && allele1 == parent2) || (allele0 == parent2 && allele1 == parent1))) 0
|
||||
else if (reqTemperature.isDefined && reqTemperature.get != housing.getTemperature) 0
|
||||
else if (reqHumidity.isDefined && reqHumidity.get != housing.getHumidity) 0
|
||||
else if (!testReq(reqTemperature, housing.getTemperature)) 0
|
||||
else if (!testReq(reqHumidity, housing.getHumidity)) 0
|
||||
else if (!testReq(reqBiomeId, housing.getBiomeId)) 0
|
||||
else if (!testReq(reqBlock, getBlockUnderHousing(housing))) 0
|
||||
else if (!testReq(reqBlockMeta, getBlockMetaUnderHousing(housing))) 0
|
||||
else chance
|
||||
|
||||
override val getRoot = AlleleManager.alleleRegistry.getSpeciesRoot("rootBees").asInstanceOf[IBeeRoot]
|
||||
@@ -44,7 +67,9 @@ class BeeMutation(parent1: IAlleleBeeSpecies, parent2: IAlleleBeeSpecies, result
|
||||
override def getSpecialConditions = {
|
||||
import scala.collection.JavaConversions._
|
||||
reqTemperature.map(x => Misc.toLocalF("gendustry.req.temperature", x)) ++
|
||||
reqHumidity.map(x => Misc.toLocalF("gendustry.req.humidity", x))
|
||||
reqHumidity.map(x => Misc.toLocalF("gendustry.req.humidity", x)) ++
|
||||
reqBiome.map(x => Misc.toLocalF("gendustry.req.biome", x.biomeName)) ++
|
||||
reqBlock.map(x => Misc.toLocalF("gendustry.req.block", new ItemStack(x, 1, reqBlockMeta.getOrElse(0)).getDisplayName))
|
||||
}
|
||||
|
||||
override def getBaseChance = chance
|
||||
|
||||
@@ -15,8 +15,12 @@ import forestry.api.genetics.AlleleManager
|
||||
import forestry.api.genetics.IClassification.EnumClassLevel
|
||||
import net.bdew.gendustry.Gendustry
|
||||
import net.bdew.gendustry.config.Tuning
|
||||
import net.bdew.gendustry.config.loader.{MReqHumidity, MReqTemperature, TuningLoader}
|
||||
import net.bdew.gendustry.config.loader._
|
||||
import net.bdew.lib.Misc
|
||||
import net.bdew.lib.recipes.StackBlock
|
||||
import net.bdew.lib.recipes.gencfg.ConfigSection
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraftforge.oredict.OreDictionary
|
||||
|
||||
object CustomContent {
|
||||
val reg = AlleleManager.alleleRegistry
|
||||
@@ -71,6 +75,15 @@ object CustomContent {
|
||||
mutation.reqHumidity = Some(EnumHumidity.valueOf(hum.toUpperCase))
|
||||
case MReqTemperature(temp: String) =>
|
||||
mutation.reqTemperature = Some(EnumTemperature.valueOf(temp.toUpperCase))
|
||||
case MReqBlock(ref: StackBlock) =>
|
||||
val stack = TuningLoader.loader.getConcreteStack(ref)
|
||||
val block = Block.getBlockFromItem(stack.getItem)
|
||||
if (block == null) sys.error("Ivalid block reference: %s".format(ref))
|
||||
mutation.reqBlock = Some(block)
|
||||
if (stack.getItemDamage != OreDictionary.WILDCARD_VALUE)
|
||||
mutation.reqBlockMeta = Some(stack.getItemDamage)
|
||||
case MReqBiome(name: String) =>
|
||||
mutation.reqBiome = Option(Misc.getBiomeByName(name))
|
||||
}
|
||||
|
||||
mutation.getRoot.registerMutation(mutation)
|
||||
|
||||
Reference in new issue
Block a user