mirror of
https://github.com/GTNewHorizons/gendustry.git
synced 2026-11-27 15:32:55 +00:00
Merged changes from main branch
Update hive spawn example Added "Near" hive spawn condition Made hive debugger check if hive replaces air or a block Added hive debugger Update!
This commit is contained in:
commit
6154317ccc
12 files changed
+165
-9
No files matched your search
+1
-1
@@ -2,7 +2,7 @@ gendustry.version=1.6.0
|
||||
gendustry.api.version=2.2.0
|
||||
curseforge.id=70492
|
||||
|
||||
bdlib.version=1.9.1.95
|
||||
bdlib.version=1.9.2.98
|
||||
|
||||
minecraft.version=1.7.10
|
||||
forge.version=10.13.4.1448-1.7.10
|
||||
|
||||
@@ -19,10 +19,10 @@ HiveGen Test { // hive ID - must be unique, determines block name
|
||||
Under Leaves // Block above hive must be leaves
|
||||
NextTo OD:logWood // At least 1 block next to hive must be any kind of wood (ore dictionary)
|
||||
NextTo Air // At least 1 block next to hive must be air
|
||||
Replace Replaceable // Spawn instead of air or "replaceable" material blocks (plants, etc.)
|
||||
Replace Air // Spawn instead of air
|
||||
|
||||
Drops {
|
||||
90% "forestry.speciesIndustrious" (10% ignoble) + I:Forestry:beeCombs @ 0
|
||||
90% "gendustry.bee.Test" (10% ignoble) + I:Forestry:beeCombs @ 0
|
||||
3% "forestry.speciesValiant" + I:Forestry:beeCombs @ 1
|
||||
}
|
||||
|
||||
@@ -36,3 +36,21 @@ HiveGen Test { // hive ID - must be unique, determines block name
|
||||
Color 0x80FF80 // And apply a greenish color multiplier to them
|
||||
LightLevel 15 // Should emit max light
|
||||
}
|
||||
|
||||
HiveGen Rock {
|
||||
YLevel 0 - 64
|
||||
SpawnChance 10
|
||||
SpawnDebug
|
||||
|
||||
Near OD:oreIron // Spawn must be near stone and air, replacing a stone block
|
||||
Near Air
|
||||
Replace B:stone
|
||||
|
||||
Drops {
|
||||
100% "forestry.speciesValiant" (50% ignoble) + I:Forestry:beeCombs @ 0
|
||||
}
|
||||
|
||||
TopTexture "minecraft:iron_ore"
|
||||
SideTexture "minecraft:iron_ore"
|
||||
Color 0xFFFF80
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
tile.gendustry.BeeHiveTest.name=Test Hive
|
||||
tile.gendustry.BeeHiveRock.name=Rock Hive
|
||||
@@ -30,6 +30,7 @@ item.gendustry.scoop.name=Scooporator MX200 Turbo
|
||||
item.gendustry.ImportCover.name=Item Import Cover
|
||||
item.gendustry.EjectCover.name=Item Eject Cover
|
||||
item.gendustry.PollenKit.name=Pollen Collection Kit
|
||||
item.gendustry.HiveSpawnDebugger.name=Hive Spawning Debugger
|
||||
|
||||
# ==== FLUIDS ====
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ item.gendustry.grafter.name=工业剪枝器
|
||||
item.gendustry.scoop.name=MX200涡轮捕蜂网
|
||||
item.gendustry.ImportCover.name=物品输入盖板
|
||||
item.gendustry.EjectCover.name=物品输出盖板
|
||||
item.gendustry.PollenKit.name=花粉收集装备
|
||||
|
||||
# ==== FLUIDS ====
|
||||
|
||||
@@ -72,6 +73,7 @@ gendustry.upgrades.cooler.name=冷却器升级
|
||||
gendustry.upgrades.desert.name=沙漠环境升级
|
||||
gendustry.upgrades.plains.name=平原环境升级
|
||||
gendustry.upgrades.jungle.name=丛林环境升级
|
||||
gendustry.upgrades.ocean.name=海洋环境升级
|
||||
gendustry.upgrades.stabilizer.name=基因稳定升级
|
||||
|
||||
# ==== GUI AND TOOLTIPS ====
|
||||
@@ -116,9 +118,6 @@ gendustry.label.mod.sieve=* 花粉收集
|
||||
gendustry.label.mod.temperature=* 温度
|
||||
gendustry.label.mod.humidity=* 湿度
|
||||
|
||||
gendustry.error.power=能量不足
|
||||
gendustry.error.disabled=被配置文件禁用
|
||||
|
||||
gendustry.label.sample.rootBees=采集自蜜蜂
|
||||
gendustry.label.sample.rootTrees=采集自树苗
|
||||
gendustry.label.sample.rootButterflies=采集自蝴蝶
|
||||
@@ -137,6 +136,10 @@ gendustry.rsmode.never=禁用
|
||||
gendustry.rsmode.rs_on=收到红石信号时启用
|
||||
gendustry.rsmode.rs_off=收到红石信号时禁用
|
||||
|
||||
gendustry.label.items=%s 物品
|
||||
|
||||
gendustry.label.shift=<按下SHIFT获取更多信息>
|
||||
|
||||
# ==== CHROMOSOMES (should match forestry) ====
|
||||
|
||||
gendustry.chromosome.FLOWER_PROVIDER=鲜花
|
||||
@@ -167,7 +170,6 @@ gendustry.chromosome.SAPPINESS=树汁
|
||||
|
||||
// Botany
|
||||
|
||||
SPECIES,
|
||||
gendustry.chromosome.PRIMARY=原生种
|
||||
gendustry.chromosome.SECONDARY=次生种
|
||||
gendustry.chromosome.PH_TOLERANCE=pH耐受性
|
||||
@@ -202,6 +204,8 @@ gendustry.req.humidity=湿度需求: %s
|
||||
gendustry.req.biome=生态群系需求: %s
|
||||
gendustry.req.block=方块需要: %s
|
||||
|
||||
gendustry.req.message=特殊需求
|
||||
|
||||
# ==== BEE SPECIES ====
|
||||
gendustry.bees.species.black=黑色
|
||||
gendustry.bees.species.red=红色
|
||||
@@ -220,6 +224,10 @@ gendustry.bees.species.magenta=品红色
|
||||
gendustry.bees.species.orange=橙色
|
||||
gendustry.bees.species.white=白色
|
||||
|
||||
gendustry.bees.species.derpious=逗逼
|
||||
gendustry.bees.species.derpious.description=一个有趣的种类,看起来喜欢传播鲜花和范二.
|
||||
|
||||
|
||||
# ==== COMBS ====
|
||||
|
||||
gendustry.honeycomb.black.name=黑色蜂巢
|
||||
@@ -259,6 +267,11 @@ gendustry.honeydrop.white.name=白色蜂蜜滴
|
||||
itemGroup.bdew.gendustry=基因工业
|
||||
itemGroup.bdew.templates=基因工业|模板
|
||||
itemGroup.bdew.samples=基因工业|样本
|
||||
itemGroup.bdew.hives=基因工业|自定义蜂房
|
||||
|
||||
for.gendustry.errorstate.disabled.description=能量不足
|
||||
for.gendustry.errorstate.disabled.help=被配置文件禁用
|
||||
|
||||
#this will be moved to bdlib at some point
|
||||
bdlib.label.empty=空
|
||||
|
||||
@@ -45,6 +45,10 @@ object Items extends ItemManager(GendustryCreativeTabs.main) {
|
||||
regItem(PollenKit)
|
||||
}
|
||||
|
||||
if (ForestryHelper.haveRoot("Bees")) {
|
||||
regItem(HiveSpawnDebugger)
|
||||
}
|
||||
|
||||
val coverEject = regItem(EjectCover)
|
||||
val coverImport = regItem(ImportCover)
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ trait ParserHives extends RecipeParser with GenericConfigParser {
|
||||
| "Under" ~> blockFilter ^^ HDLocationUnder
|
||||
| "Above" ~> blockFilter ^^ HDLocationAbove
|
||||
| "NextTo" ~> blockFilter ^^ HDLocationNextTo
|
||||
| "Near" ~> blockFilter ^^ HDLocationNear
|
||||
| "Replace" ~> blockFilter ^^ HDReplace
|
||||
| "TopTexture" ~> unescapeStr ^^ HDTopTexture
|
||||
| "BottomTexture" ~> unescapeStr ^^ HDBottomTexture
|
||||
|
||||
@@ -49,6 +49,8 @@ case class HDLocationAbove(blocks: BlockFilterDef) extends HiveDefCondition
|
||||
|
||||
case class HDLocationNextTo(blocks: BlockFilterDef) extends HiveDefCondition
|
||||
|
||||
case class HDLocationNear(blocks: BlockFilterDef) extends HiveDefCondition
|
||||
|
||||
case class HDReplace(blocks: BlockFilterDef) extends HiveDefCondition
|
||||
|
||||
trait BlockFilterDef
|
||||
|
||||
@@ -26,6 +26,7 @@ import net.minecraftforge.oredict.OreDictionary
|
||||
|
||||
object CustomHives {
|
||||
var definitions = List.empty[CSHiveDefinition]
|
||||
var hives = Map.empty[String, HiveDescription]
|
||||
|
||||
def registerHiveDefinition(definition: CSHiveDefinition): Unit = {
|
||||
definitions :+= definition
|
||||
@@ -95,16 +96,21 @@ object CustomHives {
|
||||
EnumHumidity.values().filter(x => humidityNames.contains(x.getName.toLowerCase)).toSet
|
||||
|
||||
|
||||
val conditions = for (condition <- Misc.filterType(definition.definition, classOf[HiveDefCondition])) yield {
|
||||
var conditions = (for (condition <- Misc.filterType(definition.definition, classOf[HiveDefCondition])) yield {
|
||||
condition match {
|
||||
case HDLocationUnder(f) => Some(ConditionUnder(resolveFilter(f)))
|
||||
case HDLocationAbove(f) => Some(ConditionAbove(resolveFilter(f)))
|
||||
case HDLocationNextTo(f) => Some(ConditionNextTo(resolveFilter(f)))
|
||||
case HDLocationNear(f) => Some(ConditionNear(resolveFilter(f)))
|
||||
case HDReplace(f) => Some(ConditionReplace(resolveFilter(f)))
|
||||
case _ =>
|
||||
Gendustry.logWarn("Unknown condition %s", condition)
|
||||
None
|
||||
}
|
||||
}).flatten.toList
|
||||
|
||||
if (!conditions.exists(_.isInstanceOf[ConditionReplace])) {
|
||||
conditions :+= ConditionReplace(BlockFilterAir)
|
||||
}
|
||||
|
||||
val drops = (for (drop <- Misc.filterType(definition.definition, classOf[HDDrops]).flatMap(_.drops)) yield {
|
||||
@@ -133,7 +139,7 @@ object CustomHives {
|
||||
validBiome = biomes,
|
||||
validTemperature = temperatures,
|
||||
validHumidity = humidities,
|
||||
conditions = conditions.flatten.toList,
|
||||
conditions = conditions,
|
||||
drops = drops.toList,
|
||||
spawnDebug = spawnDebug
|
||||
)
|
||||
@@ -142,6 +148,8 @@ object CustomHives {
|
||||
|
||||
HiveManager.hiveRegistry.registerHive("Gendustry:" + definition.id, hive)
|
||||
|
||||
hives += definition.id -> hive
|
||||
|
||||
val sideTexture = getSingleStatement(definition, classOf[HDSideTexture]) map (_.loc) getOrElse "%s:beehives/%s/side".format(Gendustry.modId, definition.id).toLowerCase
|
||||
val topTexture = getSingleStatement(definition, classOf[HDTopTexture]) map (_.loc) getOrElse "%s:beehives/%s/top".format(Gendustry.modId, definition.id).toLowerCase
|
||||
val bottomTexture = getSingleStatement(definition, classOf[HDTopTexture]) map (_.loc) getOrElse topTexture
|
||||
|
||||
@@ -9,26 +9,37 @@
|
||||
|
||||
package net.bdew.gendustry.custom.hives
|
||||
|
||||
import cpw.mods.fml.common.registry.GameData
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.world.World
|
||||
|
||||
trait BlockFilter {
|
||||
def matches(world: World, x: Int, y: Int, z: Int): Boolean
|
||||
def getDesctiption: String
|
||||
}
|
||||
|
||||
case class BlockFilterList(valid: Set[(Block, Int)]) extends BlockFilter {
|
||||
override def matches(world: World, x: Int, y: Int, z: Int) =
|
||||
valid.exists { case (block, meta) => block == world.getBlock(x, y, z) && (meta == -1 || meta == world.getBlockMetadata(x, y, z)) }
|
||||
override def getDesctiption: String = {
|
||||
val names = for ((block, meta) <- valid.toList) yield {
|
||||
GameData.getBlockRegistry.getNameForObject(block) + (if (meta > 0) "@%d".format(meta) else "@*")
|
||||
}
|
||||
names.mkString(" OR ")
|
||||
}
|
||||
}
|
||||
|
||||
object BlockFilterAir extends BlockFilter {
|
||||
override def matches(world: World, x: Int, y: Int, z: Int): Boolean = world.isAirBlock(x, y, z)
|
||||
override def getDesctiption: String = "[AIR]"
|
||||
}
|
||||
|
||||
object BlockFilterReplaceable extends BlockFilter {
|
||||
override def matches(world: World, x: Int, y: Int, z: Int): Boolean = world.getBlock(x, y, z).getMaterial.isReplaceable
|
||||
override def getDesctiption: String = "[REPLACEABLE]"
|
||||
}
|
||||
|
||||
object BlockFilterLeaves extends BlockFilter {
|
||||
override def matches(world: World, x: Int, y: Int, z: Int): Boolean = world.getBlock(x, y, z).isLeaves(world, x, y, z)
|
||||
override def getDesctiption: String = "[LEAVES]"
|
||||
}
|
||||
@@ -13,24 +13,41 @@ import net.minecraft.world.World
|
||||
|
||||
trait HiveSpawnCondition {
|
||||
def isValidLocation(world: World, x: Int, y: Int, z: Int): Boolean
|
||||
def getDescription: String
|
||||
}
|
||||
|
||||
case class ConditionUnder(blocks: BlockFilter) extends HiveSpawnCondition {
|
||||
override def isValidLocation(world: World, x: Int, y: Int, z: Int): Boolean =
|
||||
y < world.getHeight && blocks.matches(world, x, y + 1, z)
|
||||
override def getDescription: String = "Under " + blocks.getDesctiption
|
||||
}
|
||||
|
||||
case class ConditionAbove(blocks: BlockFilter) extends HiveSpawnCondition {
|
||||
override def isValidLocation(world: World, x: Int, y: Int, z: Int): Boolean =
|
||||
y >= 1 && blocks.matches(world, x, y - 1, z)
|
||||
override def getDescription: String = "Above " + blocks.getDesctiption
|
||||
}
|
||||
|
||||
case class ConditionNextTo(blocks: BlockFilter) extends HiveSpawnCondition {
|
||||
override def isValidLocation(world: World, x: Int, y: Int, z: Int): Boolean =
|
||||
blocks.matches(world, x + 1, y, z) || blocks.matches(world, x - 1, y, z) || blocks.matches(world, x, y, z + 1) || blocks.matches(world, x, y, z - 1)
|
||||
override def getDescription: String = "Next To " + blocks.getDesctiption
|
||||
}
|
||||
|
||||
case class ConditionNear(blocks: BlockFilter) extends HiveSpawnCondition {
|
||||
override def isValidLocation(world: World, x: Int, y: Int, z: Int): Boolean = (
|
||||
blocks.matches(world, x + 1, y, z)
|
||||
|| blocks.matches(world, x - 1, y, z)
|
||||
|| blocks.matches(world, x, y + 1, z)
|
||||
|| blocks.matches(world, x, y - 1, z)
|
||||
|| blocks.matches(world, x, y, z + 1)
|
||||
|| blocks.matches(world, x, y, z - 1)
|
||||
)
|
||||
override def getDescription: String = "Near " + blocks.getDesctiption
|
||||
}
|
||||
|
||||
case class ConditionReplace(blocks: BlockFilter) extends HiveSpawnCondition {
|
||||
override def isValidLocation(world: World, x: Int, y: Int, z: Int): Boolean =
|
||||
blocks.matches(world, x, y, z)
|
||||
override def getDescription: String = "Replacing " + blocks.getDesctiption
|
||||
}
|
||||
@@ -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.items
|
||||
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import forestry.api.core.{EnumHumidity, EnumTemperature}
|
||||
import net.bdew.gendustry.custom.CustomHives
|
||||
import net.bdew.gendustry.custom.hives.{BlockFilterAir, ConditionReplace, HiveDescription}
|
||||
import net.bdew.lib.Misc
|
||||
import net.bdew.lib.block.BlockRef
|
||||
import net.bdew.lib.items.SimpleItem
|
||||
import net.minecraft.client.renderer.texture.IIconRegister
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.init.Items
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.world.World
|
||||
|
||||
object HiveSpawnDebugger extends SimpleItem("HiveSpawnDebugger") {
|
||||
|
||||
class CheckResult(val isSuccess: Boolean)
|
||||
|
||||
case class CheckResultSuccess() extends CheckResult(true)
|
||||
|
||||
case class CheckResultFailed(msg: String) extends CheckResult(false)
|
||||
|
||||
def checkSpawnLocation(hive: HiveDescription, world: World, x: Int, y: Int, z: Int): CheckResult = {
|
||||
val biome = world.getBiomeGenForCoords(x, z)
|
||||
if (!hive.isGoodBiome(biome)) CheckResultFailed("Wrong Biome")
|
||||
else if (!hive.isGoodHumidity(EnumHumidity.getFromValue(biome.rainfall))) CheckResultFailed("Wrong Humidity")
|
||||
else if (!hive.isGoodTemperature(EnumTemperature.getFromValue(biome.temperature))) CheckResultFailed("Wrong Temperature")
|
||||
else if (y > hive.yMax || y < hive.yMin) CheckResultFailed("Incorrect Y level")
|
||||
else {
|
||||
val failed = hive.conditions.find(!_.isValidLocation(world, x, y, z))
|
||||
if (failed.isDefined)
|
||||
CheckResultFailed("Condition failed: " + failed.get.getDescription)
|
||||
else
|
||||
CheckResultSuccess()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override def onItemUse(stack: ItemStack, player: EntityPlayer, world: World, x: Int, y: Int, z: Int, side: Int, xOff: Float, yOff: Float, zOff: Float): Boolean = {
|
||||
if (!world.isRemote) {
|
||||
import net.bdew.lib.helpers.ChatHelper._
|
||||
player.addChatMessage(" ==== Checking Spawn At (%d,%d,%d) ===".format(x, y, z))
|
||||
for ((id, hive) <- CustomHives.hives) {
|
||||
val pos = if (hive.conditions.contains(ConditionReplace(BlockFilterAir))) {
|
||||
// Hive spawns in air, check block next to one clicked
|
||||
BlockRef(x, y, z).neighbour(Misc.forgeDirection(side))
|
||||
} else {
|
||||
// Hive spawns replaces block, check clicked block
|
||||
BlockRef(x, y, z)
|
||||
}
|
||||
val msg =
|
||||
checkSpawnLocation(hive, world, pos.x, pos.y, pos.z) match {
|
||||
case CheckResultFailed(error) =>
|
||||
error.setColor(Color.RED)
|
||||
case CheckResultSuccess() =>
|
||||
("OK at " + pos).setColor(Color.GREEN)
|
||||
}
|
||||
|
||||
player.addChatMessage(L(" * %s - %s", C(id).setColor(Color.YELLOW), msg))
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT) override
|
||||
def registerIcons(reg: IIconRegister): Unit = {}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def getIconFromDamage(par1: Int) = Items.stick.getIconFromDamage(0)
|
||||
}
|
||||
Reference in new issue
Block a user