Matyáš Vítek
11/10/2024, 4:00 PMJoffrey
11/10/2024, 4:03 PMgetOrPut
and then consistently add to the overrides list.Joffrey
11/10/2024, 4:04 PMJoffrey
11/10/2024, 4:09 PMval item = itemModels.getOrPut(parentPath) {
ItemModel(
key = NamespacedKey.minecraft("items/generated"),
layers = mapOf("layer0" to NamespacedKey.minecraft("item/$parentMaterial")),
overrides = mutableListOf(), // probably make this a default value in the constructor
)
}
item.overrides += modelOverride
Joffrey
11/10/2024, 4:12 PMval item = itemModels.getOrPut(parentPath) { generatedItem(material = parentMaterial) }
item.overrides += modelOverride
// later
fun generatedItem(material: String) = ItemModel(
key = NamespacedKey.minecraft("items/generated"),
layers = mapOf("layer0" to NamespacedKey.minecraft("item/$material")),
overrides = mutableListOf(), // probably make this a default value in the constructor
)
Matyáš Vítek
11/10/2024, 4:29 PMDaniel Pitts
11/10/2024, 4:33 PMDaniel Pitts
11/10/2024, 4:35 PM/snippet
...Daniel Pitts
11/10/2024, 4:35 PMandries.fc
11/11/2024, 8:05 AMKlitos Kyriacou
11/11/2024, 9:48 AMitemModels[parentPath]!!
because it may be deleted by another thread between checking and using.Joffrey
11/11/2024, 9:58 AMgetOrPut
is not atomic because it's implemented as an extension, so it most likely also contains a race conditionKlitos Kyriacou
11/11/2024, 10:24 AMConcurrentMap
which is atomic.Matyáš Vítek
11/13/2024, 8:26 AM