Search in sources :

Example 1 with MissingModException

use of net.modificationstation.stationapi.api.util.exception.MissingModException in project StationAPI by ModificationStation.

the class JsonRecipesLoader method registerRecipe.

private static void registerRecipe(URL recipe) {
    try {
        String rawId = new Gson().fromJson(new InputStreamReader(recipe.openStream()), JsonRecipeType.class).getType();
        Identifier recipeId;
        try {
            recipeId = Identifier.of(rawId);
        } catch (MissingModException e) {
            LOGGER.warn("Found an unknown recipe type " + rawId + ". Ignoring.");
            return;
        }
        JsonRecipesRegistry.INSTANCE.computeIfAbsent(recipeId, identifier -> new HashSet<>()).add(recipe);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : ResourceManager(net.modificationstation.stationapi.api.resource.ResourceManager) java.util(java.util) MissingModException(net.modificationstation.stationapi.api.util.exception.MissingModException) MODID(net.modificationstation.stationapi.api.StationAPI.MODID) Filters(net.modificationstation.stationapi.api.resource.Filters) EventListener(net.mine_diver.unsafeevents.listener.EventListener) java.net(java.net) java.io(java.io) ListenerPriority(net.mine_diver.unsafeevents.listener.ListenerPriority) EventBusPolicy(net.modificationstation.stationapi.api.mod.entrypoint.EventBusPolicy) LOGGER(net.modificationstation.stationapi.api.StationAPI.LOGGER) Gson(com.google.gson.Gson) PreInitEvent(net.modificationstation.stationapi.api.event.mod.PreInitEvent) Entrypoint(net.modificationstation.stationapi.api.mod.entrypoint.Entrypoint) Identifier(net.modificationstation.stationapi.api.registry.Identifier) JsonRecipesRegistry(net.modificationstation.stationapi.api.registry.JsonRecipesRegistry) Identifier(net.modificationstation.stationapi.api.registry.Identifier) MissingModException(net.modificationstation.stationapi.api.util.exception.MissingModException) Gson(com.google.gson.Gson)

Aggregations

Gson (com.google.gson.Gson)1 java.io (java.io)1 java.net (java.net)1 java.util (java.util)1 EventListener (net.mine_diver.unsafeevents.listener.EventListener)1 ListenerPriority (net.mine_diver.unsafeevents.listener.ListenerPriority)1 LOGGER (net.modificationstation.stationapi.api.StationAPI.LOGGER)1 MODID (net.modificationstation.stationapi.api.StationAPI.MODID)1 PreInitEvent (net.modificationstation.stationapi.api.event.mod.PreInitEvent)1 Entrypoint (net.modificationstation.stationapi.api.mod.entrypoint.Entrypoint)1 EventBusPolicy (net.modificationstation.stationapi.api.mod.entrypoint.EventBusPolicy)1 Identifier (net.modificationstation.stationapi.api.registry.Identifier)1 JsonRecipesRegistry (net.modificationstation.stationapi.api.registry.JsonRecipesRegistry)1 Filters (net.modificationstation.stationapi.api.resource.Filters)1 ResourceManager (net.modificationstation.stationapi.api.resource.ResourceManager)1 MissingModException (net.modificationstation.stationapi.api.util.exception.MissingModException)1