Skip to content

Commit 74ba83a

Browse files
committed
Fix game no launching due to forgetting to register the new ingredient registries
1 parent 70ee523 commit 74ba83a

File tree

5 files changed

+28
-11
lines changed

5 files changed

+28
-11
lines changed

src/api/java/mekanism/api/MekanismAPI.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,11 @@ private static <T> ResourceKey<Registry<MapCodec<? extends T>>> codecRegistryKey
230230
*/
231231
public static final Registry<MapCodec<? extends RobitSkin>> ROBIT_SKIN_SERIALIZER_REGISTRY = new RegistryBuilder<>(ROBIT_SKIN_SERIALIZER_REGISTRY_NAME).create();
232232

233-
//TODO - 1.20.5: Docs
233+
/**
234+
* Constant location representing the name all empty chemicals will be registered under.
235+
*
236+
* @since 10.6.0
237+
*/
234238
public static final ResourceLocation EMPTY_CHEMICAL_NAME = new ResourceLocation(MEKANISM_MODID, "empty");
235239

236240
//TODO: Potentially define these with DeferredHolder for purposes of fully defining them outside of the API

src/api/java/mekanism/api/chemical/Chemical.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,12 @@ public Stream<TagKey<CHEMICAL>> getTags() {
255255
return getAsHolder().tags();
256256
}
257257

258-
//TODO - 1.20.5: Docs
258+
/**
259+
* Helper method to get the holder for this chemical. Unlike {@link net.minecraft.world.item.Item#builtInRegistryHolder()} and similar, this looks up the holder from
260+
* the registry when called.
261+
*
262+
* @since 10.6.0
263+
*/
259264
public Holder<CHEMICAL> getAsHolder() {
260265
return getRegistry().wrapAsHolder((CHEMICAL) this);
261266
}

src/main/java/mekanism/common/Mekanism.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ private void registerRegistries(NewRegistryEvent event) {
267267
event.register(MekanismAPI.INFUSE_TYPE_REGISTRY);
268268
event.register(MekanismAPI.PIGMENT_REGISTRY);
269269
event.register(MekanismAPI.SLURRY_REGISTRY);
270+
event.register(MekanismAPI.GAS_INGREDIENT_TYPES);
271+
event.register(MekanismAPI.INFUSION_INGREDIENT_TYPES);
272+
event.register(MekanismAPI.PIGMENT_INGREDIENT_TYPES);
273+
event.register(MekanismAPI.SLURRY_INGREDIENT_TYPES);
270274
event.register(MekanismAPI.MODULE_REGISTRY);
271275
event.register(MekanismAPI.ROBIT_SKIN_SERIALIZER_REGISTRY);
272276
}

src/main/java/mekanism/common/integration/crafttweaker/ingredient/CrTItemStackIngredient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public static ItemStackIngredient or(ItemStackIngredient _this, ItemStackIngredi
233233
}
234234

235235
private static void addIngredient(List<Ingredient> ingredients, Ingredient ingredient) {
236-
if (ingredient.isCustom() && ingredient.getCustomIngredient() instanceof CompoundIngredient compoundIngredient) {
236+
if (ingredient.getCustomIngredient() instanceof CompoundIngredient compoundIngredient) {
237237
ingredients.addAll(compoundIngredient.children());
238238
} else {
239239
ingredients.add(ingredient);

src/main/java/mekanism/common/recipe/ingredients/ChemicalIngredientUtil.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ private ChemicalIngredientUtil() {
2121
}
2222

2323
//TODO - 1.20.5: Test this
24+
@SuppressWarnings("unchecked")
2425
public static <CHEMICAL extends Chemical<CHEMICAL>, INGREDIENT extends IChemicalIngredient<CHEMICAL, INGREDIENT>, SINGLE extends SingleChemicalIngredient<CHEMICAL, INGREDIENT>,
2526
TAG extends TagChemicalIngredient<CHEMICAL, INGREDIENT>> MapCodec<INGREDIENT> singleOrTagCodec(MapCodec<SINGLE> singleCodec, MapCodec<TAG> tagCodec) {
26-
return NeoForgeExtraCodecs.xor(singleCodec, tagCodec).xmap(either -> either.map(i -> (INGREDIENT) i, i -> (INGREDIENT) i), ingredient -> {
27-
if (ingredient instanceof SingleChemicalIngredient) {
28-
return Either.left((SINGLE) ingredient);
29-
} else if (ingredient instanceof TagChemicalIngredient) {
30-
return Either.right((TAG) ingredient);
31-
}
32-
throw new IllegalStateException("Basic chemical ingredient should be either a chemical or a tag!");
33-
});
27+
return NeoForgeExtraCodecs.xor(singleCodec, tagCodec).flatXmap(
28+
either -> DataResult.success(either.map(i -> (INGREDIENT) i, i -> (INGREDIENT) i)),
29+
ingredient -> {
30+
if (ingredient instanceof SingleChemicalIngredient) {
31+
return DataResult.success(Either.left((SINGLE) ingredient));
32+
} else if (ingredient instanceof TagChemicalIngredient) {
33+
return DataResult.success(Either.right((TAG) ingredient));
34+
}
35+
return DataResult.error(() -> "Basic chemical ingredient should be either a chemical or a tag!");
36+
});
3437
}
3538

3639
@SuppressWarnings("RedundantTypeArguments")
@@ -54,6 +57,7 @@ public static <CHEMICAL extends Chemical<CHEMICAL>, INGREDIENT extends IChemical
5457
});
5558
}
5659

60+
@SuppressWarnings("unchecked")
5761
public static <CHEMICAL extends Chemical<CHEMICAL>, INGREDIENT extends IChemicalIngredient<CHEMICAL, INGREDIENT>> Codec<INGREDIENT> codec(Codec<List<INGREDIENT>> listCodec,
5862
Codec<INGREDIENT> mapCodecCodec, Function<List<? extends INGREDIENT>, INGREDIENT> compoundCreator) {
5963
// [{...}, {...}] is turned into a CompoundChemicalIngredient instance

0 commit comments

Comments
 (0)