From 9cc8430c9985a5111cc3da0ae074ac69fa3bd60c Mon Sep 17 00:00:00 2001 From: Sara Freimer Date: Sun, 25 Aug 2024 10:32:49 -0500 Subject: [PATCH] Restructure how we define aliases in preparation of JEI's upcoming ability to define aliases --- .../aliases/AdditionsAliasMapping.java | 16 ++ .../aliases}/AdditionsAliases.java | 4 +- .../client/AdditionsLangProvider.java | 2 +- .../emi/AdditionsEmiAliasProvider.java | 26 -- .../common/AdditionsDataGenerator.java | 4 +- .../client/GeneratorsLangProvider.java | 2 +- .../emi/GeneratorsEmiAliasProvider.java | 83 ------ .../common/GeneratorsDataGenerator.java | 4 +- ...iasProvider.java => EmiAliasProvider.java} | 81 +++--- .../client/lang/BaseLanguageProvider.java | 2 +- .../client/lang/MekanismLangProvider.java | 2 +- .../PersistingDisabledProvidersProvider.java | 16 +- .../tools/client/ToolsLangProvider.java | 2 +- .../emi/ToolsEmiAliasProvider.java | 47 ---- .../tools/common/ToolsDataGenerator.java | 4 +- .../alias/GeneratorsAliasMapping.java | 69 +++++ .../alias}/GeneratorsAliases.java | 4 +- .../recipe_viewer/alias/IAliasMapping.java | 6 + .../alias}/IAliasedTranslation.java | 2 +- .../alias/MekanismAliasMapping.java} | 248 +++++++++--------- .../recipe_viewer/alias}/MekanismAliases.java | 2 +- .../recipe_viewer/alias/RVAliasHelper.java | 99 +++++++ .../common/tile/TileEntityFluidTank.java | 2 + .../aliases/ToolsAliasMapping.java | 39 +++ .../recipe_viewer/aliases}/ToolsAliases.java | 4 +- .../{ => recipe_viewer}/jei/ToolsJEI.java | 2 +- 26 files changed, 419 insertions(+), 353 deletions(-) create mode 100644 src/additions/java/mekanism/additions/client/recipe_viewer/aliases/AdditionsAliasMapping.java rename src/{datagen/additions/java/mekanism/additions/client/integration => additions/java/mekanism/additions/client/recipe_viewer/aliases}/AdditionsAliases.java (86%) delete mode 100644 src/datagen/additions/java/mekanism/additions/client/integration/emi/AdditionsEmiAliasProvider.java delete mode 100644 src/datagen/generators/java/mekanism/generators/client/integration/emi/GeneratorsEmiAliasProvider.java rename src/datagen/main/java/mekanism/client/integration/emi/{BaseEmiAliasProvider.java => EmiAliasProvider.java} (74%) delete mode 100644 src/datagen/tools/java/mekanism/tools/client/integration/emi/ToolsEmiAliasProvider.java create mode 100644 src/generators/java/mekanism/generators/client/recipe_viewer/alias/GeneratorsAliasMapping.java rename src/{datagen/generators/java/mekanism/generators/client/integration => generators/java/mekanism/generators/client/recipe_viewer/alias}/GeneratorsAliases.java (89%) create mode 100644 src/main/java/mekanism/client/recipe_viewer/alias/IAliasMapping.java rename src/{datagen/main/java/mekanism/client/integration => main/java/mekanism/client/recipe_viewer/alias}/IAliasedTranslation.java (75%) rename src/{datagen/main/java/mekanism/client/integration/emi/MekanismEmiAliasProvider.java => main/java/mekanism/client/recipe_viewer/alias/MekanismAliasMapping.java} (54%) rename src/{datagen/main/java/mekanism/client/integration => main/java/mekanism/client/recipe_viewer/alias}/MekanismAliases.java (99%) create mode 100644 src/main/java/mekanism/client/recipe_viewer/alias/RVAliasHelper.java create mode 100644 src/tools/java/mekanism/tools/client/recipe_viewer/aliases/ToolsAliasMapping.java rename src/{datagen/tools/java/mekanism/tools/client/integration => tools/java/mekanism/tools/client/recipe_viewer/aliases}/ToolsAliases.java (83%) rename src/tools/java/mekanism/tools/client/{ => recipe_viewer}/jei/ToolsJEI.java (97%) diff --git a/src/additions/java/mekanism/additions/client/recipe_viewer/aliases/AdditionsAliasMapping.java b/src/additions/java/mekanism/additions/client/recipe_viewer/aliases/AdditionsAliasMapping.java new file mode 100644 index 00000000000..ed37512e29d --- /dev/null +++ b/src/additions/java/mekanism/additions/client/recipe_viewer/aliases/AdditionsAliasMapping.java @@ -0,0 +1,16 @@ +package mekanism.additions.client.recipe_viewer.aliases; + +import mekanism.additions.common.registries.AdditionsBlocks; +import mekanism.additions.common.registries.AdditionsItems; +import mekanism.client.recipe_viewer.alias.IAliasMapping; +import mekanism.client.recipe_viewer.alias.RVAliasHelper; + +public class AdditionsAliasMapping implements IAliasMapping { + + @Override + public void addAliases(RVAliasHelper rv) { + rv.addAliases(AdditionsItems.WALKIE_TALKIE, AdditionsAliases.WALKIE_TALKIE_RADIO); + rv.addAliases(AdditionsBlocks.GLOW_PANELS.values(), AdditionsAliases.GLOW_PANEL_LIGHT_SOURCE); + rv.addAliases(AdditionsBlocks.PLASTIC_ROADS.values(), AdditionsAliases.PLASTIC_ROAD_PATH); + } +} \ No newline at end of file diff --git a/src/datagen/additions/java/mekanism/additions/client/integration/AdditionsAliases.java b/src/additions/java/mekanism/additions/client/recipe_viewer/aliases/AdditionsAliases.java similarity index 86% rename from src/datagen/additions/java/mekanism/additions/client/integration/AdditionsAliases.java rename to src/additions/java/mekanism/additions/client/recipe_viewer/aliases/AdditionsAliases.java index 9f12a52b5c8..ed98bfe1204 100644 --- a/src/datagen/additions/java/mekanism/additions/client/integration/AdditionsAliases.java +++ b/src/additions/java/mekanism/additions/client/recipe_viewer/aliases/AdditionsAliases.java @@ -1,8 +1,8 @@ -package mekanism.additions.client.integration; +package mekanism.additions.client.recipe_viewer.aliases; import mekanism.additions.common.MekanismAdditions; import mekanism.api.annotations.NothingNullByDefault; -import mekanism.client.integration.IAliasedTranslation; +import mekanism.client.recipe_viewer.alias.IAliasedTranslation; import net.minecraft.Util; @NothingNullByDefault diff --git a/src/datagen/additions/java/mekanism/additions/client/AdditionsLangProvider.java b/src/datagen/additions/java/mekanism/additions/client/AdditionsLangProvider.java index 6fcdd104651..9b85a9de7d0 100644 --- a/src/datagen/additions/java/mekanism/additions/client/AdditionsLangProvider.java +++ b/src/datagen/additions/java/mekanism/additions/client/AdditionsLangProvider.java @@ -1,7 +1,7 @@ package mekanism.additions.client; import java.util.Map; -import mekanism.additions.client.integration.AdditionsAliases; +import mekanism.additions.client.recipe_viewer.aliases.AdditionsAliases; import mekanism.additions.common.AdditionsLang; import mekanism.additions.common.AdditionsTags; import mekanism.additions.common.MekanismAdditions; diff --git a/src/datagen/additions/java/mekanism/additions/client/integration/emi/AdditionsEmiAliasProvider.java b/src/datagen/additions/java/mekanism/additions/client/integration/emi/AdditionsEmiAliasProvider.java deleted file mode 100644 index 1f963e66ab9..00000000000 --- a/src/datagen/additions/java/mekanism/additions/client/integration/emi/AdditionsEmiAliasProvider.java +++ /dev/null @@ -1,26 +0,0 @@ -package mekanism.additions.client.integration.emi; - -import java.util.concurrent.CompletableFuture; -import mekanism.additions.client.integration.AdditionsAliases; -import mekanism.additions.common.MekanismAdditions; -import mekanism.additions.common.registries.AdditionsBlocks; -import mekanism.additions.common.registries.AdditionsItems; -import mekanism.api.annotations.NothingNullByDefault; -import mekanism.client.integration.emi.BaseEmiAliasProvider; -import net.minecraft.core.HolderLookup; -import net.minecraft.data.PackOutput; - -@NothingNullByDefault -public class AdditionsEmiAliasProvider extends BaseEmiAliasProvider { - - public AdditionsEmiAliasProvider(PackOutput output, CompletableFuture registries) { - super(output, registries, MekanismAdditions.MODID); - } - - @Override - protected void addAliases(HolderLookup.Provider lookupProvider) { - addAliases(AdditionsItems.WALKIE_TALKIE, AdditionsAliases.WALKIE_TALKIE_RADIO); - addAliases(AdditionsBlocks.GLOW_PANELS.values(), AdditionsAliases.GLOW_PANEL_LIGHT_SOURCE); - addAliases(AdditionsBlocks.PLASTIC_ROADS.values(), AdditionsAliases.PLASTIC_ROAD_PATH); - } -} \ No newline at end of file diff --git a/src/datagen/additions/java/mekanism/additions/common/AdditionsDataGenerator.java b/src/datagen/additions/java/mekanism/additions/common/AdditionsDataGenerator.java index 6767f326ca1..748266508d4 100644 --- a/src/datagen/additions/java/mekanism/additions/common/AdditionsDataGenerator.java +++ b/src/datagen/additions/java/mekanism/additions/common/AdditionsDataGenerator.java @@ -6,8 +6,8 @@ import mekanism.additions.client.AdditionsLangProvider; import mekanism.additions.client.AdditionsSoundProvider; import mekanism.additions.client.AdditionsSpriteSourceProvider; -import mekanism.additions.client.integration.emi.AdditionsEmiAliasProvider; import mekanism.additions.client.integration.emi.AdditionsEmiDefaults; +import mekanism.additions.client.recipe_viewer.aliases.AdditionsAliasMapping; import mekanism.additions.common.loot.AdditionsLootProvider; import mekanism.additions.common.recipe.AdditionsRecipeProvider; import mekanism.common.BasePackMetadataGenerator; @@ -51,7 +51,7 @@ public static void gatherData(GatherDataEvent event) { gen.addProvider(event.includeServer(), new AdditionsAdvancementProvider(output, lookupProvider, existingFileHelper)); //Data generator to help with persisting data when porting across MC versions when optional deps aren't updated yet // DO NOT ADD OTHERS AFTER THIS ONE - PersistingDisabledProvidersProvider.addDisabledEmiProvider(event, lookupProvider, MekanismAdditions.MODID, () -> AdditionsEmiAliasProvider::new, + PersistingDisabledProvidersProvider.addDisabledEmiProvider(event, lookupProvider, MekanismAdditions.MODID, AdditionsAliasMapping::new, () -> AdditionsEmiDefaults::new); } } \ No newline at end of file diff --git a/src/datagen/generators/java/mekanism/generators/client/GeneratorsLangProvider.java b/src/datagen/generators/java/mekanism/generators/client/GeneratorsLangProvider.java index 82bcb22dba0..c7b6d671722 100644 --- a/src/datagen/generators/java/mekanism/generators/client/GeneratorsLangProvider.java +++ b/src/datagen/generators/java/mekanism/generators/client/GeneratorsLangProvider.java @@ -1,7 +1,7 @@ package mekanism.generators.client; import mekanism.client.lang.BaseLanguageProvider; -import mekanism.generators.client.integration.GeneratorsAliases; +import mekanism.generators.client.recipe_viewer.alias.GeneratorsAliases; import mekanism.generators.common.GeneratorTags; import mekanism.generators.common.GeneratorsLang; import mekanism.generators.common.MekanismGenerators; diff --git a/src/datagen/generators/java/mekanism/generators/client/integration/emi/GeneratorsEmiAliasProvider.java b/src/datagen/generators/java/mekanism/generators/client/integration/emi/GeneratorsEmiAliasProvider.java deleted file mode 100644 index cea51e9d55b..00000000000 --- a/src/datagen/generators/java/mekanism/generators/client/integration/emi/GeneratorsEmiAliasProvider.java +++ /dev/null @@ -1,83 +0,0 @@ -package mekanism.generators.client.integration.emi; - -import dev.emi.emi.api.stack.EmiStack; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import mekanism.api.annotations.NothingNullByDefault; -import mekanism.client.integration.MekanismAliases; -import mekanism.client.integration.emi.BaseEmiAliasProvider; -import mekanism.common.registries.MekanismBlocks; -import mekanism.common.util.ChemicalUtil; -import mekanism.generators.client.integration.GeneratorsAliases; -import mekanism.generators.common.MekanismGenerators; -import mekanism.generators.common.registries.GeneratorsBlocks; -import mekanism.generators.common.registries.GeneratorsChemicals; -import mekanism.generators.common.registries.GeneratorsFluids; -import mekanism.generators.common.registries.GeneratorsItems; -import net.minecraft.core.HolderLookup; -import net.minecraft.data.PackOutput; - -@NothingNullByDefault -public class GeneratorsEmiAliasProvider extends BaseEmiAliasProvider { - - public GeneratorsEmiAliasProvider(PackOutput output, CompletableFuture registries) { - super(output, registries, MekanismGenerators.MODID); - } - - @Override - protected void addAliases(HolderLookup.Provider lookupProvider) { - addChemicalAliases(); - addMultiblockAliases(); - addAliases(GeneratorsBlocks.GAS_BURNING_GENERATOR, GeneratorsAliases.GBG_ETHENE, GeneratorsAliases.GBG_ETHYLENE); - addModuleAliases(GeneratorsItems.ITEMS); - } - - private void addChemicalAliases() { - addAliases(List.of( - ingredient(GeneratorsFluids.FUSION_FUEL), - ingredient(GeneratorsChemicals.FUSION_FUEL) - ), GeneratorsAliases.FUSION_FUEL); - } - - private void addMultiblockAliases() { - addAliases(GeneratorsBlocks.REACTOR_GLASS, - MekanismAliases.BOILER_COMPONENT, - MekanismAliases.EVAPORATION_COMPONENT, - MekanismAliases.MATRIX_COMPONENT, - MekanismAliases.SPS_COMPONENT, - MekanismAliases.SPS_FULL_COMPONENT, - MekanismAliases.TANK_COMPONENT - ); - addAliases(GeneratorsBlocks.ADVANCED_SOLAR_GENERATOR, MekanismAliases.EVAPORATION_COMPONENT); - addAlias(GeneratorsAliases.FISSION_COMPONENT, - GeneratorsBlocks.FISSION_REACTOR_CASING, - GeneratorsBlocks.FISSION_REACTOR_PORT, - GeneratorsBlocks.FISSION_REACTOR_LOGIC_ADAPTER, - GeneratorsBlocks.FISSION_FUEL_ASSEMBLY, - GeneratorsBlocks.CONTROL_ROD_ASSEMBLY, - GeneratorsBlocks.REACTOR_GLASS - ); - addAliases(List.of( - EmiStack.of(GeneratorsBlocks.FUSION_REACTOR_CONTROLLER), - EmiStack.of(GeneratorsBlocks.FUSION_REACTOR_FRAME), - EmiStack.of(GeneratorsBlocks.FUSION_REACTOR_PORT), - EmiStack.of(GeneratorsBlocks.FUSION_REACTOR_LOGIC_ADAPTER), - EmiStack.of(GeneratorsBlocks.LASER_FOCUS_MATRIX), - EmiStack.of(GeneratorsBlocks.REACTOR_GLASS), - EmiStack.of(ChemicalUtil.getFilledVariant(GeneratorsItems.HOHLRAUM, GeneratorsChemicals.FUSION_FUEL)) - ), GeneratorsAliases.FUSION_COMPONENT); - addAlias(GeneratorsAliases.TURBINE_COMPONENT, - GeneratorsBlocks.TURBINE_CASING, - GeneratorsBlocks.TURBINE_VENT, - GeneratorsBlocks.TURBINE_VALVE, - GeneratorsBlocks.TURBINE_ROTOR, - GeneratorsItems.TURBINE_BLADE, - GeneratorsBlocks.SATURATING_CONDENSER, - GeneratorsBlocks.ELECTROMAGNETIC_COIL, - GeneratorsBlocks.ROTATIONAL_COMPLEX, - GeneratorsBlocks.REACTOR_GLASS, - MekanismBlocks.PRESSURE_DISPERSER, - MekanismBlocks.STRUCTURAL_GLASS - ); - } -} \ No newline at end of file diff --git a/src/datagen/generators/java/mekanism/generators/common/GeneratorsDataGenerator.java b/src/datagen/generators/java/mekanism/generators/common/GeneratorsDataGenerator.java index 0d5864685be..6379d1f6470 100644 --- a/src/datagen/generators/java/mekanism/generators/common/GeneratorsDataGenerator.java +++ b/src/datagen/generators/java/mekanism/generators/common/GeneratorsDataGenerator.java @@ -9,8 +9,8 @@ import mekanism.generators.client.GeneratorsLangProvider; import mekanism.generators.client.GeneratorsSoundProvider; import mekanism.generators.client.GeneratorsSpriteSourceProvider; -import mekanism.generators.client.integration.emi.GeneratorsEmiAliasProvider; import mekanism.generators.client.integration.emi.GeneratorsEmiDefaults; +import mekanism.generators.client.recipe_viewer.alias.GeneratorsAliasMapping; import mekanism.generators.common.loot.GeneratorsLootProvider; import net.minecraft.core.HolderLookup; import net.minecraft.data.DataGenerator; @@ -47,7 +47,7 @@ public static void gatherData(GatherDataEvent event) { gen.addProvider(event.includeServer(), new GeneratorsAdvancementProvider(output, lookupProvider, existingFileHelper)); //Data generator to help with persisting data when porting across MC versions when optional deps aren't updated yet // DO NOT ADD OTHERS AFTER THIS ONE - PersistingDisabledProvidersProvider.addDisabledEmiProvider(event, lookupProvider, MekanismGenerators.MODID, () -> GeneratorsEmiAliasProvider::new, + PersistingDisabledProvidersProvider.addDisabledEmiProvider(event, lookupProvider, MekanismGenerators.MODID, GeneratorsAliasMapping::new, () -> GeneratorsEmiDefaults::new); } } \ No newline at end of file diff --git a/src/datagen/main/java/mekanism/client/integration/emi/BaseEmiAliasProvider.java b/src/datagen/main/java/mekanism/client/integration/emi/EmiAliasProvider.java similarity index 74% rename from src/datagen/main/java/mekanism/client/integration/emi/BaseEmiAliasProvider.java rename to src/datagen/main/java/mekanism/client/integration/emi/EmiAliasProvider.java index c03dca9559d..d89584ca8f1 100644 --- a/src/datagen/main/java/mekanism/client/integration/emi/BaseEmiAliasProvider.java +++ b/src/datagen/main/java/mekanism/client/integration/emi/EmiAliasProvider.java @@ -8,6 +8,7 @@ import com.mojang.serialization.JsonOps; import com.mojang.serialization.codecs.RecordCodecBuilder; import dev.emi.emi.api.EmiInitRegistry; +import dev.emi.emi.api.neoforge.NeoForgeEmiStack; import dev.emi.emi.api.stack.EmiIngredient; import dev.emi.emi.api.stack.EmiStack; import dev.emi.emi.api.stack.serializer.EmiIngredientSerializer; @@ -16,23 +17,22 @@ import dev.emi.emi.registry.EmiPluginContainer; import java.nio.file.Path; import java.util.Arrays; -import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.function.Function; +import java.util.function.Supplier; import mekanism.api.SerializationConstants; import mekanism.api.annotations.NothingNullByDefault; -import mekanism.api.gear.IModuleHelper; import mekanism.api.providers.IChemicalProvider; import mekanism.api.providers.IFluidProvider; import mekanism.api.text.IHasTranslationKey; +import mekanism.client.recipe_viewer.alias.IAliasMapping; +import mekanism.client.recipe_viewer.alias.RVAliasHelper; import mekanism.client.recipe_viewer.emi.ChemicalEmiStack; import mekanism.common.DataGenSerializationConstants; -import mekanism.common.content.gear.IModuleItem; import mekanism.common.integration.MekanismHooks; import mekanism.common.lib.collection.HashList; -import mekanism.common.registration.impl.ItemDeferredRegister; import net.minecraft.core.HolderLookup; import net.minecraft.data.CachedOutput; import net.minecraft.data.DataProvider; @@ -41,12 +41,12 @@ import net.minecraft.data.PackOutput.Target; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.ExtraCodecs; -import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.ItemLike; -import net.neoforged.neoforge.registries.DeferredHolder; +import net.neoforged.neoforge.fluids.FluidStack; @NothingNullByDefault -public abstract class BaseEmiAliasProvider implements DataProvider { +public class EmiAliasProvider implements DataProvider, RVAliasHelper { private static boolean emiSerializersInitialized; @@ -65,55 +65,74 @@ private static void bootstrapEmi() { private final CompletableFuture registries; private final HashList data = new HashList<>(); + private final Supplier mappings; private final PathProvider pathProvider; private final String modid; - protected BaseEmiAliasProvider(PackOutput output, CompletableFuture registries, String modid) { + public EmiAliasProvider(PackOutput output, CompletableFuture registries, String modid, Supplier mappings) { this.pathProvider = output.createPathProvider(Target.RESOURCE_PACK, "aliases"); this.registries = registries; this.modid = modid; + this.mappings = mappings; } @Override public final CompletableFuture run(CachedOutput cachedOutput) { bootstrapEmi(); return this.registries.thenCompose(lookupProvider -> { - addAliases(lookupProvider); + IAliasMapping mapping = mappings.get(); + mapping.addAliases(this); Path path = pathProvider.json(ResourceLocation.fromNamespaceAndPath(MekanismHooks.EMI_MOD_ID, modid)); return DataProvider.saveStable(cachedOutput, lookupProvider, AliasInfo.LIST_CODEC, data.elements(), path); }); } - protected EmiIngredient ingredient(IFluidProvider fluidProvider) { + @Override + public EmiIngredient ingredient(ItemLike itemLike) { + return EmiStack.of(itemLike); + } + + @Override + public EmiIngredient ingredient(ItemStack item) { + return EmiStack.of(item); + } + + @Override + public EmiIngredient ingredient(IFluidProvider fluidProvider) { return EmiStack.of(fluidProvider.getFluid(), 1); } - protected EmiIngredient ingredient(IChemicalProvider chemicalProvider) { - return ChemicalEmiStack.create(chemicalProvider, 1); + @Override + public EmiIngredient ingredient(FluidStack fluid) { + return NeoForgeEmiStack.of(fluid); } - protected abstract void addAliases(HolderLookup.Provider lookupProvider); + @Override + public EmiIngredient ingredient(IChemicalProvider chemicalProvider) { + return ChemicalEmiStack.create(chemicalProvider, 1); + } - protected void addAlias(IHasTranslationKey alias, ItemLike... items) { - if (items.length == 0) { - throw new IllegalArgumentException("Expected to have at least one item"); - } - addAliases(Arrays.stream(items).map(EmiStack::of).toList(), alias); + @Override + public void addAliases(IFluidProvider fluidProvider, IChemicalProvider chemicalProvider, IHasTranslationKey... aliases) { + addAliases(List.of(ingredient(fluidProvider), ingredient(chemicalProvider)), aliases); } - protected void addAliases(ItemLike item, IHasTranslationKey... aliases) { - addAliases(EmiStack.of(item), aliases); + @Override + public void addItemAliases(List stacks, IHasTranslationKey... aliases) { + addAliases(stacks, aliases); } - protected void addAliases(Collection stacks, IHasTranslationKey... aliases) { - addAliases(stacks.stream().map(EmiStack::of).toList(), aliases); + @Override + public void addFluidAliases(List stacks, IHasTranslationKey... aliases) { + addAliases(stacks, aliases); } - protected void addAliases(EmiIngredient stack, IHasTranslationKey... aliases) { - addAliases(List.of(stack), aliases); + @Override + public void addChemicalAliases(List stacks, IHasTranslationKey... aliases) { + addAliases(stacks, aliases); } - protected void addAliases(List stacks, IHasTranslationKey... aliases) { + private void addAliases(List stacks, IHasTranslationKey... aliases) { if (aliases.length == 0) { throw new IllegalArgumentException("Expected to have at least one alias"); } @@ -130,18 +149,6 @@ protected void addAliases(List stacks, IHasTranslationKey... alia } } - protected void addModuleAliases(ItemDeferredRegister items) { - for (DeferredHolder entry : items.getEntries()) { - if (entry.get() instanceof IModuleItem module) { - addAliases(entry.get(), IModuleHelper.INSTANCE.getSupported(module.getModuleData()) - .stream() - .map(item -> (IHasTranslationKey) item::getDescriptionId) - .toArray(IHasTranslationKey[]::new) - ); - } - } - } - @Override public String getName() { return "EMI Alias Provider: " + modid; diff --git a/src/datagen/main/java/mekanism/client/lang/BaseLanguageProvider.java b/src/datagen/main/java/mekanism/client/lang/BaseLanguageProvider.java index cdd03a7369b..e3b70e10ff8 100644 --- a/src/datagen/main/java/mekanism/client/lang/BaseLanguageProvider.java +++ b/src/datagen/main/java/mekanism/client/lang/BaseLanguageProvider.java @@ -8,7 +8,7 @@ import mekanism.api.providers.IBlockProvider; import mekanism.api.providers.IModuleDataProvider; import mekanism.api.text.IHasTranslationKey; -import mekanism.client.integration.IAliasedTranslation; +import mekanism.client.recipe_viewer.alias.IAliasedTranslation; import mekanism.client.lang.FormatSplitter.Component; import mekanism.common.Mekanism; import mekanism.common.advancements.MekanismAdvancement; diff --git a/src/datagen/main/java/mekanism/client/lang/MekanismLangProvider.java b/src/datagen/main/java/mekanism/client/lang/MekanismLangProvider.java index a9e671cb0f0..0abd428c26f 100644 --- a/src/datagen/main/java/mekanism/client/lang/MekanismLangProvider.java +++ b/src/datagen/main/java/mekanism/client/lang/MekanismLangProvider.java @@ -11,7 +11,7 @@ import mekanism.api.robit.RobitSkin; import mekanism.api.text.APILang; import mekanism.api.text.EnumColor; -import mekanism.client.integration.MekanismAliases; +import mekanism.client.recipe_viewer.alias.MekanismAliases; import mekanism.common.Mekanism; import mekanism.common.MekanismLang; import mekanism.common.advancements.MekanismAdvancements; diff --git a/src/datagen/main/java/mekanism/common/PersistingDisabledProvidersProvider.java b/src/datagen/main/java/mekanism/common/PersistingDisabledProvidersProvider.java index 78238332b14..f8b739dcd76 100644 --- a/src/datagen/main/java/mekanism/common/PersistingDisabledProvidersProvider.java +++ b/src/datagen/main/java/mekanism/common/PersistingDisabledProvidersProvider.java @@ -16,8 +16,10 @@ import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; import java.util.stream.Collectors; -import mekanism.client.integration.emi.MekanismEmiAliasProvider; +import mekanism.client.integration.emi.EmiAliasProvider; import mekanism.client.integration.emi.MekanismEmiDefaults; +import mekanism.client.recipe_viewer.alias.IAliasMapping; +import mekanism.client.recipe_viewer.alias.MekanismAliasMapping; import mekanism.common.integration.MekanismHooks; import mekanism.common.integration.crafttweaker.MekanismCrTExampleProvider; import mekanism.common.integration.projecte.MekanismCustomConversions; @@ -54,7 +56,7 @@ public static void addDisableableProviders(GatherDataEvent event, CompletableFut Set pathsToSkip = new HashSet<>(); List fakeProviders = new ArrayList<>(); if (modList.isLoaded(MekanismHooks.EMI_MOD_ID)) { - gen.addProvider(event.includeClient(), new MekanismEmiAliasProvider(output, lookupProvider)); + gen.addProvider(event.includeClient(), new EmiAliasProvider(output, lookupProvider, Mekanism.MODID, MekanismAliasMapping::new)); gen.addProvider(event.includeClient(), new MekanismEmiDefaults(output, existingFileHelper, lookupProvider)); } else { pathsToSkip.add("emi/aliases"); @@ -81,14 +83,14 @@ public static void addDisableableProviders(GatherDataEvent event, CompletableFut } public static void addDisabledEmiProvider(GatherDataEvent event, CompletableFuture lookupProvider, String modid, - Supplier aliasProviderFunction, Supplier defaultsProviderFunction) { + Supplier mappings, Supplier defaultsProviderFunction) { DataGenerator gen = event.getGenerator(); PackOutput output = gen.getPackOutput(); ModList modList = ModList.get(); Set pathsToSkip = new HashSet<>(); List fakeProviders = new ArrayList<>(); if (modList.isLoaded(MekanismHooks.EMI_MOD_ID)) { - gen.addProvider(event.includeClient(), aliasProviderFunction.get().create(output, lookupProvider)); + gen.addProvider(event.includeClient(), new EmiAliasProvider(output, lookupProvider, modid, mappings)); gen.addProvider(event.includeClient(), defaultsProviderFunction.get().create(output, event.getExistingFileHelper(), lookupProvider)); } else { pathsToSkip.add("emi/aliases"); @@ -200,12 +202,6 @@ private static Path getProviderCachePath(Path cacheDir, String providerName) { return cacheDir.resolve(Hashing.sha1().hashString(providerName, StandardCharsets.UTF_8).toString()); } - @FunctionalInterface - public interface SimpleProvider { - - DataProvider create(PackOutput packOutput, CompletableFuture registries); - } - @FunctionalInterface public interface ExistingFileProvider { diff --git a/src/datagen/tools/java/mekanism/tools/client/ToolsLangProvider.java b/src/datagen/tools/java/mekanism/tools/client/ToolsLangProvider.java index 64edb3fd5d1..c6047c98424 100644 --- a/src/datagen/tools/java/mekanism/tools/client/ToolsLangProvider.java +++ b/src/datagen/tools/java/mekanism/tools/client/ToolsLangProvider.java @@ -4,7 +4,7 @@ import mekanism.api.text.EnumColor; import mekanism.client.lang.BaseLanguageProvider; import mekanism.common.util.EnumUtils; -import mekanism.tools.client.integration.ToolsAliases; +import mekanism.tools.client.recipe_viewer.aliases.ToolsAliases; import mekanism.tools.common.MekanismTools; import mekanism.tools.common.ToolsLang; import mekanism.tools.common.ToolsTags; diff --git a/src/datagen/tools/java/mekanism/tools/client/integration/emi/ToolsEmiAliasProvider.java b/src/datagen/tools/java/mekanism/tools/client/integration/emi/ToolsEmiAliasProvider.java deleted file mode 100644 index 5f2850788d1..00000000000 --- a/src/datagen/tools/java/mekanism/tools/client/integration/emi/ToolsEmiAliasProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -package mekanism.tools.client.integration.emi; - -import java.util.concurrent.CompletableFuture; -import mekanism.api.annotations.NothingNullByDefault; -import mekanism.api.text.IHasTranslationKey; -import mekanism.client.integration.MekanismAliases; -import mekanism.client.integration.emi.BaseEmiAliasProvider; -import mekanism.tools.common.MekanismTools; -import mekanism.tools.common.registries.ToolsItems; -import net.minecraft.core.HolderLookup; -import net.minecraft.data.PackOutput; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.Items; -import net.minecraft.world.level.ItemLike; - -@NothingNullByDefault -public class ToolsEmiAliasProvider extends BaseEmiAliasProvider { - - public ToolsEmiAliasProvider(PackOutput output, CompletableFuture registries) { - super(output, registries, MekanismTools.MODID); - } - - @Override - protected void addAliases(HolderLookup.Provider lookupProvider) { - addVanillaPaxelAliases(ToolsItems.WOOD_PAXEL, Items.WOODEN_AXE, Items.WOODEN_PICKAXE, Items.WOODEN_SHOVEL); - addVanillaPaxelAliases(ToolsItems.STONE_PAXEL, Items.STONE_AXE, Items.STONE_PICKAXE, Items.STONE_SHOVEL); - addVanillaPaxelAliases(ToolsItems.GOLD_PAXEL, Items.GOLDEN_AXE, Items.GOLDEN_PICKAXE, Items.GOLDEN_SHOVEL); - addVanillaPaxelAliases(ToolsItems.IRON_PAXEL, Items.IRON_AXE, Items.IRON_PICKAXE, Items.IRON_SHOVEL); - addVanillaPaxelAliases(ToolsItems.DIAMOND_PAXEL, Items.DIAMOND_AXE, Items.DIAMOND_PICKAXE, Items.DIAMOND_SHOVEL); - addVanillaPaxelAliases(ToolsItems.NETHERITE_PAXEL, Items.NETHERITE_AXE, Items.NETHERITE_PICKAXE, Items.NETHERITE_SHOVEL); - - addPaxelAliases(ToolsItems.BRONZE_PAXEL, ToolsItems.BRONZE_AXE, ToolsItems.BRONZE_PICKAXE, ToolsItems.BRONZE_SHOVEL); - addPaxelAliases(ToolsItems.LAPIS_LAZULI_PAXEL, ToolsItems.LAPIS_LAZULI_AXE, ToolsItems.LAPIS_LAZULI_PICKAXE, ToolsItems.LAPIS_LAZULI_SHOVEL); - addPaxelAliases(ToolsItems.OSMIUM_PAXEL, ToolsItems.OSMIUM_AXE, ToolsItems.OSMIUM_PICKAXE, ToolsItems.OSMIUM_SHOVEL); - addPaxelAliases(ToolsItems.REFINED_GLOWSTONE_PAXEL, ToolsItems.REFINED_GLOWSTONE_AXE, ToolsItems.REFINED_GLOWSTONE_PICKAXE, ToolsItems.REFINED_GLOWSTONE_SHOVEL); - addPaxelAliases(ToolsItems.REFINED_OBSIDIAN_PAXEL, ToolsItems.REFINED_OBSIDIAN_AXE, ToolsItems.REFINED_OBSIDIAN_PICKAXE, ToolsItems.REFINED_OBSIDIAN_SHOVEL); - addPaxelAliases(ToolsItems.STEEL_PAXEL, ToolsItems.STEEL_AXE, ToolsItems.STEEL_PICKAXE, ToolsItems.STEEL_SHOVEL); - } - - private void addPaxelAliases(ItemLike paxel, IHasTranslationKey axe, IHasTranslationKey pickaxe, IHasTranslationKey shovel) { - addAliases(paxel, axe, pickaxe, shovel, MekanismAliases.TOOL_MULTI); - } - - private void addVanillaPaxelAliases(ItemLike paxel, Item axe, Item pickaxe, Item shovel) { - addPaxelAliases(paxel, axe::getDescriptionId, pickaxe::getDescriptionId, shovel::getDescriptionId); - } -} \ No newline at end of file diff --git a/src/datagen/tools/java/mekanism/tools/common/ToolsDataGenerator.java b/src/datagen/tools/java/mekanism/tools/common/ToolsDataGenerator.java index 292a7c417cd..82a0dfdf3f7 100644 --- a/src/datagen/tools/java/mekanism/tools/common/ToolsDataGenerator.java +++ b/src/datagen/tools/java/mekanism/tools/common/ToolsDataGenerator.java @@ -7,8 +7,8 @@ import mekanism.tools.client.ToolsItemModelProvider; import mekanism.tools.client.ToolsLangProvider; import mekanism.tools.client.ToolsSpriteSourceProvider; -import mekanism.tools.client.integration.emi.ToolsEmiAliasProvider; import mekanism.tools.client.integration.emi.ToolsEmiDefaults; +import mekanism.tools.client.recipe_viewer.aliases.ToolsAliasMapping; import mekanism.tools.common.recipe.ToolsRecipeProvider; import net.minecraft.core.HolderLookup; import net.minecraft.data.DataGenerator; @@ -42,6 +42,6 @@ public static void gatherData(GatherDataEvent event) { gen.addProvider(event.includeServer(), new ToolsAdvancementProvider(output, lookupProvider, existingFileHelper)); //Data generator to help with persisting data when porting across MC versions when optional deps aren't updated yet // DO NOT ADD OTHERS AFTER THIS ONE - PersistingDisabledProvidersProvider.addDisabledEmiProvider(event, lookupProvider, MekanismTools.MODID, () -> ToolsEmiAliasProvider::new, () -> ToolsEmiDefaults::new); + PersistingDisabledProvidersProvider.addDisabledEmiProvider(event, lookupProvider, MekanismTools.MODID, ToolsAliasMapping::new, () -> ToolsEmiDefaults::new); } } \ No newline at end of file diff --git a/src/generators/java/mekanism/generators/client/recipe_viewer/alias/GeneratorsAliasMapping.java b/src/generators/java/mekanism/generators/client/recipe_viewer/alias/GeneratorsAliasMapping.java new file mode 100644 index 00000000000..06c542433c0 --- /dev/null +++ b/src/generators/java/mekanism/generators/client/recipe_viewer/alias/GeneratorsAliasMapping.java @@ -0,0 +1,69 @@ +package mekanism.generators.client.recipe_viewer.alias; + +import java.util.List; +import mekanism.client.recipe_viewer.alias.IAliasMapping; +import mekanism.client.recipe_viewer.alias.MekanismAliases; +import mekanism.client.recipe_viewer.alias.RVAliasHelper; +import mekanism.common.registries.MekanismBlocks; +import mekanism.common.util.ChemicalUtil; +import mekanism.generators.common.registries.GeneratorsBlocks; +import mekanism.generators.common.registries.GeneratorsChemicals; +import mekanism.generators.common.registries.GeneratorsFluids; +import mekanism.generators.common.registries.GeneratorsItems; + +public class GeneratorsAliasMapping implements IAliasMapping { + + @Override + public void addAliases(RVAliasHelper rv) { + addChemicalAliases(rv); + addMultiblockAliases(rv); + rv.addAliases(GeneratorsBlocks.GAS_BURNING_GENERATOR, GeneratorsAliases.GBG_ETHENE, GeneratorsAliases.GBG_ETHYLENE); + rv.addModuleAliases(GeneratorsItems.ITEMS); + } + + private void addChemicalAliases(RVAliasHelper rv) { + rv.addAliases(GeneratorsFluids.FUSION_FUEL, GeneratorsChemicals.FUSION_FUEL, GeneratorsAliases.FUSION_FUEL); + } + + private void addMultiblockAliases(RVAliasHelper rv) { + rv.addAliases(GeneratorsBlocks.REACTOR_GLASS, + MekanismAliases.BOILER_COMPONENT, + MekanismAliases.EVAPORATION_COMPONENT, + MekanismAliases.MATRIX_COMPONENT, + MekanismAliases.SPS_COMPONENT, + MekanismAliases.SPS_FULL_COMPONENT, + MekanismAliases.TANK_COMPONENT + ); + rv.addAliases(GeneratorsBlocks.ADVANCED_SOLAR_GENERATOR, MekanismAliases.EVAPORATION_COMPONENT); + rv.addAlias(GeneratorsAliases.FISSION_COMPONENT, + GeneratorsBlocks.FISSION_REACTOR_CASING, + GeneratorsBlocks.FISSION_REACTOR_PORT, + GeneratorsBlocks.FISSION_REACTOR_LOGIC_ADAPTER, + GeneratorsBlocks.FISSION_FUEL_ASSEMBLY, + GeneratorsBlocks.CONTROL_ROD_ASSEMBLY, + GeneratorsBlocks.REACTOR_GLASS + ); + rv.addItemAliases(List.of( + GeneratorsBlocks.FUSION_REACTOR_CONTROLLER.getItemStack(), + GeneratorsBlocks.FUSION_REACTOR_FRAME.getItemStack(), + GeneratorsBlocks.FUSION_REACTOR_PORT.getItemStack(), + GeneratorsBlocks.FUSION_REACTOR_LOGIC_ADAPTER.getItemStack(), + GeneratorsBlocks.LASER_FOCUS_MATRIX.getItemStack(), + GeneratorsBlocks.REACTOR_GLASS.getItemStack(), + ChemicalUtil.getFilledVariant(GeneratorsItems.HOHLRAUM, GeneratorsChemicals.FUSION_FUEL) + ), GeneratorsAliases.FUSION_COMPONENT); + rv.addAlias(GeneratorsAliases.TURBINE_COMPONENT, + GeneratorsBlocks.TURBINE_CASING, + GeneratorsBlocks.TURBINE_VENT, + GeneratorsBlocks.TURBINE_VALVE, + GeneratorsBlocks.TURBINE_ROTOR, + GeneratorsItems.TURBINE_BLADE, + GeneratorsBlocks.SATURATING_CONDENSER, + GeneratorsBlocks.ELECTROMAGNETIC_COIL, + GeneratorsBlocks.ROTATIONAL_COMPLEX, + GeneratorsBlocks.REACTOR_GLASS, + MekanismBlocks.PRESSURE_DISPERSER, + MekanismBlocks.STRUCTURAL_GLASS + ); + } +} \ No newline at end of file diff --git a/src/datagen/generators/java/mekanism/generators/client/integration/GeneratorsAliases.java b/src/generators/java/mekanism/generators/client/recipe_viewer/alias/GeneratorsAliases.java similarity index 89% rename from src/datagen/generators/java/mekanism/generators/client/integration/GeneratorsAliases.java rename to src/generators/java/mekanism/generators/client/recipe_viewer/alias/GeneratorsAliases.java index 5c923abda70..4a01db427fc 100644 --- a/src/datagen/generators/java/mekanism/generators/client/integration/GeneratorsAliases.java +++ b/src/generators/java/mekanism/generators/client/recipe_viewer/alias/GeneratorsAliases.java @@ -1,7 +1,7 @@ -package mekanism.generators.client.integration; +package mekanism.generators.client.recipe_viewer.alias; import mekanism.api.annotations.NothingNullByDefault; -import mekanism.client.integration.IAliasedTranslation; +import mekanism.client.recipe_viewer.alias.IAliasedTranslation; import mekanism.generators.common.MekanismGenerators; import net.minecraft.Util; diff --git a/src/main/java/mekanism/client/recipe_viewer/alias/IAliasMapping.java b/src/main/java/mekanism/client/recipe_viewer/alias/IAliasMapping.java new file mode 100644 index 00000000000..54508d9d7a4 --- /dev/null +++ b/src/main/java/mekanism/client/recipe_viewer/alias/IAliasMapping.java @@ -0,0 +1,6 @@ +package mekanism.client.recipe_viewer.alias; + +public interface IAliasMapping { + + void addAliases(RVAliasHelper rv); +} \ No newline at end of file diff --git a/src/datagen/main/java/mekanism/client/integration/IAliasedTranslation.java b/src/main/java/mekanism/client/recipe_viewer/alias/IAliasedTranslation.java similarity index 75% rename from src/datagen/main/java/mekanism/client/integration/IAliasedTranslation.java rename to src/main/java/mekanism/client/recipe_viewer/alias/IAliasedTranslation.java index dd23a8573ea..7f284460396 100644 --- a/src/datagen/main/java/mekanism/client/integration/IAliasedTranslation.java +++ b/src/main/java/mekanism/client/recipe_viewer/alias/IAliasedTranslation.java @@ -1,4 +1,4 @@ -package mekanism.client.integration; +package mekanism.client.recipe_viewer.alias; import mekanism.api.text.IHasTranslationKey; diff --git a/src/datagen/main/java/mekanism/client/integration/emi/MekanismEmiAliasProvider.java b/src/main/java/mekanism/client/recipe_viewer/alias/MekanismAliasMapping.java similarity index 54% rename from src/datagen/main/java/mekanism/client/integration/emi/MekanismEmiAliasProvider.java rename to src/main/java/mekanism/client/recipe_viewer/alias/MekanismAliasMapping.java index f904b38cd8e..9182ba9f86f 100644 --- a/src/datagen/main/java/mekanism/client/integration/emi/MekanismEmiAliasProvider.java +++ b/src/main/java/mekanism/client/recipe_viewer/alias/MekanismAliasMapping.java @@ -1,12 +1,9 @@ -package mekanism.client.integration.emi; +package mekanism.client.recipe_viewer.alias; -import dev.emi.emi.api.stack.EmiStack; import java.util.List; import java.util.Map; -import java.util.concurrent.CompletableFuture; import mekanism.api.annotations.NothingNullByDefault; import mekanism.api.text.IHasTranslationKey; -import mekanism.client.integration.MekanismAliases; import mekanism.common.Mekanism; import mekanism.common.content.blocktype.FactoryType; import mekanism.common.item.block.ItemBlockEnergyCube; @@ -21,8 +18,6 @@ import mekanism.common.util.FluidUtils; import mekanism.common.util.StorageUtils; import net.minecraft.Util; -import net.minecraft.core.HolderLookup; -import net.minecraft.data.PackOutput; import net.minecraft.resources.ResourceKey; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.item.Items; @@ -30,77 +25,70 @@ import net.minecraft.world.item.enchantment.Enchantments; @NothingNullByDefault -public class MekanismEmiAliasProvider extends BaseEmiAliasProvider { - - public MekanismEmiAliasProvider(PackOutput output, CompletableFuture registries) { - super(output, registries, Mekanism.MODID); - } +public final class MekanismAliasMapping implements IAliasMapping { @Override - protected void addAliases(HolderLookup.Provider lookupProvider) { - addChemicalAliases(); - addUnitAliases(); - addFactoryAliases(); - addGearAliases(); - addMultiblockAliases(); - addStorageAliases(); - addTransferAliases(); - addUpgradeAliases(); - addMiscAliases(); + public void addAliases(RVAliasHelper rv) { + addChemicalAliases(rv); + addUnitAliases(rv); + addFactoryAliases(rv); + addGearAliases(rv); + addMultiblockAliases(rv); + addStorageAliases(rv); + addTransferAliases(rv); + addUpgradeAliases(rv); + addMiscAliases(rv); } - private void addChemicalAliases() { - addAliases(List.of( - ingredient(MekanismFluids.ETHENE), - ingredient(MekanismChemicals.ETHENE) - ), MekanismAliases.ETHENE_ETHYLENE); + private void addChemicalAliases(RVAliasHelper rv) { + rv.addAliases(MekanismFluids.ETHENE, MekanismChemicals.ETHENE, MekanismAliases.ETHENE_ETHYLENE); } - private void addUnitAliases() { - addAliases(MekanismBlocks.MODIFICATION_STATION, MekanismAliases.UNIT_INSTALLER, MekanismAliases.UNIT_INSTALLER_MODULE); - addAliases(MekanismItems.MODULE_RADIATION_SHIELDING, MekanismAliases.RADIATION_PROTECTION); - addAliases(MekanismItems.MODULE_ENERGY, MekanismAliases.ENERGY_STORAGE); + private void addUnitAliases(RVAliasHelper rv) { + rv.addAliases(MekanismBlocks.MODIFICATION_STATION, MekanismAliases.UNIT_INSTALLER, MekanismAliases.UNIT_INSTALLER_MODULE); + rv.addAliases(MekanismItems.MODULE_RADIATION_SHIELDING, MekanismAliases.RADIATION_PROTECTION); + rv.addAliases(MekanismItems.MODULE_ENERGY, MekanismAliases.ENERGY_STORAGE); - addAliases(MekanismItems.MODULE_FORTUNE, getTranslationKey(Enchantments.FORTUNE)); - addAliases(MekanismItems.MODULE_ATTACK_AMPLIFICATION, MekanismAliases.UNIT_DAMAGE, getTranslationKey(Enchantments.SHARPNESS)); - addAliases(MekanismItems.MODULE_EXCAVATION_ESCALATION, MekanismAliases.UNIT_DIG_SPEED, getTranslationKey(Enchantments.EFFICIENCY)); - addAliases(MekanismItems.MODULE_BLASTING, MekanismAliases.TOOL_HAMMER, MekanismAliases.UNIT_AOE, MekanismAliases.UNIT_AOE_LONG); - addAliases(MekanismItems.MODULE_FARMING, MekanismAliases.TOOL_AXE, MekanismAliases.TOOL_HOE, MekanismAliases.TOOL_SHOVEL); + rv.addAliases(MekanismItems.MODULE_FORTUNE, getTranslationKey(Enchantments.FORTUNE)); + rv.addAliases(MekanismItems.MODULE_ATTACK_AMPLIFICATION, MekanismAliases.UNIT_DAMAGE, getTranslationKey(Enchantments.SHARPNESS)); + rv.addAliases(MekanismItems.MODULE_EXCAVATION_ESCALATION, MekanismAliases.UNIT_DIG_SPEED, getTranslationKey(Enchantments.EFFICIENCY)); + rv.addAliases(MekanismItems.MODULE_BLASTING, MekanismAliases.TOOL_HAMMER, MekanismAliases.UNIT_AOE, MekanismAliases.UNIT_AOE_LONG); + rv.addAliases(MekanismItems.MODULE_FARMING, MekanismAliases.TOOL_AXE, MekanismAliases.TOOL_HOE, MekanismAliases.TOOL_SHOVEL); - addAliases(MekanismItems.MODULE_VISION_ENHANCEMENT, MobEffects.NIGHT_VISION.value()::getDescriptionId); - addAliases(MekanismItems.MODULE_NUTRITIONAL_INJECTION, MekanismAliases.UNIT_FEEDER); + rv.addAliases(MekanismItems.MODULE_VISION_ENHANCEMENT, MobEffects.NIGHT_VISION.value()::getDescriptionId); + rv.addAliases(MekanismItems.MODULE_NUTRITIONAL_INJECTION, MekanismAliases.UNIT_FEEDER); //Note: Jetpack module pairing with normal flight alias is in done in the gear section - addAliases(MekanismItems.MODULE_GRAVITATIONAL_MODULATING, MekanismAliases.CREATIVE_FLIGHT); - addAliases(MekanismItems.MODULE_CHARGE_DISTRIBUTION, MekanismAliases.ITEM_CHARGER); - addAliases(MekanismItems.MODULE_HYDRAULIC_PROPULSION, MekanismAliases.AUTO_STEP, MekanismAliases.STEP_ASSIST, MobEffects.JUMP.value()::getDescriptionId); - addAliases(MekanismItems.MODULE_HYDROSTATIC_REPULSOR, MekanismAliases.UNIT_HYDROSTATIC_SPEED, getTranslationKey(Enchantments.DEPTH_STRIDER)); - addAliases(MekanismItems.MODULE_MOTORIZED_SERVO, getTranslationKey(Enchantments.SWIFT_SNEAK)); - addAliases(MekanismItems.MODULE_LOCOMOTIVE_BOOSTING, MobEffects.MOVEMENT_SPEED.value()::getDescriptionId); - addAliases(MekanismItems.MODULE_SOUL_SURFER, getTranslationKey(Enchantments.SOUL_SPEED)); - - addModuleAliases(MekanismItems.ITEMS); + rv.addAliases(MekanismItems.MODULE_GRAVITATIONAL_MODULATING, MekanismAliases.CREATIVE_FLIGHT); + rv.addAliases(MekanismItems.MODULE_CHARGE_DISTRIBUTION, MekanismAliases.ITEM_CHARGER); + rv.addAliases(MekanismItems.MODULE_HYDRAULIC_PROPULSION, MekanismAliases.AUTO_STEP, MekanismAliases.STEP_ASSIST, MobEffects.JUMP.value()::getDescriptionId); + rv.addAliases(MekanismItems.MODULE_HYDROSTATIC_REPULSOR, MekanismAliases.UNIT_HYDROSTATIC_SPEED, getTranslationKey(Enchantments.DEPTH_STRIDER)); + rv.addAliases(MekanismItems.MODULE_MOTORIZED_SERVO, getTranslationKey(Enchantments.SWIFT_SNEAK)); + rv.addAliases(MekanismItems.MODULE_LOCOMOTIVE_BOOSTING, MobEffects.MOVEMENT_SPEED.value()::getDescriptionId); + rv.addAliases(MekanismItems.MODULE_SOUL_SURFER, getTranslationKey(Enchantments.SOUL_SPEED)); + + rv.addModuleAliases(MekanismItems.ITEMS); } - private IHasTranslationKey getTranslationKey(ResourceKey enchantmentKey) { + private static IHasTranslationKey getTranslationKey(ResourceKey enchantmentKey) { return () -> Util.makeDescriptionId("enchantment", enchantmentKey.location()); } - private void addFactoryAliases() { + private void addFactoryAliases(RVAliasHelper rv) { for (FactoryType factoryType : EnumUtils.FACTORY_TYPES) { //Allow searching for factories by the name of the base block - addAlias(factoryType.getBaseBlock(), + rv.addAlias(factoryType.getBaseBlock(), MekanismBlocks.getFactory(FactoryTier.BASIC, factoryType), MekanismBlocks.getFactory(FactoryTier.ADVANCED, factoryType), MekanismBlocks.getFactory(FactoryTier.ELITE, factoryType), MekanismBlocks.getFactory(FactoryTier.ULTIMATE, factoryType) ); //Add the type as a way to look-up the base block - addAliases(factoryType.getBaseBlock(), () -> Util.makeDescriptionId("alias", Mekanism.rl(factoryType.getRegistryNameComponent()))); + rv.addAliases(factoryType.getBaseBlock(), () -> Util.makeDescriptionId("alias", Mekanism.rl(factoryType.getRegistryNameComponent()))); } } - private void addGearAliases() { - addAliases(MekanismItems.ATOMIC_DISASSEMBLER, MekanismItems.MEKA_TOOL, + private void addGearAliases(RVAliasHelper rv) { + rv.addAliases(MekanismItems.ATOMIC_DISASSEMBLER, MekanismItems.MEKA_TOOL, MekanismAliases.TOOL_MULTI, MekanismAliases.TOOL_AXE, MekanismAliases.TOOL_PICKAXE, @@ -109,42 +97,43 @@ private void addGearAliases() { MekanismAliases.TOOL_WEAPON ); - addAliases(MekanismItems.CONFIGURATOR, MekanismAliases.TOOL_DIAGNOSTIC, MekanismAliases.TOOL_WRENCH); - addAlias(MekanismAliases.TOOL_DIAGNOSTIC, MekanismItems.NETWORK_READER, MekanismItems.CONFIGURATION_CARD); + rv.addAliases(MekanismItems.CONFIGURATOR, MekanismAliases.TOOL_DIAGNOSTIC, MekanismAliases.TOOL_WRENCH); + rv.addAlias(MekanismAliases.TOOL_DIAGNOSTIC, MekanismItems.NETWORK_READER, MekanismItems.CONFIGURATION_CARD); - addAlias(MekanismAliases.FLIGHT, MekanismItems.JETPACK, MekanismItems.ARMORED_JETPACK, MekanismItems.MODULE_JETPACK); - addAlias(MekanismAliases.RADIATION_PROTECTION, MekanismItems.HAZMAT_MASK, MekanismItems.HAZMAT_GOWN, MekanismItems.HAZMAT_PANTS, MekanismItems.HAZMAT_BOOTS); + rv.addAlias(MekanismAliases.FLIGHT, MekanismItems.JETPACK, MekanismItems.ARMORED_JETPACK, MekanismItems.MODULE_JETPACK); + rv.addAlias(MekanismAliases.RADIATION_PROTECTION, MekanismItems.HAZMAT_MASK, MekanismItems.HAZMAT_GOWN, MekanismItems.HAZMAT_PANTS, MekanismItems.HAZMAT_BOOTS); - addAliases(List.of(MekanismItems.FREE_RUNNERS, MekanismItems.ARMORED_FREE_RUNNERS), + rv.addAliases(List.of(MekanismItems.FREE_RUNNERS, MekanismItems.ARMORED_FREE_RUNNERS), MekanismAliases.FREE_RUNNER_LONG_FALL, MekanismAliases.FREE_RUNNER_FALL_PROTECTION, MekanismAliases.AUTO_STEP, MekanismAliases.STEP_ASSIST ); - addAliases(MekanismItems.MEKASUIT_BOOTS, MekanismAliases.FREE_RUNNER_LONG_FALL, MekanismAliases.FREE_RUNNER_FALL_PROTECTION, MekanismAliases.MEKA_SUIT_POWER_ARMOR); - addAlias(MekanismAliases.MEKA_SUIT_POWER_ARMOR, MekanismItems.MEKASUIT_HELMET, MekanismItems.MEKASUIT_BODYARMOR, MekanismItems.MEKASUIT_PANTS); + rv.addAliases(MekanismItems.MEKASUIT_BOOTS, MekanismAliases.FREE_RUNNER_LONG_FALL, MekanismAliases.FREE_RUNNER_FALL_PROTECTION, MekanismAliases.MEKA_SUIT_POWER_ARMOR); + rv.addAlias(MekanismAliases.MEKA_SUIT_POWER_ARMOR, MekanismItems.MEKASUIT_HELMET, MekanismItems.MEKASUIT_BODYARMOR, MekanismItems.MEKASUIT_PANTS); - addAliases(EmiStack.of( - FluidUtils.getFilledVariant(MekanismItems.CANTEEN, MekanismFluids.NUTRITIONAL_PASTE.getFluid()) - ), MekanismAliases.CANTEEN_EDIBLE, MekanismAliases.CANTEEN_FOOD_STORAGE); + rv.addAliases(FluidUtils.getFilledVariant(MekanismItems.CANTEEN, MekanismFluids.NUTRITIONAL_PASTE.getFluid()), + MekanismAliases.CANTEEN_EDIBLE, + MekanismAliases.CANTEEN_FOOD_STORAGE + ); } - private void addMultiblockAliases() { - addAlias(MekanismAliases.BOILER_COMPONENT, + private void addMultiblockAliases(RVAliasHelper rv) { + rv.addAlias(MekanismAliases.BOILER_COMPONENT, MekanismBlocks.BOILER_CASING, MekanismBlocks.BOILER_VALVE, MekanismBlocks.PRESSURE_DISPERSER, MekanismBlocks.SUPERHEATING_ELEMENT, MekanismBlocks.STRUCTURAL_GLASS ); - addAlias(MekanismAliases.EVAPORATION_COMPONENT, + rv.addAlias(MekanismAliases.EVAPORATION_COMPONENT, MekanismBlocks.THERMAL_EVAPORATION_CONTROLLER, MekanismBlocks.THERMAL_EVAPORATION_BLOCK, MekanismBlocks.THERMAL_EVAPORATION_VALVE, MekanismBlocks.STRUCTURAL_GLASS ); - addAliases(List.of( + rv.addAliases(List.of( MekanismBlocks.INDUCTION_CASING, MekanismBlocks.INDUCTION_PORT, MekanismBlocks.BASIC_INDUCTION_CELL, @@ -157,7 +146,7 @@ private void addMultiblockAliases() { MekanismBlocks.ULTIMATE_INDUCTION_PROVIDER, MekanismBlocks.STRUCTURAL_GLASS ), MekanismAliases.MATRIX_COMPONENT); - addAliases(List.of( + rv.addAliases(List.of( MekanismBlocks.INDUCTION_CASING, MekanismBlocks.INDUCTION_PORT, MekanismBlocks.BASIC_INDUCTION_CELL, @@ -165,7 +154,7 @@ private void addMultiblockAliases() { MekanismBlocks.ELITE_INDUCTION_CELL, MekanismBlocks.ULTIMATE_INDUCTION_CELL ), MekanismAliases.ENERGY_STORAGE, MekanismAliases.ENERGY_STORAGE_BATTERY, MekanismAliases.ITEM_CHARGER); - addAliases(List.of( + rv.addAliases(List.of( MekanismBlocks.INDUCTION_PORT, MekanismBlocks.BASIC_INDUCTION_PROVIDER, MekanismBlocks.ADVANCED_INDUCTION_PROVIDER, @@ -173,13 +162,13 @@ private void addMultiblockAliases() { MekanismBlocks.ULTIMATE_INDUCTION_PROVIDER ), MekanismAliases.ENERGY_TRANSFER, MekanismAliases.ENERGY_THROUGHPUT, MekanismAliases.ITEM_CHARGER); - addAliases(List.of( + rv.addAliases(List.of( MekanismBlocks.SPS_CASING, MekanismBlocks.SPS_PORT, MekanismBlocks.SUPERCHARGED_COIL, MekanismBlocks.STRUCTURAL_GLASS ), MekanismAliases.SPS_COMPONENT, MekanismAliases.SPS_FULL_COMPONENT); - addAliases(List.of(MekanismBlocks.DYNAMIC_TANK, MekanismBlocks.DYNAMIC_VALVE, MekanismBlocks.STRUCTURAL_GLASS), + rv.addAliases(List.of(MekanismBlocks.DYNAMIC_TANK, MekanismBlocks.DYNAMIC_VALVE, MekanismBlocks.STRUCTURAL_GLASS), MekanismAliases.TANK_COMPONENT, MekanismAliases.FLUID_STORAGE, MekanismAliases.CHEMICAL_STORAGE, @@ -191,22 +180,22 @@ private void addMultiblockAliases() { ); } - private void addStorageAliases() { - addStorageBlockAliases(); - addQIOAliases(); - addAliases(List.of( + private void addStorageAliases(RVAliasHelper rv) { + addStorageBlockAliases(rv); + addQIOAliases(rv); + rv.addAliases(List.of( MekanismBlocks.BASIC_BIN, MekanismBlocks.ADVANCED_BIN, MekanismBlocks.ELITE_BIN, MekanismBlocks.ULTIMATE_BIN, MekanismBlocks.CREATIVE_BIN ), MekanismAliases.BIN_DRAWER, MekanismAliases.ITEM_STORAGE); - addAliases(List.of( + rv.addAliases(List.of( MekanismBlocks.PERSONAL_BARREL, MekanismBlocks.PERSONAL_CHEST ), MekanismAliases.PERSONAL_BACKPACK, MekanismAliases.ITEM_STORAGE, MekanismAliases.STORAGE_PORTABLE); - addAliases(List.of( + rv.addAliases(List.of( MekanismBlocks.BASIC_FLUID_TANK, MekanismBlocks.ADVANCED_FLUID_TANK, MekanismBlocks.ELITE_FLUID_TANK, @@ -214,7 +203,7 @@ private void addStorageAliases() { MekanismBlocks.CREATIVE_FLUID_TANK ), MekanismAliases.FLUID_STORAGE, MekanismAliases.STORAGE_PORTABLE, Items.BUCKET::getDescriptionId);//Note: We add bucket as the tanks can act as buckets - addAliases(List.of( + rv.addAliases(List.of( MekanismBlocks.BASIC_CHEMICAL_TANK, MekanismBlocks.ADVANCED_CHEMICAL_TANK, MekanismBlocks.ELITE_CHEMICAL_TANK, @@ -229,57 +218,57 @@ private void addStorageAliases() { MekanismAliases.SLURRY_STORAGE ); - addAliases(List.of( - EmiStack.of(MekanismBlocks.BASIC_ENERGY_CUBE), - EmiStack.of(MekanismBlocks.ADVANCED_ENERGY_CUBE), - EmiStack.of(MekanismBlocks.ELITE_ENERGY_CUBE), - EmiStack.of(MekanismBlocks.ULTIMATE_ENERGY_CUBE), - EmiStack.of(StorageUtils.getFilledEnergyVariant( + rv.addItemAliases(List.of( + MekanismBlocks.BASIC_ENERGY_CUBE.getItemStack(), + MekanismBlocks.ADVANCED_ENERGY_CUBE.getItemStack(), + MekanismBlocks.ELITE_ENERGY_CUBE.getItemStack(), + MekanismBlocks.ULTIMATE_ENERGY_CUBE.getItemStack(), + StorageUtils.getFilledEnergyVariant( ItemBlockEnergyCube.withEnergyCubeSideConfig(MekanismBlocks.CREATIVE_ENERGY_CUBE, ItemBlockEnergyCube.ALL_OUTPUT) - )) + ) ), MekanismAliases.ENERGY_STORAGE, MekanismAliases.ENERGY_STORAGE_BATTERY, MekanismAliases.ITEM_CHARGER); - addAliases(MekanismItems.ENERGY_TABLET, MekanismAliases.ENERGY_STORAGE, MekanismAliases.ENERGY_STORAGE_BATTERY); + rv.addAliases(MekanismItems.ENERGY_TABLET, MekanismAliases.ENERGY_STORAGE, MekanismAliases.ENERGY_STORAGE_BATTERY); - addAliases(List.of( - EmiStack.of(MekanismBlocks.CREATIVE_BIN), - EmiStack.of(MekanismBlocks.CREATIVE_FLUID_TANK), - EmiStack.of(MekanismBlocks.CREATIVE_CHEMICAL_TANK), - EmiStack.of(ItemBlockEnergyCube.withEnergyCubeSideConfig(MekanismBlocks.CREATIVE_ENERGY_CUBE, ItemBlockEnergyCube.ALL_INPUT)) + rv.addItemAliases(List.of( + MekanismBlocks.CREATIVE_BIN.getItemStack(), + MekanismBlocks.CREATIVE_FLUID_TANK.getItemStack(), + MekanismBlocks.CREATIVE_CHEMICAL_TANK.getItemStack(), + ItemBlockEnergyCube.withEnergyCubeSideConfig(MekanismBlocks.CREATIVE_ENERGY_CUBE, ItemBlockEnergyCube.ALL_INPUT) ), MekanismAliases.STORAGE_TRASHCAN, MekanismAliases.STORAGE_VOID); } - private void addStorageBlockAliases() { - addAliases(MekanismBlocks.BRONZE_BLOCK, MekanismAliases.BLOCK_BRONZE); - addAliases(MekanismBlocks.CHARCOAL_BLOCK, MekanismAliases.BLOCK_CHARCOAL); - addAliases(MekanismBlocks.STEEL_BLOCK, MekanismAliases.BLOCK_STEEL); - addAliases(MekanismBlocks.FLUORITE_BLOCK, MekanismAliases.BLOCK_FLUORITE); + private void addStorageBlockAliases(RVAliasHelper rv) { + rv.addAliases(MekanismBlocks.BRONZE_BLOCK, MekanismAliases.BLOCK_BRONZE); + rv.addAliases(MekanismBlocks.CHARCOAL_BLOCK, MekanismAliases.BLOCK_CHARCOAL); + rv.addAliases(MekanismBlocks.STEEL_BLOCK, MekanismAliases.BLOCK_STEEL); + rv.addAliases(MekanismBlocks.FLUORITE_BLOCK, MekanismAliases.BLOCK_FLUORITE); //Dynamic storage blocks for (Map.Entry> entry : MekanismBlocks.PROCESSED_RESOURCE_BLOCKS.entrySet()) { BlockRegistryObject block = entry.getValue(); - addAliases(block, () -> Util.makeDescriptionId("alias", block.getId().withPath(entry.getKey().getRegistrySuffix()))); + rv.addAliases(block, () -> Util.makeDescriptionId("alias", block.getId().withPath(entry.getKey().getRegistrySuffix()))); } } - private void addQIOAliases() { - addAliases(MekanismBlocks.QIO_REDSTONE_ADAPTER, MekanismAliases.QIO_FULL, MekanismAliases.QIO_ADAPTER_EMITTER); - addAliases(MekanismBlocks.QIO_DRIVE_ARRAY, MekanismAliases.QIO_FULL, MekanismAliases.QIO_DRIVE_BAY); - addAliases(MekanismItems.PORTABLE_QIO_DASHBOARD, MekanismAliases.PORTABLE_CRAFTING_TABLE, MekanismAliases.QIO_FULL, MekanismAliases.QIO_DASHBOARD_WIRELESS_TERMINAL); - addAliases(List.of( + private void addQIOAliases(RVAliasHelper rv) { + rv.addAliases(MekanismBlocks.QIO_REDSTONE_ADAPTER, MekanismAliases.QIO_FULL, MekanismAliases.QIO_ADAPTER_EMITTER); + rv.addAliases(MekanismBlocks.QIO_DRIVE_ARRAY, MekanismAliases.QIO_FULL, MekanismAliases.QIO_DRIVE_BAY); + rv.addAliases(MekanismItems.PORTABLE_QIO_DASHBOARD, MekanismAliases.PORTABLE_CRAFTING_TABLE, MekanismAliases.QIO_FULL, MekanismAliases.QIO_DASHBOARD_WIRELESS_TERMINAL); + rv.addAliases(List.of( MekanismBlocks.QIO_DASHBOARD, MekanismItems.PORTABLE_QIO_DASHBOARD ), MekanismAliases.QIO_FULL, MekanismAliases.QIO_DASHBOARD_TERMINAL, MekanismAliases.QIO_DASHBOARD_GRID); - addAliases(List.of( + rv.addAliases(List.of( MekanismItems.BASE_QIO_DRIVE, MekanismItems.HYPER_DENSE_QIO_DRIVE, MekanismItems.TIME_DILATING_QIO_DRIVE, MekanismItems.SUPERMASSIVE_QIO_DRIVE ), MekanismAliases.QIO_FULL, MekanismAliases.QIO_DRIVE_CELL, MekanismAliases.QIO_DRIVE_DISK, MekanismAliases.ITEM_STORAGE); - addAliases(MekanismBlocks.QIO_EXPORTER, MekanismAliases.QIO_FULL, MekanismAliases.ROUND_ROBIN); - addAliases(MekanismBlocks.QIO_IMPORTER, MekanismAliases.QIO_FULL); + rv.addAliases(MekanismBlocks.QIO_EXPORTER, MekanismAliases.QIO_FULL, MekanismAliases.ROUND_ROBIN); + rv.addAliases(MekanismBlocks.QIO_IMPORTER, MekanismAliases.QIO_FULL); } - private void addTransferAliases() { - addAliases(List.of( + private void addTransferAliases(RVAliasHelper rv) { + rv.addAliases(List.of( MekanismBlocks.BASIC_UNIVERSAL_CABLE, MekanismBlocks.ADVANCED_UNIVERSAL_CABLE, MekanismBlocks.ELITE_UNIVERSAL_CABLE, @@ -292,7 +281,7 @@ private void addTransferAliases() { MekanismAliases.TRANSMITTER_TUBE ); - addAliases(List.of( + rv.addAliases(List.of( MekanismBlocks.BASIC_THERMODYNAMIC_CONDUCTOR, MekanismBlocks.ADVANCED_THERMODYNAMIC_CONDUCTOR, MekanismBlocks.ELITE_THERMODYNAMIC_CONDUCTOR, @@ -305,14 +294,14 @@ private void addTransferAliases() { MekanismAliases.TRANSMITTER_TUBE ); - addAliases(List.of( + rv.addAliases(List.of( MekanismBlocks.BASIC_MECHANICAL_PIPE, MekanismBlocks.ADVANCED_MECHANICAL_PIPE, MekanismBlocks.ELITE_MECHANICAL_PIPE, MekanismBlocks.ULTIMATE_MECHANICAL_PIPE ), MekanismAliases.FLUID_TRANSFER, MekanismAliases.TRANSMITTER, MekanismAliases.TRANSMITTER_CONDUIT, MekanismAliases.TRANSMITTER_TUBE); - addAliases(List.of( + rv.addAliases(List.of( MekanismBlocks.BASIC_LOGISTICAL_TRANSPORTER, MekanismBlocks.ADVANCED_LOGISTICAL_TRANSPORTER, MekanismBlocks.ELITE_LOGISTICAL_TRANSPORTER, @@ -326,10 +315,10 @@ private void addTransferAliases() { MekanismAliases.TRANSMITTER_PIPE, MekanismAliases.TRANSMITTER_TUBE ); - addAliases(MekanismBlocks.DIVERSION_TRANSPORTER, MekanismAliases.REDSTONE_CONTROL); - addAliases(MekanismBlocks.LOGISTICAL_SORTER, MekanismAliases.ITEM_TRANSFER, MekanismAliases.ROUND_ROBIN); + rv.addAliases(MekanismBlocks.DIVERSION_TRANSPORTER, MekanismAliases.REDSTONE_CONTROL); + rv.addAliases(MekanismBlocks.LOGISTICAL_SORTER, MekanismAliases.ITEM_TRANSFER, MekanismAliases.ROUND_ROBIN); - addAliases(List.of( + rv.addAliases(List.of( MekanismBlocks.BASIC_PRESSURIZED_TUBE, MekanismBlocks.ADVANCED_PRESSURIZED_TUBE, MekanismBlocks.ELITE_PRESSURIZED_TUBE, @@ -346,7 +335,7 @@ private void addTransferAliases() { MekanismAliases.TRANSMITTER_PIPE ); - addAliases(MekanismBlocks.QUANTUM_ENTANGLOPORTER, + rv.addAliases(MekanismBlocks.QUANTUM_ENTANGLOPORTER, MekanismAliases.ENERGY_TRANSFER, MekanismAliases.HEAT_TRANSFER, MekanismAliases.FLUID_TRANSFER, @@ -368,15 +357,15 @@ private void addTransferAliases() { ); } - private void addUpgradeAliases() { - addAliases(MekanismItems.SPEED_UPGRADE, MekanismAliases.UPGRADE_AUGMENT, MekanismAliases.UPGRADE_OVERCLOCK); - addAliases(MekanismItems.ENERGY_UPGRADE, MekanismAliases.UPGRADE_AUGMENT, MekanismAliases.ENERGY_STORAGE); - addAliases(MekanismItems.FILTER_UPGRADE, MekanismAliases.UPGRADE_AUGMENT); - addAliases(MekanismItems.MUFFLING_UPGRADE, MekanismAliases.UPGRADE_AUGMENT, MekanismAliases.UPGRADE_MUFFLER); - addAliases(MekanismItems.CHEMICAL_UPGRADE, MekanismAliases.UPGRADE_AUGMENT); - addAliases(MekanismItems.ANCHOR_UPGRADE, MekanismAliases.UPGRADE_AUGMENT, MekanismAliases.CHUNK_LOADER); - addAliases(MekanismItems.STONE_GENERATOR_UPGRADE, MekanismAliases.UPGRADE_AUGMENT, MekanismAliases.UPGRADE_HOLE_FILLER); - addAliases(List.of( + private void addUpgradeAliases(RVAliasHelper rv) { + rv.addAliases(MekanismItems.SPEED_UPGRADE, MekanismAliases.UPGRADE_AUGMENT, MekanismAliases.UPGRADE_OVERCLOCK); + rv.addAliases(MekanismItems.ENERGY_UPGRADE, MekanismAliases.UPGRADE_AUGMENT, MekanismAliases.ENERGY_STORAGE); + rv.addAliases(MekanismItems.FILTER_UPGRADE, MekanismAliases.UPGRADE_AUGMENT); + rv.addAliases(MekanismItems.MUFFLING_UPGRADE, MekanismAliases.UPGRADE_AUGMENT, MekanismAliases.UPGRADE_MUFFLER); + rv.addAliases(MekanismItems.CHEMICAL_UPGRADE, MekanismAliases.UPGRADE_AUGMENT); + rv.addAliases(MekanismItems.ANCHOR_UPGRADE, MekanismAliases.UPGRADE_AUGMENT, MekanismAliases.CHUNK_LOADER); + rv.addAliases(MekanismItems.STONE_GENERATOR_UPGRADE, MekanismAliases.UPGRADE_AUGMENT, MekanismAliases.UPGRADE_HOLE_FILLER); + rv.addAliases(List.of( MekanismItems.BASIC_TIER_INSTALLER, MekanismItems.ADVANCED_TIER_INSTALLER, MekanismItems.ELITE_TIER_INSTALLER, @@ -384,19 +373,18 @@ private void addUpgradeAliases() { ), MekanismAliases.INSTALLER_FACTORY, MekanismAliases.INSTALLER_UPGRADE); } - private void addMiscAliases() { - addAliases(MekanismItems.CRAFTING_FORMULA, MekanismAliases.CRAFTING_PATTERN); - addAliases(MekanismBlocks.FORMULAIC_ASSEMBLICATOR, MekanismAliases.AUTO_CRAFTER); - addAliases(MekanismBlocks.DIMENSIONAL_STABILIZER, MekanismAliases.CHUNK_LOADER); - addAliases(MekanismBlocks.FLUIDIC_PLENISHER, MekanismAliases.PLENISHER_PLACER, MekanismAliases.PLENISHER_REVERSE); - addAliases(MekanismBlocks.OREDICTIONIFICATOR, MekanismAliases.TAG_CONVERTER); - addAliases(MekanismBlocks.ROTARY_CONDENSENTRATOR, + private void addMiscAliases(RVAliasHelper rv) { + rv.addAliases(MekanismItems.CRAFTING_FORMULA, MekanismAliases.CRAFTING_PATTERN); + rv.addAliases(MekanismBlocks.FORMULAIC_ASSEMBLICATOR, MekanismAliases.AUTO_CRAFTER); + rv.addAliases(MekanismBlocks.DIMENSIONAL_STABILIZER, MekanismAliases.CHUNK_LOADER); + rv.addAliases(MekanismBlocks.FLUIDIC_PLENISHER, MekanismAliases.PLENISHER_PLACER, MekanismAliases.PLENISHER_REVERSE); + rv.addAliases(MekanismBlocks.OREDICTIONIFICATOR, MekanismAliases.TAG_CONVERTER); + rv.addAliases(MekanismBlocks.ROTARY_CONDENSENTRATOR, MekanismAliases.ROTARY_DECONDENSENTRATOR, MekanismAliases.ROTARY_CHEMICAL_TO_FLUID, MekanismAliases.ROTARY_GAS_TO_FLUID, MekanismAliases.ROTARY_FLUID_TO_CHEMICAL, MekanismAliases.ROTARY_FLUID_TO_GAS - ); } } \ No newline at end of file diff --git a/src/datagen/main/java/mekanism/client/integration/MekanismAliases.java b/src/main/java/mekanism/client/recipe_viewer/alias/MekanismAliases.java similarity index 99% rename from src/datagen/main/java/mekanism/client/integration/MekanismAliases.java rename to src/main/java/mekanism/client/recipe_viewer/alias/MekanismAliases.java index ea877de3a13..be061680030 100644 --- a/src/datagen/main/java/mekanism/client/integration/MekanismAliases.java +++ b/src/main/java/mekanism/client/recipe_viewer/alias/MekanismAliases.java @@ -1,4 +1,4 @@ -package mekanism.client.integration; +package mekanism.client.recipe_viewer.alias; import mekanism.api.annotations.NothingNullByDefault; import mekanism.api.text.IHasTranslationKey; diff --git a/src/main/java/mekanism/client/recipe_viewer/alias/RVAliasHelper.java b/src/main/java/mekanism/client/recipe_viewer/alias/RVAliasHelper.java new file mode 100644 index 00000000000..c27f5928431 --- /dev/null +++ b/src/main/java/mekanism/client/recipe_viewer/alias/RVAliasHelper.java @@ -0,0 +1,99 @@ +package mekanism.client.recipe_viewer.alias; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import mekanism.api.gear.IModuleHelper; +import mekanism.api.providers.IChemicalProvider; +import mekanism.api.providers.IFluidProvider; +import mekanism.api.text.IHasTranslationKey; +import mekanism.common.content.gear.IModuleItem; +import mekanism.common.registration.impl.ItemDeferredRegister; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.ItemLike; +import net.neoforged.neoforge.fluids.FluidStack; +import net.neoforged.neoforge.registries.DeferredHolder; + +public interface RVAliasHelper { + + ITEM ingredient(ItemLike itemLike); + + ITEM ingredient(ItemStack item); + + FLUID ingredient(IFluidProvider fluidProvider); + + FLUID ingredient(FluidStack fluid); + + CHEMICAL ingredient(IChemicalProvider chemicalProvider); + + default void addAlias(IHasTranslationKey alias, ItemLike... items) { + if (items.length == 0) { + throw new IllegalArgumentException("Expected to have at least one item"); + } + addItemAliases(Arrays.stream(items).map(this::ingredient).toList(), alias); + } + + default void addAliases(IFluidProvider fluidProvider, IChemicalProvider chemicalProvider, IHasTranslationKey... aliases) { + addAliases(fluidProvider, aliases); + addAliases(chemicalProvider, aliases); + } + + default void addAliases(ItemLike item, IHasTranslationKey... aliases) { + addAliases(new ItemStack(item), aliases); + } + + default void addAliases(ItemStack stack, IHasTranslationKey... aliases) { + addItemAliases(List.of(ingredient(stack)), aliases); + } + + default void addAliases(Collection stacks, IHasTranslationKey... aliases) { + addItemAliases(stacks.stream().map(this::ingredient).toList(), aliases); + } + + default void addItemAliases(Collection stacks, IHasTranslationKey... aliases) { + addItemAliases(stacks.stream().map(this::ingredient).toList(), aliases); + } + + default void addAliases(IFluidProvider fluidProvider, IHasTranslationKey... aliases) { + addFluidAliases(List.of(ingredient(fluidProvider)), aliases); + } + + default void addAliases(FluidStack stack, IHasTranslationKey... aliases) { + addFluidAliases(List.of(ingredient(stack)), aliases); + } + + default void addAliases(IChemicalProvider chemicalProvider, IHasTranslationKey... aliases) { + addChemicalAliases(List.of(ingredient(chemicalProvider)), aliases); + } + + default void addItemAlias(ITEM item, IHasTranslationKey... aliases) { + addItemAliases(List.of(item), aliases); + } + + void addItemAliases(List stacks, IHasTranslationKey... aliases); + + default void addFluidAlias(FLUID fluid, IHasTranslationKey... aliases) { + addFluidAliases(List.of(fluid), aliases); + } + + void addFluidAliases(List stacks, IHasTranslationKey... aliases); + + default void addChemicalAlias(CHEMICAL chemical, IHasTranslationKey... aliases) { + addChemicalAliases(List.of(chemical), aliases); + } + + void addChemicalAliases(List stacks, IHasTranslationKey... aliases); + + default void addModuleAliases(ItemDeferredRegister items) { + for (DeferredHolder entry : items.getEntries()) { + if (entry.get() instanceof IModuleItem module) { + addAliases(entry.get(), IModuleHelper.INSTANCE.getSupported(module.getModuleData()) + .stream() + .map(item -> (IHasTranslationKey) item::getDescriptionId) + .toArray(IHasTranslationKey[]::new) + ); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityFluidTank.java b/src/main/java/mekanism/common/tile/TileEntityFluidTank.java index 7dbca4325c9..8ec3cdb129a 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFluidTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityFluidTank.java @@ -133,6 +133,7 @@ protected boolean onUpdateServer() { } float scale = MekanismUtils.getScale(prevScale, fluidTank); + //TODO - 1.21: Figure out handling of stacked tanks where it may be going back and forth between being full and not? if (MekanismUtils.scaleChanged(scale, prevScale)) { if (prevScale == 0 || scale == 0) { //If it was empty and no longer is, or wasn't empty and now is empty we want to recheck the block lighting @@ -206,6 +207,7 @@ public FluidStack insertFluid(@NotNull FluidStack stack, @Nullable Direction sid private FluidStack insertExcess(@NotNull FluidStack stack, @Nullable Direction side, @NotNull Action action, @NotNull FluidStack remainder) { if (side == Direction.UP && action.execute() && remainder.getAmount() < stack.getAmount() && !isRemote()) { if (valve == 0) { + //TODO - 1.21: Only mark it as needing a packet if our fluid tank volume is below a certain amount?? needsPacket = true; } valve = SharedConstants.TICKS_PER_SECOND; diff --git a/src/tools/java/mekanism/tools/client/recipe_viewer/aliases/ToolsAliasMapping.java b/src/tools/java/mekanism/tools/client/recipe_viewer/aliases/ToolsAliasMapping.java new file mode 100644 index 00000000000..d4dadb1c1ee --- /dev/null +++ b/src/tools/java/mekanism/tools/client/recipe_viewer/aliases/ToolsAliasMapping.java @@ -0,0 +1,39 @@ +package mekanism.tools.client.recipe_viewer.aliases; + +import mekanism.api.text.IHasTranslationKey; +import mekanism.client.recipe_viewer.alias.IAliasMapping; +import mekanism.client.recipe_viewer.alias.MekanismAliases; +import mekanism.client.recipe_viewer.alias.RVAliasHelper; +import mekanism.tools.common.registries.ToolsItems; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.ItemLike; + +public class ToolsAliasMapping implements IAliasMapping { + + @Override + public void addAliases(RVAliasHelper rv) { + addVanillaPaxelAliases(rv, ToolsItems.WOOD_PAXEL, Items.WOODEN_AXE, Items.WOODEN_PICKAXE, Items.WOODEN_SHOVEL); + addVanillaPaxelAliases(rv, ToolsItems.STONE_PAXEL, Items.STONE_AXE, Items.STONE_PICKAXE, Items.STONE_SHOVEL); + addVanillaPaxelAliases(rv, ToolsItems.GOLD_PAXEL, Items.GOLDEN_AXE, Items.GOLDEN_PICKAXE, Items.GOLDEN_SHOVEL); + addVanillaPaxelAliases(rv, ToolsItems.IRON_PAXEL, Items.IRON_AXE, Items.IRON_PICKAXE, Items.IRON_SHOVEL); + addVanillaPaxelAliases(rv, ToolsItems.DIAMOND_PAXEL, Items.DIAMOND_AXE, Items.DIAMOND_PICKAXE, Items.DIAMOND_SHOVEL); + addVanillaPaxelAliases(rv, ToolsItems.NETHERITE_PAXEL, Items.NETHERITE_AXE, Items.NETHERITE_PICKAXE, Items.NETHERITE_SHOVEL); + + addPaxelAliases(rv, ToolsItems.BRONZE_PAXEL, ToolsItems.BRONZE_AXE, ToolsItems.BRONZE_PICKAXE, ToolsItems.BRONZE_SHOVEL); + addPaxelAliases(rv, ToolsItems.LAPIS_LAZULI_PAXEL, ToolsItems.LAPIS_LAZULI_AXE, ToolsItems.LAPIS_LAZULI_PICKAXE, ToolsItems.LAPIS_LAZULI_SHOVEL); + addPaxelAliases(rv, ToolsItems.OSMIUM_PAXEL, ToolsItems.OSMIUM_AXE, ToolsItems.OSMIUM_PICKAXE, ToolsItems.OSMIUM_SHOVEL); + addPaxelAliases(rv, ToolsItems.REFINED_GLOWSTONE_PAXEL, ToolsItems.REFINED_GLOWSTONE_AXE, ToolsItems.REFINED_GLOWSTONE_PICKAXE, ToolsItems.REFINED_GLOWSTONE_SHOVEL); + addPaxelAliases(rv, ToolsItems.REFINED_OBSIDIAN_PAXEL, ToolsItems.REFINED_OBSIDIAN_AXE, ToolsItems.REFINED_OBSIDIAN_PICKAXE, ToolsItems.REFINED_OBSIDIAN_SHOVEL); + addPaxelAliases(rv, ToolsItems.STEEL_PAXEL, ToolsItems.STEEL_AXE, ToolsItems.STEEL_PICKAXE, ToolsItems.STEEL_SHOVEL); + } + + private void addPaxelAliases(RVAliasHelper rv, ItemLike paxel, IHasTranslationKey axe, IHasTranslationKey pickaxe, + IHasTranslationKey shovel) { + rv.addAliases(paxel, axe, pickaxe, shovel, MekanismAliases.TOOL_MULTI); + } + + private void addVanillaPaxelAliases(RVAliasHelper rv, ItemLike paxel, Item axe, Item pickaxe, Item shovel) { + addPaxelAliases(rv, paxel, axe::getDescriptionId, pickaxe::getDescriptionId, shovel::getDescriptionId); + } +} \ No newline at end of file diff --git a/src/datagen/tools/java/mekanism/tools/client/integration/ToolsAliases.java b/src/tools/java/mekanism/tools/client/recipe_viewer/aliases/ToolsAliases.java similarity index 83% rename from src/datagen/tools/java/mekanism/tools/client/integration/ToolsAliases.java rename to src/tools/java/mekanism/tools/client/recipe_viewer/aliases/ToolsAliases.java index 4a0054d5e8d..5e277ed3a3d 100644 --- a/src/datagen/tools/java/mekanism/tools/client/integration/ToolsAliases.java +++ b/src/tools/java/mekanism/tools/client/recipe_viewer/aliases/ToolsAliases.java @@ -1,7 +1,7 @@ -package mekanism.tools.client.integration; +package mekanism.tools.client.recipe_viewer.aliases; import mekanism.api.annotations.NothingNullByDefault; -import mekanism.client.integration.IAliasedTranslation; +import mekanism.client.recipe_viewer.alias.IAliasedTranslation; import mekanism.tools.common.MekanismTools; import net.minecraft.Util; diff --git a/src/tools/java/mekanism/tools/client/jei/ToolsJEI.java b/src/tools/java/mekanism/tools/client/recipe_viewer/jei/ToolsJEI.java similarity index 97% rename from src/tools/java/mekanism/tools/client/jei/ToolsJEI.java rename to src/tools/java/mekanism/tools/client/recipe_viewer/jei/ToolsJEI.java index 940a571118f..630c9d40736 100644 --- a/src/tools/java/mekanism/tools/client/jei/ToolsJEI.java +++ b/src/tools/java/mekanism/tools/client/recipe_viewer/jei/ToolsJEI.java @@ -1,4 +1,4 @@ -package mekanism.tools.client.jei; +package mekanism.tools.client.recipe_viewer.jei; import mekanism.client.recipe_viewer.jei.MekanismJEI; import mekanism.client.recipe_viewer.jei.RecipeRegistryHelper;