x4UI

模组

· 作者 X4yi

是我模组的 UI 框架。

0 本站下载 0 关注 更新于 3 天前

最新 r1.0b6 · 1.12.2 · Forge

一键开服(送7天)

X4UI Framework

一个现代化、高性能的面向对象的 Minecraft Forge 1.12.2 GUI 框架。

English • Español


?? English

About X4UI

Tired of dealing with hardcoded coordinates, messy drawScreen overrides, and infinite bugs in the archaic Vanilla Minecraft 1.12.2 GUI system?

X4UI is a standalone, flexible, and dynamic user interface framework extracted from Hammers Unbound. It brings modern web-like development paradigms (like FlexBox layouts, DOM-tree structures, and event bubbling) straight into Forge 1.12.2.

When should I use X4UI?

You should use X4UI if you are building:

  • Interactive Guidebooks or Manuals: Need to render formatted text? X4UI includes a native GuiMarkdown parser that automatically converts Markdown text into beautiful, structured UI elements (Headers, blockquotes, bullets, and images).
  • RPG Skill Trees & Complex Menus: Nested panels, buttons, toggles, and sliders are handled automatically.
  • Dynamic Inventories / Custom Forges: GuiScrollPanel provides out-of-the-box OpenGL clipping (GL_SCISSOR_TEST), allowing you to create smooth, scrollable lists of ingredients without items rendering outside the box. Nested scroll panels automatically intersect their scissor boxes using ScissorHelper.

Key Features

  • DOM Architecture: Build your UI by nesting components (rootPanel.addChild(new GuiButton(...))).
  • FlexBox Layouts: GuiPanel supports automatic VERTICAL and HORIZONTAL stacking with gaps and margins. No more manual math for UI placement!
  • High Performance (Dirty Flag System): Layouts are only recalculated when a component physically changes, saving massive amounts of CPU and preventing FPS drops even in screens with hundreds of elements.
  • Event Bubbling: Clicks and scroll events accurately respect Z-index. Clicking an overlapping button will trigger the top-most one and stop propagating.
  • Micro-Animations: Built-in lerp logic for buttery-smooth hover and click transitions. All animations are FPS-independent and scaled by delta-time to ensure the same speed on any hardware.
  • Memory Safety (LRU Caching): The FontWidthCache system ensures complex text parsing (like Markdown) won't cause memory leaks by limiting cached strings using an automatic LRU eviction policy.

Installation (For Developers)

Add the following to your build.gradle:

repositories {
    maven { url 'https://api.modrinth.com/maven' }
}

dependencies {
    // Replace r1.0b3 with the latest release tag
    compile 'maven.modrinth:x4ui:r1.0b3'
}

Quick Start

To use X4UI, simply extend GuiBaseScreen instead of Vanilla's GuiScreen:

public class MyCustomScreen extends GuiBaseScreen {
    
    public MyCustomScreen() {
        super(null, "My Title");
    }

    @Override
    protected void initComponents() {
        // rootPanel is automatically created by GuiBaseScreen
        rootPanel.setFlexDirection(FlexDirection.VERTICAL);
        rootPanel.setGap(5);
        
        GuiLabel titleLabel = new GuiLabel(0, 0, "HELLO X4UI!");
        GuiButton closeButton = new GuiButton(0, 0, 100, 20, "Close", () -> this.closeScreen());
        
        rootPanel.addChild(titleLabel);
        rootPanel.addChild(closeButton);
    }
}

?? Español

Sobre X4UI

¿Cansado de lidiar con coordenadas estáticas (hardcodeadas), sobreescrituras desordenadas de drawScreen e infinitos bugs en el arcaico sistema de interfaces de Vanilla Minecraft 1.12.2?

X4UI es un framework de interfaces de usuario dinámico, flexible e independiente, extraído del mod Hammers Unbound. Trae consigo los paradigmas de desarrollo web modernos (como diseños FlexBox, estructuras en árbol DOM y propagación de eventos) directamente a Forge 1.12.2.

¿Cuándo debería usar X4UI?

Deberías considerar usar X4UI si estás creando:

  • Guías o Manuales Interactivos: ¿Necesitas renderizar texto con formato? X4UI incluye un analizador nativo GuiMarkdown que convierte automáticamente texto en elementos de UI estructurados y hermosos (Encabezados, citas, viñetas e imágenes).
  • Árboles de Habilidades RPG y Menús Complejos: Los paneles anidados, botones, interruptores y deslizadores (sliders) se manejan automáticamente.
  • Inventarios Dinámicos / Forjas Customizadas: GuiScrollPanel proporciona recorte OpenGL nativo (GL_SCISSOR_TEST), permitiéndote crear listas de ingredientes desplazables y suaves sin que los ítems se rendericen fuera de la caja. Los paneles anidados calcularán sus áreas de recorte perfectamente gracias a ScissorHelper.

主要特性

  • DOM 架构: 通过嵌套组件来构建界面(rootPanel.addChild(new GuiButton(...)))。
  • FlexBox 布局: GuiPanel 支持自动堆叠的 VERTICAL(垂直)和 HORIZONTAL(水平)布局,并包含边距与间距。再也不用手动计算数学公式来定位界面元素了!
  • 高性能(脏标记系统): 仅当组件发生物理变化时才会重新进行数学布局计算。这能节省大量处理资源,防止 FPS 下降,即使是在拥有数百个元素的菜单中也是如此。
  • 事件传播: 点击和滚动操作会精确遵循 Z 轴索引。点击重叠的按钮将触发位于上方的按钮,并阻止事件向下层传播。
  • 微动画: 内置插值(lerp)逻辑,实现流畅的“悬停”和点击过渡效果。动画独立于 FPS(按 DeltaTime 缩放),确保在任何 PC 上视觉速度一致。
  • 内存安全(LRU 缓存): FontWidthCache 系统确保复杂文本(如 Markdown)的分析不会导致内存泄漏,它通过使用自动清理策略的 LRU(最近最少使用)算法来限制缓存字符串的数量。

安装方法(针对开发者)

将以下内容添加到你的 build.gradle 文件中:

repositories {
    maven { url 'https://api.modrinth.com/maven' }
}

dependencies {
    // 请将 r1.0b3 替换为最新版本号
    compile 'maven.modrinth:x4ui:r1.0b3'
}

快速入门

要使用 X4UI,只需让你的类继承自 GuiBaseScreen,而不是原版经典的 GuiScreen:

public class MyCustomScreen extends GuiBaseScreen {
    
    public MyCustomScreen() {
        super(null, "Mi Título");
    }

    @Override
    protected void initComponents() {
        // rootPanel 由 GuiBaseScreen 自动创建
        rootPanel.setFlexDirection(FlexDirection.VERTICAL);
        rootPanel.setGap(5);
        
        GuiLabel titleLabel = new GuiLabel(0, 0, "HOLA X4UI!");
        GuiButton closeButton = new GuiButton(0, 0, 100, 20, "Cerrar", () -> this.closeScreen());
        
        rootPanel.addChild(titleLabel);
        rootPanel.addChild(closeButton);
    }
}

X4UI 是开源软件,根据 GNU 通用公共许可证 v3 (GPL-3.0) 发布。

你是这个资源的作者?登录后可认领此资源。

评论 0

0.0
暂无评分
5 星
0
4 星
0
3 星
0
2 星
0
1 星
0
我的评分

登录后参与评分

还没有评论,来抢沙发吧

评论配图

相似资源