Fixed Fluid Transformation recipes requiring byproducts

This commit is contained in:
thedarkcolour 2025-01-05 16:27:56 -08:00
parent ed89544011
commit 2efbfb676f
No known key found for this signature in database
GPG Key ID: 6599A8E0516C8F38
3 changed files with 9 additions and 1 deletions

View File

@ -1,5 +1,6 @@
## Ex Deorum 3.5
- Remove Yellorium Dust sieve drop (#116)
- Fixed Fluid Transformation recipes requiring byproducts
## Ex Deorum 3.4
- Fix JEI bug with sieve recipes overflowing due to JEI API changes

View File

@ -34,6 +34,8 @@ import java.util.function.Function;
// much simpler version of SimpleWeightedRandomList that supports .equals
public class WeightedList<T> {
private static final WeightedList<Object> EMPTY = new WeightedList<>(0, new Object[0], new int[0]);
private final int totalWeight;
private final Object[] values;
private final int[] weights;
@ -134,6 +136,11 @@ public class WeightedList<T> {
return new Builder<>();
}
@SuppressWarnings("unchecked")
public static <T> WeightedList<T> empty() {
return (WeightedList<T>) EMPTY;
}
public static class Builder<T> {
private final ArrayList<T> values = new ArrayList<>();
private final IntArrayList weights = new IntArrayList();

View File

@ -57,7 +57,7 @@ public record FluidTransformationRecipe(
CodecUtil.fluidField("result_fluid", FluidTransformationRecipe::resultFluid),
Codec.INT.fieldOf("result_color").forGetter(FluidTransformationRecipe::resultColor),
BlockPredicate.CODEC.fieldOf("catalyst").forGetter(FluidTransformationRecipe::catalyst),
WeightedList.codec(Codec.STRING.xmap(RecipeUtil::parseBlockState, RecipeUtil::writeBlockState)).fieldOf("byproducts").forGetter(FluidTransformationRecipe::byproducts),
WeightedList.codec(Codec.STRING.xmap(RecipeUtil::parseBlockState, RecipeUtil::writeBlockState)).optionalFieldOf("byproducts", WeightedList.empty()).forGetter(FluidTransformationRecipe::byproducts),
Codec.INT.fieldOf("duration").forGetter(FluidTransformationRecipe::duration)
).apply(instance, FluidTransformationRecipe::new));
public static final StreamCodec<RegistryFriendlyByteBuf, FluidTransformationRecipe> STREAM_CODEC = StreamCodec.of(FluidTransformationRecipe::toNetwork, FluidTransformationRecipe::fromNetwork);