Skip to content

Commit

Permalink
Fixed recipe condition encoding (#1992)
Browse files Browse the repository at this point in the history
  • Loading branch information
krossgg committed Sep 21, 2024
1 parent f315e99 commit c829115
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public abstract class RecipeCondition {

public static <
RC extends RecipeCondition> Products.P1<RecordCodecBuilder.Mu<RC>, Boolean> isReverse(RecordCodecBuilder.Instance<RC> instance) {
return instance.group(Codec.BOOL.fieldOf("reverse").forGetter(val -> val.isReverse));
return instance.group(Codec.BOOL.optionalFieldOf("reverse", false).forGetter(val -> val.isReverse));
}

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public RecipeCondition createTemplate() {
@Override
public JsonObject serialize() {
JsonObject config = super.serialize();
config.addProperty("dim", dimension.toString());
config.addProperty("dimension", dimension.toString());
return config;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1084,10 +1084,9 @@ public void toJson(JsonObject json) {
if (!conditions.isEmpty()) {
JsonArray array = new JsonArray();
for (RecipeCondition condition : conditions) {
JsonObject cond = new JsonObject();
cond.addProperty("type", GTRegistries.RECIPE_CONDITIONS.getKey(condition.getType()));
cond.add("data", condition.serialize());
array.add(cond);
var condJson = condition.serialize();
condJson.addProperty("type", GTRegistries.RECIPE_CONDITIONS.getKey(condition.getType()));
array.add(condJson);
}
json.add("recipeConditions", array);
}
Expand Down

0 comments on commit c829115

Please sign in to comment.