Skip to content

Commit

Permalink
serialize biome tags to lower case (LotsOfPixelsStudios#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
12rcu authored Jul 21, 2024
1 parent 6413a83 commit fdf9145
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
}
}
Original file line number Diff line number Diff line change
@@ -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"
)
)
}
}
}

0 comments on commit fdf9145

Please sign in to comment.