diff --git a/src/main/java/com/simibubi/create/AllTags.java b/src/main/java/com/simibubi/create/AllTags.java index 3286b6c05..7c1391947 100644 --- a/src/main/java/com/simibubi/create/AllTags.java +++ b/src/main/java/com/simibubi/create/AllTags.java @@ -355,13 +355,12 @@ public class AllTags { } public boolean matches(RecipeSerializer recipeSerializer) { - return Registry.RECIPE_SERIALIZER.getOrCreateTag(tag).contains(ForgeRegistries.RECIPE_SERIALIZERS.getHolder(recipeSerializer).orElseThrow()); + return ForgeRegistries.RECIPE_SERIALIZERS.getHolder(recipeSerializer).orElseThrow().is(tag); } private static void init() {} } - public static void init() { AllBlockTags.init(); AllItemTags.init(); diff --git a/src/main/java/com/simibubi/create/Create.java b/src/main/java/com/simibubi/create/Create.java index 7d83687ef..c5fbec2ba 100644 --- a/src/main/java/com/simibubi/create/Create.java +++ b/src/main/java/com/simibubi/create/Create.java @@ -177,13 +177,13 @@ public class Create { gen.addProvider(AllSoundEvents.provider(gen)); } if (event.includeServer()) { + gen.addProvider(new RecipeSerializerTagGen(gen, event.getExistingFileHelper())); gen.addProvider(new AllAdvancements(gen)); gen.addProvider(new StandardRecipeGen(gen)); gen.addProvider(new MechanicalCraftingRecipeGen(gen)); gen.addProvider(new SequencedAssemblyRecipeGen(gen)); ProcessingRecipeGen.registerAll(gen); // AllOreFeatureConfigEntries.gatherData(event); - gen.addProvider(new RecipeSerializerTagGen(gen, event.getExistingFileHelper())); } } diff --git a/src/main/java/com/simibubi/create/compat/Mods.java b/src/main/java/com/simibubi/create/compat/Mods.java index 36bd60e52..4f7e8a316 100644 --- a/src/main/java/com/simibubi/create/compat/Mods.java +++ b/src/main/java/com/simibubi/create/compat/Mods.java @@ -14,26 +14,40 @@ import net.minecraftforge.registries.ForgeRegistries; * For compatibility with and without another mod present, we have to define load conditions of the specific code */ public enum Mods { - DYNAMICTREES, - TCONSTRUCT, - CURIOS, - COMPUTERCRAFT, + CURIOS, + DYNAMICTREES, + OCCULTISM, STORAGEDRAWERS, + TCONSTRUCT, XLPACKETS; - /** - * @return a boolean of whether the mod is loaded or not based on mod id - */ - public boolean isLoaded() { - return ModList.get().isLoaded(asId()); + private final String id; + + Mods() { + id = Lang.asId(name()); } /** * @return the mod id */ - public String asId() { - return Lang.asId(name()); + public String id() { + return id; + } + + public ResourceLocation rl(String path) { + return new ResourceLocation(id, path); + } + + public Block getBlock(String id) { + return ForgeRegistries.BLOCKS.getValue(rl(id)); + } + + /** + * @return a boolean of whether the mod is loaded or not based on mod id + */ + public boolean isLoaded() { + return ModList.get().isLoaded(id); } /** @@ -56,8 +70,4 @@ public enum Mods { toExecute.get().run(); } } - - public Block getBlock(String id) { - return ForgeRegistries.BLOCKS.getValue(new ResourceLocation(asId(), id)); - } } diff --git a/src/main/java/com/simibubi/create/compat/storageDrawers/StorageDrawers.java b/src/main/java/com/simibubi/create/compat/storageDrawers/StorageDrawers.java index f671c259a..854decc6d 100644 --- a/src/main/java/com/simibubi/create/compat/storageDrawers/StorageDrawers.java +++ b/src/main/java/com/simibubi/create/compat/storageDrawers/StorageDrawers.java @@ -10,7 +10,7 @@ import net.minecraftforge.items.IItemHandler; public class StorageDrawers { public static boolean isDrawer(BlockEntity be) { - return be != null && Mods.STORAGEDRAWERS.asId() + return be != null && Mods.STORAGEDRAWERS.id() .equals(be.getType() .getRegistryName() .getNamespace()); diff --git a/src/main/java/com/simibubi/create/content/redstone/displayLink/AllDisplayBehaviours.java b/src/main/java/com/simibubi/create/content/redstone/displayLink/AllDisplayBehaviours.java index 31b58f671..efb481a8f 100644 --- a/src/main/java/com/simibubi/create/content/redstone/displayLink/AllDisplayBehaviours.java +++ b/src/main/java/com/simibubi/create/content/redstone/displayLink/AllDisplayBehaviours.java @@ -237,10 +237,10 @@ public class AllDisplayBehaviours { Mods.COMPUTERCRAFT.executeIfInstalled(() -> () -> { DisplayBehaviour computerDisplaySource = register(Create.asResource("computer_display_source"), new ComputerDisplaySource()); - assignBlockEntity(computerDisplaySource, new ResourceLocation(Mods.COMPUTERCRAFT.asId(), "wired_modem_full")); - assignBlockEntity(computerDisplaySource, new ResourceLocation(Mods.COMPUTERCRAFT.asId(), "computer_normal")); - assignBlockEntity(computerDisplaySource, new ResourceLocation(Mods.COMPUTERCRAFT.asId(), "computer_advanced")); - assignBlockEntity(computerDisplaySource, new ResourceLocation(Mods.COMPUTERCRAFT.asId(), "computer_command")); + assignBlockEntity(computerDisplaySource, Mods.COMPUTERCRAFT.rl("wired_modem_full")); + assignBlockEntity(computerDisplaySource, Mods.COMPUTERCRAFT.rl("computer_normal")); + assignBlockEntity(computerDisplaySource, Mods.COMPUTERCRAFT.rl("computer_advanced")); + assignBlockEntity(computerDisplaySource, Mods.COMPUTERCRAFT.rl("computer_command")); }); } } diff --git a/src/main/java/com/simibubi/create/foundation/data/RecipeSerializerTagGen.java b/src/main/java/com/simibubi/create/foundation/data/RecipeSerializerTagGen.java index e97042957..15e8328eb 100644 --- a/src/main/java/com/simibubi/create/foundation/data/RecipeSerializerTagGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/RecipeSerializerTagGen.java @@ -2,30 +2,30 @@ package com.simibubi.create.foundation.data; import org.jetbrains.annotations.Nullable; -import com.simibubi.create.AllTags; +import com.simibubi.create.AllTags.AllRecipeSerializerTags; import com.simibubi.create.Create; +import com.simibubi.create.compat.Mods; import net.minecraft.core.Registry; import net.minecraft.data.DataGenerator; import net.minecraft.data.tags.TagsProvider; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraftforge.common.data.ExistingFileHelper; public class RecipeSerializerTagGen extends TagsProvider> { - public RecipeSerializerTagGen(DataGenerator pGenerator, @Nullable ExistingFileHelper existingFileHelper) { - super(pGenerator, Registry.RECIPE_SERIALIZER, Create.ID, existingFileHelper); + public RecipeSerializerTagGen(DataGenerator generator, @Nullable ExistingFileHelper existingFileHelper) { + super(generator, Registry.RECIPE_SERIALIZER, Create.ID, existingFileHelper); } @Override public String getName() { - return "Create Recipe Serializer Tags"; + return "Create's Recipe Serializer Tags"; } @Override protected void addTags() { - this.tag(AllTags.AllRecipeSerializerTags.AUTOMATION_IGNORE.tag) - .addOptional(new ResourceLocation("occultism", "spirit_trade")) - .addOptional(new ResourceLocation("occultism", "ritual")); + this.tag(AllRecipeSerializerTags.AUTOMATION_IGNORE.tag) + .addOptional(Mods.OCCULTISM.rl("spirit_trade")) + .addOptional(Mods.OCCULTISM.rl("ritual")); } } diff --git a/src/main/java/com/simibubi/create/infrastructure/ponder/AllPonderTags.java b/src/main/java/com/simibubi/create/infrastructure/ponder/AllPonderTags.java index ed99bdc0c..929dde7bf 100644 --- a/src/main/java/com/simibubi/create/infrastructure/ponder/AllPonderTags.java +++ b/src/main/java/com/simibubi/create/infrastructure/ponder/AllPonderTags.java @@ -7,7 +7,6 @@ import com.simibubi.create.compat.Mods; import com.simibubi.create.foundation.ponder.PonderRegistry; import com.simibubi.create.foundation.ponder.PonderTag; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Block; @@ -314,7 +313,7 @@ public class AllPonderTags { .add(Blocks.TARGET); Mods.COMPUTERCRAFT.executeIfInstalled(() -> () -> { - Block computer = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(Mods.COMPUTERCRAFT.asId(), "computer_advanced")); + Block computer = ForgeRegistries.BLOCKS.getValue(Mods.COMPUTERCRAFT.rl("computer_advanced")); if (computer != null) PonderRegistry.TAGS.forTag(DISPLAY_SOURCES).add(computer); });