forked from bdew-minecraft/gendustry
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
186 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |