diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index 0be49080a..81e3b1bdd 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -528,12 +528,11 @@ object DataGen { event.generator.addProvider(event.includeServer(), matterData) val registrySetBuilder = RegistrySetBuilder() - val set = registrySetBuilder .add(Registries.DAMAGE_TYPE, ::registerDamageTypes) .add(Registries.CONFIGURED_FEATURE, ::registerConfiguredFeatures) .add(Registries.PLACED_FEATURE, ::registerPlacedFeatures) - event.generator.addProvider(event.includeServer(), DatapackBuiltinEntriesProvider(event.generator.packOutput, event.lookupProvider, set, setOf(MOD_ID))) + event.generator.addProvider(event.includeServer(), DatapackBuiltinEntriesProvider(event.generator.packOutput, event.lookupProvider, registrySetBuilder, setOf(MOD_ID))) registerDamageTypeTags(tagsProvider.damageTypes) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt index a6f5ad5f6..671566490 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt @@ -46,35 +46,29 @@ class TagsProvider(private val event: GatherDataEvent) { inner class Appender(val tag: TagKey) { constructor(tag: ResourceLocation) : this(TagKey.create(registryKey, tag)) + init { + require(tag.registry == registryKey) { "Trying to create appender for $tag inside registry $registryKey" } + } + private val locations by lazy { tags.computeIfAbsent(tag) { ObjectArraySet() } } private val rigidLocations by lazy { rigidTags.computeIfAbsent(tag) { ObjectArraySet() } } private val tagsInTags by lazy { tagInTag.computeIfAbsent(tag) { ObjectArraySet() } } fun add(value: ResourceLocation): Appender { - if (!locations.add(value)) { - throw IllegalStateException("Tag $tag of registry $registryKey already contains $value") - } - + check(locations.add(value)) { "Tag ${tag.location} of registry ${registryKey.location()} already contains $value" } return this } fun add(value: ResourceKey): Appender { - require(value.registry() == registryKey.location()) { "Invalid registry in provided ResourceKey: ${value.registry()} (this tag appender is for $registryKey)" } - - if (!rigidLocations.add(value)) { - throw IllegalStateException("Tag $tag of registry ${registryKey.location()} already contains $value") - } - - return this + require(value.registry() == registryKey.location()) { "Invalid registry in provided ResourceKey: ${value.registry()} (this tag appender is for ${registryKey.location()})" } + // check(rigidLocations.add(value)) { "Tag ${tag.location} of registry ${registryKey.location()} already contains $value" } + // return this + return add(value.location()) } fun add(value: TagKey): Appender { - require(value.registry() == registryKey.location()) { "Invalid registry in provided ResourceKey: ${value.registry()} (this tag appender is for $registryKey)" } - - if (!tagsInTags.add(value)) { - throw IllegalStateException("Tag $tag of registry ${registryKey.location()} already contains $value") - } - + require(value.registry() == registryKey) { "Invalid registry in provided ResourceKey: ${value.registry().location()} (this tag appender is for ${registryKey.location()})" } + check(tagsInTags.add(value)) { "Tag ${tag.location} of registry ${registryKey.location()} already contains $value" } return this } @@ -128,10 +122,6 @@ class TagsProvider(private val event: GatherDataEvent) { fun forge(path: String) = Appender(ResourceLocation("forge", path)) override fun addTags(provider: HolderLookup.Provider) { - if (tags.isEmpty()) { - return - } - for ((tag, values) in tags) { val appender = tag(tag)