99import dev .emi .emi .api .recipe .VanillaEmiRecipeCategories ;
1010import dev .emi .emi .api .stack .Comparison ;
1111import dev .emi .emi .api .stack .EmiIngredient ;
12+ import dev .emi .emi .api .stack .EmiRegistryAdapter ;
1213import dev .emi .emi .api .stack .EmiStack ;
1314import java .util .ArrayList ;
1415import java .util .Collection ;
@@ -98,26 +99,30 @@ public class MekanismEmi implements EmiPlugin {
9899
99100 @ SuppressWarnings ("Convert2Diamond" )//Can't be detected properly
100101 private static final ChemicalEmiIngredientSerializer <Gas , GasEmiStack > GAS_SERIALIZER = new ChemicalEmiIngredientSerializer <Gas , GasEmiStack >("Gas" , MekanismAPI .GAS_REGISTRY , GasEmiStack ::new );
102+ private static final EmiRegistryAdapter <Gas > GAS_REGISTRY_ADAPTER = EmiRegistryAdapter .simple (Gas .class , MekanismAPI .GAS_REGISTRY , GasEmiStack ::new );
101103 @ SuppressWarnings ("Convert2Diamond" )//Can't be detected properly
102104 private static final ChemicalEmiIngredientSerializer <InfuseType , InfusionEmiStack > INFUSION_SERIALIZER = new ChemicalEmiIngredientSerializer <InfuseType , InfusionEmiStack >("Infuse Type" , MekanismAPI .INFUSE_TYPE_REGISTRY , InfusionEmiStack ::new );
105+ private static final EmiRegistryAdapter <InfuseType > INFUSE_TYPE_REGISTRY_ADAPTER = EmiRegistryAdapter .simple (InfuseType .class , MekanismAPI .INFUSE_TYPE_REGISTRY , InfusionEmiStack ::new );
103106 @ SuppressWarnings ("Convert2Diamond" )//Can't be detected properly
104107 private static final ChemicalEmiIngredientSerializer <Pigment , PigmentEmiStack > PIGMENT_SERIALIZER = new ChemicalEmiIngredientSerializer <Pigment , PigmentEmiStack >("Pigment" , MekanismAPI .PIGMENT_REGISTRY , PigmentEmiStack ::new );
108+ private static final EmiRegistryAdapter <Pigment > PIGMENT_REGISTRY_ADAPTER = EmiRegistryAdapter .simple (Pigment .class , MekanismAPI .PIGMENT_REGISTRY , PigmentEmiStack ::new );
105109 @ SuppressWarnings ("Convert2Diamond" )//Can't be detected properly
106110 private static final ChemicalEmiIngredientSerializer <Slurry , SlurryEmiStack > SLURRY_SERIALIZER = new ChemicalEmiIngredientSerializer <Slurry , SlurryEmiStack >("Slurry" , MekanismAPI .SLURRY_REGISTRY , SlurryEmiStack ::new );
111+ private static final EmiRegistryAdapter <Slurry > SLURRY_REGISTRY_ADAPTER = EmiRegistryAdapter .simple (Slurry .class , MekanismAPI .SLURRY_REGISTRY , SlurryEmiStack ::new );
107112
108- //TODO - 1.20.4: I believe this doesn't work because of https://github.com/emilyploszaj/emi/issues/475
109113 private static final Comparison MEKANISM_COMPARISON = Comparison .compareData (emiStack -> {
110- ItemStack stack = emiStack .getItemStack ();
111114 //TODO - 1.20.5: Re-evaluate if we want the components check or if it should check it slightly differently?
112- if (!stack . getComponents ().isEmpty ()) {
115+ if (!emiStack . getComponentChanges ().isEmpty ()) {
113116 Set <Object > representation = new HashSet <>();
117+ ItemStack stack = emiStack .getItemStack ();
114118 addChemicalComponent (representation , stack , ContainerType .GAS , Capabilities .GAS .item ());
115119 addChemicalComponent (representation , stack , ContainerType .INFUSION , Capabilities .INFUSION .item ());
116120 addChemicalComponent (representation , stack , ContainerType .PIGMENT , Capabilities .PIGMENT .item ());
117121 addChemicalComponent (representation , stack , ContainerType .SLURRY , Capabilities .SLURRY .item ());
118122 addFluidComponent (representation , stack );
119123 addEnergyComponent (representation , stack );
120124 if (!representation .isEmpty ()) {
125+
121126 return representation ;
122127 }
123128 }
@@ -204,7 +209,11 @@ public void initialize(EmiInitRegistry registry) {
204209 registry .addIngredientSerializer (InfusionEmiStack .class , INFUSION_SERIALIZER );
205210 registry .addIngredientSerializer (PigmentEmiStack .class , PIGMENT_SERIALIZER );
206211 registry .addIngredientSerializer (SlurryEmiStack .class , SLURRY_SERIALIZER );
207- //TODO - 1.20.4: Add a support for tag ingredients https://github.com/emilyploszaj/emi/issues/483
212+ //TODO - 1.20.5: Test this works properly for getting things to display as tags
213+ registry .addRegistryAdapter (GAS_REGISTRY_ADAPTER );
214+ registry .addRegistryAdapter (INFUSE_TYPE_REGISTRY_ADAPTER );
215+ registry .addRegistryAdapter (PIGMENT_REGISTRY_ADAPTER );
216+ registry .addRegistryAdapter (SLURRY_REGISTRY_ADAPTER );
208217 }
209218
210219 private <CHEMICAL extends Chemical <CHEMICAL >> void addEmiStacks (EmiRegistry emiRegistry , ChemicalEmiIngredientSerializer <CHEMICAL , ?> serializer ) {
@@ -217,7 +226,6 @@ private <CHEMICAL extends Chemical<CHEMICAL>> void addEmiStacks(EmiRegistry emiR
217226
218227 @ Override
219228 public void register (EmiRegistry registry ) {
220- //TODO - 1.20.4: Tooltips in EMI in mekanism screens render behind the items rendered in EMI https://github.com/emilyploszaj/emi/issues/480
221229 addEmiStacks (registry , GAS_SERIALIZER );
222230 addEmiStacks (registry , INFUSION_SERIALIZER );
223231 addEmiStacks (registry , PIGMENT_SERIALIZER );
0 commit comments