Skip to content

Commit

Permalink
Fix config lists
Browse files Browse the repository at this point in the history
  • Loading branch information
barribob committed Jun 5, 2021
1 parent a3ff34f commit ba906b5
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 19 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ org.gradle.jvmargs=-Xmx1G
loom_version=0.5-SNAPSHOT

# Mod Properties
mod_version = 1.1.1
mod_version = 1.1.2
maven_group = net.barribob
archives_base_name = BOMD

Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/net/barribob/boss/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ object Mod {
@Suppress("unused")
fun init() {
AutoConfig.register(ModConfig::class.java, ::JanksonConfigSerializer)
AutoConfig.getConfigHolder(ModConfig::class.java).config.postInit()
AutoConfig.getConfigHolder(ModConfig::class.java).save()

GeckoLib.initialize()

Expand Down
18 changes: 2 additions & 16 deletions src/main/kotlin/net/barribob/boss/config/LichConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,8 @@ class LichConfig {

data class SummonMechanic(
val isEnabled: Boolean = true,
val entitiesThatCountToSummonCounter: MutableList<String> = mutableListOf(
"minecraft:zombie",
"minecraft:skeleton",
"minecraft:drowned",
"minecraft:giant",
"minecraft:husk",
"minecraft:phantom",
"minecraft:skeleton_horse",
"minecraft:stray",
"minecraft:wither",
"minecraft:wither_skeleton",
"minecraft:zoglin",
"minecraft:zombie_horse",
"minecraft:zombie_villager",
"minecraft:zombified_piglin"
),

var entitiesThatCountToSummonCounter: MutableList<String>? = null,

@ConfigEntry.BoundedDiscrete(min = 1, max = 1000)
val numEntitiesKilledToDropSoulStar: Int = 50
Expand Down
27 changes: 27 additions & 0 deletions src/main/kotlin/net/barribob/boss/config/ModConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,31 @@ class ModConfig : ConfigData {
@ConfigEntry.Category("Gauntlet")
@TransitiveObject
val gauntletConfig = GauntletConfig()

fun postInit() {
val entitiesThatCountToSummonCounter = lichConfig.summonMechanic.entitiesThatCountToSummonCounter
if (entitiesThatCountToSummonCounter == null) {
val defaultEntities = mutableListOf(
"minecraft:zombie",
"minecraft:skeleton",
"minecraft:drowned",
"minecraft:giant",
"minecraft:husk",
"minecraft:phantom",
"minecraft:skeleton_horse",
"minecraft:stray",
"minecraft:wither",
"minecraft:wither_skeleton",
"minecraft:zoglin",
"minecraft:zombie_horse",
"minecraft:zombie_villager",
"minecraft:zombified_piglin"
)
lichConfig.summonMechanic.entitiesThatCountToSummonCounter = defaultEntities.toMutableList()
}
else {
lichConfig.summonMechanic.entitiesThatCountToSummonCounter =
entitiesThatCountToSummonCounter.toSet().toMutableList()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import net.minecraft.util.Identifier
import net.minecraft.util.registry.Registry

class LichKillCounter(private val config: LichConfig.SummonMechanic) : ServerEntityCombatEvents.AfterKilledOtherEntity {
private val countedEntities = config.entitiesThatCountToSummonCounter.map { Registry.ENTITY_TYPE[Identifier(it)] }
private val countedEntities = config.entitiesThatCountToSummonCounter?.map { Registry.ENTITY_TYPE[Identifier(it)] } ?: listOf()

override fun afterKilledOtherEntity(sWorld: ServerWorld, entity: Entity, killedEntity: LivingEntity) {
if (entity is ServerPlayerEntity && killedEntity.type in countedEntities) {
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/net/barribob/boss/utils/InGameTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ class InGameTests(private val debugPoints: DebugPointsNetworkHandler) {
val zombie = EntityType.ZOMBIE.create(source.world) ?: return
val pos = source.player.pos.add(VecUtils.yAxis.multiply(-5.0))
zombie.setPos(pos)
if(source.world.getBlockState(BlockPos(pos).up()).block != Blocks.LAVA.defaultState) source.world.setBlockState(BlockPos(pos).up(), Blocks.LAVA.defaultState)
source.world.spawnEntity(zombie)
ModComponents.getWorldEventScheduler(source.world).addEvent(TimedEvent({
zombie.damage(DamageSource.player(source.player), 30f)
Expand Down

0 comments on commit ba906b5

Please sign in to comment.