Group mob browser by creature with labeled helpers effects and skills
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
## Установка и работа
|
## Установка и работа
|
||||||
|
|
||||||
1. Установите `AstraPlusEditor-0.3.5.jar` из `build/libs` в папку `mods` **клиента администратора**.
|
1. Установите `AstraPlusEditor-0.3.6.jar` из `build/libs` в папку `mods` **клиента администратора**.
|
||||||
Этот JAR не устанавливается на сервер. Для меню мобов требуется серверный **AstraPlus 0.5.0 или новее**.
|
Этот JAR не устанавливается на сервер. Для меню мобов требуется серверный **AstraPlus 0.5.0 или новее**.
|
||||||
Версия протокола редактора остаётся 1; каналы необязательны.
|
Версия протокола редактора остаётся 1; каналы необязательны.
|
||||||
Для вкладки **Зачарования** требуется **AstraPlus 0.5.5**.
|
Для вкладки **Зачарования** требуется **AstraPlus 0.5.5**.
|
||||||
@@ -129,6 +129,23 @@
|
|||||||
содержат загруженные сервером определения; просмотр ничего не призывает и не сохраняет.
|
содержат загруженные сервером определения; просмотр ничего не призывает и не сохраняет.
|
||||||
Каждый моб и навык находится в отдельном файле `astraplus/contents/<namespace>/mobs|skills/<path>.json`.
|
Каждый моб и навык находится в отдельном файле `astraplus/contents/<namespace>/mobs|skills/<path>.json`.
|
||||||
|
|
||||||
|
С **AstraPlus 0.5.39** каталог показывает раскрываемые группы: основной моб, его призываемые
|
||||||
|
мобы и технические сущности. Стрелка слева раскрывает группу, нажатие карточки открывает
|
||||||
|
соответствующее определение. Навыки группы находятся в отдельном раскрываемом разделе;
|
||||||
|
их карточки открывают редактор навыка. Цвет и текст обозначают роль, отступы и соединительные
|
||||||
|
линии показывают принадлежность. У технического носителя без модели показан значок `FX`.
|
||||||
|
Подсказка содержит ID мобов, которые его призывают. Общая сущность может входить в несколько групп.
|
||||||
|
Раскрытие сохраняется при возвращении из карточки и изменении размера окна.
|
||||||
|
|
||||||
|
Поиск по имени, ID или исходному псевдониму подмоба либо навыка показывает всю его группу
|
||||||
|
и раскрывает результат. Страницы содержат до 20 целых групп. Связи вычисляются по действиям
|
||||||
|
`summon`, включая именованные и вложенные навыки, случайные вызовы, callbacks и `orElseCast`.
|
||||||
|
Техническая роль определяется по отключённым задачам ИИ, нулевой скорости, неуязвимости
|
||||||
|
и отсутствию столкновений; по одному имени роль не угадывается. Вызовы внутри JavaScript
|
||||||
|
статически не разбираются. Определения без найденных родителей и циклические группы остаются
|
||||||
|
доступны. Старый сервер показывает обычный список с пояснением, что группировка требует обновления.
|
||||||
|
Просмотр и раскрытие не меняют файлы или поведение мобов.
|
||||||
|
|
||||||
- Карточка моба показывает ванильную основу, здоровье и урон. **Основное** и **Свойства и защита**
|
- Карточка моба показывает ванильную основу, здоровье и урон. **Основное** и **Свойства и защита**
|
||||||
открывают атрибуты, движение, коллизии, гравитацию, неуязвимость, исчезновение, угрозу и защиту от повреждений.
|
открывают атрибуты, движение, коллизии, гравитацию, неуязвимость, исчезновение, угрозу и защиту от повреждений.
|
||||||
У необязательных числовых настроек пустое поле наследует значение основы или сервера.
|
У необязательных числовых настроек пустое поле наследует значение основы или сервера.
|
||||||
@@ -208,6 +225,7 @@
|
|||||||
./gradlew.bat runVerificationClient -PnetworkVerification=true
|
./gradlew.bat runVerificationClient -PnetworkVerification=true
|
||||||
./gradlew.bat runCompatibilityClient
|
./gradlew.bat runCompatibilityClient
|
||||||
./gradlew.bat runVerificationClient -PiconVerification=true
|
./gradlew.bat runVerificationClient -PiconVerification=true
|
||||||
|
./gradlew.bat runVerificationClient -PmobGroupsVerification=true
|
||||||
```
|
```
|
||||||
|
|
||||||
`build` собирает клиентский JAR и выполняет тесты наследования компонентов и сохранности черновиков: неизвестные
|
`build` собирает клиентский JAR и выполняет тесты наследования компонентов и сохранности черновиков: неизвестные
|
||||||
@@ -222,6 +240,11 @@
|
|||||||
не включён в распространяемый JAR; его запуск защищён специальным JVM-флагом.
|
не включён в распространяемый JAR; его запуск защищён специальным JVM-флагом.
|
||||||
Обычная визуальная проверка использует тестовые данные без входа на сервер.
|
Обычная визуальная проверка использует тестовые данные без входа на сервер.
|
||||||
|
|
||||||
|
`mobGroupsVerification` проверяет настоящий список групп, раскрытие мышью, отдельный раздел
|
||||||
|
навыков, переход по типу определения, прокрутку и границы при GUI scale 2/3. Пять снимков
|
||||||
|
и `mob-groups-gui-result.txt` сохраняются в `build/isolated-editor`. В этом сценарии нет мира
|
||||||
|
и рендера моделей; проверяются структура и управление каталогом.
|
||||||
|
|
||||||
`iconVerification` использует отдельный сервер на `127.0.0.1:26702` (порт можно задать
|
`iconVerification` использует отдельный сервер на `127.0.0.1:26702` (порт можно задать
|
||||||
`-PiconVerificationPort=...`) и загруженный ресурспак. Проверяются серверные стеки каталога,
|
`-PiconVerificationPort=...`) и загруженный ресурспак. Проверяются серверные стеки каталога,
|
||||||
ограничение больших данных, отсутствие модели, совместимость со старым ответом, открытие
|
ограничение больших данных, отсутствие модели, совместимость со старым ответом, открытие
|
||||||
|
|||||||
+2
-1
@@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "online.astradev"
|
group = "online.astradev"
|
||||||
version = "0.3.5"
|
version = "0.3.6"
|
||||||
repositories { mavenCentral() }
|
repositories { mavenCentral() }
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation("com.google.code.gson:gson:2.14.0")
|
testImplementation("com.google.code.gson:gson:2.14.0")
|
||||||
@@ -46,6 +46,7 @@ neoForge {
|
|||||||
loadedMods.set(setOf(mods.getByName("astrapluseditor"), mods.getByName("astrapluseditor_verify")))
|
loadedMods.set(setOf(mods.getByName("astrapluseditor"), mods.getByName("astrapluseditor_verify")))
|
||||||
gameDirectory.set(layout.buildDirectory.dir("isolated-editor"))
|
gameDirectory.set(layout.buildDirectory.dir("isolated-editor"))
|
||||||
systemProperty("astrapluseditor.isolatedVerification", "true")
|
systemProperty("astrapluseditor.isolatedVerification", "true")
|
||||||
|
systemProperty("astrapluseditor.mobGroupsVerification", providers.gradleProperty("mobGroupsVerification").orElse("false").get())
|
||||||
systemProperty("astrapluseditor.recipeVerification", providers.gradleProperty("recipeVerification").orElse("false").get())
|
systemProperty("astrapluseditor.recipeVerification", providers.gradleProperty("recipeVerification").orElse("false").get())
|
||||||
systemProperty("astrapluseditor.enchantmentVerification", providers.gradleProperty("enchantmentVerification").orElse("false").get())
|
systemProperty("astrapluseditor.enchantmentVerification", providers.gradleProperty("enchantmentVerification").orElse("false").get())
|
||||||
systemProperty("astrapluseditor.networkVerification", providers.gradleProperty("networkVerification").orElse("false").get())
|
systemProperty("astrapluseditor.networkVerification", providers.gradleProperty("networkVerification").orElse("false").get())
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package online.astradev.plus.editor.form;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
/** Presentation only: expansion never changes or reassigns server definitions. */
|
||||||
|
public final class MobGroups {
|
||||||
|
public record Row(JsonObject entry, String group, String role, int indent, boolean expandable, boolean expanded) {
|
||||||
|
public String id() { return entry.get("id").getAsString(); }
|
||||||
|
public boolean skill() { return role.equals("skill"); }
|
||||||
|
public boolean section() { return role.equals("skills"); }
|
||||||
|
}
|
||||||
|
private final Set<String> expanded = new HashSet<>(), expandedSkills = new HashSet<>();
|
||||||
|
private final Set<String> searchCollapsed = new HashSet<>();
|
||||||
|
private JsonArray groups = new JsonArray(), flat = new JsonArray();
|
||||||
|
private boolean searching;
|
||||||
|
|
||||||
|
public void values(JsonObject response, boolean searching) {
|
||||||
|
groups = response.has("groups") ? response.getAsJsonArray("groups").deepCopy() : new JsonArray();
|
||||||
|
flat = response.has("entries") ? response.getAsJsonArray("entries").deepCopy() : new JsonArray();
|
||||||
|
this.searching = searching;
|
||||||
|
searchCollapsed.clear();
|
||||||
|
}
|
||||||
|
public void toggle(Row row) {
|
||||||
|
if (searching) {
|
||||||
|
String key = row.group + (row.section() ? "/skills" : "");
|
||||||
|
if (!searchCollapsed.add(key)) searchCollapsed.remove(key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Set<String> state = row.section() ? expandedSkills : expanded;
|
||||||
|
if (!state.add(row.group)) state.remove(row.group);
|
||||||
|
}
|
||||||
|
public List<Row> rows() {
|
||||||
|
var rows = new ArrayList<Row>();
|
||||||
|
for (var element : flat) rows.add(new Row(element.getAsJsonObject(), "", "mob", 0, false, false));
|
||||||
|
for (var element : groups) {
|
||||||
|
var group = element.getAsJsonObject(); var mob = group.getAsJsonObject("mob"); String id = mob.get("id").getAsString();
|
||||||
|
var members = group.getAsJsonArray("members"); var skills = group.getAsJsonArray("skills");
|
||||||
|
boolean hasChildren = !members.isEmpty() || !skills.isEmpty(), open = searching ? !searchCollapsed.contains(id) : expanded.contains(id);
|
||||||
|
var root = mob.deepCopy();
|
||||||
|
root.addProperty("summary", "Подмобы: " + members.size() + "; навыки: " + skills.size());
|
||||||
|
rows.add(new Row(root, id, role(mob), 0, hasChildren, open));
|
||||||
|
if (!open) continue;
|
||||||
|
for (var member : members) rows.add(new Row(member.getAsJsonObject(), id, role(member.getAsJsonObject()), 1, false, false));
|
||||||
|
if (!skills.isEmpty()) {
|
||||||
|
boolean skillOpen = searching ? !searchCollapsed.contains(id + "/skills") : expandedSkills.contains(id);
|
||||||
|
var section = new JsonObject(); section.addProperty("id", id); section.addProperty("name", "Навыки группы (" + skills.size() + ")");
|
||||||
|
rows.add(new Row(section, id, "skills", 1, true, skillOpen));
|
||||||
|
if (skillOpen) for (var skill : skills) rows.add(new Row(skill.getAsJsonObject(), id, "skill", 2, false, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return List.copyOf(rows);
|
||||||
|
}
|
||||||
|
private static String role(JsonObject entry) { return entry.has("role") ? entry.get("role").getAsString() : "mob"; }
|
||||||
|
public static String label(String role) {
|
||||||
|
return switch (role) {
|
||||||
|
case "main" -> "Основной моб";
|
||||||
|
case "summoned" -> "Призываемый моб";
|
||||||
|
case "technical" -> "Техническая сущность";
|
||||||
|
case "skill" -> "Навык";
|
||||||
|
case "skills" -> "Действия и эффекты группы";
|
||||||
|
default -> "Моб";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@ public final class MobBrowserScreen extends EditorScreen {
|
|||||||
private final Map<String, String> rows = new LinkedHashMap<>();
|
private final Map<String, String> rows = new LinkedHashMap<>();
|
||||||
private ChoiceList list;
|
private ChoiceList list;
|
||||||
private MobList mobList;
|
private MobList mobList;
|
||||||
|
private final online.astradev.plus.editor.form.MobGroups groups = new online.astradev.plus.editor.form.MobGroups();
|
||||||
private net.minecraft.client.gui.components.Button previous, next;
|
private net.minecraft.client.gui.components.Button previous, next;
|
||||||
private String query = "";
|
private String query = "";
|
||||||
private int page, pages = 1, delay, generation;
|
private int page, pages = 1, delay, generation;
|
||||||
@@ -29,15 +30,15 @@ public final class MobBrowserScreen extends EditorScreen {
|
|||||||
search.setMaxLength(256); search.setHint(Component.literal("Поиск по названию или namespace:id")); search.setValue(query);
|
search.setMaxLength(256); search.setHint(Component.literal("Поиск по названию или namespace:id")); search.setValue(query);
|
||||||
search.setResponder(value -> { query = value; page = 0; delay = 6; });
|
search.setResponder(value -> { query = value; page = 0; delay = 6; });
|
||||||
if (skill) {
|
if (skill) {
|
||||||
list = addRenderableWidget(new ChoiceList(minecraft, 12, 92, width - 24, Math.max(26, height - 193), row -> load(rows.get(row))));
|
list = addRenderableWidget(new ChoiceList(minecraft, 12, 92, width - 24, Math.max(26, height - 158), row -> load(rows.get(row))));
|
||||||
list.values(rows.keySet().stream().toList());
|
list.values(rows.keySet().stream().toList());
|
||||||
} else mobList = addRenderableWidget(new MobList(minecraft, 12, 92, width - 24,
|
} else mobList = addRenderableWidget(new MobList(minecraft, 12, 92, width - 24,
|
||||||
Math.max(52, height - 193), connection, this::load));
|
Math.max(40, height - 158), connection, groups, (id, isSkill) -> load(id, isSkill)));
|
||||||
button(skill ? "+ Навык" : "+ Моб", 12, height - 94, 130, this::create);
|
button(skill ? "+ Навык" : "+ Моб", 12, height - 27, 60, this::create);
|
||||||
button("Обновить", width - 142, height - 94, 130, this::refresh);
|
button("Обновить", 78, height - 27, 72, this::refresh);
|
||||||
previous = button("←", 12, height - 27, 30, () -> { if (page > 0) { page--; refresh(); } }); previous.active = page > 0;
|
previous = button("←", 156, height - 27, 24, () -> { if (page > 0) { page--; refresh(); } }); previous.active = page > 0;
|
||||||
next = button("→", 48, height - 27, 30, () -> { if (page + 1 < pages) { page++; refresh(); } }); next.active = page + 1 < pages;
|
next = button("→", 186, height - 27, 24, () -> { if (page + 1 < pages) { page++; refresh(); } }); next.active = page + 1 < pages;
|
||||||
button("Закрыть", width - 112, height - 27, 100, this::onClose);
|
button("Закрыть", width - 92, height - 27, 80, this::onClose);
|
||||||
connection.request("mob_catalog", new JsonObject(), response -> {
|
connection.request("mob_catalog", new JsonObject(), response -> {
|
||||||
if (EditorConnection.success(response)) catalog.update(response); else reply(response);
|
if (EditorConnection.success(response)) catalog.update(response); else reply(response);
|
||||||
});
|
});
|
||||||
@@ -47,6 +48,7 @@ public final class MobBrowserScreen extends EditorScreen {
|
|||||||
private void refresh() {
|
private void refresh() {
|
||||||
int current = ++generation;
|
int current = ++generation;
|
||||||
var request = new JsonObject(); request.addProperty("page", page); request.addProperty("query", query);
|
var request = new JsonObject(); request.addProperty("page", page); request.addProperty("query", query);
|
||||||
|
if (!skill) request.addProperty("grouped", true);
|
||||||
status("Загружается каталог…", false);
|
status("Загружается каталог…", false);
|
||||||
connection.request(skill ? "skill_list" : "mob_list", request, response -> {
|
connection.request(skill ? "skill_list" : "mob_list", request, response -> {
|
||||||
if (current != generation) return;
|
if (current != generation) return;
|
||||||
@@ -60,19 +62,24 @@ public final class MobBrowserScreen extends EditorScreen {
|
|||||||
page = response.has("page") ? response.get("page").getAsInt() : page;
|
page = response.has("page") ? response.get("page").getAsInt() : page;
|
||||||
pages = Math.max(1, response.has("pages") ? response.get("pages").getAsInt() : 1);
|
pages = Math.max(1, response.has("pages") ? response.get("pages").getAsInt() : 1);
|
||||||
if (skill) list.values(rows.keySet().stream().toList());
|
if (skill) list.values(rows.keySet().stream().toList());
|
||||||
else mobList.values(response.has("entries") ? response.getAsJsonArray("entries") : new com.google.gson.JsonArray());
|
else mobList.values(response, !query.isBlank());
|
||||||
previous.active = page > 0; next.active = page + 1 < pages;
|
previous.active = page > 0; next.active = page + 1 < pages;
|
||||||
status("Страница " + (page + 1) + " / " + pages + ". " + (skill ? "Откройте навык, чтобы изучить действия и условия." : "Откройте моба, чтобы изучить модель, поведение и получить яйцо."), false);
|
status("Страница " + (page + 1) + " / " + pages + ". " + (skill ? "Откройте навык, чтобы изучить действия и условия."
|
||||||
|
: response.has("groups") ? "Стрелка раскрывает группу. Карточка открывает определение."
|
||||||
|
: "Плоский список: для групп обновите сервер AstraPlus."), false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private void load(String id) {
|
private void load(String id) {
|
||||||
|
load(id, skill);
|
||||||
|
}
|
||||||
|
private void load(String id, boolean isSkill) {
|
||||||
if (id == null) return;
|
if (id == null) return;
|
||||||
var request = new JsonObject(); request.addProperty("id", id);
|
var request = new JsonObject(); request.addProperty("id", id);
|
||||||
connection.request(skill ? "skill_get" : "mob_get", request, response -> {
|
connection.request(isSkill ? "skill_get" : "mob_get", request, response -> {
|
||||||
if (!EditorConnection.success(response)) { reply(response); return; }
|
if (!EditorConnection.success(response)) { reply(response); return; }
|
||||||
if (minecraft.gui.screen() != this) return;
|
if (minecraft.gui.screen() != this) return;
|
||||||
minecraft.gui.setScreen(new MobEditorScreen(this, connection, catalog,
|
minecraft.gui.setScreen(new MobEditorScreen(this, connection, catalog,
|
||||||
online.astradev.plus.editor.form.MobDocuments.draft(response), skill,
|
online.astradev.plus.editor.form.MobDocuments.draft(response), isSkill,
|
||||||
response.has("details") ? response.getAsJsonObject("details") : new JsonObject()));
|
response.has("details") ? response.getAsJsonObject("details") : new JsonObject()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,8 @@ package online.astradev.plus.editor.screen;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
||||||
@@ -19,24 +18,31 @@ import net.minecraft.world.entity.LivingEntity;
|
|||||||
import online.astradev.plus.editor.client.preview.PreviewModel;
|
import online.astradev.plus.editor.client.preview.PreviewModel;
|
||||||
import online.astradev.plus.editor.client.preview.PreviewScene;
|
import online.astradev.plus.editor.client.preview.PreviewScene;
|
||||||
import online.astradev.plus.editor.network.EditorConnection;
|
import online.astradev.plus.editor.network.EditorConnection;
|
||||||
|
import online.astradev.plus.editor.form.MobGroups;
|
||||||
|
|
||||||
/** Visible rows load their model lazily; every thumbnail uses a fixed rest pose. */
|
/** Visible rows load their model lazily; every thumbnail uses a fixed rest pose. */
|
||||||
public final class MobList extends ObjectSelectionList<MobList.Row> {
|
public final class MobList extends ObjectSelectionList<MobList.Row> {
|
||||||
private static int nextPreviewId = -1;
|
private static int nextPreviewId = -1;
|
||||||
private final EditorConnection connection;
|
private final EditorConnection connection;
|
||||||
private final Consumer<String> selected;
|
private final BiConsumer<String, Boolean> selected;
|
||||||
|
private final MobGroups groups;
|
||||||
private final Map<String, Thumbnail> models = new HashMap<>();
|
private final Map<String, Thumbnail> models = new HashMap<>();
|
||||||
private int pending;
|
private int pending;
|
||||||
|
|
||||||
public MobList(Minecraft minecraft, int x, int y, int width, int height,
|
public MobList(Minecraft minecraft, int x, int y, int width, int height,
|
||||||
EditorConnection connection, Consumer<String> selected) {
|
EditorConnection connection, MobGroups groups, BiConsumer<String, Boolean> selected) {
|
||||||
super(minecraft, width, height, y, 52);
|
super(minecraft, width, height, y, minecraft.getWindow().getGuiScaledHeight() < 300 ? 40 : 52);
|
||||||
setX(x); this.connection = connection; this.selected = selected;
|
setX(x); this.connection = connection; this.groups = groups; this.selected = selected;
|
||||||
|
rebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void values(JsonArray entries) {
|
public void values(JsonObject response, boolean searching) {
|
||||||
clearEntries(); models.clear();
|
groups.values(response, searching); models.clear(); rebuild(); setScrollAmount(0);
|
||||||
entries.forEach(entry -> addEntry(new Row(entry.getAsJsonObject())));
|
}
|
||||||
|
private void rebuild() {
|
||||||
|
double scroll = scrollAmount();
|
||||||
|
clearEntries(); groups.rows().forEach(entry -> addEntry(new Row(entry)));
|
||||||
|
setScrollAmount(scroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getRowWidth() { return width - 16; }
|
@Override public int getRowWidth() { return width - 16; }
|
||||||
@@ -68,10 +74,13 @@ public final class MobList extends ObjectSelectionList<MobList.Row> {
|
|||||||
|
|
||||||
public final class Row extends ObjectSelectionList.Entry<Row> {
|
public final class Row extends ObjectSelectionList.Entry<Row> {
|
||||||
private final String id, name, entityId, modelId;
|
private final String id, name, entityId, modelId;
|
||||||
|
private final MobGroups.Row data;
|
||||||
private LivingEntity entity;
|
private LivingEntity entity;
|
||||||
private boolean resolved;
|
private boolean resolved;
|
||||||
|
|
||||||
private Row(JsonObject entry) {
|
private Row(MobGroups.Row data) {
|
||||||
|
this.data = data;
|
||||||
|
JsonObject entry = data.entry();
|
||||||
id = entry.get("id").getAsString();
|
id = entry.get("id").getAsString();
|
||||||
name = entry.has("name") ? entry.get("name").getAsString() : id;
|
name = entry.has("name") ? entry.get("name").getAsString() : id;
|
||||||
entityId = entry.has("entity") ? entry.get("entity").getAsString() : "";
|
entityId = entry.has("entity") ? entry.get("entity").getAsString() : "";
|
||||||
@@ -79,21 +88,34 @@ public final class MobList extends ObjectSelectionList<MobList.Row> {
|
|||||||
? entry.getAsJsonArray("models").get(0).getAsString() : "";
|
? entry.getAsJsonArray("models").get(0).getAsString() : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Component getNarration() { return Component.literal(name + ", " + id); }
|
@Override public Component getNarration() { return Component.literal(name + ", " + MobGroups.label(data.role()) + ", " + id
|
||||||
|
+ (data.expandable() ? data.expanded() ? ", группа раскрыта" : ", группа свёрнута" : "")); }
|
||||||
|
|
||||||
@Override public void extractContent(GuiGraphicsExtractor graphics, int mouseX, int mouseY, boolean hovered, float a) {
|
@Override public void extractContent(GuiGraphicsExtractor graphics, int mouseX, int mouseY, boolean hovered, float a) {
|
||||||
int x = getContentX() + 4, y = getContentY();
|
int inset = 18 * data.indent();
|
||||||
graphics.fill(getX(), getY(), getX() + getWidth(), getY() + getHeight() - 2,
|
int x = getContentX() + 22 + inset, y = getContentY();
|
||||||
|
int iconSize = getHeight() < 50 ? 34 : 46;
|
||||||
|
int lineSpacing = getHeight() < 50 ? 12 : 15;
|
||||||
|
int color = data.skill() || data.section() ? 0xFFB7A2E0 : data.role().equals("technical") ? 0xFFD9AF72 : 0xFF75CBB9;
|
||||||
|
graphics.fill(getX() + inset, getY(), getX() + getWidth(), getY() + getHeight() - 2,
|
||||||
getSelected() == this ? 0xFF304C53 : hovered ? 0xFF293D46 : 0xFF1B2830);
|
getSelected() == this ? 0xFF304C53 : hovered ? 0xFF293D46 : 0xFF1B2830);
|
||||||
graphics.fill(x, y + 2, x + 46, y + 48, 0xFF101C23);
|
graphics.fill(getX() + inset, getY(), getX() + inset + 2, getY() + getHeight() - 2, color);
|
||||||
|
if (data.indent() > 0) graphics.fill(getX() + 8, getY(), getX() + 10, getY() + getHeight(), 0xFF415C67);
|
||||||
|
if (data.expandable()) graphics.text(minecraft.font, data.expanded() ? "▼" : "▶", x - 14, y + iconSize / 2 - 3, color);
|
||||||
|
graphics.fill(x, y + 2, x + iconSize, y + 2 + iconSize, 0xFF101C23);
|
||||||
String hint = "";
|
String hint = "";
|
||||||
if (!modelId.isEmpty()) {
|
if (data.skill() || data.section()) {
|
||||||
|
graphics.text(minecraft.font, data.section() ? "{}" : "S", x + iconSize / 2 - 6, y + iconSize / 2 - 3, color);
|
||||||
|
} else if (data.role().equals("technical") && modelId.isEmpty()) {
|
||||||
|
graphics.text(minecraft.font, "FX", x + iconSize / 2 - 6, y + iconSize / 2 - 3, color);
|
||||||
|
hint = "Служебный носитель эффекта: неподвижен, неуязвим, без столкновений и задач ИИ.";
|
||||||
|
} else if (!modelId.isEmpty()) {
|
||||||
Thumbnail thumbnail = model(modelId);
|
Thumbnail thumbnail = model(modelId);
|
||||||
if (thumbnail != null && thumbnail.scene != null && thumbnail.scene.hasGeometry() && thumbnail.scene.missing().isEmpty())
|
if (thumbnail != null && thumbnail.scene != null && thumbnail.scene.hasGeometry() && thumbnail.scene.missing().isEmpty())
|
||||||
thumbnail.scene.extract(graphics, x + 1, y + 3, x + 45, y + 47, 0, 0.65F, -0.15F, 1);
|
thumbnail.scene.extract(graphics, x + 1, y + 3, x + iconSize - 1, y + iconSize + 1, 0, 0.65F, -0.15F, 1);
|
||||||
else {
|
else {
|
||||||
hint = thumbnail == null ? "Загружается модель…" : thumbnail.hint;
|
hint = thumbnail == null ? "Загружается модель…" : thumbnail.hint;
|
||||||
graphics.text(minecraft.font, "…", x + 19, y + 21, 0xFF91A6B2);
|
graphics.text(minecraft.font, "…", x + iconSize / 2 - 4, y + iconSize / 2 - 2, 0xFF91A6B2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!resolved && minecraft.level != null) {
|
if (!resolved && minecraft.level != null) {
|
||||||
@@ -105,25 +127,35 @@ public final class MobList extends ObjectSelectionList<MobList.Row> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
int size = Math.max(1, (int) (34 / Math.max(1, Math.max(entity.getBbHeight(), entity.getBbWidth()))));
|
int size = Math.max(1, (int) ((iconSize - 12) / Math.max(1, Math.max(entity.getBbHeight(), entity.getBbWidth()))));
|
||||||
InventoryScreen.renderEntityInInventoryFollowsAngle(graphics, x + 1, y + 3, x + 45, y + 47,
|
InventoryScreen.renderEntityInInventoryFollowsAngle(graphics, x + 1, y + 3, x + iconSize - 1, y + iconSize + 1,
|
||||||
size, 0, -0.7F, 0.1F, entity);
|
size, 0, -0.7F, 0.1F, entity);
|
||||||
} else {
|
} else {
|
||||||
hint = "Предпросмотр этого типа сущности недоступен";
|
hint = "Предпросмотр этого типа сущности недоступен";
|
||||||
graphics.text(minecraft.font, "?", x + 19, y + 21, 0xFF91A6B2);
|
graphics.text(minecraft.font, "?", x + iconSize / 2 - 4, y + iconSize / 2 - 2, 0xFF91A6B2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int textX = x + 54, textWidth = Math.max(0, getContentWidth() - 62);
|
int textX = x + iconSize + 8, textWidth = Math.max(0, getContentWidth() - 34 - iconSize - inset);
|
||||||
graphics.text(minecraft.font, minecraft.font.plainSubstrByWidth(name, textWidth), textX, y + 6, 0xFFE5EFF1);
|
graphics.text(minecraft.font, minecraft.font.plainSubstrByWidth(name, textWidth), textX, y + 5, 0xFFE5EFF1);
|
||||||
graphics.text(minecraft.font, minecraft.font.plainSubstrByWidth(id, textWidth), textX, y + 21, 0xFF9AAFB8);
|
graphics.text(minecraft.font, minecraft.font.plainSubstrByWidth(id, textWidth), textX, y + 5 + lineSpacing, 0xFF9AAFB8);
|
||||||
graphics.text(minecraft.font, minecraft.font.plainSubstrByWidth(entityId, textWidth), textX, y + 35, 0xFF91A6B2);
|
String role = MobGroups.label(data.role());
|
||||||
|
String caption = role + (data.entry().has("summary") ? "; " + data.entry().get("summary").getAsString() : "");
|
||||||
|
graphics.text(minecraft.font, minecraft.font.plainSubstrByWidth(caption, textWidth), textX, y + 5 + lineSpacing * 2, color);
|
||||||
if (hovered) graphics.setTooltipForNextFrame(minecraft.font,
|
if (hovered) graphics.setTooltipForNextFrame(minecraft.font,
|
||||||
Component.literal(name + "\n" + id + (hint.isEmpty() ? "" : "\n" + hint)), mouseX, mouseY);
|
Component.literal(name + "\n" + id + "\n" + role
|
||||||
|
+ (entityId.isEmpty() ? "" : "\nОснова: " + entityId)
|
||||||
|
+ (data.entry().has("summary") ? "\n" + data.entry().get("summary").getAsString() : "")
|
||||||
|
+ (data.entry().has("parents") && !data.entry().getAsJsonArray("parents").isEmpty()
|
||||||
|
? "\nПризывают: " + String.join(", ", data.entry().getAsJsonArray("parents").asList().stream().map(value -> value.getAsString()).toList()) : "")
|
||||||
|
+ (hint.isEmpty() ? "" : "\n" + hint)), mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
|
@Override public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
|
||||||
if (event.button() != 0) return false;
|
if (event.button() != 0) return false;
|
||||||
setSelected(this); selected.accept(id); return true;
|
if (data.expandable() && (data.section() || event.x() < getContentX() + 22 + 18 * data.indent())) {
|
||||||
|
groups.toggle(data); rebuild(); return true;
|
||||||
|
}
|
||||||
|
setSelected(this); selected.accept(id, data.skill()); return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package online.astradev.plus.editor.form;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
final class MobGroupsTest {
|
||||||
|
private JsonObject fixture() {
|
||||||
|
return JsonParser.parseString("""
|
||||||
|
{"groups":[{"mob":{"id":"example:boss","name":"Boss","role":"main"},
|
||||||
|
"members":[{"id":"example:effect","role":"technical"}],
|
||||||
|
"skills":[{"id":"example:attack","name":"Attack"}]}]}
|
||||||
|
""").getAsJsonObject();
|
||||||
|
}
|
||||||
|
@Test void collapsesAndExpandsIndependentSectionsWithoutMutatingResponse() {
|
||||||
|
var response = fixture(); var original = response.deepCopy(); var groups = new MobGroups(); groups.values(response, false);
|
||||||
|
assertEquals(1, groups.rows().size()); groups.toggle(groups.rows().get(0));
|
||||||
|
assertEquals(3, groups.rows().size()); assertEquals("technical", groups.rows().get(1).role());
|
||||||
|
assertTrue(groups.rows().get(2).section()); groups.toggle(groups.rows().get(2));
|
||||||
|
assertEquals(4, groups.rows().size()); assertTrue(groups.rows().get(3).skill());
|
||||||
|
assertEquals(2, groups.rows().get(3).indent());
|
||||||
|
groups.toggle(groups.rows().get(0)); assertEquals(1, groups.rows().size());
|
||||||
|
groups.toggle(groups.rows().get(0)); assertEquals(4, groups.rows().size());
|
||||||
|
groups.values(response, false); assertEquals(4, groups.rows().size()); assertEquals(original, response);
|
||||||
|
}
|
||||||
|
@Test void searchOpensResultsButStillAllowsCollapseAndPreservesNormalState() {
|
||||||
|
var groups = new MobGroups(); groups.values(fixture(), true); assertEquals(4, groups.rows().size());
|
||||||
|
groups.toggle(groups.rows().get(0)); assertEquals(1, groups.rows().size());
|
||||||
|
groups.values(fixture(), false); assertEquals(1, groups.rows().size());
|
||||||
|
}
|
||||||
|
@Test void oldServerKeepsFlatCatalogWithoutClaimingToKnowRoles() {
|
||||||
|
var groups = new MobGroups(); groups.values(JsonParser.parseString("{\"entries\":[{\"id\":\"example:mob\"}]}").getAsJsonObject(), false);
|
||||||
|
assertEquals(1, groups.rows().size()); assertEquals("mob", groups.rows().get(0).role()); assertFalse(groups.rows().get(0).expandable());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -45,6 +45,7 @@ public final class EditorVerification {
|
|||||||
private final IconVerification icons = Boolean.getBoolean("astrapluseditor.iconVerification") ? new IconVerification() : null;
|
private final IconVerification icons = Boolean.getBoolean("astrapluseditor.iconVerification") ? new IconVerification() : null;
|
||||||
private final EnchantmentGuiVerification enchantments = Boolean.getBoolean("astrapluseditor.enchantmentVerification") ? new EnchantmentGuiVerification() : null;
|
private final EnchantmentGuiVerification enchantments = Boolean.getBoolean("astrapluseditor.enchantmentVerification") ? new EnchantmentGuiVerification() : null;
|
||||||
private final RecipeGuiVerification recipes = Boolean.getBoolean("astrapluseditor.recipeVerification") ? new RecipeGuiVerification() : null;
|
private final RecipeGuiVerification recipes = Boolean.getBoolean("astrapluseditor.recipeVerification") ? new RecipeGuiVerification() : null;
|
||||||
|
private final MobGroupsGuiVerification mobGroups = Boolean.getBoolean("astrapluseditor.mobGroupsVerification") ? new MobGroupsGuiVerification() : null;
|
||||||
|
|
||||||
public EditorVerification() {
|
public EditorVerification() {
|
||||||
if (!Boolean.getBoolean("astrapluseditor.isolatedVerification"))
|
if (!Boolean.getBoolean("astrapluseditor.isolatedVerification"))
|
||||||
@@ -53,6 +54,7 @@ public final class EditorVerification {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void tick(ClientTickEvent.Post event) {
|
private void tick(ClientTickEvent.Post event) {
|
||||||
|
if (mobGroups != null) { mobGroups.tick(); return; }
|
||||||
if (recipes != null) { recipes.tick(); return; }
|
if (recipes != null) { recipes.tick(); return; }
|
||||||
if (enchantments != null) { enchantments.tick(); return; }
|
if (enchantments != null) { enchantments.tick(); return; }
|
||||||
if (icons != null) { icons.tick(); return; }
|
if (icons != null) { icons.tick(); return; }
|
||||||
|
|||||||
+94
@@ -0,0 +1,94 @@
|
|||||||
|
package online.astradev.plus.editor.verification;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.Screenshot;
|
||||||
|
import net.minecraft.client.gui.components.AbstractWidget;
|
||||||
|
import net.minecraft.client.input.MouseButtonEvent;
|
||||||
|
import net.minecraft.client.input.MouseButtonInfo;
|
||||||
|
import online.astradev.plus.editor.network.EditorConnection;
|
||||||
|
import online.astradev.plus.editor.screen.EditorScreen;
|
||||||
|
import online.astradev.plus.editor.screen.MobBrowserScreen;
|
||||||
|
import online.astradev.plus.editor.screen.MobList;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
|
/** Real grouped browser and mouse controls; isolated client, no server or world mutations. */
|
||||||
|
final class MobGroupsGuiVerification {
|
||||||
|
private int tick;
|
||||||
|
private volatile int screenshots;
|
||||||
|
private boolean started;
|
||||||
|
private MobBrowserScreen screen;
|
||||||
|
private MobList list;
|
||||||
|
private final JsonObject fixture = JsonParser.parseString("""
|
||||||
|
{"groups":[{"mob":{"id":"example:guardian","name":"Хранитель руин","entity":"minecraft:zombie","role":"main"},
|
||||||
|
"members":[{"id":"example:guardian_helper","name":"Малый страж","entity":"minecraft:zombie","role":"summoned","parents":["example:guardian"]},
|
||||||
|
{"id":"example:guardian_dust","name":"Облако пыли","entity":"minecraft:armor_stand","role":"technical","parents":["example:guardian"]}],
|
||||||
|
"skills":[{"id":"example:guardian_attack","name":"Удар по земле"},{"id":"example:guardian_summon","name":"Призыв стражей"}]},
|
||||||
|
{"mob":{"id":"example:beetle","name":"Панцирный жук","entity":"minecraft:pig","role":"main"},"members":[],"skills":[]}]}
|
||||||
|
""").getAsJsonObject();
|
||||||
|
|
||||||
|
void tick() {
|
||||||
|
var mc = Minecraft.getInstance();
|
||||||
|
try {
|
||||||
|
if (!started) {
|
||||||
|
if (!mc.isGameLoadFinished() || mc.gui.overlay() != null) return;
|
||||||
|
started = true; GLFW.glfwHideWindow(mc.getWindow().handle());
|
||||||
|
mc.getWindow().setWidth(1280); mc.getWindow().setHeight(720); mc.framebufferSizeChanged();
|
||||||
|
mc.options.guiScale().set(2); mc.resizeGui(); show(false);
|
||||||
|
}
|
||||||
|
switch (++tick) {
|
||||||
|
case 15 -> { require(list.children().size() == 2, "collapsed roots"); capture("mob-groups-collapsed.png"); }
|
||||||
|
case 20 -> click(0, true);
|
||||||
|
case 30 -> { require(list.children().size() == 5, "expanded mobs and skill section"); capture("mob-groups-expanded.png"); }
|
||||||
|
case 35 -> {
|
||||||
|
list.setScrollAmount(156);
|
||||||
|
}
|
||||||
|
case 40 -> click(3, false);
|
||||||
|
case 50 -> { require(list.children().size() == 7, "expanded skill definitions"); capture("mob-groups-skills.png"); }
|
||||||
|
case 55 -> { mc.options.guiScale().set(3); mc.resizeGui(); show(true); }
|
||||||
|
case 65 -> capture("mob-groups-small.png");
|
||||||
|
case 70 -> { list.setScrollAmount(156); }
|
||||||
|
case 80 -> capture("mob-groups-small-skills.png");
|
||||||
|
case 85 -> {
|
||||||
|
// Clicking a skill must request skill_get, without opening or spawning a mob.
|
||||||
|
var selected = new java.util.concurrent.atomic.AtomicReference<String>();
|
||||||
|
var data = new online.astradev.plus.editor.form.MobGroups(); data.values(fixture, true);
|
||||||
|
var isolated = new MobList(mc, 12, 92, screen.width - 24, 52, EditorConnection.INSTANCE, data,
|
||||||
|
(id, skill) -> selected.set(id + ":" + skill));
|
||||||
|
var row = isolated.children().get(4);
|
||||||
|
row.mouseClicked(new MouseButtonEvent(200, 100, new MouseButtonInfo(0, 0)), false);
|
||||||
|
require("example:guardian_attack:true".equals(selected.get()), "skill selection route");
|
||||||
|
require(screenshots == 5, "screenshots finished");
|
||||||
|
Files.writeString(mc.gameDirectory.toPath().resolve("mob-groups-gui-result.txt"),
|
||||||
|
"PASS: grouped browser, real expansion clicks, separate skills, selection route, scrolling, GUI scales 2/3, bounds, 5 captures. No world/model rendering in this scenario.");
|
||||||
|
mc.stop();
|
||||||
|
}
|
||||||
|
default -> { }
|
||||||
|
}
|
||||||
|
} catch (Exception error) {
|
||||||
|
try { Files.writeString(mc.gameDirectory.toPath().resolve("mob-groups-gui-result.txt"), "FAIL: " + error); } catch (Exception ignored) { }
|
||||||
|
mc.stop(); throw new IllegalStateException(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void show(boolean search) throws Exception {
|
||||||
|
screen = new MobBrowserScreen(EditorConnection.INSTANCE, false); Minecraft.getInstance().gui.setScreen(screen);
|
||||||
|
list = screen.children().stream().filter(MobList.class::isInstance).map(MobList.class::cast).findFirst().orElseThrow();
|
||||||
|
list.values(fixture, search);
|
||||||
|
var status = EditorScreen.class.getDeclaredMethod("status", String.class, boolean.class); status.setAccessible(true);
|
||||||
|
status.invoke(screen, "Стрелка раскрывает группу. Карточка открывает определение.", false);
|
||||||
|
}
|
||||||
|
private void click(int index, boolean arrow) {
|
||||||
|
var row = list.children().get(index);
|
||||||
|
row.mouseClicked(new MouseButtonEvent(row.getX() + (arrow ? 10 : 90), row.getY() + 24, new MouseButtonInfo(0, 0)), false);
|
||||||
|
}
|
||||||
|
private void capture(String file) {
|
||||||
|
var mc = Minecraft.getInstance();
|
||||||
|
for (var child : screen.children()) if (child instanceof AbstractWidget w)
|
||||||
|
require(w.getX() >= 0 && w.getY() >= 0 && w.getX() + w.getWidth() <= screen.width && w.getY() + w.getHeight() <= screen.height,
|
||||||
|
"widget bounds: " + w.getClass().getSimpleName() + " " + w.getX() + "," + w.getY() + " " + w.getWidth() + "x" + w.getHeight() + " screen " + screen.width + "x" + screen.height);
|
||||||
|
Screenshot.grab(mc.gameDirectory, file, mc.gameRenderer.mainRenderTarget(), 1, ignored -> screenshots++);
|
||||||
|
}
|
||||||
|
private static void require(boolean value, String message) { if (!value) throw new IllegalStateException(message); }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user