/
Belyash5
/
Flu
Обзор
Документация
Войти
/
Belyash5
/
Flu
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/main/java/com/hbm/tileentity/IConfigurableMachine.java
32 строки
1 KB
Bob
steam engine model, some more config crap
04 ноя 2022, 01:16
04 ноя 2022, 01:16
385a7ce
Код
Авторство
О чём код?
package com.hbm.tileentity; import java.io.IOException; import com.google.gson.JsonObject; import com.google.gson.stream.JsonWriter; public interface IConfigurableMachine { /* the name for the JOSN object for this machine */ public String getConfigName(); /* reads the JSON object and sets the machine's parameters, use defaults and ignore if a value is not yet present */ public void readIfPresent(JsonObject obj); /* writes the entire config for this machine using the relevant values */ public void writeConfig(JsonWriter writer) throws IOException; public static boolean grab(JsonObject obj, String name, boolean def) { return obj.has(name) ? obj.get(name).getAsBoolean() : def; } public static int grab(JsonObject obj, String name, int def) { return obj.has(name) ? obj.get(name).getAsInt() : def; } public static long grab(JsonObject obj, String name, long def) { return obj.has(name) ? obj.get(name).getAsLong() : def; } public static double grab(JsonObject obj, String name, double def) { return obj.has(name) ? obj.get(name).getAsDouble() : def; } }