Moved save logic inside the 1.20 branch, as they don't compile without errors on 1.21

Change hybridizer logic to no longer require a catalyst
fix brachiosaurus_dna.png
Fix flame texture on generator for 1.21
Adds power handling for machines in NF 1.21
Adds power handling to fabric
Actually fix screen registration for Fabric 1.20
This commit is contained in:
2026-05-20 22:56:50 -04:00
parent 40292ae052
commit 05325f6008
35 changed files with 631 additions and 230 deletions
@@ -101,7 +101,7 @@ public record DNAAnalyzerRecipe(
).forGetter(DNAAnalyzerRecipe::inputs),
ItemStack.CODEC.fieldOf("result").forGetter(DNAAnalyzerRecipe::output),
Codec.unboundedMap(ResourceLocation.CODEC, Codec.INT).optionalFieldOf("weights", java.util.Map.of()).forGetter(DNAAnalyzerRecipe::weights)
).apply(inst, DNAAnalyzerRecipe::new));
).apply(inst, (inputs, output, weights) -> new DNAAnalyzerRecipe(Constants.rl("dna_analyzer"), inputs, output, weights)));
public static final StreamCodec<RegistryFriendlyByteBuf, DNAAnalyzerRecipe> STREAM_CODEC = StreamCodec.of(
(buf, r) -> {
@@ -114,7 +114,13 @@ public record DNAAnalyzerRecipe(
int size = buf.readVarInt();
NonNullList<Ingredient> ins = NonNullList.create();
for(int i=0; i<size; i++) ins.add(Ingredient.CONTENTS_STREAM_CODEC.decode(buf));
return new DNAAnalyzerRecipe(ins, ItemStack.STREAM_CODEC.decode(buf), buf.readMap(m -> new java.util.HashMap<>(), ResourceLocation.STREAM_CODEC, ByteBufCodecs.VAR_INT));
ItemStack output = ItemStack.STREAM_CODEC.decode(buf);
java.util.Map<ResourceLocation, Integer> weights = buf.readMap(
java.util.HashMap<ResourceLocation, Integer>::new,
ResourceLocation.STREAM_CODEC,
ByteBufCodecs.VAR_INT
);
return new DNAAnalyzerRecipe(Constants.rl("dna_analyzer"), ins, output, weights);
}
);
@@ -108,7 +108,7 @@ public record DNAExtractorRecipe(
).forGetter(DNAExtractorRecipe::inputs),
ItemStack.CODEC.fieldOf("result").forGetter(DNAExtractorRecipe::output),
Codec.unboundedMap(ResourceLocation.CODEC, Codec.INT).optionalFieldOf("weights", java.util.Map.of()).forGetter(DNAExtractorRecipe::weights)
).apply(inst, DNAExtractorRecipe::new));
).apply(inst, (inputs, output, weights) -> new DNAExtractorRecipe(Constants.rl("dna_extractor"), inputs, output, weights)));
public static final StreamCodec<RegistryFriendlyByteBuf, DNAExtractorRecipe> STREAM_CODEC = StreamCodec.of(
(buf, r) -> {
@@ -121,7 +121,13 @@ public record DNAExtractorRecipe(
int size = buf.readVarInt();
NonNullList<Ingredient> ins = NonNullList.create();
for(int i=0; i<size; i++) ins.add(Ingredient.CONTENTS_STREAM_CODEC.decode(buf));
return new DNAExtractorRecipe(ins, ItemStack.STREAM_CODEC.decode(buf), buf.readMap(m -> new java.util.HashMap<>(), ResourceLocation.STREAM_CODEC, ByteBufCodecs.VAR_INT));
ItemStack output = ItemStack.STREAM_CODEC.decode(buf);
java.util.Map<ResourceLocation, Integer> weights = buf.readMap(
java.util.HashMap<ResourceLocation, Integer>::new,
ResourceLocation.STREAM_CODEC,
ByteBufCodecs.VAR_INT
);
return new DNAExtractorRecipe(Constants.rl("dna_extractor"), ins, output, weights);
}
);
@Override public MapCodec<DNAExtractorRecipe> codec() { return CODEC; }
@@ -94,7 +94,7 @@ public record DNAHybridizerRecipe(ResourceLocation id, NonNullList<Ingredient> i
l -> DataResult.success(List.copyOf(l))
).forGetter(DNAHybridizerRecipe::inputs),
ItemStack.CODEC.fieldOf("result").forGetter(DNAHybridizerRecipe::output)
).apply(inst, DNAHybridizerRecipe::new));
).apply(inst, (inputs, output) -> new DNAHybridizerRecipe(Constants.rl("dna_hybridizer"), inputs, output)));
public static final StreamCodec<RegistryFriendlyByteBuf, DNAHybridizerRecipe> STREAM_CODEC = StreamCodec.of(
(buf, r) -> {
@@ -106,7 +106,8 @@ public record DNAHybridizerRecipe(ResourceLocation id, NonNullList<Ingredient> i
int size = buf.readVarInt();
NonNullList<Ingredient> ins = NonNullList.create();
for(int i=0; i<size; i++) ins.add(Ingredient.CONTENTS_STREAM_CODEC.decode(buf));
return new DNAHybridizerRecipe(ins, ItemStack.STREAM_CODEC.decode(buf));
ItemStack output = ItemStack.STREAM_CODEC.decode(buf);
return new DNAHybridizerRecipe(Constants.rl("dna_hybridizer"), ins, output);
}
);
@Override public MapCodec<DNAHybridizerRecipe> codec() { return CODEC; }
@@ -68,7 +68,7 @@ public record EmbryoCalcificationMachineRecipe(ResourceLocation id, NonNullList<
list -> DataResult.success(List.copyOf(list))
).forGetter(EmbryoCalcificationMachineRecipe::inputs),
ItemStack.CODEC.fieldOf("result").forGetter(EmbryoCalcificationMachineRecipe::output)
).apply(instance, EmbryoCalcificationMachineRecipe::new));
).apply(instance, (inputs, output) -> new EmbryoCalcificationMachineRecipe(Constants.rl("embryo_calcification_machine"), inputs, output)));
public static final StreamCodec<RegistryFriendlyByteBuf, EmbryoCalcificationMachineRecipe> STREAM_CODEC = StreamCodec.of(
(buf, recipe) -> {
@@ -80,7 +80,7 @@ public record EmbryoCalcificationMachineRecipe(ResourceLocation id, NonNullList<
int size = buf.readVarInt();
NonNullList<Ingredient> ins = NonNullList.create();
for(int i=0; i<size; i++) ins.add(Ingredient.CONTENTS_STREAM_CODEC.decode(buf));
return new EmbryoCalcificationMachineRecipe(ins, ItemStack.STREAM_CODEC.decode(buf));
return new EmbryoCalcificationMachineRecipe(Constants.rl("embryo_calcification_machine"), ins, ItemStack.STREAM_CODEC.decode(buf));
}
);
@Override public MapCodec<EmbryoCalcificationMachineRecipe> codec() { return CODEC; }
@@ -150,7 +150,11 @@ public class EmbryonicMachineRecipe implements Recipe<EmbryonicMachineRecipeInpu
buf -> {
NonNullList<Ingredient> inputs = ByteBufCodecs.collection(NonNullList::createWithCapacity, Ingredient.CONTENTS_STREAM_CODEC).decode(buf);
ItemStack output = ItemStack.STREAM_CODEC.decode(buf);
Map<ResourceLocation, Integer> weights = buf.readMap(ResourceLocation.STREAM_CODEC, ByteBufCodecs.VAR_INT);
Map<ResourceLocation, Integer> weights = buf.readMap(
HashMap<ResourceLocation, Integer>::new,
ResourceLocation.STREAM_CODEC,
ByteBufCodecs.VAR_INT
);
return new EmbryonicMachineRecipe(inputs, output, weights);
}
);
@@ -171,23 +171,27 @@ public class FossilCleanerRecipe implements Recipe<FossilCleanerRecipeInput> {
WEIGHTS_CODEC.optionalFieldOf("fossil_weights", Map.of()).forGetter(FossilCleanerRecipe::weights)
).apply(inst, FossilCleanerRecipe::new));
public static final StreamCodec<RegistryFriendlyByteBuf, FossilCleanerRecipe> STREAM_CODEC = StreamCodec.of(
(buf, recipe) -> {
ByteBufCodecs.collection(NonNullList::createWithCapacity, Ingredient.CONTENTS_STREAM_CODEC).encode(buf, recipe.inputs());
ItemStack.STREAM_CODEC.encode(buf, recipe.output());
buf.writeMap(recipe.weights(), ResourceLocation.STREAM_CODEC, ByteBufCodecs.VAR_INT);
},
buf -> {
NonNullList<Ingredient> inputs = ByteBufCodecs.collection(NonNullList::createWithCapacity, Ingredient.CONTENTS_STREAM_CODEC).decode(buf);
ItemStack output = ItemStack.STREAM_CODEC.decode(buf);
Map<ResourceLocation, Integer> weights = buf.readMap(ResourceLocation.STREAM_CODEC, ByteBufCodecs.VAR_INT);
return new FossilCleanerRecipe(inputs, output, weights);
}
);
public static final StreamCodec<RegistryFriendlyByteBuf, FossilCleanerRecipe> STREAM_CODEC = StreamCodec.of(
(buf, recipe) -> {
ByteBufCodecs.collection(NonNullList::createWithCapacity, Ingredient.CONTENTS_STREAM_CODEC).encode(buf, recipe.inputs());
ItemStack.STREAM_CODEC.encode(buf, recipe.output());
buf.writeMap(recipe.weights(), ResourceLocation.STREAM_CODEC, ByteBufCodecs.VAR_INT);
},
buf -> {
NonNullList<Ingredient> inputs = ByteBufCodecs.collection(NonNullList::createWithCapacity, Ingredient.CONTENTS_STREAM_CODEC).decode(buf);
ItemStack output = ItemStack.STREAM_CODEC.decode(buf);
Map<ResourceLocation, Integer> weights = buf.readMap(
HashMap<ResourceLocation, Integer>::new,
ResourceLocation.STREAM_CODEC,
ByteBufCodecs.VAR_INT
);
return new FossilCleanerRecipe(inputs, output, weights);
}
);
@Override public MapCodec<FossilCleanerRecipe> codec() { return CODEC; }
@Override public StreamCodec<RegistryFriendlyByteBuf, FossilCleanerRecipe> streamCodec() { return STREAM_CODEC; }
*///?} else {
@Override public MapCodec<FossilCleanerRecipe> codec() { return CODEC; }
@Override public StreamCodec<RegistryFriendlyByteBuf, FossilCleanerRecipe> streamCodec() { return STREAM_CODEC; }
*///?} else {
@Override
public FossilCleanerRecipe fromJson(ResourceLocation id, JsonObject json) {
ItemStack output = ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "result"));
@@ -174,7 +174,11 @@ public class FossilGrinderRecipe implements Recipe<FossilGrinderRecipeInput> {
buf -> {
NonNullList<Ingredient> inputs = ByteBufCodecs.collection(NonNullList::createWithCapacity, Ingredient.CONTENTS_STREAM_CODEC).decode(buf);
ItemStack output = ItemStack.STREAM_CODEC.decode(buf);
Map<ResourceLocation, Integer> weights = buf.readMap(ResourceLocation.STREAM_CODEC, ByteBufCodecs.VAR_INT);
Map<ResourceLocation, Integer> weights = buf.readMap(
HashMap<ResourceLocation, Integer>::new,
ResourceLocation.STREAM_CODEC,
ByteBufCodecs.VAR_INT
);
return new FossilGrinderRecipe(inputs, output, weights);
}
);