aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/gui/entity/ModifyAge.kt
blob: 99154ef4e977c338eaeaf92562da1aa06cc0f7d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package moe.nea.firmament.gui.entity

import com.google.gson.JsonObject
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.decoration.ArmorStand
import net.minecraft.world.entity.monster.Zombie
import net.minecraft.world.entity.AgeableMob

object ModifyAge : EntityModifier {
    override fun apply(entity: LivingEntity, info: JsonObject): LivingEntity {
        val isBaby = info["baby"]?.asBoolean ?: false
        if (entity is AgeableMob) {
            entity.age = if (isBaby) -1 else 1
        } else if (entity is Zombie) {
            entity.isBaby = isBaby
        } else if (entity is ArmorStand) {
            entity.isSmall = isBaby
        } else {
            error("Cannot set age for $entity")
        }
        return entity
    }

}