mirror of
https://github.com/GTNewHorizons/gendustry.git
synced 2026-11-18 19:39:08 +00:00
Started work on customizeable bees
This commit is contained in:
1 parent
81dbba790d
commit
1e5e4d6080
7 files changed
+246
-4
No files matched your search
@@ -0,0 +1,42 @@
|
||||
cfg Branches {
|
||||
cfg Metal { // Section name is unused but must be unique
|
||||
UID = "gendustry.metal" // uid of new branch, should be namespaced to prevent colissions
|
||||
Parent = apidae // Parent uid, for bees should be "apidae"
|
||||
Scientific = Metalis // Fluff
|
||||
}
|
||||
}
|
||||
|
||||
cfg Bees {
|
||||
cfg Iron {
|
||||
Dominant = Yes // Whether species allele is dominant or recessive
|
||||
|
||||
Glowing = No // Whether icon should be glowing
|
||||
PrimaryColor = {255 0 0} // RGB Values (0-255)
|
||||
SecondaryColor = {0 0 255}
|
||||
|
||||
Secret = No // If true - will not show up in NEI or creative and
|
||||
// will not count against the species total.
|
||||
|
||||
Humidity = Normal // Arid, Normal, Damp
|
||||
Temperature = Hot // None, Icy, Cold, Normal, Warm, Hot, Hellish
|
||||
|
||||
Nocturnal = No // If true - only works at night
|
||||
|
||||
Binominal = Ferris // Fluff
|
||||
Authority = BDEW
|
||||
|
||||
Branch = "gendustry.metal"
|
||||
|
||||
Products : DropsList( // List of drops with chances
|
||||
50% $forestryI(beeComb) // Can use all the specifiers usable in recipes
|
||||
10% I:ingotIron
|
||||
)
|
||||
|
||||
Specialty : DropsList() // Empty list
|
||||
|
||||
cfg Traits {
|
||||
Base = "forestry.speciesIndustrious" // Copy traits from another species
|
||||
Humidity_Tolerance = "forestry.toleranceBoth4" // Override a single trait
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,5 +179,9 @@ gendustry.givesample.error.chromosome=Chromosome not found: %s
|
||||
gendustry.givesample.error.invalid=Invalid allele for requested chromosome
|
||||
gendustry.givesample.success=Given sample (Species=%s, Chromosome=%s, Allele=%s) to %s
|
||||
|
||||
# ==== BEES ====
|
||||
gendustry.bee.species.Iron=Iron
|
||||
gendustry.bee.species.Iron.description=Theese strudy bees can collect small chunks of iron from the environment
|
||||
|
||||
#this will be moved to bdlib at some point
|
||||
bdlib.label.empty=Empty
|
||||
@@ -23,6 +23,7 @@ import cpw.mods.fml.relauncher.Side
|
||||
import net.bdew.gendustry.gui.HintIcons
|
||||
import net.bdew.gendustry.compat.triggers.TriggerProvider
|
||||
import net.minecraft.command.CommandHandler
|
||||
import net.bdew.gendustry.custom.CustomContent
|
||||
|
||||
@Mod(modid = Gendustry.modId, version = "GENDUSTRY_VER", name = "Gendustry", dependencies = "required-after:Forestry@[2.3.1.0,);after:BuildCraft|energy;after:BuildCraft|Silicon;after:IC2;after:CoFHCore;after:BinnieCore;after:ExtraBees;after:ExtraTrees;after:MineFactoryReloaded;required-after:bdlib@[BDLIB_VER,)", modLanguage = "scala")
|
||||
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
|
||||
@@ -47,6 +48,7 @@ object Gendustry {
|
||||
configFile = event.getSuggestedConfigurationFile
|
||||
TuningLoader.load("tuning")
|
||||
TuningLoader.load("recipes")
|
||||
TuningLoader.load("bees")
|
||||
TuningLoader.load("override", false)
|
||||
TriggerProvider.registerTriggers()
|
||||
if (event.getSide == Side.CLIENT) {
|
||||
@@ -60,10 +62,13 @@ object Gendustry {
|
||||
NetworkRegistry.instance.registerGuiHandler(this, Config.guiHandler)
|
||||
Upgrades.init()
|
||||
TuningLoader.loadDealayed()
|
||||
CustomContent.registerBranches()
|
||||
CustomContent.registerSpecies()
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
def postInit(event: FMLPostInitializationEvent) {
|
||||
CustomContent.registerTemplates()
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.bdew.gendustry.Gendustry
|
||||
import net.bdew.lib.recipes.gencfg.ConfigSection
|
||||
import net.bdew.lib.recipes.gencfg.CfgVal
|
||||
import cpw.mods.fml.common.FMLCommonHandler
|
||||
import net.bdew.lib.recipes.lootlist.{LootListParser, LootListLoader}
|
||||
|
||||
object Tuning extends ConfigSection
|
||||
|
||||
@@ -42,7 +43,7 @@ object TuningLoader {
|
||||
|
||||
case class StAssembly(rec: List[(Char, Int)], power: Int, result: StackRef, cnt: Int) extends CraftingStatement
|
||||
|
||||
class Parser extends RecipeParser with GenericConfigParser {
|
||||
class Parser extends RecipeParser with GenericConfigParser with LootListParser {
|
||||
override def delayedStatement = mutagen | dna | protein | assembly | super.delayedStatement
|
||||
|
||||
def mutagen = "mutagen" ~> ":" ~> spec ~ ("->" ~> int) ^^ {
|
||||
@@ -73,7 +74,7 @@ object TuningLoader {
|
||||
def cfgDiv = ident ~ ("/" ~> "=" ~> decimalNumber) ^^ { case id ~ n => CfgVal(id, EntryModifierDiv(n.toFloat)) }
|
||||
}
|
||||
|
||||
class Loader extends RecipeLoader with GenericConfigLoader {
|
||||
class Loader extends RecipeLoader with GenericConfigLoader with LootListLoader {
|
||||
val cfgStore = Tuning
|
||||
|
||||
override def newParser(): RecipeParser = new Parser()
|
||||
@@ -124,7 +125,7 @@ object TuningLoader {
|
||||
|
||||
def load(part: String, checkJar: Boolean = true) {
|
||||
val f = new File(Gendustry.configDir, "%s-%s.cfg".format(Gendustry.modId, part))
|
||||
val (path,reader) = if (f.exists() && f.canRead) {
|
||||
val (path, reader) = if (f.exists() && f.canRead) {
|
||||
Gendustry.logInfo("Loading configuration from %s", f.toString)
|
||||
(f.getCanonicalPath, new FileReader(f))
|
||||
} else if (checkJar) {
|
||||
@@ -138,7 +139,7 @@ object TuningLoader {
|
||||
loader.load(reader)
|
||||
} catch {
|
||||
case e: Throwable =>
|
||||
FMLCommonHandler.instance().raiseException(e,"Gendustry config loading failed in file %s: %s".format(path, e.getMessage), true)
|
||||
FMLCommonHandler.instance().raiseException(e, "Gendustry config loading failed in file %s: %s".format(path, e.getMessage), true)
|
||||
} finally {
|
||||
reader.close()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013 - 2014
|
||||
* 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
|
||||
* https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package net.bdew.gendustry.custom
|
||||
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import forestry.api.core.IIconProvider
|
||||
import net.minecraft.util.Icon
|
||||
import net.minecraft.client.renderer.texture.IconRegister
|
||||
import forestry.api.apiculture.EnumBeeType
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
object BeeIconProvider extends IIconProvider {
|
||||
var icons: Array[Array[Icon]] = null
|
||||
val iconType = "default"
|
||||
|
||||
override def registerIcons(register: IconRegister) {
|
||||
if (icons != null)
|
||||
return
|
||||
|
||||
icons = Array.fill(EnumBeeType.values().length, 3)(null)
|
||||
|
||||
EnumBeeType.values().filter(_ != EnumBeeType.NONE).foreach(beeType => {
|
||||
icons(beeType.ordinal())(0) = register.registerIcon("forestry:bees/%s/%s.outline".format(iconType, beeType).toLowerCase)
|
||||
if (beeType == EnumBeeType.LARVAE)
|
||||
icons(beeType.ordinal())(1) = register.registerIcon("forestry:bees/%s/%s.body".format(iconType, beeType).toLowerCase)
|
||||
else
|
||||
icons(beeType.ordinal())(1) = register.registerIcon("forestry:bees/%s/body1".format(iconType).toLowerCase)
|
||||
icons(beeType.ordinal())(2) = register.registerIcon("forestry:bees/%s/%s.body2".format(iconType, beeType).toLowerCase)
|
||||
})
|
||||
}
|
||||
|
||||
override def getIcon(texUID: Short) = null
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013 - 2014
|
||||
* 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
|
||||
* https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package net.bdew.gendustry.custom
|
||||
|
||||
import forestry.api.apiculture._
|
||||
import forestry.api.core.{EnumTemperature, EnumHumidity}
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.world.World
|
||||
import forestry.api.genetics.{AlleleManager, IIndividual}
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import net.bdew.lib.recipes.gencfg.{EntryStr, ConfigSection}
|
||||
import net.bdew.lib.Misc
|
||||
import net.bdew.gendustry.Gendustry
|
||||
import net.bdew.lib.recipes.lootlist.EntryLootList
|
||||
import net.bdew.gendustry.config.TuningLoader
|
||||
|
||||
class BeeSpecies(cfg: ConfigSection, ident: String) extends IAlleleBeeSpecies {
|
||||
// IAllele
|
||||
override val getName = Misc.toLocal("gendustry.bee.species." + ident)
|
||||
override val isDominant = cfg.getBoolean("Dominant")
|
||||
override val getUID = "gendustry.bee." + ident
|
||||
|
||||
// IAlleleSpecies
|
||||
override val getIconProvider = BeeIconProvider
|
||||
|
||||
val primaryColour = cfg.getColor("PrimaryColor").asRGB
|
||||
val secondaryColour = cfg.getColor("SecondaryColor").asRGB
|
||||
|
||||
override def getIconColour(renderPass: Int) = renderPass match {
|
||||
case 0 => primaryColour
|
||||
case 1 => secondaryColour
|
||||
case _ => 0xFFFFFF
|
||||
}
|
||||
|
||||
//FIXME
|
||||
override val isSecret = cfg.getBoolean("Secret")
|
||||
override val isCounted = !isSecret
|
||||
override val hasEffect = cfg.getBoolean("Glowing")
|
||||
override val getHumidity = EnumHumidity.valueOf(cfg.getString("Humidity").toUpperCase)
|
||||
override val getTemperature = EnumTemperature.valueOf(cfg.getString("Temperature").toUpperCase)
|
||||
override def getResearchBounty(world: World, researcher: String, individual: IIndividual, bountyLevel: Int) = ???
|
||||
override def getResearchSuitability(itemstack: ItemStack) = ???
|
||||
override def getComplexity = ???
|
||||
override def getBranch = AlleleManager.alleleRegistry.getClassification("genus." + cfg.getString("Branch"))
|
||||
override def getAuthority = cfg.getString("Authority")
|
||||
override def getBinomial = cfg.getString("Binominal")
|
||||
override def getDescription = Misc.toLocal("gendustry.bee.species." + ident + ".description")
|
||||
|
||||
// IAlleleBeeSpecies
|
||||
override def getEntityTexture = "textures/entity/bees/honeyBee.png"
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def getIcon(kind: EnumBeeType, renderPass: Int) =
|
||||
BeeIconProvider.icons(kind.ordinal())(renderPass)
|
||||
|
||||
// no jubilance for now
|
||||
override def isJubilant(genome: IBeeGenome, housing: IBeeHousing) = true
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
def prepareLootList(name: String) =
|
||||
TuningLoader.loader.resolveLootList(cfg.rawget(name, classOf[EntryLootList]))
|
||||
.toMap.map(x => x._2 -> new Integer(x._1)).asJava
|
||||
|
||||
Gendustry.logInfo("Resolving products list for bee '%s'...", ident)
|
||||
override val getProducts = prepareLootList("Products")
|
||||
getProducts.asScala.foreach(x => Gendustry.logInfo(" [%d%%] %s", x._2, x._1))
|
||||
|
||||
Gendustry.logInfo("Resolving specialty list for bee '%s'...", ident)
|
||||
override val getSpecialty = prepareLootList("Specialty")
|
||||
getProducts.asScala.foreach(x => Gendustry.logInfo(" [%d%%] %s", x._2, x._1))
|
||||
|
||||
override def isNocturnal = cfg.getBoolean("Nocturnal")
|
||||
override val getRoot = AlleleManager.alleleRegistry.getSpeciesRoot("rootBees").asInstanceOf[IBeeRoot]
|
||||
|
||||
// Internal stuff
|
||||
|
||||
def getTemplate = {
|
||||
val traits = cfg.getSection("Traits")
|
||||
val tpl = (
|
||||
if (traits.hasValue("Base")) {
|
||||
Option(getRoot.getTemplate(traits.getString("Base")))
|
||||
.getOrElse(sys.error("Template %s not found".format(traits.getString("Base"))))
|
||||
} else {
|
||||
getRoot.getDefaultTemplate
|
||||
}).clone()
|
||||
|
||||
tpl(0) = this
|
||||
|
||||
for ((chrName, entry) <- traits.filterType(classOf[EntryStr]) if chrName != "Base") {
|
||||
val chromosome = EnumBeeChromosome.valueOf(chrName.toUpperCase)
|
||||
val allele = Option(AlleleManager.alleleRegistry.getAllele(entry.v))
|
||||
.getOrElse(sys.error("Allele %s not found".format(entry.v)))
|
||||
if (!chromosome.getAlleleClass.isInstance(allele))
|
||||
sys.error("Allele %s is not valid for chromosome %s".format(allele.getUID, chromosome))
|
||||
tpl(chromosome.ordinal()) = allele
|
||||
}
|
||||
|
||||
tpl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013 - 2014
|
||||
* 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
|
||||
* https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package net.bdew.gendustry.custom
|
||||
|
||||
import net.bdew.gendustry.config.Tuning
|
||||
import net.bdew.lib.recipes.gencfg.ConfigSection
|
||||
import forestry.api.genetics.AlleleManager
|
||||
import forestry.api.genetics.IClassification.EnumClassLevel
|
||||
|
||||
object CustomContent {
|
||||
val reg = AlleleManager.alleleRegistry
|
||||
var mySpecies = List.empty[BeeSpecies]
|
||||
|
||||
def registerBranches() {
|
||||
Tuning.getSection("Branches").filterType(classOf[ConfigSection]).foreach({
|
||||
case (_, cfg) =>
|
||||
val cls = reg.createAndRegisterClassification(EnumClassLevel.GENUS, cfg.getString("UID"), cfg.getString("Scientific"))
|
||||
reg.getClassification("family." + cfg.getString("Parent")).addMemberGroup(cls)
|
||||
})
|
||||
}
|
||||
|
||||
def registerSpecies() {
|
||||
Tuning.getSection("Bees").filterType(classOf[ConfigSection]).foreach({
|
||||
case (uid, cfg) =>
|
||||
val species = new BeeSpecies(cfg, uid)
|
||||
mySpecies +:= species
|
||||
reg.registerAllele(species)
|
||||
})
|
||||
}
|
||||
|
||||
def registerTemplates() {
|
||||
mySpecies.foreach(sp => sp.getRoot.registerTemplate(sp.getTemplate))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user