Skip to content

Conversation

@a-ognev
Copy link

@a-ognev a-ognev commented Feb 18, 2025

Забыл подтянуть изменения. Конфликты исправил.

  • Доработан аддон Ic2
    • Добавлена поддержка энергохранилищ
    • добавлена поддержка механизмов
  • В аддон ic2 Добавлена поддержка семян (Не убивает механику анализатора семян)
  • Мелкие правки в модуле TE

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

- Удалены лишние языковые файлы
- Доработка модуля ic2:
    - Удален лишний код
    - Переименованны переменные
- Доработка модуля te:
    - Удален лишний код
    - Переименованы переменные
    - Изменен способ получения данных о предмете
- Добавлена поддежка энергохранилищ
- Добавлено отображение процента и энергоуровня
- Изменены наименования переменных
- Добавлена поддержка механизмов ic2
-Добавлена поддержка семян ic2
@a-ognev a-ognev marked this pull request as ready for review February 18, 2025 09:45
Comment on lines 62 to 118
// 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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Объявление переменной и присвоение в разных местах. Много лишних строк получается. Всё равно ничего не отправится из-за RuntimeException. И зачем указывать полный импорт базового пакета (java.lang)?

Copy link
Author

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.
Но по-моему код станет нечитаемым и будет горизонтальным. В какую сторону копать?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Напрямую значительно сократит код. Так и делай.

Есть посмотреть устройство Compount тега, hasKey() для примитивов не нужен - там возвращается заглушка в крайнем случае. Она для сложных структур вроде List и Compound нужна.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я чувствую что умные мысли догоняют меня, но я быстрее. Сейчас перепишу код и отправлю как это будет выглядеть. 10 минут

Comment on lines 59 to 108
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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Снова избыточное разбрасывание переменных.

@a-ognev
Copy link
Author

a-ognev commented Feb 18, 2025

Я Здесь смотрю всё. Это достоверный источник?

@a-ognev
Copy link
Author

a-ognev commented Feb 18, 2025

Также не могу не отправить не стандартизированные данные, рука не подымается. Поэтому есть конструкции вроде tag.setLong("capacity", 0);

@TheAndrey
Copy link

Я Здесь смотрю всё. Это достоверный источник?

Скажите, в чём вы редактируете код?

@a-ognev
Copy link
Author

a-ognev commented Feb 18, 2025

IntelliJ IDEA, так как привык работать в PHPStorm, WebStorm и PyCharm. Eclipse не привычен

@a-ognev
Copy link
Author

a-ognev commented Feb 18, 2025

Саму IDE не настраивал пока. только основные настройки подтянулись, поэтому всё выглядит так:
image

@TheAndrey
Copy link

Настроить надо, чтобы не быть как слепой котёнок. Все библиотеки будут с исходным кодом и не будет необходимости ходить по левым сайтам. JDK 1.8 скачать может сама, потом gradle build и reload project чтобы все настройки подтянулись.

https://mcmodding.ru/1.12/preparation/setup-idea/

@a-ognev
Copy link
Author

a-ognev commented Feb 18, 2025

Благодарю! Я настроил только сборщик, на среду силы тратить не стал. Теперь будет намного проще

@TheAndrey TheAndrey merged commit d704b41 into RedServer:1.12 Feb 18, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants