-
Notifications
You must be signed in to change notification settings - Fork 1
[feature] Add new modules (fix conflicts) #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Удалены лишние языковые файлы
- Доработка модуля ic2:
- Удален лишний код
- Переименованны переменные
- Доработка модуля te:
- Удален лишний код
- Переименованы переменные
- Изменен способ получения данных о предмете
- Добавлена поддежка энергохранилищ - Добавлено отображение процента и энергоуровня - Изменены наименования переменных
- Добавлена поддержка механизмов ic2
-Добавлена поддержка семян ic2
| // TODO: Переместить в объект? Ассоциативный массив? | ||
| // TODO: Оптимизировать типы | ||
| int scanLevel = 0; | ||
| int storageNutrients = 0; | ||
| int storageWater = 0; | ||
| int storageWeedEX = 0; | ||
|
|
||
| int terrainNutrients = 0; | ||
| int terrainHumidity = 0; | ||
| int terrainAirQuality = 0; | ||
| int lightLevel = 0; | ||
|
|
||
| int currentSize = -1; | ||
| int growthPoints = -1; | ||
| int statGrowth = -1; | ||
| int statGain = -1; | ||
| int statResistance = -1; | ||
|
|
||
| try { | ||
| if (IC2Module.crops.isInstance(te)) { | ||
| scanLevel = (Integer) IC2Module.cropsScanLevel.invoke(te); | ||
| storageNutrients = (Integer) IC2Module.cropsStorageNutrients.invoke(te); | ||
| storageWater = (Integer) IC2Module.cropsStorageWater.invoke(te); | ||
| storageWeedEX = (Integer) IC2Module.cropsStorageWeedEX.invoke(te); | ||
| terrainNutrients = (Integer) IC2Module.cropsTerrainNutrients.invoke(te); | ||
| terrainHumidity = (Integer) IC2Module.cropsTerrainHumidity.invoke(te); | ||
| terrainAirQuality = (Integer) IC2Module.cropsTerrainAirQuality.invoke(te); | ||
| lightLevel = (Integer) IC2Module.cropsLightLevel.invoke(te); | ||
| if (scanLevel >= 1) { | ||
| currentSize = (Integer) IC2Module.cropsCurrentSize.invoke(te); | ||
| growthPoints = (Integer) IC2Module.cropsGrowthPoints.invoke(te); | ||
| } | ||
| if (scanLevel >= 4) { | ||
| statGrowth = (Integer) IC2Module.cropsStatGrowth.invoke(te); | ||
| statGain = (Integer) IC2Module.cropsStatGain.invoke(te); | ||
| statResistance = (Integer) IC2Module.cropsStatResistance.invoke(te); | ||
| } | ||
|
|
||
|
|
||
| } | ||
| } catch (java.lang.Exception e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
|
|
||
| tag.setInteger("scanLevel", scanLevel); | ||
| tag.setInteger("storageNutrients", storageNutrients); | ||
| tag.setInteger("storageWater", storageWater); | ||
| tag.setInteger("storageWeedEX", storageWeedEX); | ||
| tag.setInteger("terrainNutrients", terrainNutrients); | ||
| tag.setInteger("terrainHumidity", terrainHumidity); | ||
| tag.setInteger("terrainAirQuality", terrainAirQuality); | ||
| tag.setInteger("lightLevel", lightLevel); | ||
| tag.setInteger("currentSize", currentSize); | ||
| tag.setInteger("growthPoints", growthPoints); | ||
| tag.setInteger("statGrowth", statGrowth); | ||
| tag.setInteger("statGain", statGain); | ||
| tag.setInteger("statResistance", statResistance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Объявление переменной и присвоение в разных местах. Много лишних строк получается. Всё равно ничего не отправится из-за RuntimeException. И зачем указывать полный импорт базового пакета (java.lang)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Скопировал обработку из рандомного места чтобы была, я буду обработку ошибок менять и перепишу с логгер waila на логгер стандартный, вроде catch (Exception e) {LOGGER.error("Failed to get crop data", e);} . Это не финальная версия. Меня больше волнует что можно сделать с полотном переменных? Придумал только напрямую, вроде tag.setInteger("scanLevel", IC2Module.cropsScanLevel.invoke(te)); и в getWailaBody использовать тернарник tag.hasKey("scanLevel") ? tag.getInteger("scanLevel") : 0.
Но по-моему код станет нечитаемым и будет горизонтальным. В какую сторону копать?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Напрямую значительно сократит код. Так и делай.
Есть посмотреть устройство Compount тега, hasKey() для примитивов не нужен - там возвращается заглушка в крайнем случае. Она для сложных структур вроде List и Compound нужна.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я чувствую что умные мысли догоняют меня, но я быстрее. Сейчас перепишу код и отправлю как это будет выглядеть. 10 минут
| double storage = -1; | ||
| int production = -1; | ||
| long maxStorage = -1; | ||
| double stored = 0; | ||
| long capacity = 0; | ||
| int input = 0; | ||
| int output = 0; | ||
| int tier = 0; | ||
|
|
||
| try { | ||
| if (IC2Module.generator.isInstance(te)) { | ||
| storage = IC2Module.generatorStorage.getDouble(te); | ||
| production = IC2Module.generatorProduction.getInt(te); | ||
| maxStorage = IC2Module.generatorMaxStorage.getLong(te); | ||
| stored = IC2Module.generatorStored.getDouble(te); | ||
| capacity = IC2Module.generatorCapacity.getLong(te); | ||
| output = IC2Module.generatorOutput.getInt(te); | ||
| tier = IC2Module.generatorTier.getInt(te); | ||
|
|
||
| } else if (IC2Module.eBlock.isInstance(te)) { | ||
| stored = IC2Module.eBlockStored.getDouble(te); | ||
| capacity = IC2Module.eBlockCapacity.getLong(te); | ||
| output = IC2Module.eBlockOutput.getInt(te); | ||
| tier = IC2Module.eBlockTier.getInt(te); | ||
|
|
||
| } else if (IC2Module.eMachine.isInstance(te)) { | ||
| input = IC2Module.eMachineInput.getInt(te); | ||
| tier = IC2Module.eMachineTier.getInt(te); | ||
| } | ||
|
|
||
| } catch (java.lang.Exception e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| tag.setDouble("storage", storage); | ||
| tag.setInteger("production", production); | ||
| tag.setLong("maxStorage", maxStorage); | ||
|
|
||
| tag.setDouble("stored", stored); | ||
| tag.setLong("capacity", capacity); | ||
| tag.setInteger("input", input); | ||
| tag.setInteger("output", output); | ||
| tag.setInteger("tier", tier); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Снова избыточное разбрасывание переменных.
|
Я Здесь смотрю всё. Это достоверный источник? |
|
Также не могу не отправить не стандартизированные данные, рука не подымается. Поэтому есть конструкции вроде |
Скажите, в чём вы редактируете код? |
|
IntelliJ IDEA, так как привык работать в PHPStorm, WebStorm и PyCharm. Eclipse не привычен |
|
Настроить надо, чтобы не быть как слепой котёнок. Все библиотеки будут с исходным кодом и не будет необходимости ходить по левым сайтам. JDK 1.8 скачать может сама, потом gradle build и reload project чтобы все настройки подтянулись. |
|
Благодарю! Я настроил только сборщик, на среду силы тратить не стал. Теперь будет намного проще |

Забыл подтянуть изменения. Конфликты исправил.
Семена нужно дорабатывать поэтому реквест можно не принимать, отправил на ревью, так как не нравится это полотно кода. Возможно стоит создать декоратор или метод/класс хелпер