Changelog
Fixed all machines missing their id field in the recipe record, which fixes JEI
This commit is contained in:
@@ -29,6 +29,7 @@ import net.minecraft.core.RegistryAccess;
|
||||
/*?}*/
|
||||
|
||||
public record DNAAnalyzerRecipe(
|
||||
ResourceLocation id,
|
||||
NonNullList<Ingredient> inputs,
|
||||
ItemStack output,
|
||||
java.util.Map<ResourceLocation, Integer> weights
|
||||
@@ -73,7 +74,7 @@ public record DNAAnalyzerRecipe(
|
||||
public ResourceLocation getId() {
|
||||
// In 1.20.1, the ID was stored. In 1.21.1, it's handled by the registry.
|
||||
// If you need the ID specifically in 1.20.1, you'd need to add it to the record.
|
||||
return Constants.rl("dna_analyzing");
|
||||
return id;
|
||||
}
|
||||
/*?}*/
|
||||
|
||||
@@ -126,14 +127,14 @@ public record DNAAnalyzerRecipe(
|
||||
NonNullList<Ingredient> inputs = NonNullList.withSize(2, Ingredient.EMPTY);
|
||||
for (int i = 0; i < 2; i++) inputs.set(i, Ingredient.fromJson(ingredients.get(i)));
|
||||
ItemStack output = ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "result"));
|
||||
return new DNAAnalyzerRecipe(inputs, output, java.util.Map.of()); // Weights logic can be added here
|
||||
return new DNAAnalyzerRecipe(id, inputs, output, java.util.Map.of()); // Weights logic can be added here
|
||||
}
|
||||
|
||||
@Override
|
||||
public DNAAnalyzerRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf buf) {
|
||||
NonNullList<Ingredient> inputs = NonNullList.withSize(buf.readInt(), Ingredient.EMPTY);
|
||||
for (int i = 0; i < inputs.size(); i++) inputs.set(i, Ingredient.fromNetwork(buf));
|
||||
return new DNAAnalyzerRecipe(inputs, buf.readItem(), java.util.Map.of());
|
||||
return new DNAAnalyzerRecipe(id, inputs, buf.readItem(), java.util.Map.of());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,6 +32,7 @@ import net.minecraft.core.RegistryAccess;
|
||||
/*?}*/
|
||||
|
||||
public record DNAExtractorRecipe(
|
||||
ResourceLocation id,
|
||||
NonNullList<Ingredient> inputs,
|
||||
ItemStack output,
|
||||
java.util.Map<ResourceLocation, Integer> weights
|
||||
@@ -86,7 +87,7 @@ public record DNAExtractorRecipe(
|
||||
*//*?} else {*/
|
||||
@Override public ItemStack assemble(DNAExtractorRecipeInput input, RegistryAccess a) { return handleAmberExtraction(input); }
|
||||
@Override public ItemStack getResultItem(RegistryAccess a) { return output.copy(); }
|
||||
@Override public ResourceLocation getId() { return Constants.rl("dna_extracting"); }
|
||||
@Override public ResourceLocation getId() { return id; }
|
||||
/*?}*/
|
||||
|
||||
@Override public boolean canCraftInDimensions(int w, int h) { return true; }
|
||||
@@ -130,12 +131,12 @@ public record DNAExtractorRecipe(
|
||||
JsonArray ingredients = GsonHelper.getAsJsonArray(json, "ingredients");
|
||||
NonNullList<Ingredient> inputs = NonNullList.withSize(2, Ingredient.EMPTY);
|
||||
for (int i = 0; i < 2; i++) inputs.set(i, Ingredient.fromJson(ingredients.get(i)));
|
||||
return new DNAExtractorRecipe(inputs, ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "result")), java.util.Map.of());
|
||||
return new DNAExtractorRecipe(id, inputs, ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "result")), java.util.Map.of());
|
||||
}
|
||||
@Override public DNAExtractorRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf buf) {
|
||||
NonNullList<Ingredient> inputs = NonNullList.withSize(buf.readInt(), Ingredient.EMPTY);
|
||||
for (int i = 0; i < inputs.size(); i++) inputs.set(i, Ingredient.fromNetwork(buf));
|
||||
return new DNAExtractorRecipe(inputs, buf.readItem(), java.util.Map.of());
|
||||
return new DNAExtractorRecipe(id, inputs, buf.readItem(), java.util.Map.of());
|
||||
}
|
||||
@Override public void toNetwork(FriendlyByteBuf buf, DNAExtractorRecipe recipe) {
|
||||
buf.writeInt(recipe.inputs().size());
|
||||
|
||||
@@ -28,7 +28,7 @@ import net.minecraft.util.GsonHelper;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
/*?}*/
|
||||
|
||||
public record DNAHybridizerRecipe(NonNullList<Ingredient> inputs, ItemStack output) implements Recipe<DNAHybridizerRecipeInput> {
|
||||
public record DNAHybridizerRecipe(ResourceLocation id, NonNullList<Ingredient> inputs, ItemStack output) implements Recipe<DNAHybridizerRecipeInput> {
|
||||
|
||||
@Override
|
||||
public NonNullList<Ingredient> getIngredients() {
|
||||
@@ -78,7 +78,7 @@ public record DNAHybridizerRecipe(NonNullList<Ingredient> inputs, ItemStack outp
|
||||
*//*?} else {*/
|
||||
@Override public ItemStack assemble(DNAHybridizerRecipeInput input, RegistryAccess a) { return output.copy(); }
|
||||
@Override public ItemStack getResultItem(RegistryAccess a) { return output.copy(); }
|
||||
@Override public ResourceLocation getId() { return Constants.rl("dna_hybridizing"); }
|
||||
@Override public ResourceLocation getId() { return id; }
|
||||
/*?}*/
|
||||
|
||||
@Override public boolean canCraftInDimensions(int w, int h) { return true; }
|
||||
@@ -117,12 +117,12 @@ public record DNAHybridizerRecipe(NonNullList<Ingredient> inputs, ItemStack outp
|
||||
NonNullList<Ingredient> inputs = NonNullList.withSize(9, Ingredient.EMPTY);
|
||||
for (int i = 0; i < Math.min(ings.size(), 8); i++) inputs.set(i, Ingredient.fromJson(ings.get(i)));
|
||||
if (json.has("catalyst")) inputs.set(8, Ingredient.fromJson(json.get("catalyst")));
|
||||
return new DNAHybridizerRecipe(inputs, ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "result")));
|
||||
return new DNAHybridizerRecipe(id, inputs, ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "result")));
|
||||
}
|
||||
@Override public DNAHybridizerRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf buf) {
|
||||
NonNullList<Ingredient> inputs = NonNullList.withSize(9, Ingredient.EMPTY);
|
||||
for (int i = 0; i < 9; i++) inputs.set(i, Ingredient.fromNetwork(buf));
|
||||
return new DNAHybridizerRecipe(inputs, buf.readItem());
|
||||
return new DNAHybridizerRecipe(id, inputs, buf.readItem());
|
||||
}
|
||||
@Override public void toNetwork(FriendlyByteBuf buf, DNAHybridizerRecipe r) {
|
||||
for (int i = 0; i < 9; i++) (i < r.inputs().size() ? r.inputs().get(i) : Ingredient.EMPTY).toNetwork(buf);
|
||||
|
||||
+4
-4
@@ -25,7 +25,7 @@ import net.minecraft.util.GsonHelper;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
/*?}*/
|
||||
|
||||
public record EmbryoCalcificationMachineRecipe(NonNullList<Ingredient> inputs, ItemStack output)
|
||||
public record EmbryoCalcificationMachineRecipe(ResourceLocation id, NonNullList<Ingredient> inputs, ItemStack output)
|
||||
implements Recipe<EmbryoCalcificationMachineRecipeInput> {
|
||||
|
||||
@Override
|
||||
@@ -53,7 +53,7 @@ public record EmbryoCalcificationMachineRecipe(NonNullList<Ingredient> inputs, I
|
||||
*//*?} else {*/
|
||||
@Override public ItemStack assemble(EmbryoCalcificationMachineRecipeInput input, RegistryAccess a) { return output.copy(); }
|
||||
@Override public ItemStack getResultItem(RegistryAccess a) { return output.copy(); }
|
||||
@Override public ResourceLocation getId() { return Constants.rl("embryonic_machining"); }
|
||||
@Override public ResourceLocation getId() { return id; }
|
||||
/*?}*/
|
||||
|
||||
@Override public boolean canCraftInDimensions(int width, int height) { return true; }
|
||||
@@ -91,12 +91,12 @@ public record EmbryoCalcificationMachineRecipe(NonNullList<Ingredient> inputs, I
|
||||
NonNullList<Ingredient> inputs = NonNullList.withSize(2, Ingredient.EMPTY);
|
||||
for (int i = 0; i < 2; i++) inputs.set(i, Ingredient.fromJson(ingredients.get(i)));
|
||||
ItemStack output = ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "result"));
|
||||
return new EmbryoCalcificationMachineRecipe(inputs, output);
|
||||
return new EmbryoCalcificationMachineRecipe(id, inputs, output);
|
||||
}
|
||||
@Override public EmbryoCalcificationMachineRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf buf) {
|
||||
NonNullList<Ingredient> inputs = NonNullList.withSize(buf.readInt(), Ingredient.EMPTY);
|
||||
for (int i = 0; i < inputs.size(); i++) inputs.set(i, Ingredient.fromNetwork(buf));
|
||||
return new EmbryoCalcificationMachineRecipe(inputs, buf.readItem());
|
||||
return new EmbryoCalcificationMachineRecipe(id, inputs, buf.readItem());
|
||||
}
|
||||
@Override public void toNetwork(FriendlyByteBuf buf, EmbryoCalcificationMachineRecipe recipe) {
|
||||
buf.writeInt(recipe.inputs().size());
|
||||
|
||||
Reference in New Issue
Block a user