-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Now it uses Tooltips to show you more information about each condition. - Also shows if it spawns in a structure and the "weight" of each spawn (rarity)
- Loading branch information
1 parent
77f6320
commit 4df85f2
Showing
5 changed files
with
134 additions
and
86 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
37 changes: 22 additions & 15 deletions
37
common/src/main/kotlin/com/rafacasari/mod/cobbledex/utils/BiomeUtils.kt
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,33 +1,40 @@ | ||
package com.rafacasari.mod.cobbledex.utils | ||
|
||
import com.cobblemon.mod.common.api.spawning.condition.SpawningCondition | ||
import com.cobblemon.mod.common.api.conditional.RegistryLikeCondition | ||
import com.cobblemon.mod.common.api.spawning.detail.PokemonSpawnDetail | ||
import net.minecraft.registry.Registry | ||
import net.minecraft.registry.RegistryKeys | ||
import net.minecraft.text.MutableText | ||
import net.minecraft.util.Identifier | ||
import net.minecraft.world.World | ||
import net.minecraft.world.biome.Biome | ||
|
||
data class CobbledexBiome(val identifier: Identifier, val biome: Biome) | ||
data class BiomeChecker(val spawnDetail: PokemonSpawnDetail, val biomeCondition: RegistryLikeCondition<Biome>, val biomeList : List<MutableText>) | ||
|
||
object BiomeUtils { | ||
|
||
fun getBiomesRegistry(world: World) : Registry<Biome> { | ||
return world.registryManager.get(RegistryKeys.BIOME) | ||
} | ||
|
||
fun getAllBiomes(world: World) : List<CobbledexBiome> { | ||
val registry: Registry<Biome> = world.registryManager.get(RegistryKeys.BIOME) | ||
return registry.entrySet.map { entry -> CobbledexBiome(entry.key.value, entry.value) } | ||
} | ||
|
||
fun canSpawnAt (biome: Biome, world: World, condition: SpawningCondition<*>) : Boolean { | ||
|
||
val registry: Registry<Biome> = world.registryManager.get(RegistryKeys.BIOME) | ||
if (condition.biomes == null) return false | ||
|
||
val count = condition.biomes!!.count { biomeCondition -> | ||
biomeCondition.fits( | ||
biome, | ||
registry | ||
) | ||
} | ||
|
||
return count > 0 | ||
} | ||
// fun canSpawnAt (biome: Biome, world: World, condition: SpawningCondition<*>) : Boolean { | ||
// | ||
// val registry: Registry<Biome> = world.registryManager.get(RegistryKeys.BIOME) | ||
// if (condition.biomes == null) return false | ||
// | ||
// val count = condition.biomes!!.count { biomeCondition -> | ||
// biomeCondition.fits( | ||
// biome, | ||
// registry | ||
// ) | ||
// } | ||
// | ||
// return count > 0 | ||
// } | ||
} |
Oops, something went wrong.