registries: damage type codec

This fixes a joining crash on 1.19.4
This commit is contained in:
Bixilon 2023-03-14 19:53:27 +01:00
parent 42ea8dcb5f
commit c5cba29fe9
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 7 additions and 2 deletions

View File

@ -26,6 +26,7 @@ class DamageType(
val scaling: String?, val scaling: String?,
) : RegistryItem() { ) : RegistryItem() {
companion object : ResourceLocationCodec<DamageType> { companion object : ResourceLocationCodec<DamageType> {
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: Map<String, Any>): DamageType { override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: Map<String, Any>): DamageType {
return DamageType( return DamageType(

View File

@ -115,7 +115,7 @@ class Registries : Parentable<Registries> {
val entityDataIndexMap: MutableMap<EntityDataField, Int> = mutableMapOf() val entityDataIndexMap: MutableMap<EntityDataField, Int> = mutableMapOf()
val entityType: Registry<EntityType> = register("entity_type", Registry(codec = EntityType)) val entityType: Registry<EntityType> = register("entity_type", Registry(codec = EntityType))
val damageType: Registry<DamageType> = register("damage_type", Registry()) val damageType: Registry<DamageType> = register("damage_type", Registry(codec = DamageType))
val blockEntityType = BlockEntityTypeRegistry() val blockEntityType = BlockEntityTypeRegistry()
val blockDataType: Registry<BlockDataDataType> = Registry(codec = BlockDataDataType) val blockDataType: Registry<BlockDataDataType> = Registry(codec = BlockDataDataType)
@ -259,7 +259,11 @@ class Registries : Parentable<Registries> {
value.asJsonObject()["value"].listCast()!! value.asJsonObject()["value"].listCast()!!
} }
registry.update(values, this) try {
registry.update(values, this)
} catch (error: Throwable) {
throw Exception("Can not update $fixedKey registry", error)
}
} }
} }