mirror of
https://github.com/GTNewHorizons/gendustry.git
synced 2026-10-26 14:34:13 +00:00
Added custom flower alleles (WIP)
This commit is contained in:
1 parent
746bcf63d0
commit
7a55a63833
10 files changed
+186
-6
No files matched your search
+2
-2
@@ -5,7 +5,7 @@ curseforge.id=70492
|
||||
bdlib.version=1.9.4.109
|
||||
|
||||
minecraft.version=1.7.10
|
||||
forge.version=10.13.4.1558-1.7.10
|
||||
forge.version=10.13.4.1566-1.7.10
|
||||
|
||||
nei.version=1.0.5.118
|
||||
ccl.version=1.1.3.140
|
||||
@@ -13,7 +13,7 @@ ccc.version=1.0.7.47
|
||||
|
||||
buildcraft.version=7.1.14
|
||||
ic2.version=2.2.802-experimental
|
||||
forestry.version=4.2.1.48
|
||||
forestry.version=4.2.3.51
|
||||
waila.version=1.5.10
|
||||
mekanism.version=8.1.7.5
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ if HaveForestryModule Bees <<
|
||||
cfg Traits {
|
||||
Base = "forestry.speciesForest" // Copy traits from another species
|
||||
Nocturnal = "forestry.boolTrue" // Override a single trait
|
||||
Flower_Provider = "gendustry.flowersGoldBlocks" // See below
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,6 +64,14 @@ if HaveForestryModule Bees <<
|
||||
}
|
||||
}
|
||||
|
||||
// Custom Flower allele that accepts gold blocks and spreads gold ore
|
||||
|
||||
FlowerAllele goldBlocks { // Allele UID will be gendustry.flowersGoldBlocks (note the capitalization)
|
||||
Dominant // can be either Dominant or Recessive
|
||||
Accepts OD:blockGold, OD:blockIron // List of blocks that are accepted as "flowers"
|
||||
Spread OD:oreGold 1.0 // A block that will be spread randomly, with weight
|
||||
}
|
||||
|
||||
recipes {
|
||||
|
||||
// http://bdew.net/gendustry/configuration/centrifuge-recipes/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
gendustry.bees.species.Test=Test
|
||||
gendustry.bees.species.Test.description=A curious species of bees, used to demonstrate the config system
|
||||
gendustry.honeycomb.test.name=Test Comb
|
||||
gendustry.honeydrop.test.name=Test Honey Drop
|
||||
gendustry.honeydrop.test.name=Test Honey Drop
|
||||
gendustry.allele.flowers.goldBlocks=Gold Bocks
|
||||
@@ -24,7 +24,7 @@ import net.bdew.gendustry.compat.triggers.TriggerProvider
|
||||
import net.bdew.gendustry.compat.{ForestryHelper, PowerProxy}
|
||||
import net.bdew.gendustry.config._
|
||||
import net.bdew.gendustry.config.loader.TuningLoader
|
||||
import net.bdew.gendustry.custom.{CustomContent, CustomHives}
|
||||
import net.bdew.gendustry.custom.{CustomContent, CustomFlowerAlleles, CustomHives}
|
||||
import net.bdew.gendustry.forestry.GeneRecipe
|
||||
import net.bdew.gendustry.gui.HintIcons
|
||||
import net.bdew.gendustry.machines.apiary.GendustryErrorStates
|
||||
@@ -113,6 +113,7 @@ object Gendustry {
|
||||
def postInit(event: FMLPostInitializationEvent) {
|
||||
TuningLoader.loadDelayed()
|
||||
if (ForestryHelper.haveRoot("Bees")) {
|
||||
CustomFlowerAlleles.registerAlleles()
|
||||
CustomContent.registerTemplates()
|
||||
CustomContent.registerMutations()
|
||||
CustomHives.registerHives()
|
||||
|
||||
@@ -14,7 +14,7 @@ import forestry.api.recipes.RecipeManagers
|
||||
import net.bdew.gendustry.Gendustry
|
||||
import net.bdew.gendustry.compat.ForestryHelper
|
||||
import net.bdew.gendustry.config.Tuning
|
||||
import net.bdew.gendustry.custom.CustomHives
|
||||
import net.bdew.gendustry.custom.{CustomFlowerAlleles, CustomHives}
|
||||
import net.bdew.gendustry.fluids.{LiquidDNASources, MutagenSources, ProteinSources}
|
||||
import net.bdew.lib.recipes._
|
||||
import net.bdew.lib.recipes.gencfg.GenericConfigLoader
|
||||
@@ -112,6 +112,8 @@ class Loader extends RecipeLoader with GenericConfigLoader with LootListLoader {
|
||||
override def processConfigStatement(s: ConfigStatement): Unit = s match {
|
||||
case x: CSHiveDefinition =>
|
||||
CustomHives.registerHiveDefinition(x)
|
||||
case x: CSFlowerAllele =>
|
||||
CustomFlowerAlleles.addDefinition(x)
|
||||
case _ => super.processConfigStatement(s)
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import net.bdew.lib.recipes.RecipeParser
|
||||
import net.bdew.lib.recipes.gencfg.{CfgVal, GenericConfigParser}
|
||||
import net.bdew.lib.recipes.lootlist.LootListParser
|
||||
|
||||
class Parser extends RecipeParser with GenericConfigParser with LootListParser with ParserHives {
|
||||
class Parser extends RecipeParser with GenericConfigParser with LootListParser with ParserHives with ParserAlleles {
|
||||
override def recipeStatement = mutagen | dna | protein | assembly | stMutation | centrifuge | squeezer | super.recipeStatement
|
||||
|
||||
// === Machine Recipes ===
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013 - 2015
|
||||
* https://github.com/bdew/gendustry
|
||||
*
|
||||
* This mod is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://bdew.net/minecraft-mod-public-license/
|
||||
*/
|
||||
|
||||
package net.bdew.gendustry.config.loader
|
||||
|
||||
import net.bdew.lib.recipes.RecipeParser
|
||||
import net.bdew.lib.recipes.gencfg.GenericConfigParser
|
||||
|
||||
trait ParserAlleles extends RecipeParser with GenericConfigParser {
|
||||
private def blocks = spec ~ ("," ~> spec).* ^^ { case sp1 ~ spl => List(sp1) ++ spl }
|
||||
|
||||
private def flowerStatement = (
|
||||
"Accepts" ~> blocks ^^ FADAccepts
|
||||
| "Spread" ~> spec ~ decimalNumber ^^ { case spec ~ chance => FADSpread(spec, chance.toDouble) }
|
||||
| "Dominant" ^^^ FADDominant(true)
|
||||
| "Recessive" ^^^ FADDominant(false)
|
||||
)
|
||||
|
||||
private def flowerDef = "FlowerAllele" ~> str ~ ("{" ~> flowerStatement.* <~ "}") ^^ { case id ~ statements => CSFlowerAllele(id, statements) }
|
||||
|
||||
override def configStatement = super.configStatement | flowerDef
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013 - 2015
|
||||
* https://github.com/bdew/gendustry
|
||||
*
|
||||
* This mod is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://bdew.net/minecraft-mod-public-license/
|
||||
*/
|
||||
|
||||
package net.bdew.gendustry.config.loader
|
||||
|
||||
import net.bdew.lib.recipes.{ConfigStatement, StackRef}
|
||||
|
||||
case class CSFlowerAllele(id: String, definition: List[FlowerAlleleDefStatement]) extends ConfigStatement
|
||||
|
||||
trait FlowerAlleleDefStatement
|
||||
|
||||
case class FADAccepts(accepts: List[StackRef]) extends FlowerAlleleDefStatement
|
||||
|
||||
case class FADSpread(block: StackRef, weight: Double) extends FlowerAlleleDefStatement
|
||||
|
||||
case class FADDominant(dominant: Boolean) extends FlowerAlleleDefStatement
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013 - 2015
|
||||
* https://github.com/bdew/gendustry
|
||||
*
|
||||
* This mod is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://bdew.net/minecraft-mod-public-license/
|
||||
*/
|
||||
|
||||
package net.bdew.gendustry.custom
|
||||
|
||||
import forestry.api.apiculture.{EnumBeeChromosome, FlowerManager}
|
||||
import forestry.api.genetics._
|
||||
import net.bdew.gendustry.Gendustry
|
||||
import net.bdew.gendustry.config.loader._
|
||||
import net.bdew.lib.Misc
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraftforge.oredict.OreDictionary
|
||||
|
||||
object CustomFlowerAlleles {
|
||||
var definitions = List.empty[CSFlowerAllele]
|
||||
lazy val flowerRegistry = FlowerManager.flowerRegistry
|
||||
|
||||
def addDefinition(definition: CSFlowerAllele) = definitions +:= definition
|
||||
|
||||
def registerAlleles(): Unit = {
|
||||
for (CSFlowerAllele(id, definition) <- definitions) {
|
||||
val dominant = {
|
||||
val entries = Misc.filterType(definition, classOf[FADDominant])
|
||||
if (entries.isEmpty) {
|
||||
Gendustry.logWarn("Flower allele %s has no Dominant/Recessive flag, assuming dominant", id)
|
||||
true
|
||||
} else {
|
||||
if (entries.size > 1) {
|
||||
Gendustry.logWarn("Flower allele %s has multiple Dominant/Recessive flags, only the first will be used", id)
|
||||
}
|
||||
entries.head.dominant
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
val flowerType = "gendustry." + id
|
||||
|
||||
val flowerProvider = CustomFlowerProvider(flowerType, id)
|
||||
|
||||
Gendustry.logDebug("Registering custom flower allele %s", id)
|
||||
|
||||
AlleleManager.alleleFactory.createFlowers(Gendustry.modId, "flowers", id, flowerProvider, dominant, EnumBeeChromosome.FLOWER_PROVIDER)
|
||||
|
||||
for {
|
||||
entry <- Misc.filterType(definition, classOf[FADAccepts])
|
||||
stackRef <- entry.accepts
|
||||
item <- TuningLoader.loader.getAllConcreteStacks(stackRef)
|
||||
block <- Option(Block.getBlockFromItem(item.getItem))
|
||||
} {
|
||||
Gendustry.logDebug("Registering custom acceptable flower for allele %s: %s", id, item)
|
||||
if (item.getItemDamage == OreDictionary.WILDCARD_VALUE) {
|
||||
flowerRegistry.registerAcceptableFlower(block, flowerType)
|
||||
} else {
|
||||
flowerRegistry.registerAcceptableFlower(block, item.getItemDamage, flowerType)
|
||||
}
|
||||
}
|
||||
|
||||
for {
|
||||
FADSpread(stackRef, weight) <- Misc.filterType(definition, classOf[FADSpread])
|
||||
} {
|
||||
val item = TuningLoader.loader.getConcreteStackNoWildcard(stackRef)
|
||||
val block = Block.getBlockFromItem(item.getItem)
|
||||
Gendustry.logDebug("Registering custom spread flower for allele %s: %s (weight %.03f)", id, item, weight)
|
||||
if (block == null)
|
||||
Gendustry.logWarn("Definition %s in flower allele %s doesn't refer to a block, it will be ignored", stackRef, id)
|
||||
else if (item.getItemDamage == OreDictionary.WILDCARD_VALUE)
|
||||
flowerRegistry.registerPlantableFlower(block, 0, weight, flowerType)
|
||||
else
|
||||
flowerRegistry.registerPlantableFlower(block, item.getItemDamage, weight, flowerType)
|
||||
}
|
||||
}
|
||||
definitions = List.empty
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013 - 2015
|
||||
* https://github.com/bdew/gendustry
|
||||
*
|
||||
* This mod is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://bdew.net/minecraft-mod-public-license/
|
||||
*/
|
||||
|
||||
package net.bdew.gendustry.custom
|
||||
|
||||
import forestry.api.apiculture.FlowerManager
|
||||
import forestry.api.genetics.{IFlowerProvider, IIndividual, IPollinatable}
|
||||
import net.bdew.lib.Misc
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.world.World
|
||||
import net.minecraftforge.common.EnumPlantType
|
||||
|
||||
case class CustomFlowerProvider(flowerType: String, name: String) extends IFlowerProvider {
|
||||
def getFlowerType = flowerType
|
||||
|
||||
def isAcceptedPollinatable(world: World, pollinatable: IPollinatable) = {
|
||||
val plantTypes = pollinatable.getPlantType
|
||||
plantTypes.size > 1 || !plantTypes.contains(EnumPlantType.Nether)
|
||||
}
|
||||
|
||||
def growFlower(world: World, individual: IIndividual, x: Int, y: Int, z: Int) =
|
||||
FlowerManager.flowerRegistry.growFlower(flowerType, world, individual, x, y, z)
|
||||
|
||||
def getDescription: String =
|
||||
Misc.toLocal("gendustry.allele.flowers." + name)
|
||||
|
||||
def affectProducts(world: World, individual: IIndividual, x: Int, y: Int, z: Int, products: Array[ItemStack]): Array[ItemStack] =
|
||||
products
|
||||
|
||||
def getFlowers = FlowerManager.flowerRegistry.getAcceptableFlowers(flowerType)
|
||||
}
|
||||
Reference in new issue
Block a user