Updates backend dependencies and fixes amber random DNA implementation

This commit is contained in:
2026-06-09 21:18:11 -04:00
parent 51191fa245
commit 5786bfec65
13 changed files with 139 additions and 57 deletions
@@ -164,10 +164,34 @@ public class ForgeRecipeProvider extends RecipeProvider implements ModRecipeProv
.save(output);
}
@Override
public void amberRandomDNA(ItemLike testTube, ItemLike amber, ItemLike defaultDna, int count) {
DNAExtractingRecipeBuilder.amberRandomDNAUniform(testTube, amber, defaultDna, count)
.unlockedBy("has_amber", has(amber))
.save(output);
}
@Override
public void amberRandomDNA(ItemLike testTube, ItemLike amber, ItemLike defaultDna, Object... weightedDnaAndCount) {
int count = getAmberRandomDNACount(weightedDnaAndCount);
DNAExtractingRecipeBuilder builder = DNAExtractingRecipeBuilder.amberRandomDNAUniform(testTube, amber, defaultDna, count);
addAmberRandomDNAWeights(builder, weightedDnaAndCount);
builder.unlockedBy("has_amber", has(amber))
.save(output);
}
private static int getAmberRandomDNACount(Object... weightedDnaAndCount) {
if (weightedDnaAndCount.length == 0 || !(weightedDnaAndCount[weightedDnaAndCount.length - 1] instanceof Number count)) {
throw new IllegalArgumentException("amberRandomDNA requires the final argument to be the recipe count");
}
return count.intValue();
}
private static void addAmberRandomDNAWeights(DNAExtractingRecipeBuilder builder, Object... weightedDnaAndCount) {
if ((weightedDnaAndCount.length - 1) % 2 != 0) {
throw new IllegalArgumentException("amberRandomDNA weights must be provided as ItemLike, weight pairs before the count");
}
for (int i = 0; i < weightedDnaAndCount.length - 1; i += 2) {
if (!(weightedDnaAndCount[i] instanceof ItemLike dnaItem) || !(weightedDnaAndCount[i + 1] instanceof Number weight)) {
throw new IllegalArgumentException("amberRandomDNA weights must be provided as ItemLike, weight pairs before the count");
}
builder.addDNAWeight(dnaItem, weight.intValue());
}
}
}