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 fccf96442..5aa004f90 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -406,7 +406,7 @@ object DataGen { val lootModifier = LootModifiers(event.generator) val languageProvider = MatteryLanguageProvider(event.generator) val matterData = MatterDataProvider(event) - val researchProvider = AndroidResearchDataProvider(event.generator, MOD_ID).also { it.exec { addResearchData(it, languageProvider) } } + val researchProvider = AndroidResearchDataProvider(event).also { it.exec { addResearchData(it, languageProvider) } } this.blockModelProvider = blockModelProvider this.blockStateProvider = blockStateProvider diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementProvider.kt index e2afbc95d..fb18e1e70 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementProvider.kt @@ -1,12 +1,13 @@ package ru.dbotthepony.mc.otm.datagen.advancements import net.minecraft.advancements.Advancement +import net.minecraft.core.HolderLookup import net.minecraftforge.common.data.ExistingFileHelper import net.minecraftforge.data.event.GatherDataEvent import java.util.LinkedList import java.util.function.Consumer -class AdvancementProvider(event: GatherDataEvent) : net.minecraft.data.advancements.AdvancementProvider(event.generator, event.existingFileHelper) { +class AdvancementProvider(event: GatherDataEvent) : net.minecraft.data.advancements.AdvancementProvider(event.generator.packOutput, event.lookupProvider, listOf(), event.existingFileHelper) { private val callbacks = LinkedList<(Consumer, ExistingFileHelper) -> Unit>() fun exec(callback: (Consumer, ExistingFileHelper) -> Unit) { @@ -19,7 +20,7 @@ class AdvancementProvider(event: GatherDataEvent) : net.minecraft.data.advanceme } } - override fun registerAdvancements(consumer: Consumer, fileHelper: ExistingFileHelper) { + override fun registerAdvancements(registries: HolderLookup.Provider, consumer: Consumer, fileHelper: ExistingFileHelper) { for (callback in callbacks) { callback.invoke(consumer, fileHelper) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt index 6aa71da6f..3cc1641bc 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt @@ -9,6 +9,7 @@ import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction import net.minecraft.advancements.critereon.StatePropertiesPredicate import net.minecraft.data.DataGenerator import net.minecraft.data.loot.LootTableProvider +import net.minecraft.data.loot.LootTableSubProvider import net.minecraft.resources.ResourceLocation import net.minecraft.world.level.ItemLike import net.minecraft.world.level.block.Block @@ -32,11 +33,6 @@ import java.util.function.BiConsumer import java.util.function.Consumer import java.util.function.Supplier -private typealias LootTableSaver = BiConsumer -private typealias LootTableCallback = Consumer -private typealias LootTableCallbackProvider = Supplier -private typealias LootTuple = Pair - data class NbtCopy(val source: String, val destination: String, val strategy: CopyNbtFunction.MergeStrategy = CopyNbtFunction.MergeStrategy.REPLACE) fun TileNbtCopy(source: String, strategy: CopyNbtFunction.MergeStrategy = CopyNbtFunction.MergeStrategy.REPLACE): NbtCopy { @@ -65,7 +61,7 @@ private val poweredMatterWorker = arrayOf( TileNbtCopy(MatteryBlockEntity.MATTER_STORAGE_KEY), ) -class LootTables(generator: DataGenerator) : LootTableProvider(generator) { +class LootTables(generator: DataGenerator) : LootTableProvider(generator.packOutput, setOf() /* because we don't fucking validate you fuck */, listOf() /* because we attach everything after class is constructed duh */) { private val providersTable = Reference2ObjectArrayMap LootTable.Builder>>() fun builder(context: LootContextParamSet, id: ResourceLocation, provider: LootTable.Builder.() -> Unit) { @@ -80,10 +76,10 @@ class LootTables(generator: DataGenerator) : LootTableProvider(generator) { .put(id, provider) == null) { "Duplicate loot pool entry for $id" } } - override fun getTables(): List { + override fun getTables(): List { return providersTable.entries.stream().map { entry -> - Pair.of(LootTableCallbackProvider { - LootTableCallback { + SubProviderEntry({ + LootTableSubProvider { for ((id, callback) in entry.value) { it.accept(id, callback.invoke()) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt index 7f9d49323..65b3cd2c6 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt @@ -3,12 +3,12 @@ package ru.dbotthepony.mc.otm.datagen.models import com.google.gson.JsonArray import com.google.gson.JsonObject import com.google.gson.JsonPrimitive -import com.mojang.math.Vector3f import net.minecraft.client.renderer.block.model.BlockModel import net.minecraft.core.Direction import net.minecraft.resources.ResourceLocation import net.minecraftforge.client.model.generators.ModelBuilder import net.minecraftforge.common.data.ExistingFileHelper +import org.joml.Vector3f import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.core.set diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt index fea76cc46..971a5c3d7 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.data.recipes.RecipeCategory import net.minecraft.data.recipes.SimpleCookingRecipeBuilder import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.datagen.modLocation @@ -9,8 +10,8 @@ import ru.dbotthepony.mc.otm.registry.MItems import java.util.function.Consumer fun addBlastingRecipes(consumer: Consumer) { - SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItems.MIRROR_COMPOUND), MItems.MIRROR, 0.1f, 100).unlockedBy(MItems.MIRROR_COMPOUND).save(consumer) + SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItems.MIRROR_COMPOUND), RecipeCategory.MISC, MItems.MIRROR, 0.1f, 100).unlockedBy(MItems.MIRROR_COMPOUND).save(consumer) - SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_PLATES), MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates")) - SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_PLATES), MItems.TRITANIUM_INGOT, 0f, 50).unlockedBy(MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates_blasting")) + SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_PLATES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates")) + SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_PLATES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 50).unlockedBy(MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates_blasting")) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 9527f614a..5ff8c0076 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.data.recipes.RecipeCategory import net.minecraft.data.recipes.ShapelessRecipeBuilder import net.minecraft.tags.ItemTags import net.minecraft.world.item.ItemStack @@ -16,36 +17,38 @@ import ru.dbotthepony.mc.otm.datagen.modLocation import java.util.function.Consumer fun addCraftingTableRecipes(consumer: Consumer) { - MatteryRecipe(MRegistry.CARGO_CRATES.item) + val machinesCategory = RecipeCategory.DECORATIONS + + MatteryRecipe(MRegistry.CARGO_CRATES.item, category = RecipeCategory.DECORATIONS) .row(MItemTags.TRITANIUM_PLATES, Tags.Items.CHESTS, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItemTags.TRITANIUM_PLATES) .unlockedBy(Tags.Items.CHESTS) .build(consumer) for ((dye, crate) in MRegistry.CARGO_CRATES.blocks) { - ShapelessRecipeBuilder(crate, 1) + ShapelessRecipeBuilder(RecipeCategory.DECORATIONS, crate, 1) .requires(Ingredient.of(MRegistry.CARGO_CRATES.allItems.entries.stream().filter { it.key != dye }.map { ItemStack(it.value) })) .requires(dye.tag) .unlockedBy(MRegistry.CARGO_CRATES.allItems.entries.stream().filter { it.key != dye }.map { it.value }) .save(consumer, "${crate.registryName}_alt") } - ShapelessRecipeBuilder(MItems.TRITANIUM_INGOT_BLOCK, 1) + ShapelessRecipeBuilder(RecipeCategory.BUILDING_BLOCKS, MItems.TRITANIUM_INGOT_BLOCK, 1) .requires(Ingredient.of(MItemTags.TRITANIUM_INGOTS), 9) .unlockedBy(MItemTags.TRITANIUM_INGOTS) .save(consumer) - ShapelessRecipeBuilder(MItems.TRITANIUM_INGOT, 9) + ShapelessRecipeBuilder(RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 9) .requires(Ingredient.of(MItemTags.TRITANIUM_INGOTS_STORAGE)) .unlockedBy(MItemTags.TRITANIUM_INGOTS_STORAGE) .save(consumer, modLocation("tritanium_ingot_from_storage")) - ShapelessRecipeBuilder(MItems.ENERGY_COUNTER, 1) + ShapelessRecipeBuilder(machinesCategory, MItems.ENERGY_COUNTER, 1) .requires(MItems.ENERGY_COUNTER) .unlockedBy(MItems.ENERGY_COUNTER) .save(consumer, modLocation("energy_counter_reset")) - MatteryRecipe(MBlocks.PLATE_PRESS) + MatteryRecipe(MBlocks.PLATE_PRESS, category = machinesCategory) .row(MItems.ELECTRIC_PARTS, MItems.ENERGY_BUS, MItems.ELECTRIC_PARTS) .row(MItemTags.TRITANIUM_INGOTS, Items.BLAST_FURNACE, MItemTags.TRITANIUM_INGOTS) .row(MItemTags.PISTONS, MItemTags.TRITANIUM_INGOTS, MItemTags.PISTONS) @@ -53,14 +56,14 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(MItems.ELECTRIC_PARTS) .build(consumer) - MatteryRecipe(MBlocks.PLATE_PRESS) + MatteryRecipe(MBlocks.PLATE_PRESS, category = machinesCategory) .rowB(MItems.MACHINE_FRAME) .rowAC(MItemTags.PISTONS, MItemTags.PISTONS) .unlockedBy(MItemTags.TRITANIUM_INGOTS) .unlockedBy(MItems.ELECTRIC_PARTS) .build(consumer, "advanced") - MatteryRecipe(MItems.PATTERN_DRIVE_NORMAL) + MatteryRecipe(MItems.PATTERN_DRIVE_NORMAL, category = machinesCategory) .rowAC(MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT) .row(MItemTags.ADVANCED_CIRCUIT, MItemTags.TRITANIUM_PLATES, MItemTags.ADVANCED_CIRCUIT) .rowAC(MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT) @@ -68,7 +71,7 @@ fun addCraftingTableRecipes(consumer: Consumer) { .build(consumer) // Машины - MatteryRecipe(MItems.MATTER_RECYCLER) + MatteryRecipe(MItems.MATTER_RECYCLER, category = machinesCategory) .row(MItems.MATTER_CAPACITOR_PARTS, Items.HOPPER, MItemTags.BASIC_CIRCUIT) .row(MItemTags.TRITANIUM_PLATES, MItems.MACHINE_FRAME, MItemTags.TRITANIUM_PLATES) .row(MItems.MATTER_CABLE, MItems.MATTER_IO_PORT, MItems.MATTER_CABLE) @@ -76,21 +79,21 @@ fun addCraftingTableRecipes(consumer: Consumer) { .build(consumer) // Блоки - MatteryRecipe(MItems.MATTER_CAPACITOR_BANK) + MatteryRecipe(MItems.MATTER_CAPACITOR_BANK, category = machinesCategory) .row(Tags.Items.GLASS, MItemTags.IRON_PLATES, Tags.Items.GLASS) .row(MItemTags.IRON_PLATES, MItems.MACHINE_FRAME, MItemTags.IRON_PLATES) .row(MItems.MATTER_CABLE, MItems.MATTER_IO_PORT, MItems.MATTER_CABLE) .unlockedBy(MItems.MATTER_CABLE) .build(consumer) - MatteryRecipe(MItems.BATTERY_BANK) + MatteryRecipe(MItems.BATTERY_BANK, category = machinesCategory) .row(Tags.Items.GLASS, MItemTags.IRON_PLATES, Tags.Items.GLASS) .row(MItemTags.IRON_PLATES, MItems.MACHINE_FRAME, MItemTags.IRON_PLATES) .row(MItems.ELECTRIC_PARTS, MItems.ENERGY_BUS, MItems.ELECTRIC_PARTS) .unlockedBy(MItems.ENERGY_BUS) .build(consumer) - MatteryRecipe(MItems.GRAVITATION_STABILIZER) + MatteryRecipe(MItems.GRAVITATION_STABILIZER, category = machinesCategory) .row(MItemTags.ADVANCED_CIRCUIT, MItems.GRAVITATION_FIELD_SENSOR, MItemTags.ADVANCED_CIRCUIT) .row(MItems.MATTER_TRANSFORM_MATRIX, MItems.MACHINE_FRAME, MItems.MATTER_TRANSFORM_MATRIX) .row(MItemTags.TRITANIUM_PLATES, MItems.GRAVITATION_FIELD_LIMITER, MItemTags.TRITANIUM_PLATES) @@ -98,7 +101,7 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(MItems.GRAVITATION_FIELD_SENSOR) .build(consumer) - MatteryRecipe(MItems.PORTABLE_GRAVITATION_STABILIZER) + MatteryRecipe(MItems.PORTABLE_GRAVITATION_STABILIZER, category = RecipeCategory.COMBAT) .rowB(MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItems.GRAVITATION_FIELD_SENSOR, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItems.GRAVITATION_FIELD_LIMITER, MItemTags.TRITANIUM_PLATES) @@ -106,53 +109,53 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(MItems.GRAVITATION_FIELD_SENSOR) .build(consumer) - MatteryRecipe(MItems.GRAVITATION_FIELD_SENSOR) + MatteryRecipe(MItems.GRAVITATION_FIELD_SENSOR, category = RecipeCategory.MISC) .rowB(MItemTags.BASIC_CIRCUIT) .row(MItemTags.TRITANIUM_PLATES, MItems.ELECTROMAGNET, MItemTags.TRITANIUM_PLATES) .rowB(MItemTags.IRON_PLATES) .unlockedBy(MItems.ELECTROMAGNET) .build(consumer) - MatteryRecipe(MItems.GRAVITATION_FIELD_LIMITER) + MatteryRecipe(MItems.GRAVITATION_FIELD_LIMITER, category = RecipeCategory.MISC) .row(Tags.Items.ENDER_PEARLS, MItemTags.ADVANCED_CIRCUIT, Tags.Items.ENDER_PEARLS) .row(MItemTags.GOLD_WIRES, MItems.QUANTUM_TRANSCEIVER, MItemTags.GOLD_WIRES) .rowB(MItemTags.TRITANIUM_PLATES) .unlockedBy(MItems.QUANTUM_TRANSCEIVER) .build(consumer) - MatteryRecipe(MItems.BLACK_HOLE_SCANNER) + MatteryRecipe(MItems.BLACK_HOLE_SCANNER, category = RecipeCategory.TOOLS) .row(MItemTags.IRON_PLATES, Tags.Items.GLASS_PANES_COLORLESS, MItemTags.IRON_PLATES) .row(MItemTags.GOLD_WIRES, MItems.GRAVITATION_FIELD_SENSOR, MItemTags.ADVANCED_CIRCUIT) .rowAC(Tags.Items.DUSTS_GLOWSTONE, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItems.GRAVITATION_FIELD_SENSOR) .build(consumer) - MatteryRecipe(MItems.PHANTOM_ATTRACTOR) + MatteryRecipe(MItems.PHANTOM_ATTRACTOR, category = machinesCategory) .row(Tags.Items.DUSTS_REDSTONE, Tags.Items.GLASS_COLORLESS, Tags.Items.DUSTS_REDSTONE) .row(MItemTags.TRITANIUM_PLATES, MItems.QUANTUM_TRANSCEIVER, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, ItemTags.BEDS, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItems.QUANTUM_TRANSCEIVER) .build(consumer) - MatteryRecipe(MItems.QUANTUM_TRANSCEIVER, 2) + MatteryRecipe(MItems.QUANTUM_TRANSCEIVER, 2, category = RecipeCategory.MISC) .rowAC(MItemTags.COPPER_WIRES, MItemTags.COPPER_WIRES) .row(MItemTags.GOLD_WIRES, Tags.Items.ENDER_PEARLS, MItemTags.GOLD_WIRES) .row(MItemTags.GOLD_WIRES, MItems.ELECTROMAGNET, MItemTags.GOLD_WIRES) .unlockedBy(Tags.Items.ENDER_PEARLS) .build(consumer) - MatteryRecipe(MItems.ELECTROMAGNET) + MatteryRecipe(MItems.ELECTROMAGNET, category = RecipeCategory.MISC) .row(MItemTags.COPPER_WIRES, Tags.Items.INGOTS_IRON, MItemTags.COPPER_WIRES) .unlockedBy(Tags.Items.ENDER_PEARLS) .build(consumer) - MatteryRecipe(MItems.ENERGY_SERVO) + MatteryRecipe(MItems.ENERGY_SERVO, category = RecipeCategory.MISC) .row(MItemTags.TRITANIUM_PLATES, MItems.MACHINE_FRAME, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItems.ENERGY_BUS, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItems.ENERGY_BUS) .build(consumer) - MatteryRecipe(MItems.MIRROR_COMPOUND, 3) + MatteryRecipe(MItems.MIRROR_COMPOUND, 3, category = RecipeCategory.MISC) .row(Tags.Items.GLASS_PANES_COLORLESS, Tags.Items.GLASS_PANES_COLORLESS, Tags.Items.GLASS_PANES_COLORLESS) .row(MItemTags.IRON_PLATES, MItemTags.IRON_PLATES, MItemTags.IRON_PLATES) .unlockedBy(MItemTags.IRON_PLATES) @@ -160,79 +163,79 @@ fun addCraftingTableRecipes(consumer: Consumer) { .build(consumer) // броня - MatteryRecipe(MItems.TRITANIUM_HELMET) + MatteryRecipe(MItems.TRITANIUM_HELMET, category = RecipeCategory.COMBAT) .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItemTags.IRON_PLATES, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItemTags.TRITANIUM_PLATES) .build(consumer) - MatteryRecipe(MItems.TRITANIUM_PANTS) + MatteryRecipe(MItems.TRITANIUM_PANTS, category = RecipeCategory.COMBAT) .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItemTags.IRON_PLATES, MItemTags.TRITANIUM_PLATES) .rowAC(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItemTags.TRITANIUM_PLATES) .build(consumer) - MatteryRecipe(MItems.TRITANIUM_CHESTPLATE) + MatteryRecipe(MItems.TRITANIUM_CHESTPLATE, category = RecipeCategory.COMBAT) .row(MItemTags.TRITANIUM_PLATES, MItemTags.IRON_PLATES, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItemTags.TRITANIUM_PLATES) .build(consumer) - MatteryRecipe(MItems.TRITANIUM_BOOTS) + MatteryRecipe(MItems.TRITANIUM_BOOTS, category = RecipeCategory.COMBAT) .rowAC(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItemTags.IRON_PLATES, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItemTags.TRITANIUM_PLATES) .build(consumer) // простые батарейки - MatteryRecipe(MItems.BATTERY_CRUDE) + MatteryRecipe(MItems.BATTERY_CRUDE, category = RecipeCategory.MISC) .rowB(Tags.Items.DUSTS_REDSTONE) .rowB(Tags.Items.CROPS_POTATO) .rowB(Tags.Items.INGOTS_IRON) .build(consumer) - MatteryRecipe(MItems.BATTERY_BASIC) + MatteryRecipe(MItems.BATTERY_BASIC, category = RecipeCategory.MISC) .rowAC(Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE) .rowB(MItems.ELECTRIC_PARTS) .rowB(MItemTags.IRON_PLATES) .build(consumer) - MatteryRecipe(MItems.BATTERY_NORMAL) + MatteryRecipe(MItems.BATTERY_NORMAL, category = RecipeCategory.MISC) .rowB(MItems.ELECTRIC_PARTS) .row(MItemTags.COPPER_WIRES, MItemTags.IRON_PLATES, MItemTags.COPPER_WIRES) .row(Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE) .build(consumer) - MatteryRecipe(MItems.BATTERY_DENSE) + MatteryRecipe(MItems.BATTERY_DENSE, category = RecipeCategory.MISC) .row(Tags.Items.DUSTS_REDSTONE, MItems.ENERGY_BUS, Tags.Items.DUSTS_REDSTONE) .row(MItemTags.GOLD_WIRES, MItemTags.TRITANIUM_PLATES, MItemTags.GOLD_WIRES) .row(Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE) .build(consumer) - MatteryRecipe(MItems.BATTERY_CAPACITOR) + MatteryRecipe(MItems.BATTERY_CAPACITOR, category = RecipeCategory.MISC) .row(Tags.Items.DUSTS_REDSTONE, MItems.ENERGY_BUS, Tags.Items.DUSTS_REDSTONE) .row(MItemTags.GOLD_WIRES, MItemTags.TRITANIUM_PLATES, MItemTags.GOLD_WIRES) .row(MItemTags.GOLD_WIRES, Tags.Items.DUSTS_REDSTONE, MItemTags.GOLD_WIRES) .build(consumer) // накопители материи - MatteryRecipe(MItems.MATTER_CAPACITOR_DENSE) + MatteryRecipe(MItems.MATTER_CAPACITOR_DENSE, category = RecipeCategory.MISC) .row(MItems.MATTER_CAPACITOR_PARTS, Tags.Items.GLASS, MItems.MATTER_CAPACITOR_PARTS) .row(MItemTags.TRITANIUM_PLATES, Tags.Items.ENDER_PEARLS, MItemTags.TRITANIUM_PLATES) .rowAC(Tags.Items.GEMS_DIAMOND, Tags.Items.GEMS_DIAMOND) .build(consumer) // станция андроида - MatteryRecipe(MItems.ANDROID_STATION) + MatteryRecipe(MItems.ANDROID_STATION, category = machinesCategory) .row(MItems.ELECTRIC_PARTS, MItemTags.ADVANCED_CIRCUIT, MItems.ELECTRIC_PARTS) .row(MItemTags.TRITANIUM_PLATES, MItems.MACHINE_FRAME, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItems.ELECTRIC_PARTS, MItemTags.TRITANIUM_PLATES) .build(consumer) // Энерго меч - MatteryRecipe(MItems.ENERGY_SWORD) + MatteryRecipe(MItems.ENERGY_SWORD, category = RecipeCategory.COMBAT) .rowBC(MItemTags.TRITANIUM_PLATES, MItemTags.GOLD_WIRES) .rowBC(MItemTags.TRITANIUM_PLATES, MItemTags.GOLD_WIRES) .row(MItems.BATTERY_CAPACITOR, MItems.TRITANIUM_SWORD, MItemTags.ADVANCED_CIRCUIT) @@ -240,14 +243,14 @@ fun addCraftingTableRecipes(consumer: Consumer) { .buildEnergetic(consumer) // лампа - MatteryRecipe(MItems.LABORATORY_LAMP) + MatteryRecipe(MItems.LABORATORY_LAMP, category = RecipeCategory.REDSTONE) .row(MItemTags.IRON_PLATES, MItemTags.HARDENED_GLASS_PANES_COLORLESS, MItemTags.IRON_PLATES) .row(MItems.MIRROR, Items.GLOWSTONE, MItems.MIRROR) .row(MItemTags.TRITANIUM_PLATES, Tags.Items.DUSTS_REDSTONE, MItemTags.TRITANIUM_PLATES) .build(consumer) // апгрейд на сетку крафта - MatteryRecipe(MItems.ExopackUpgrades.CRAFTING_UPGRADE) + MatteryRecipe(MItems.ExopackUpgrades.CRAFTING_UPGRADE, category = RecipeCategory.TOOLS) .row(MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT) .row(MItemTags.CRAFTING_TABLES, MItems.QUANTUM_TRANSCEIVER, MItemTags.CRAFTING_TABLES) .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt index d3f4b6067..2ae7fc69d 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt @@ -19,7 +19,7 @@ import ru.dbotthepony.mc.otm.registry.MRegistry import java.util.function.Consumer private fun stairs(base: ItemLike, result: ItemLike, consumer: Consumer) { - MatteryRecipe(result, 4) + MatteryRecipe(result, 4, category = RecipeCategory.BUILDING_BLOCKS) .rowA(base) .rowAB(base, base) .row(base, base, base) @@ -28,14 +28,14 @@ private fun stairs(base: ItemLike, result: ItemLike, consumer: Consumer) { - MatteryRecipe(result, 6) + MatteryRecipe(result, 6, category = RecipeCategory.BUILDING_BLOCKS) .row(base, base, base) .unlockedBy(base) .build(consumer) } private fun wall(base: ItemLike, result: ItemLike, consumer: Consumer) { - MatteryRecipe(result, 6) + MatteryRecipe(result, 6, category = RecipeCategory.BUILDING_BLOCKS) .row(base, base, base) .row(base, base, base) .unlockedBy(base) @@ -44,7 +44,7 @@ private fun wall(base: ItemLike, result: ItemLike, consumer: Consumer) { SingleItemRecipeBuilder - .stonecutting(Ingredient.of(base), result, amount) + .stonecutting(Ingredient.of(base), RecipeCategory.BUILDING_BLOCKS, result, amount) .unlockedBy(base) .save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "stonecutting/${result.asItem().registryName!!.path}_from_${base.asItem().registryName!!.path}")) } @@ -78,6 +78,7 @@ fun addDecorativesRecipes(provider: MatteryRecipeProvider, consumer: Consumer(3) private var index = 0 @@ -120,7 +121,7 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1) { throw NoSuchElementException("No recipe rows were defined") } - val builder = ShapedRecipeBuilder(result, count) + val builder = ShapedRecipeBuilder(category, result, count) val pairs = ArrayList>() val iterator = charlist.iterator() diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt index f985ee946..54d3e6ab0 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt @@ -63,7 +63,7 @@ fun T.unlockedBy(item: TagKey): T { return this } -class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generatorIn) { +class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generatorIn.packOutput) { private val callbacks = LinkedList() fun exec(callback: RecipeBuilderCallback): MatteryRecipeProvider { @@ -71,7 +71,7 @@ class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generat return this } - override fun buildCraftingRecipes(callback: Consumer) { + override fun buildRecipes(callback: Consumer) { for (lambda in callbacks) { lambda(this, callback) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt index c9939a3da..f3a50e642 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.data.recipes.RecipeCategory import net.minecraft.data.recipes.SimpleCookingRecipeBuilder import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.crafting.Ingredient @@ -10,12 +11,12 @@ import ru.dbotthepony.mc.otm.registry.MItems import java.util.function.Consumer fun addOreSmeltingRecipes(consumer: Consumer) { - SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORES), MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "smelting/tritanium_ingot_from_ore_block")) - SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORES), MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "blasting/tritanium_ingot_from_ore_block")) + SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "smelting/tritanium_ingot_from_ore_block")) + SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "blasting/tritanium_ingot_from_ore_block")) - SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "smelting/tritanium_ingot_from_raw_ore")) - SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "blasting/tritanium_ingot_from_raw_ore")) + SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "smelting/tritanium_ingot_from_raw_ore")) + SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "blasting/tritanium_ingot_from_raw_ore")) - SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "smelting/tritanium_ingot_from_dust")) - SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), MItems.TRITANIUM_INGOT, 0f, 200).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "blasting/tritanium_ingot_from_dust")) + SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "smelting/tritanium_ingot_from_dust")) + SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 200).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "blasting/tritanium_ingot_from_dust")) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt index 72fb7f8b0..08f55b308 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.data.recipes.RecipeCategory import net.minecraft.data.recipes.ShapelessRecipeBuilder import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack @@ -15,21 +16,21 @@ import java.util.function.Consumer fun addShapelessRecipes(consumer: Consumer) { for (color in DyeColor.values()) { - ShapelessRecipeBuilder(MItems.CARGO_CRATE_MINECARTS[color]!!, 1) + ShapelessRecipeBuilder(RecipeCategory.TRANSPORTATION, MItems.CARGO_CRATE_MINECARTS[color]!!, 1) .requires(Items.MINECART) .requires(MRegistry.CARGO_CRATES.items[color]!!) .unlockedBy(Items.MINECART) .unlockedBy(MRegistry.CARGO_CRATES.items[color]!!) .save(consumer) - ShapelessRecipeBuilder(MItems.CARGO_CRATE_MINECARTS[color]!!, 1) + ShapelessRecipeBuilder(RecipeCategory.TRANSPORTATION, MItems.CARGO_CRATE_MINECARTS[color]!!, 1) .requires(Ingredient.of(MItems.CARGO_CRATE_MINECARTS.entries.stream().filter { it.key != color }.map { ItemStack(it.value) })) .requires(color.tag) .unlockedBy(MItems.CARGO_CRATE_MINECARTS.entries.stream().filter { it.key != color }.map { it.value }) .save(consumer, modLocation(MItems.CARGO_CRATE_MINECARTS[color]!!.registryName!!.path + "_alt")) } - ShapelessRecipeBuilder(MItems.CARGO_CRATE_MINECARTS[null]!!, 1) + ShapelessRecipeBuilder(RecipeCategory.TRANSPORTATION, MItems.CARGO_CRATE_MINECARTS[null]!!, 1) .requires(Items.MINECART) .requires(MRegistry.CARGO_CRATES.item) .unlockedBy(Items.MINECART) 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 7df9e7f57..8e3ce80e7 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 @@ -1,7 +1,11 @@ package ru.dbotthepony.mc.otm.datagen.tags import it.unimi.dsi.fastutil.objects.ObjectArraySet +import net.minecraft.core.HolderLookup import net.minecraft.core.Registry +import net.minecraft.core.registries.BuiltInRegistries +import net.minecraft.core.registries.Registries +import net.minecraft.resources.ResourceKey import net.minecraft.resources.ResourceLocation import net.minecraft.tags.BlockTags import net.minecraft.tags.GameEventTags @@ -11,6 +15,7 @@ import net.minecraft.world.item.Tier import net.minecraft.world.item.Tiers import net.minecraft.world.level.block.Block import net.minecraftforge.data.event.GatherDataEvent +import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.datagen.DataGen import java.util.stream.Stream @@ -58,22 +63,24 @@ interface ForgeTagAppender : MTagAppender { class TagsProvider( private val event: GatherDataEvent ) { - inner class Delegate(registry: Registry) : MinecraftTagsProvider(event.generator, registry, DataGen.MOD_ID, event.existingFileHelper) { + inner class Delegate(registry: ResourceKey>) : MinecraftTagsProvider(event.generator.packOutput, registry, event.lookupProvider, DataGen.MOD_ID, event.existingFileHelper) { init { event.generator.addProvider(true, this) } private val tags = HashMap, ObjectArraySet>() - override fun addTags() { + override fun addTags(provider: HolderLookup.Provider) { if (tags.isEmpty()) { return } + val registry = (BuiltInRegistries.REGISTRY.get(registryKey.location()) ?: throw NoSuchElementException("No such registry $registryKey")) as Registry + for ((tag, values) in tags) { tag(tag).also { for (value in values) { - it.add(value) + it.add(ResourceKey.create(registryKey, registry.getKey(value) ?: throw NoSuchElementException("$value is missing from $registry"))) } } } @@ -83,7 +90,7 @@ class TagsProvider( return tags.computeIfAbsent(tag) { ObjectArraySet() } } - fun getSet(location: ResourceLocation) = getSet(TagKey.create(registry.key(), location)) + fun getSet(location: ResourceLocation) = getSet(TagKey.create(registryKey, location)) fun appender(tag: TagKey, message: ((T) -> Any) = { "$it is already in $tag" }): MTagAppender { val list = getSet(tag) @@ -118,7 +125,7 @@ class TagsProvider( return object : ForgeTagAppender { override fun add(key: String, value: T): MTagAppender { - val tag = TagKey.create(registry.key(), ResourceLocation("forge", "$path/$key")) + val tag = TagKey.create(registryKey, ResourceLocation("forge", "$path/$key")) if (!getSet(tag).add(value)) { throw IllegalStateException("$value is already in $tag") @@ -128,7 +135,7 @@ class TagsProvider( } override fun addSafe(key: String, value: T): Boolean { - val tag = TagKey.create(registry.key(), ResourceLocation("forge", "$path/$key")) + val tag = TagKey.create(registryKey, ResourceLocation("forge", "$path/$key")) return getSet(tag).add(value) } @@ -161,17 +168,17 @@ class TagsProvider( } fun appender(location: ResourceLocation): MTagAppender { - return appender(TagKey.create(registry.key(), location)) + return appender(TagKey.create(registryKey, location)) } fun appender(location: ResourceLocation, message: (T) -> Any): MTagAppender { - return appender(TagKey.create(registry.key(), location), message) + return appender(TagKey.create(registryKey, location), message) } } - val blocks = Delegate(Registry.BLOCK) - val items = Delegate(Registry.ITEM) - val mobEffects = Delegate(Registry.MOB_EFFECT) + val blocks = Delegate(Registries.BLOCK) + val items = Delegate(Registries.ITEM) + val mobEffects = Delegate(Registries.MOB_EFFECT) val androidImmuneEffects = mobEffects.appender(MatteryPlayerCapability.ANDROID_IMMUNE_EFFECTS) @@ -189,8 +196,8 @@ class TagsProvider( fun ore(key: String, block: Block): TagsProvider { val forgeKey = ResourceLocation("forge", "ores/$key") - val b = TagKey.create(Registry.BLOCK_REGISTRY, forgeKey) - val i = TagKey.create(Registry.ITEM_REGISTRY, forgeKey) + val b = TagKey.create(Registries.BLOCK, forgeKey) + val i = TagKey.create(Registries.ITEM, forgeKey) items.getSet(i).add(block.asItem()) itemOres.add(block.asItem()) @@ -230,7 +237,7 @@ class TagsProvider( val rawMaterials = items.forge("raw_materials") val wires = items.forge("wires") - val gameEvents = Delegate(Registry.GAME_EVENT) + val gameEvents = Delegate(Registries.GAME_EVENT) val vibrations = gameEvents.appender(GameEventTags.VIBRATIONS) fun requiresPickaxe(block: Block, tier: Tier? = null): TagsProvider {