aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt
blob: 4eb1075547919932a69b88e5067d5babb0e892c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package at.hannibal2.skyhanni.api

import at.hannibal2.skyhanni.events.DataWatcherUpdatedEvent
import at.hannibal2.skyhanni.events.EntityCustomNameUpdateEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

class DataWatcherAPI {

    private val DATA_VALUE_CUSTOM_NAME = 2

    @SubscribeEvent
    fun onDataWatcherUpdate(event: DataWatcherUpdatedEvent) {
        for (updatedEntry in event.updatedEntries) {
            if (updatedEntry.dataValueId == DATA_VALUE_CUSTOM_NAME) {
                EntityCustomNameUpdateEvent(event.entity.customNameTag, event.entity).postAndCatch()
            }
        }
    }

    // TODO move EntityHealthUpdateEvent logic from EntityData in here
}