From 84430f2190645ec53eaf70a1f3912bfc9f8ab0a6 Mon Sep 17 00:00:00 2001 From: screret <68943070+screret@users.noreply.github.com> Date: Sat, 21 Oct 2023 11:42:50 +0300 Subject: [PATCH] change some things to be more addon dev-friendly (#485) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: make modid filter in fabric registry generator not be hardcoded. * fix: "a feature order cycle was found" should close #430, #409, #301 * feat: deprecate these. didn't work as planned. * feat: add recipe removal event to IGTAddon * feat: general tags for purified & refined ores * fix: changed my mind, removĂ­ng these now * fix: make SoundEntryProvider able to accept a filter for the mod id to run for. * fix: make VanillaRecipeHelper use ResourceLocations for recipe ids, add methods to create from string for backwards compatibility. * chore: bump version * chore: changelog --- CHANGELOG.md | 15 ++---- .../gregtechceu/gtceu/api/addon/IGTAddon.java | 23 +++------ .../gtceu/api/data/tag/TagPrefix.java | 4 ++ .../registrate/SoundEntryBuilder.java | 8 +-- .../gregtechceu/gtceu/common/CommonProxy.java | 1 + .../gtceu/common/data/GTMachines.java | 1 - .../gtceu/common/data/GTPlacements.java | 2 +- .../gtceu/common/data/GTRecipeTypes.java | 1 - .../gtceu/common/data/GTRecipes.java | 4 +- .../gtceu/data/loader/OreDataLoader.java | 1 - .../data/recipe/VanillaRecipeHelper.java | 51 +++++++++++++++---- .../recipe/misc/CraftingRecipeLoader.java | 5 +- .../fabric/GTRegistriesDatapackGenerator.java | 8 +-- .../gtceu/data/fabric/GregTechDatagen.java | 10 ++-- .../gtceu/data/forge/DataGenerators.java | 2 +- gradle.properties | 2 +- 16 files changed, 80 insertions(+), 58 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89c4454e68..3a50fa4d7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,5 @@ # ChangeLog -* fix fluid pipe throughput being too low -* fix super tank & quantum tank amount being displayed incorrectly on fabric -* fix wires not being colored -* fix large boiler not resuming work after being unloaded -* fix large distillery and some GCyM machines not forming -* fix some missing / unnecessary mixer recipes, glass vial material amount, melon maceration -* fix server crashes on multiblock recipe map modification -* fix distinct bus mode not working with circuits config -* fix placement issues when using the terminal to build a multiblock -* fix cherry and bamboo recipes not being affected by the harderWoodRecipes config -* fix spray cans being unable to color vanilla blocks -* add KubeJS bindings for GTFluidStorageKeys, GTFluidState, PropertyKey \ No newline at end of file +* fix feature order cycle on fabric +* make some API methods more addon dev friendly +* add tags for all purified/refined ores \ No newline at end of file diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/addon/IGTAddon.java b/common/src/main/java/com/gregtechceu/gtceu/api/addon/IGTAddon.java index 1460be8bee..76f0e6c285 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/addon/IGTAddon.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/addon/IGTAddon.java @@ -3,13 +3,14 @@ import com.gregtechceu.gtceu.api.addon.events.KJSRecipeKeyEvent; import com.gregtechceu.gtceu.api.addon.events.MaterialCasingCollectionEvent; import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.resources.ResourceLocation; import java.util.function.Consumer; public interface IGTAddon { /** - * You can freely initialize blocks/items/etc. here, this runs after GTCEu has setup it's content + * This runs after GTCEu has setup it's content. */ void initializeAddon(); @@ -54,20 +55,6 @@ default void registerCovers() { } - /** - * Call init on your custom RecipeType class(es) here - */ - default void registerRecipeTypes() { - - } - - /** - * Call init on your custom Machine class(es) here - */ - default void registerMachines() { - - } - /** * Call init on your custom IWorldGenLayer class(es) here */ @@ -82,7 +69,11 @@ default void registerVeinGenerators() { } - default void initializeRecipes(Consumer provider) { + default void addRecipes(Consumer provider) { + + } + + default void removeRecipes(Consumer consumer) { } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java b/common/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java index c0df341f32..c2ed8d8184 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java @@ -191,6 +191,8 @@ public static TagPrefix get(String name) { public static final TagPrefix crushedRefined = new TagPrefix("refinedOre") .defaultTagPath(FORGE, "refined_ores/%s") .defaultTagPath(FABRIC, "%s_refined_ores") + .defaultTagPath(FORGE, "refined_ores") + .defaultTagPath(FABRIC, "refined_ores") .langValue("Refined %s Ore") .materialIconType(MaterialIconType.crushedRefined) .unificationEnabled(true) @@ -200,6 +202,8 @@ public static TagPrefix get(String name) { public static final TagPrefix crushedPurified = new TagPrefix("purifiedOre") .defaultTagPath(FORGE, "purified_ores/%s") .defaultTagPath(FABRIC, "%s_purified_ores") + .defaultTagPath(FORGE, "purified_ores") + .defaultTagPath(FABRIC, "purified_ores") .langValue("Purified %s Ore") .materialIconType(MaterialIconType.crushedPurified) .unificationEnabled(true) diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/SoundEntryBuilder.java b/common/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/SoundEntryBuilder.java index 527f7287e2..8b440e8ef4 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/SoundEntryBuilder.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/SoundEntryBuilder.java @@ -32,9 +32,11 @@ public class SoundEntryBuilder { public static class SoundEntryProvider implements DataProvider { private final PackOutput output; + private final String modId; - public SoundEntryProvider(PackOutput output) { + public SoundEntryProvider(PackOutput output, String modId) { this.output = output; + this.modId = modId; } @Override @@ -44,14 +46,14 @@ public CompletableFuture run(CachedOutput cache) { @Override public String getName() { - return "GTCEU's Custom Sounds"; + return modId + "'s Custom Sounds"; } public CompletableFuture generate(Path path, CachedOutput cache) { JsonObject json = new JsonObject(); try { for (SoundEntry sound : GTRegistries.SOUNDS) { - sound.write(json); + if (sound.getId().getNamespace().equals(modId)) sound.write(json); } } catch (Exception ignored) { } diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java b/common/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java index 8115d92448..d39829b3cd 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java @@ -62,5 +62,6 @@ public static void init() { GTRegistries.REGISTRATE.registerRegistrate(); WorldGenLayers.registerAll(); GTFeatures.init(); + GTFeatures.register(); } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java index 268595b4b9..1492f217bb 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java @@ -1768,7 +1768,6 @@ public static void init() { .register(), MV, HV, EV); } - AddonFinder.getAddons().forEach(IGTAddon::registerMachines); if (GTCEu.isKubeJSLoaded()) { GTRegistryObjectBuilderTypes.registerFor(GTRegistries.MACHINES.getRegistryName()); } diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTPlacements.java b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTPlacements.java index bf01d2263a..9b9c6b1bd7 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTPlacements.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTPlacements.java @@ -38,7 +38,7 @@ public static void bootstrap(BootstapContext ctx) { PlacementUtils.countExtra(0, ConfigHolder.INSTANCE.worldgen.rubberTreeSpawnChance, 1), InSquarePlacement.spread(), SurfaceWaterDepthFilter.forMaxDepth(0), - PlacementUtils.HEIGHTMAP_OCEAN_FLOOR, + PlacementUtils.HEIGHTMAP_TOP_SOLID, BiomeFilter.biome(), PlacementUtils.filteredByBlockSurvival(GTBlocks.RUBBER_SAPLING.get()) ); diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java index 82fcd94b5e..1a65b7d76a 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java @@ -584,7 +584,6 @@ public static void init() { .save(provider); }); } - AddonFinder.getAddons().forEach(IGTAddon::registerRecipeTypes); if (GTCEu.isKubeJSLoaded()) { GTRegistryObjectBuilderTypes.registerFor(GTRegistries.RECIPE_TYPES.getRegistryName()); } diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipes.java b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipes.java index 7c7e8c2f1f..3172be7ce4 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipes.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipes.java @@ -70,7 +70,7 @@ public static void recipeAddition(Consumer consumer) { CreateRecipeLoader.init(consumer); } - AddonFinder.getAddons().forEach(addon -> addon.initializeRecipes(consumer)); + AddonFinder.getAddons().forEach(addon -> addon.addRecipes(consumer)); } /* @@ -80,5 +80,7 @@ public static void recipeAddition(Consumer consumer) { */ public static void recipeRemoval(Consumer consumer) { RecipeRemoval.init(consumer); + + AddonFinder.getAddons().forEach(addon -> addon.removeRecipes(consumer)); } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/loader/OreDataLoader.java b/common/src/main/java/com/gregtechceu/gtceu/data/loader/OreDataLoader.java index 1cbf4c3a68..da5efbd81c 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/loader/OreDataLoader.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/loader/OreDataLoader.java @@ -41,7 +41,6 @@ public OreDataLoader() { @Override protected void apply(Map resourceList, ResourceManager resourceManager, ProfilerFiller profiler) { GTRegistries.ORE_VEINS.registry().clear(); - GTFeatures.register(); GTOres.init(); if (GTCEu.isKubeJSLoaded()) { RunKJSEventInSeparateClassBecauseForgeIsDumb.fireKJSEvent(); diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/VanillaRecipeHelper.java b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/VanillaRecipeHelper.java index 9115f110b0..2dad81c93d 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/VanillaRecipeHelper.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/VanillaRecipeHelper.java @@ -16,6 +16,7 @@ import it.unimi.dsi.fastutil.objects.Object2LongMap; import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -36,27 +37,43 @@ public class VanillaRecipeHelper { public static void addSmeltingRecipe(Consumer provider, @Nonnull String regName, TagKey input, ItemStack output) { + addSmeltingRecipe(provider, GTCEu.id(regName.toLowerCase(Locale.ROOT)), input, output); + } + + public static void addSmeltingRecipe(Consumer provider, @Nonnull ResourceLocation regName, TagKey input, ItemStack output) { addSmeltingRecipe(provider, regName, input, output, 0.0f); } - public static void addSmeltingRecipe(Consumer provider, @Nonnull String regName, TagKey input, ItemStack output, float experience) { - new SmeltingRecipeBuilder(GTCEu.id(regName.toLowerCase(Locale.ROOT))).input(input).output(output).cookingTime(200).experience(experience).save(provider); + public static void addSmeltingRecipe(Consumer provider, @Nonnull ResourceLocation regName, TagKey input, ItemStack output, float experience) { + new SmeltingRecipeBuilder(regName).input(input).output(output).cookingTime(200).experience(experience).save(provider); } public static void addBlastingRecipe(Consumer provider, @Nonnull String regName, TagKey input, ItemStack output, float experience) { - new BlastingRecipeBuilder(GTCEu.id(regName.toLowerCase(Locale.ROOT))).input(input).output(output).cookingTime(100).experience(experience).save(provider); + addBlastingRecipe(provider, GTCEu.id(regName.toLowerCase(Locale.ROOT)), input, output, experience); + } + + public static void addBlastingRecipe(Consumer provider, @Nonnull ResourceLocation regName, TagKey input, ItemStack output, float experience) { + new BlastingRecipeBuilder(regName).input(input).output(output).cookingTime(100).experience(experience).save(provider); } public static void addSmokingRecipe(Consumer provider, @Nonnull String regName, TagKey input, ItemStack output, float experience) { - new SmokingRecipeBuilder(GTCEu.id(regName.toLowerCase(Locale.ROOT))).input(input).output(output).cookingTime(100).experience(experience).save(provider); + addSmokingRecipe(provider, GTCEu.id(regName.toLowerCase(Locale.ROOT)), input, output, experience); + } + + public static void addSmokingRecipe(Consumer provider, @Nonnull ResourceLocation regName, TagKey input, ItemStack output, float experience) { + new SmokingRecipeBuilder(regName).input(input).output(output).cookingTime(100).experience(experience).save(provider); } public static void addSmeltingRecipe(Consumer provider, @Nonnull String regName, ItemStack input, ItemStack output) { - addSmeltingRecipe(provider, regName, input, output, 0.0f); + addSmeltingRecipe(provider, GTCEu.id(regName.toLowerCase(Locale.ROOT)), input, output, 0.0f); } public static void addSmeltingRecipe(Consumer provider, @Nonnull String regName, ItemStack input, ItemStack output, float experience) { - new SmeltingRecipeBuilder(GTCEu.id(regName.toLowerCase(Locale.ROOT))).input(input).output(output).cookingTime(200).experience(experience).save(provider); + addSmeltingRecipe(provider, GTCEu.id(regName.toLowerCase(Locale.ROOT)), input, output, experience); + } + + public static void addSmeltingRecipe(Consumer provider, @Nonnull ResourceLocation regName, ItemStack input, ItemStack output, float experience) { + new SmeltingRecipeBuilder(regName).input(input).output(output).cookingTime(200).experience(experience).save(provider); } private static final Char2ObjectMap> TOOLS = new Char2ObjectArrayMap<>(); @@ -74,10 +91,18 @@ public static void addSmeltingRecipe(Consumer provider, @Nonnull } public static void addShapedRecipe(Consumer provider, @Nonnull String regName, @Nonnull ItemStack result, @Nonnull Object... recipe) { + addShapedRecipe(provider, GTCEu.id(regName.toLowerCase(Locale.ROOT)), result, recipe); + } + + public static void addShapedRecipe(Consumer provider, @Nonnull ResourceLocation regName, @Nonnull ItemStack result, @Nonnull Object... recipe) { addShapedRecipe(provider, false, regName, result, recipe); } public static void addStrictShapedRecipe(Consumer provider, @Nonnull String regName, @Nonnull ItemStack result, @Nonnull Object... recipe) { + addStrictShapedRecipe(provider, GTCEu.id(regName.toLowerCase(Locale.ROOT)), result, recipe); + } + + public static void addStrictShapedRecipe(Consumer provider, @Nonnull ResourceLocation regName, @Nonnull ItemStack result, @Nonnull Object... recipe) { addStrictShapedRecipe(provider, false, regName, result, recipe); } @@ -106,8 +131,8 @@ public static void addStrictShapedRecipe(Consumer provider, @Non * @param result the output for the recipe * @param recipe the contents of the recipe */ - public static void addShapedRecipe(Consumer provider, boolean withUnificationData, boolean isStrict, @Nonnull String regName, @Nonnull ItemStack result, @Nonnull Object... recipe) { - var builder = new ShapedRecipeBuilder(GTCEu.id(regName.toLowerCase(Locale.ROOT))).output(result); + public static void addShapedRecipe(Consumer provider, boolean withUnificationData, boolean isStrict, @Nonnull ResourceLocation regName, @Nonnull ItemStack result, @Nonnull Object... recipe) { + var builder = new ShapedRecipeBuilder(regName).output(result); builder.isStrict(isStrict); CharSet set = new CharOpenHashSet(); for (int i = 0; i < recipe.length; i++) { @@ -151,16 +176,20 @@ public static void addShapedRecipe(Consumer provider, boolean wi } } - public static void addShapedRecipe(Consumer provider, boolean withUnificationData, @Nonnull String regName, @Nonnull ItemStack result, @Nonnull Object... recipe) { + public static void addShapedRecipe(Consumer provider, boolean withUnificationData, @Nonnull ResourceLocation regName, @Nonnull ItemStack result, @Nonnull Object... recipe) { addShapedRecipe(provider, withUnificationData, false, regName, result, recipe); } - public static void addStrictShapedRecipe(Consumer provider, boolean withUnificationData, @Nonnull String regName, @Nonnull ItemStack result, @Nonnull Object... recipe) { + public static void addStrictShapedRecipe(Consumer provider, boolean withUnificationData, @Nonnull ResourceLocation regName, @Nonnull ItemStack result, @Nonnull Object... recipe) { addShapedRecipe(provider, withUnificationData, true, regName, result, recipe); } public static void addShapelessRecipe(Consumer provider, @Nonnull String regName, @Nonnull ItemStack result, @Nonnull Object... recipe) { - var builder = new ShapelessRecipeBuilder(GTCEu.id(regName.toLowerCase(Locale.ROOT))).output(result); + addShapelessRecipe(provider, GTCEu.id(regName.toLowerCase(Locale.ROOT)), result, recipe); + } + + public static void addShapelessRecipe(Consumer provider, @Nonnull ResourceLocation regName, @Nonnull ItemStack result, @Nonnull Object... recipe) { + var builder = new ShapelessRecipeBuilder(regName).output(result); for (Object content : recipe) { if (content instanceof Ingredient ingredient) { builder.requires(ingredient); diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/CraftingRecipeLoader.java b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/CraftingRecipeLoader.java index 542edabe06..3cd4583036 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/CraftingRecipeLoader.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/CraftingRecipeLoader.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.data.recipe.misc; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; import com.gregtechceu.gtceu.api.data.chemical.material.stack.UnificationEntry; import com.gregtechceu.gtceu.api.recipe.FacadeCoverRecipe; @@ -85,8 +86,8 @@ public static void init(Consumer provider) { VanillaRecipeHelper.addShapedRecipe(provider, "blacklight", BLACKLIGHT.asStack(), "SPS", "GRG", "CPK", 'S', new UnificationEntry(screw, TungstenCarbide), 'P', new UnificationEntry(plate, TungstenCarbide), 'G', GTBlocks.CASING_LAMINATED_GLASS.asStack(), 'R', new UnificationEntry(spring, Europium), 'C', CustomTags.IV_CIRCUITS, 'K', new UnificationEntry(cableGtSingle, Platinum)); - VanillaRecipeHelper.addShapedRecipe(provider, true, "filter_casing", GTBlocks.FILTER_CASING.asStack(), "BBB", "III", "MFR", 'B', new ItemStack(Blocks.IRON_BARS), 'I', ITEM_FILTER.asStack(), 'M', ELECTRIC_MOTOR_MV.asStack(), 'F', new UnificationEntry(frameGt, Steel), 'R', new UnificationEntry(rotor, Steel)); - VanillaRecipeHelper.addShapedRecipe(provider, true, "filter_casing_sterile", GTBlocks.FILTER_CASING_STERILE.asStack(), "BEB", "ISI", "MFR", 'B', new UnificationEntry(pipeLargeFluid, Polybenzimidazole), 'E', EMITTER_ZPM.asStack(), 'I', ITEM_FILTER.asStack(), 'S', BLACKLIGHT.asStack(), 'M', ELECTRIC_MOTOR_ZPM.asStack(), 'F', new UnificationEntry(frameGt, Tritanium), 'R', new UnificationEntry(rotor, NaquadahAlloy)); + VanillaRecipeHelper.addShapedRecipe(provider, true, GTCEu.id("filter_casing"), GTBlocks.FILTER_CASING.asStack(), "BBB", "III", "MFR", 'B', new ItemStack(Blocks.IRON_BARS), 'I', ITEM_FILTER.asStack(), 'M', ELECTRIC_MOTOR_MV.asStack(), 'F', new UnificationEntry(frameGt, Steel), 'R', new UnificationEntry(rotor, Steel)); + VanillaRecipeHelper.addShapedRecipe(provider, true, GTCEu.id("filter_casing_sterile"), GTBlocks.FILTER_CASING_STERILE.asStack(), "BEB", "ISI", "MFR", 'B', new UnificationEntry(pipeLargeFluid, Polybenzimidazole), 'E', EMITTER_ZPM.asStack(), 'I', ITEM_FILTER.asStack(), 'S', BLACKLIGHT.asStack(), 'M', ELECTRIC_MOTOR_ZPM.asStack(), 'F', new UnificationEntry(frameGt, Tritanium), 'R', new UnificationEntry(rotor, NaquadahAlloy)); /////////////////////////////////////////////////// // Shapes and Molds // diff --git a/fabric/src/main/java/com/gregtechceu/gtceu/data/fabric/GTRegistriesDatapackGenerator.java b/fabric/src/main/java/com/gregtechceu/gtceu/data/fabric/GTRegistriesDatapackGenerator.java index c9d3a5a4e1..108acf932f 100644 --- a/fabric/src/main/java/com/gregtechceu/gtceu/data/fabric/GTRegistriesDatapackGenerator.java +++ b/fabric/src/main/java/com/gregtechceu/gtceu/data/fabric/GTRegistriesDatapackGenerator.java @@ -32,16 +32,16 @@ public class GTRegistriesDatapackGenerator extends RegistriesDatapackGenerator { private final CompletableFuture registries; private final java.util.function.Predicate namespacePredicate; - private GTRegistriesDatapackGenerator(String name, PackOutput output, CompletableFuture registries) { + private GTRegistriesDatapackGenerator(String name, PackOutput output, CompletableFuture registries, Set modIds) { super(output, registries); this.name = name; - this.namespacePredicate = Set.of(GTCEu.MOD_ID)::contains; + this.namespacePredicate = modIds::contains; this.registries = registries; this.output = output; } - public GTRegistriesDatapackGenerator(PackOutput output, CompletableFuture registries, RegistrySetBuilder builder, String name) { - this(name, output, registries.thenApply(r -> constructRegistries(r, builder))); + public GTRegistriesDatapackGenerator(PackOutput output, CompletableFuture registries, RegistrySetBuilder builder, Set modIds, String name) { + this(name, output, registries.thenApply(r -> constructRegistries(r, builder)), modIds); } /** diff --git a/fabric/src/main/java/com/gregtechceu/gtceu/data/fabric/GregTechDatagen.java b/fabric/src/main/java/com/gregtechceu/gtceu/data/fabric/GregTechDatagen.java index adeb90e1e3..cc44e605f8 100644 --- a/fabric/src/main/java/com/gregtechceu/gtceu/data/fabric/GregTechDatagen.java +++ b/fabric/src/main/java/com/gregtechceu/gtceu/data/fabric/GregTechDatagen.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.data.fabric; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.api.registry.registrate.CompassNode; import com.gregtechceu.gtceu.api.registry.registrate.CompassSection; @@ -11,6 +12,7 @@ import io.github.fabricators_of_create.porting_lib.data.ExistingFileHelper; import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.Util; import net.minecraft.core.HolderLookup; @@ -24,6 +26,7 @@ import net.minecraft.data.worldgen.biome.BiomeData; import net.minecraft.server.packs.PackType; +import java.util.Set; import java.util.concurrent.CompletableFuture; /** @@ -42,22 +45,23 @@ public void onInitializeDataGenerator(FabricDataGenerator generator) { var pack = generator.createPack(); GTRegistries.REGISTRATE.setupDatagen(pack, helper); // sound - pack.addProvider((FabricDataGenerator.Pack.Factory) SoundEntryBuilder.SoundEntryProvider::new); + pack.addProvider((FabricDataOutput output) -> new SoundEntryBuilder.SoundEntryProvider(output, GTCEu.MOD_ID)); // compass pack.addProvider((FabricDataGenerator.Pack.Factory) packOutput -> new CompassSection.CompassSectionProvider(packOutput, rl -> helper.exists(rl, PackType.CLIENT_RESOURCES))); pack.addProvider((FabricDataGenerator.Pack.Factory) packOutput -> new CompassNode.CompassNodeProvider(packOutput, rl -> helper.exists(rl, PackType.CLIENT_RESOURCES))); // biome tags + var set = Set.of(GTCEu.MOD_ID); var registryAccess = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY); var registries = createProvider(registryAccess); pack.addProvider((FabricDataGenerator.Pack.Factory) output -> new BiomeTagsProviderImpl(output, registries)); pack.addProvider((FabricDataGenerator.Pack.Factory) output -> new GTRegistriesDatapackGenerator( output, registries, new RegistrySetBuilder() - .add(Registries.DAMAGE_TYPE, GTDamageTypes::bootstrap), "DamageType Data")); + .add(Registries.DAMAGE_TYPE, GTDamageTypes::bootstrap), set, "DamageType Data")); pack.addProvider((FabricDataGenerator.Pack.Factory) output -> new GTRegistriesDatapackGenerator( output, registries, new RegistrySetBuilder() .add(Registries.CONFIGURED_FEATURE, GTConfiguredFeatures::bootstrap) .add(Registries.PLACED_FEATURE, GTPlacements::bootstrap) - .add(Registries.DENSITY_FUNCTION, GTWorldgen::bootstrapDensityFunctions), "Worldgen Data")); + .add(Registries.DENSITY_FUNCTION, GTWorldgen::bootstrapDensityFunctions), set, "Worldgen Data")); } /** diff --git a/forge/src/main/java/com/gregtechceu/gtceu/data/forge/DataGenerators.java b/forge/src/main/java/com/gregtechceu/gtceu/data/forge/DataGenerators.java index e18a567e3f..79b5549808 100644 --- a/forge/src/main/java/com/gregtechceu/gtceu/data/forge/DataGenerators.java +++ b/forge/src/main/java/com/gregtechceu/gtceu/data/forge/DataGenerators.java @@ -45,7 +45,7 @@ public static void gatherData(GatherDataEvent event) { var registries = createProvider(registryAccess); if (event.includeServer()) { var set = Set.of(GTCEu.MOD_ID); - generator.addProvider(true, new SoundEntryBuilder.SoundEntryProvider(generator.getPackOutput())); + generator.addProvider(true, new SoundEntryBuilder.SoundEntryProvider(generator.getPackOutput(), GTCEu.MOD_ID)); generator.addProvider(true, new CompassSection.CompassSectionProvider(generator.getPackOutput(), rl -> event.getExistingFileHelper().exists(rl, PackType.CLIENT_RESOURCES))); generator.addProvider(true, new CompassNode.CompassNodeProvider(generator.getPackOutput(), rl -> event.getExistingFileHelper().exists(rl, PackType.CLIENT_RESOURCES))); generator.addProvider(true, bindRegistries(BiomeTagsProviderImpl::new, registries)); diff --git a/gradle.properties b/gradle.properties index b1eb95f21a..33f51ff0e4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs = -Xmx6G # Mod Info mod_id = gtceu mod_name = GregTech -mod_version = 1.0.13.b +mod_version = 1.0.13.c mod_description = GregTech CE Unofficial, ported from 1.12.2 mod_license = LGPL-3.0 license mod_url = https://github.com/GregTechCEu/GregTech-Modern/