Skip to content

Commit

Permalink
Merge all four chemical types into a singlular registry and type call…
Browse files Browse the repository at this point in the history
…ed chemical (#8196)

- Slightly adjusted IChemicalHandler to allow direct implementation alongside implementing IFluidHandler (method clashes)
- Removed all Boxed Types relating to chemicals
- Added Infusion recipes to the Chemical Oxidizer
- Added a per_tick_usage field that determines if the chemical is used each tick or only when finished to the nucleosynthesizing, compressing, injecting, metallurgic infusing, puriffying, and painting recipes
- Unified various names in recipes (old syntax ones that changed will not be able to load)

Old world data should load mostly fine with the following known exceptions:
- Chemical Dissolution Chamber items that have contents in multiple tanks will lose the stored contents
- Quantum Entangloporters that are transferring multiple different chemical types will have the first type win out

---------

Co-authored-by: Sara Freimer <[email protected]>
  • Loading branch information
thiakil and pupnewfster authored Aug 20, 2024
1 parent c08a1b7 commit b74b68b
Show file tree
Hide file tree
Showing 1,618 changed files with 14,013 additions and 28,957 deletions.
76 changes: 8 additions & 68 deletions src/api/java/mekanism/api/IMekanismAccess.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
package mekanism.api;

import java.util.ServiceLoader;
import mekanism.api.chemical.gas.Gas;
import mekanism.api.chemical.gas.GasStack;
import mekanism.api.chemical.infuse.InfuseType;
import mekanism.api.chemical.infuse.InfusionStack;
import mekanism.api.chemical.pigment.Pigment;
import mekanism.api.chemical.pigment.PigmentStack;
import mekanism.api.chemical.slurry.Slurry;
import mekanism.api.chemical.slurry.SlurryStack;
import mekanism.api.integration.emi.IMekanismEmiHelper;
import mekanism.api.integration.jei.IMekanismJEIHelper;
import mekanism.api.recipes.ingredients.GasStackIngredient;
import mekanism.api.recipes.ingredients.InfusionStackIngredient;
import mekanism.api.recipes.ingredients.PigmentStackIngredient;
import mekanism.api.recipes.ingredients.SlurryStackIngredient;
import mekanism.api.recipes.ingredients.chemical.IGasIngredient;
import mekanism.api.recipes.ingredients.chemical.IInfusionIngredient;
import mekanism.api.recipes.ingredients.chemical.IPigmentIngredient;
import mekanism.api.recipes.ingredients.chemical.ISlurryIngredient;
import mekanism.api.recipes.ingredients.creator.IChemicalIngredientCreator;
import mekanism.api.recipes.ingredients.creator.IChemicalStackIngredientCreator;
import mekanism.api.recipes.ingredients.creator.IFluidStackIngredientCreator;
Expand Down Expand Up @@ -66,62 +50,18 @@ public interface IMekanismAccess {
IFluidStackIngredientCreator fluidStackIngredientCreator();

/**
* Gets the gas stack ingredient creator.
* Gets the chemical stack ingredient creator.
*
* @apiNote Use {@link mekanism.api.recipes.ingredients.creator.IngredientCreatorAccess#gasStack()} instead.
* @apiNote Use {@link mekanism.api.recipes.ingredients.creator.IngredientCreatorAccess#chemicalStack()} instead.
* @since 10.7.0
*/
IChemicalStackIngredientCreator<Gas, GasStack, IGasIngredient, GasStackIngredient> gasStackIngredientCreator();
IChemicalStackIngredientCreator chemicalStackIngredientCreator();

/**
* Gets the gas ingredient creator.
* Gets the chemical ingredient creator.
*
* @apiNote Use {@link mekanism.api.recipes.ingredients.creator.IngredientCreatorAccess#gas()} instead.
* @since 10.6.0
* @apiNote Use {@link mekanism.api.recipes.ingredients.creator.IngredientCreatorAccess#chemical()} instead.
* @since 10.7.0
*/
IChemicalIngredientCreator<Gas, IGasIngredient> gasIngredientCreator();

/**
* Gets the infusion stack ingredient creator.
*
* @apiNote Use {@link mekanism.api.recipes.ingredients.creator.IngredientCreatorAccess#infusionStack()} instead.
*/
IChemicalStackIngredientCreator<InfuseType, InfusionStack, IInfusionIngredient, InfusionStackIngredient> infusionStackIngredientCreator();

/**
* Gets the infusion ingredient creator.
*
* @apiNote Use {@link mekanism.api.recipes.ingredients.creator.IngredientCreatorAccess#infusion()} instead.
* @since 10.6.0
*/
IChemicalIngredientCreator<InfuseType, IInfusionIngredient> infusionIngredientCreator();

/**
* Gets the pigment stack ingredient creator.
*
* @apiNote Use {@link mekanism.api.recipes.ingredients.creator.IngredientCreatorAccess#pigmentStack()} instead.
*/
IChemicalStackIngredientCreator<Pigment, PigmentStack, IPigmentIngredient, PigmentStackIngredient> pigmentStackIngredientCreator();

/**
* Gets the pigment ingredient creator.
*
* @apiNote Use {@link mekanism.api.recipes.ingredients.creator.IngredientCreatorAccess#pigment()} instead.
* @since 10.6.0
*/
IChemicalIngredientCreator<Pigment, IPigmentIngredient> pigmentIngredientCreator();

/**
* Gets the slurry stack ingredient creator.
*
* @apiNote Use {@link mekanism.api.recipes.ingredients.creator.IngredientCreatorAccess#slurryStack()} instead.
*/
IChemicalStackIngredientCreator<Slurry, SlurryStack, ISlurryIngredient, SlurryStackIngredient> slurryStackIngredientCreator();

/**
* Gets the slurry ingredient creator.
*
* @apiNote Use {@link mekanism.api.recipes.ingredients.creator.IngredientCreatorAccess#slurry()} instead.
* @since 10.6.0
*/
IChemicalIngredientCreator<Slurry, ISlurryIngredient> slurryIngredientCreator();
IChemicalIngredientCreator chemicalIngredientCreator();
}
174 changes: 30 additions & 144 deletions src/api/java/mekanism/api/MekanismAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,10 @@
import com.mojang.logging.LogUtils;
import com.mojang.serialization.MapCodec;
import mekanism.api.annotations.NothingNullByDefault;
import mekanism.api.chemical.gas.Gas;
import mekanism.api.chemical.gas.GasBuilder;
import mekanism.api.chemical.infuse.InfuseType;
import mekanism.api.chemical.infuse.InfuseTypeBuilder;
import mekanism.api.chemical.pigment.Pigment;
import mekanism.api.chemical.pigment.PigmentBuilder;
import mekanism.api.chemical.slurry.Slurry;
import mekanism.api.chemical.slurry.SlurryBuilder;
import mekanism.api.chemical.Chemical;
import mekanism.api.chemical.ChemicalBuilder;
import mekanism.api.gear.ModuleData;
import mekanism.api.recipes.ingredients.chemical.IGasIngredient;
import mekanism.api.recipes.ingredients.chemical.IInfusionIngredient;
import mekanism.api.recipes.ingredients.chemical.IPigmentIngredient;
import mekanism.api.recipes.ingredients.chemical.ISlurryIngredient;
import mekanism.api.recipes.ingredients.chemical.ChemicalIngredient;
import mekanism.api.robit.RobitSkin;
import net.minecraft.core.DefaultedRegistry;
import net.minecraft.core.Registry;
Expand All @@ -34,7 +25,7 @@ private MekanismAPI() {
/**
* The version of the api classes - may not always match the mod's version
*/
public static final String API_VERSION = "10.6.7";
public static final String API_VERSION = "10.7.0";
/**
* Mekanism's Mod ID
*/
Expand Down Expand Up @@ -68,61 +59,21 @@ private static <T> ResourceKey<Registry<MapCodec<? extends T>>> codecRegistryKey
public static final ResourceLocation EMPTY_CHEMICAL_NAME = rl("empty");

/**
* Gets the {@link ResourceKey} representing the name of the Registry for {@link Gas gases}.
* Gets the {@link ResourceKey} representing the name of the Registry for {@link Chemical chemicals}.
*
* @apiNote When registering {@link Gas gases} using {@link DeferredRegister}, use this field to get access to the {@link ResourceKey}.
* @since 10.4.0
*/
public static final ResourceKey<Registry<Gas>> GAS_REGISTRY_NAME = registryKey(Gas.class, "gas");
/**
* Gets the {@link ResourceKey} representing the name of the Registry for {@link IGasIngredient} ingredient type serializers.
*
* @apiNote When registering gas ingredient types using {@link DeferredRegister}, use this field to get access to the {@link ResourceKey}.
* @since 10.6.0
*/
public static final ResourceKey<Registry<MapCodec<? extends IGasIngredient>>> GAS_INGREDIENT_TYPE_REGISTRY_NAME = codecRegistryKey(IGasIngredient.class, "gas_ingredient_type");
/**
* Gets the {@link ResourceKey} representing the name of the Registry for {@link InfuseType infuse types}.
*
* @apiNote When registering {@link InfuseType infuse types} using {@link DeferredRegister}, use this field to get access to the {@link ResourceKey}.
* @since 10.4.0
*/
public static final ResourceKey<Registry<InfuseType>> INFUSE_TYPE_REGISTRY_NAME = registryKey(InfuseType.class, "infuse_type");
/**
* Gets the {@link ResourceKey} representing the name of the Registry for {@link IInfusionIngredient} ingredient type serializers.
*
* @apiNote When registering infusion ingredient types using {@link DeferredRegister}, use this field to get access to the {@link ResourceKey}.
* @since 10.6.0
*/
public static final ResourceKey<Registry<MapCodec<? extends IInfusionIngredient>>> INFUSION_INGREDIENT_TYPE_REGISTRY_NAME = codecRegistryKey(IInfusionIngredient.class, "infusion_ingredient_type");
/**
* Gets the {@link ResourceKey} representing the name of the Registry for {@link Pigment pigments}.
*
* @apiNote When registering {@link Pigment pigments} using {@link DeferredRegister}, use this field to get access to the {@link ResourceKey}.
* @since 10.4.0
*/
public static final ResourceKey<Registry<Pigment>> PIGMENT_REGISTRY_NAME = registryKey(Pigment.class, "pigment");
/**
* Gets the {@link ResourceKey} representing the name of the Registry for {@link IPigmentIngredient} ingredient type serializers.
*
* @apiNote When registering pigment ingredient types using {@link DeferredRegister}, use this field to get access to the {@link ResourceKey}.
* @since 10.6.0
*/
public static final ResourceKey<Registry<MapCodec<? extends IPigmentIngredient>>> PIGMENT_INGREDIENT_TYPE_REGISTRY_NAME = codecRegistryKey(IPigmentIngredient.class, "pigment_ingredient_type");
/**
* Gets the {@link ResourceKey} representing the name of the Registry for {@link Slurry sluries}.
*
* @apiNote When registering {@link Slurry sluries} using {@link DeferredRegister}, use this field to get access to the {@link ResourceKey}.
* @since 10.4.0
* @apiNote When registering {@link Chemical chemicals} using {@link DeferredRegister}, use this field to get access to the {@link ResourceKey}.
* @since 10.7.0
*/
public static final ResourceKey<Registry<Slurry>> SLURRY_REGISTRY_NAME = registryKey(Slurry.class, "slurry");
public static final ResourceKey<Registry<Chemical>> CHEMICAL_REGISTRY_NAME = registryKey(Chemical.class, "chemical");

/**
* Gets the {@link ResourceKey} representing the name of the Registry for {@link ISlurryIngredient} ingredient type serializers.
* Gets the {@link ResourceKey} representing the name of the Registry for {@link ChemicalIngredient} ingredient type serializers.
*
* @apiNote When registering slurry ingredient types using {@link DeferredRegister}, use this field to get access to the {@link ResourceKey}.
* @since 10.6.0
* @apiNote When registering chemical ingredient types using {@link DeferredRegister}, use this field to get access to the {@link ResourceKey}.
* @since 10.7.0
*/
public static final ResourceKey<Registry<MapCodec<? extends ISlurryIngredient>>> SLURRY_INGREDIENT_TYPE_REGISTRY_NAME = codecRegistryKey(ISlurryIngredient.class, "slurry_ingredient_type");
public static final ResourceKey<Registry<MapCodec<? extends ChemicalIngredient>>> CHEMICAL_INGREDIENT_TYPE_REGISTRY_NAME = codecRegistryKey(ChemicalIngredient.class, "chemical_ingredient_type");

/**
* Gets the {@link ResourceKey} representing the name of the Registry for {@link ModuleData modules}.
*
Expand All @@ -146,81 +97,26 @@ private static <T> ResourceKey<Registry<MapCodec<? extends T>>> codecRegistryKey
public static final ResourceKey<Registry<MapCodec<? extends RobitSkin>>> ROBIT_SKIN_SERIALIZER_REGISTRY_NAME = codecRegistryKey(RobitSkin.class, "robit_skin_serializer");

/**
* Gets the Registry for {@link Gas}.
* Gets the Registry for {@link Chemical}.
*
* @see #GAS_REGISTRY_NAME
* @since 10.5.0
* @see #CHEMICAL_REGISTRY_NAME
* @since 10.7.0
*/
public static final DefaultedRegistry<Gas> GAS_REGISTRY = (DefaultedRegistry<Gas>) new RegistryBuilder<>(GAS_REGISTRY_NAME)
public static final DefaultedRegistry<Chemical> CHEMICAL_REGISTRY = (DefaultedRegistry<Chemical>) new RegistryBuilder<>(CHEMICAL_REGISTRY_NAME)
.defaultKey(EMPTY_CHEMICAL_NAME)
.sync(true)
.create();

/**
* Gets the Registry for {@link IGasIngredient} type serializers.
*
* @see #GAS_INGREDIENT_TYPE_REGISTRY_NAME
* @since 10.6.0
*/
public static final Registry<MapCodec<? extends IGasIngredient>> GAS_INGREDIENT_TYPES = new RegistryBuilder<>(GAS_INGREDIENT_TYPE_REGISTRY_NAME)
.sync(true)
.create();
/**
* Gets the Registry for {@link InfuseType}.
*
* @see #INFUSE_TYPE_REGISTRY_NAME
* @since 10.5.0
*/
public static final DefaultedRegistry<InfuseType> INFUSE_TYPE_REGISTRY = (DefaultedRegistry<InfuseType>) new RegistryBuilder<>(INFUSE_TYPE_REGISTRY_NAME)
.defaultKey(EMPTY_CHEMICAL_NAME)
.sync(true)
.create();
/**
* Gets the Registry for {@link IInfusionIngredient} type serializers.
*
* @see #INFUSION_INGREDIENT_TYPE_REGISTRY_NAME
* @since 10.6.0
*/
public static final Registry<MapCodec<? extends IInfusionIngredient>> INFUSION_INGREDIENT_TYPES = new RegistryBuilder<>(INFUSION_INGREDIENT_TYPE_REGISTRY_NAME)
.sync(true)
.create();
/**
* Gets the Registry for {@link Pigment}.
*
* @see #PIGMENT_REGISTRY_NAME
* @since 10.5.0
*/
public static final DefaultedRegistry<Pigment> PIGMENT_REGISTRY = (DefaultedRegistry<Pigment>) new RegistryBuilder<>(PIGMENT_REGISTRY_NAME)
.defaultKey(EMPTY_CHEMICAL_NAME)
.sync(true)
.create();
/**
* Gets the Registry for {@link IPigmentIngredient} type serializers.
*
* @see #PIGMENT_INGREDIENT_TYPE_REGISTRY_NAME
* @since 10.6.0
*/
public static final Registry<MapCodec<? extends IPigmentIngredient>> PIGMENT_INGREDIENT_TYPES = new RegistryBuilder<>(PIGMENT_INGREDIENT_TYPE_REGISTRY_NAME)
.sync(true)
.create();
/**
* Gets the Registry for {@link Slurry}.
*
* @see #SLURRY_REGISTRY_NAME
* @since 10.5.0
*/
public static final DefaultedRegistry<Slurry> SLURRY_REGISTRY = (DefaultedRegistry<Slurry>) new RegistryBuilder<>(SLURRY_REGISTRY_NAME)
.defaultKey(EMPTY_CHEMICAL_NAME)
.sync(true)
.create();
/**
* Gets the Registry for {@link ISlurryIngredient} type serializers.
* Gets the Registry for {@link ChemicalIngredient} type serializers.
*
* @see #SLURRY_INGREDIENT_TYPE_REGISTRY_NAME
* @since 10.6.0
* @see #CHEMICAL_INGREDIENT_TYPE_REGISTRY_NAME
* @since 10.7.0
*/
public static final Registry<MapCodec<? extends ISlurryIngredient>> SLURRY_INGREDIENT_TYPES = new RegistryBuilder<>(SLURRY_INGREDIENT_TYPE_REGISTRY_NAME)
public static final Registry<MapCodec<? extends ChemicalIngredient>> CHEMICAL_INGREDIENT_TYPES = new RegistryBuilder<>(CHEMICAL_INGREDIENT_TYPE_REGISTRY_NAME)
.sync(true)
.create();

/**
* Gets the Registry for {@link ModuleData}.
*
Expand All @@ -239,22 +135,12 @@ private static <T> ResourceKey<Registry<MapCodec<? extends T>>> codecRegistryKey
public static final Registry<MapCodec<? extends RobitSkin>> ROBIT_SKIN_SERIALIZER_REGISTRY = new RegistryBuilder<>(ROBIT_SKIN_SERIALIZER_REGISTRY_NAME)
.create();

//TODO: Potentially define these with DeferredHolder for purposes of fully defining them outside of the API
// would have some minor issues with how the empty stacks are declared
/**
* Empty Gas instance.
*/
public static final Gas EMPTY_GAS = new Gas(GasBuilder.builder());
/**
* Empty Infuse Type instance.
*/
public static final InfuseType EMPTY_INFUSE_TYPE = new InfuseType(InfuseTypeBuilder.builder());
//TODO: Potentially define this with DeferredHolder for purposes of fully defining them outside of the API
/**
* Empty Pigment instance.
*/
public static final Pigment EMPTY_PIGMENT = new Pigment(PigmentBuilder.builder());
/**
* Empty Slurry instance.
* Empty Chemical instance.
*
* @since 10.7.0
*/
public static final Slurry EMPTY_SLURRY = new Slurry(SlurryBuilder.clean());
public static final Chemical EMPTY_CHEMICAL = new Chemical(ChemicalBuilder.builder());

}
Loading

0 comments on commit b74b68b

Please sign in to comment.