diff --git a/src/main/kotlin/com/lop/devtools/monstera/addon/entity/behaviour/SysSpawnRule.kt b/src/main/kotlin/com/lop/devtools/monstera/addon/entity/behaviour/SysSpawnRule.kt index 782866f..6964019 100644 --- a/src/main/kotlin/com/lop/devtools/monstera/addon/entity/behaviour/SysSpawnRule.kt +++ b/src/main/kotlin/com/lop/devtools/monstera/addon/entity/behaviour/SysSpawnRule.kt @@ -14,6 +14,26 @@ open class SysSpawnRule(private val entityId: String, private val entityName: St } } + /** + * ``` + * weight() + * densityLimit() + * spawnsOnBlockFilter = mutableListOf("") + * spawnsOnBlockPreventedFilterData = mutableListOf("") + * spawnAboveBlockFilter { } + * herd { } + * permuteType { } + * brightnessFilter { } + * heightFilter { } + * spawnsOnSurface() + * spawnsUnderground() + * spawnsUnderwater() + * disallowSpawnsInBubble() + * spawnsLava() + * biomeFilter { } + * difficultyFilter { } + * ``` + */ open fun condition(condition: BehSpawnRules.Condition.() -> Unit) { file.condition(condition) } diff --git a/src/main/kotlin/com/lop/devtools/monstera/files/beh/spawnrules/conditions/BiomeTag.kt b/src/main/kotlin/com/lop/devtools/monstera/files/beh/spawnrules/conditions/BiomeTag.kt index 77d19f9..58612dc 100644 --- a/src/main/kotlin/com/lop/devtools/monstera/files/beh/spawnrules/conditions/BiomeTag.kt +++ b/src/main/kotlin/com/lop/devtools/monstera/files/beh/spawnrules/conditions/BiomeTag.kt @@ -1,45 +1,80 @@ package com.lop.devtools.monstera.files.beh.spawnrules.conditions +import com.google.gson.annotations.SerializedName + enum class BiomeTag { + @SerializedName("animal") ANIMAL, + @SerializedName("beach") BEACH, + @SerializedName("birch") BIRCH, + @SerializedName("cold") COLD, + @SerializedName("dark_oak") DARK_OAK, + @SerializedName("deep") DEEP, + @SerializedName("desert") DESERT, + @SerializedName("edge") EDGE, + @SerializedName("extreme_hills") EXTREME_HILLS, + @SerializedName("flower_forest") FLOWER_FOREST, + @SerializedName("forest") FOREST, + @SerializedName("frozen") FROZEN, + @SerializedName("hills") HILLS, + @SerializedName("ice") ICE, + @SerializedName("ice_plains") ICE_PLAINS, + @SerializedName("jungle") JUNGLE, + @SerializedName("lakes") LAKES, + @SerializedName("lukewarm") LUKEWARM, + @SerializedName("mega") MEGA, + @SerializedName("mesa") MESA, + @SerializedName("monster") MONSTER, + @SerializedName("mooshroom_island") MOOSHROOM_ISLAND, + @SerializedName("mountain") MOUNTAIN, + @SerializedName("mutated") MUTATED, + @SerializedName("nether") NETHER, + @SerializedName("ocean") OCEAN, + @SerializedName("plains") PLAINS, + @SerializedName("plateau") PLATEAU, + @SerializedName("river") RIVER, + @SerializedName("roofed") ROOFED, + @SerializedName("savanna") SAVANNA, + @SerializedName("shore") SHORE, + @SerializedName("stone") STONE, + @SerializedName("swamp") SWAMP, + @SerializedName("taiga") TAIGA, + @SerializedName("the_end") THE_END, + @SerializedName("warm") WARM; - - override fun toString(): String { - return super.toString().lowercase() - } } \ No newline at end of file diff --git a/src/test/kotlin/com/lop/devtools/monstera/addon/entitiy/SpawnRuleTest.kt b/src/test/kotlin/com/lop/devtools/monstera/addon/entitiy/SpawnRuleTest.kt new file mode 100644 index 0000000..d5f3e3d --- /dev/null +++ b/src/test/kotlin/com/lop/devtools/monstera/addon/entitiy/SpawnRuleTest.kt @@ -0,0 +1,52 @@ +package com.lop.devtools.monstera.addon.entitiy + +import com.lop.devtools.monstera.addon.buildTestAddon +import com.lop.devtools.monstera.addon.testAddon +import com.lop.devtools.monstera.files.beh.spawnrules.PopulationControl +import com.lop.devtools.monstera.files.beh.spawnrules.conditions.BiomeTag +import kotlin.test.AfterTest +import kotlin.test.Test + +class SpawnRuleTest { + @AfterTest + fun buildTask() { + buildTestAddon() + } + + @Test + fun spawnRulesTest() = testAddon { + entity("spawn_rule_test") { + behaviour { + spawnRule { + populationControl(PopulationControl.ANIMAL) + condition { + weight(2) + biomeFilter { + filterEntry(BiomeTag.OCEAN) + } + } + } + } + } + withJsonFile(config.paths.behSpawnRules.resolve("spawn_rule_test.json")) { + assert( + this.containsKeyChainValue( + value = "ocean", + "minecraft:spawn_rules", + "conditions", + "minecraft:biome_filter", + "value" + ) + ) + assert( + this.containsKeyChainValue( + value = 2, + "minecraft:spawn_rules", + "conditions", + "minecraft:weight", + "default" + ) + ) + } + } +} \ No newline at end of file