registries: fix block entity type mappings

This commit is contained in:
Bixilon 2022-04-21 23:31:03 +02:00
parent 6ab96cfcd6
commit 2ae7c2575c
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
4 changed files with 13 additions and 10 deletions

View File

@ -30,6 +30,13 @@ class BlockEntityTypeRegistry(
return blockTypeMap[block] ?: parentRegistry?.get(block)
}
override fun get(any: Any?): BlockEntityType<*>? {
if (any is Block) {
return get(any)
}
return super.get(any)
}
override fun initialize(data: Map<ResourceLocation, Any>?, registries: Registries?, deserializer: ResourceLocationDeserializer<BlockEntityType<*>>?, flattened: Boolean, metaType: MetaTypes, alternative: AbstractRegistry<BlockEntityType<*>>?): Registry<BlockEntityType<*>> {
super.initialize(data, registries, deserializer, flattened, metaType, alternative)

View File

@ -179,6 +179,7 @@ class Registries {
field.get(this).unsafeCast<Registry<*>>().postInit(this)
}
isFullyLoaded = true
shapes.clear()
}
private fun loadShapes(pixlyzerData: Map<String, Any>?) {

View File

@ -78,18 +78,14 @@ open class Registry<T : RegistryItem>(
idValueMap[any] = value
valueIdMap[value] = any
}
is ResourceLocation -> {
resourceLocationMap[any] = value
}
is ResourceLocationAble -> {
resourceLocationMap[any.resourceLocation] = value
}
is ResourceLocation -> resourceLocationMap[any] = value
is ResourceLocationAble -> resourceLocationMap[any.resourceLocation] = value
is MultiResourceLocationAble -> {
for (resourceLocation in any.ALIASES) {
resourceLocationMap[resourceLocation] = value
}
}
else -> TODO()
else -> TODO("Can not set $any, value=$value")
}
}

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2021 Moritz Zwerger
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -39,8 +39,7 @@ abstract class RegistryItem : ResourceLocationAble {
val javaField = field.javaField ?: continue
var value: Any? = null
for (key in keys) {
val currentValue = registries[javaField.type as Class<out RegistryItem>]?.get(key) ?: continue
value = currentValue
value = registries[javaField.type as Class<out RegistryItem>]?.get(key) ?: continue
break
}
value ?: continue