Skip to content

Commit

Permalink
FarmersDelightModule: Improved the error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Xelbayria committed Dec 13, 2024
1 parent 9f45ee3 commit 398f655
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.mehvahdjukaar.every_compat.dynamicpack.ServerDynamicResourcesHandler;
import net.mehvahdjukaar.moonlight.api.resources.RPUtils;
import net.mehvahdjukaar.moonlight.api.resources.ResType;
import net.mehvahdjukaar.moonlight.api.resources.textures.Palette;
import net.mehvahdjukaar.moonlight.api.set.wood.WoodType;
import net.mehvahdjukaar.moonlight.api.set.wood.WoodTypeRegistry;
import net.mehvahdjukaar.moonlight.api.util.Utils;
Expand All @@ -19,6 +18,7 @@
import net.minecraft.world.level.block.Block;
import vectorwing.farmersdelight.common.block.CabinetBlock;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Objects;
Expand Down Expand Up @@ -80,10 +80,12 @@ public void addDynamicServerResources(ServerDynamicResourcesHandler handler, Res

public void createCuttingRecipe(String recipeType, Block input, Block output,
WoodType woodType, ServerDynamicResourcesHandler handler, ResourceManager manager) {
ResourceLocation recipeLocation = modRes("recipes/cutting/oak_"+recipeType+".json");

if (Objects.nonNull(input) && Objects.nonNull(output)) {
try (InputStream recipeStream = manager.getResource(recipeLocation).orElseThrow().open()) {
ResourceLocation recipeLocation = modRes("recipes/cutting/oak_"+recipeType+".json");

try (InputStream recipeStream = manager.getResource(recipeLocation)
.orElseThrow(() -> new FileNotFoundException(recipeLocation.toString())).open()) {
JsonObject recipe = RPUtils.deserializeJson(recipeStream);

// EDITING RECIPE
Expand All @@ -98,7 +100,7 @@ public void createCuttingRecipe(String recipeType, Block input, Block output,

handler.dynamicPack.addJson(EveryCompat.res(path), recipe, ResType.RECIPES);
} catch (IOException e) {
handler.getLogger().error("Failed to generate the cutting recipe for {} : {}", Utils.getID(output), e);
handler.getLogger().error("Failed to generate the cutting recipe for {} - {}", Utils.getID(output), e);
}
}
}
Expand Down

0 comments on commit 398f655

Please sign in to comment.