that was a bad idea
This commit is contained in:
parent
1dfdc44acd
commit
65eaf916f8
@ -1,7 +1,9 @@
|
|||||||
|
|
||||||
|
@file:Suppress("unused")
|
||||||
|
|
||||||
package ru.dbotthepony.mc.otm.datagen.loot
|
package ru.dbotthepony.mc.otm.datagen.loot
|
||||||
|
|
||||||
import com.mojang.datafixers.util.Pair
|
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.Reference2ObjectArrayMap
|
||||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction
|
import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction
|
||||||
import net.minecraft.advancements.critereon.StatePropertiesPredicate
|
import net.minecraft.advancements.critereon.StatePropertiesPredicate
|
||||||
@ -37,10 +39,6 @@ private typealias LootTableCallback = Consumer<LootTableSaver>
|
|||||||
private typealias LootTableCallbackProvider = Supplier<LootTableCallback>
|
private typealias LootTableCallbackProvider = Supplier<LootTableCallback>
|
||||||
private typealias LootTuple = Pair<LootTableCallbackProvider, LootContextParamSet>
|
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 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) {
|
inline fun LootPool.Builder.item(item: ItemLike, configurator: LootPoolSingletonContainer.Builder<*>.() -> Unit) {
|
||||||
add(LootItem.lootTableItem(item).also(configurator))
|
add(LootItem.lootTableItem(item).also(configurator))
|
||||||
@ -96,7 +94,7 @@ private val poweredMatterWorker = arrayOf(
|
|||||||
)
|
)
|
||||||
|
|
||||||
class LootTables(generator: DataGenerator) : LootTableProvider(generator) {
|
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) {
|
fun builder(context: LootContextParamSet, id: ResourceLocation, provider: LootTable.Builder.() -> Unit) {
|
||||||
provider(context, id) {
|
provider(context, id) {
|
||||||
@ -106,7 +104,7 @@ class LootTables(generator: DataGenerator) : LootTableProvider(generator) {
|
|||||||
|
|
||||||
fun provider(context: LootContextParamSet, id: ResourceLocation, provider: () -> LootTable.Builder) {
|
fun provider(context: LootContextParamSet, id: ResourceLocation, provider: () -> LootTable.Builder) {
|
||||||
check(providersTable
|
check(providersTable
|
||||||
.computeIfAbsent(context, Reference2ObjectFunction { Object2ObjectArrayMap() })
|
.computeIfAbsent(context, Reference2ObjectFunction { HashMap() })
|
||||||
.put(id, provider) == null) { "Duplicate loot pool entry for $id" }
|
.put(id, provider) == null) { "Duplicate loot pool entry for $id" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user