Skip to content

Commit

Permalink
fix: provide recipeDisable option to jsons for pack devs to disable c…
Browse files Browse the repository at this point in the history
…ompressor recipes
  • Loading branch information
MichaelHillcox committed Sep 24, 2022
1 parent 010f5da commit 279ee4f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class Singularity {
private final int timeRequired;
private Ingredient ingredient;
private boolean enabled = true;
private boolean recipeDisabled = false;

public Singularity(ResourceLocation id, String name, int[] colors, Ingredient ingredient, int ingredientCount, int timeRequired) {
this.id = id;
Expand Down Expand Up @@ -134,6 +135,14 @@ public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public boolean isRecipeDisabled() {
return recipeDisabled;
}

public void setRecipeDisabled(boolean recipeDisabled) {
this.recipeDisabled = recipeDisabled;
}

public void write(FriendlyByteBuf buffer) {
buffer.writeResourceLocation(this.id);
buffer.writeUtf(this.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
public class DynamicRecipeHandler {
@SubscribeEvent
public static void onRegisterRecipes(RegisterRecipesEvent event) {

for (var singularity : SingularityRegistryHandler.getInstance().getSingularities()) {
if (singularity.isRecipeDisabled()) {
continue;
}

var compressorRecipe = makeSingularityRecipe(singularity);

if (compressorRecipe != null)
event.register(compressorRecipe);
}



}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ public static Singularity loadFromJson(ResourceLocation id, JsonObject json, ICo
}

var enabled = GsonHelper.getAsBoolean(json, "enabled", true);
var recipeDisabled = GsonHelper.getAsBoolean(json, "recipeDisabled", false);

singularity.setEnabled(enabled);
singularity.setRecipeDisabled(recipeDisabled);

return singularity;
}
Expand Down

0 comments on commit 279ee4f

Please sign in to comment.