that was a bad idea

This commit is contained in:
DBotThePony 2022-10-16 17:41:13 +07:00
parent 1dfdc44acd
commit 65eaf916f8
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -1,7 +1,9 @@
@file:Suppress("unused")
package ru.dbotthepony.mc.otm.datagen.loot
import com.mojang.datafixers.util.Pair
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap
import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap
import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction
import net.minecraft.advancements.critereon.StatePropertiesPredicate
@ -37,10 +39,6 @@ private typealias LootTableCallback = Consumer<LootTableSaver>
private typealias LootTableCallbackProvider = Supplier<LootTableCallback>
private typealias LootTuple = Pair<LootTableCallbackProvider, LootContextParamSet>
inline fun singleLootPool(f: (LootPool.Builder) -> Unit): LootTable.Builder {
return LootTable.lootTable().withPool(LootPool.lootPool().also(f))
}
inline fun LootTable.Builder.lootPool(configurator: LootPool.Builder.() -> Unit): LootTable.Builder = withPool(LootPool.lootPool().also(configurator))
inline fun LootPool.Builder.item(item: ItemLike, configurator: LootPoolSingletonContainer.Builder<*>.() -> Unit) {
add(LootItem.lootTableItem(item).also(configurator))
@ -96,7 +94,7 @@ private val poweredMatterWorker = arrayOf(
)
class LootTables(generator: DataGenerator) : LootTableProvider(generator) {
private val providersTable = Reference2ObjectArrayMap<LootContextParamSet, Object2ObjectArrayMap<ResourceLocation, () -> LootTable.Builder>>()
private val providersTable = Reference2ObjectArrayMap<LootContextParamSet, HashMap<ResourceLocation, () -> LootTable.Builder>>()
fun builder(context: LootContextParamSet, id: ResourceLocation, provider: LootTable.Builder.() -> Unit) {
provider(context, id) {
@ -106,7 +104,7 @@ class LootTables(generator: DataGenerator) : LootTableProvider(generator) {
fun provider(context: LootContextParamSet, id: ResourceLocation, provider: () -> LootTable.Builder) {
check(providersTable
.computeIfAbsent(context, Reference2ObjectFunction { Object2ObjectArrayMap() })
.computeIfAbsent(context, Reference2ObjectFunction { HashMap() })
.put(id, provider) == null) { "Duplicate loot pool entry for $id" }
}