Search in sources :

Example 6 with Gas

use of ladysnake.gaspunk.gas.Gas in project Gaspunk by Ladysnake.

the class GasDeserializer method loadGases.

private static boolean loadGases(Path root, Path file) {
    String relative = root.relativize(file).toString();
    if (!"json".equals(FilenameUtils.getExtension(file.toString())) || relative.startsWith("_"))
        return true;
    String name = FilenameUtils.removeExtension(relative).replaceAll("\\\\", "/");
    try (BufferedReader reader = Files.newBufferedReader(file)) {
        Gas gas = GSON.fromJson(reader, Gas.class);
        ModGases.REGISTRY.register(gas.setRegistryName(name));
    } catch (Exception e) {
        GasPunk.LOGGER.error(new FormattedMessage("Error trying to load a gas from file {}", file), e);
    }
    return true;
}
Also used : BufferedReader(java.io.BufferedReader) AbstractGas(ladysnake.gaspunk.api.AbstractGas) IGas(ladysnake.gaspunk.api.IGas) Gas(ladysnake.gaspunk.gas.Gas) IOException(java.io.IOException) FormattedMessage(org.apache.logging.log4j.message.FormattedMessage)

Aggregations

Gas (ladysnake.gaspunk.gas.Gas)6 IGas (ladysnake.gaspunk.api.IGas)4 SuspendableGas (ladysnake.gaspunk.gas.SuspendableGas)3 IOException (java.io.IOException)2 AbstractGas (ladysnake.gaspunk.api.AbstractGas)2 IBreathingHandler (ladysnake.gaspunk.api.IBreathingHandler)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 JsonException (net.minecraft.client.util.JsonException)1 EnumDyeColor (net.minecraft.item.EnumDyeColor)1 ModContainer (net.minecraftforge.fml.common.ModContainer)1 FormattedMessage (org.apache.logging.log4j.message.FormattedMessage)1