跳到正文

Spell Renderer

作者:getharlik

A fast, lightweight OpenGL wrapper for Minecraft, designed for rendering 2D objects with a clean, fluent API.

收藏

截图

介绍

中文介绍正在准备中,下面暂时显示原文。

✨ Spell Renderer

Modern 2D UI rendering for Fabric mods: rounded panels, liquid glass, crisp text and draggable HUDs, all from one fluent API.

Preview

Building a good-looking interface in Minecraft usually means fighting with GuiGraphics or writing raw OpenGL yourself. Spell Renderer gives you a small, chainable builder instead. You
describe a shape and call .submit(), and the library takes care of shaders, batching, scaling and clipping.

📦 This is a library mod. On its own it adds nothing to the game. Install it if another mod needs it, or use it to build your own UI.


🎨 What you can draw

| Shape | What it’s for |
|—|—|
| Rectangle | Panels and buttons with rounded corners, a different radius per corner, and gradient colors |
| Circle | Dots, indicators, avatars |
| Image | Textures with optional rounded corners |
| Text | Sharp text at any size, using MSDF fonts |
| Icon | Named icons from your own icon fonts, e.g. Builder.icon("settings") |
| Glass | Frosted or liquid glass panels with adjustable blur, refraction and more |

🧊 New: liquid glass

Glass panels have been rebuilt from the ground up. Each panel has its own settings:

  • Blur. From barely there to heavily frosted, and every radius costs the same, so heavy blur doesn’t slow your UI down.
  • Refraction. Edges bend the background like a lens, for the liquid-glass look. Set it to 0 for flat frosted glass.
  • Chromatic split. A subtle RGB fringe along the edges.
  • Saturation. Make the background behind the glass more vivid, or turn it grayscale.
  • Highlight. A thin rim of light along the edge.
  Builder.glass()
          .pos(20, 20)
          .size(200, 120)
          .radius(16)
          .blur(16)
          .refraction(0.9f)
          .chromatic(4)
          .saturation(1.4f)
          .highlight(0.3f)
          .submit();

Glass now looks the same at every UI scale, and stacking glass on glass works as you’d expect.

⚡ Features

  • 🔗 Fluent builder. Position, size, color, round and fade a shape in one readable chain.
  • 🖱️ Draggable shapes. Add .draggable("id") to a shape and players can move it with the mouse. Its children move with it, it can’t leave the screen, and its position can be saved and restored.
  • 👪 Parenting. Attach shapes to a parent and they follow its position, depth and opacity.
  • 🚀 Batched rendering. Shapes of the same type are drawn together in one draw call.
  • 🔤 MSDF text. Text stays sharp at any scale and any GUI size.
  • ✂️ Scissors. Clip drawing to a region, which is handy for scroll lists and masked panels.
  • 🔍 Scaling. Scale your whole UI independently of Minecraft’s GUI scale.
  • 🧭 Render contexts. Draw on the HUD during gameplay or on the GUI layer above every screen. (World rendering is in development.)

🧑‍💻 How it looks in code

  SpellRenderer.on(RenderContext.HUD, () -> {
      var panel = Builder.rect()
              .pos(20, 20)
              .size(220, 80)
              .radius(12)
              .color(new Color(30, 30, 40))
              .draggable("my-panel");   // players can move it while chat is open
      panel.submit();

      Builder.text("Hello, Spell!")
              .pos(12, 12)
              .size(24)
              .parent(panel)            // moves together with the panel
              .submit();
  });

📥 Getting started

Add it from the Modrinth Maven:

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

  dependencies {
      modImplementation "maven.modrinth:spell-renderer:<version>"
      include "maven.modrinth:spell-renderer:<version>" // optional: bundle it inside your mod
  }

Maven setup, adding fonts and icons, and the full API are in the documentation on GitHub.

📋 Requirements

  • Minecraft 1.21.8
  • Fabric Loader 0.18.5+
  • Fabric API
  • Java 21

💬 Found a bug or have an idea?

Open an issue on GitHub. Feedback and contributions are welcome!

常见问题

Spell Renderer 支持哪些 Minecraft 版本?

Spell Renderer 支持 Minecraft Java 版 1.21.8,可用的加载器:Fabric。下载时注意选择和你游戏版本一致的文件。

Spell Renderer 怎么安装?

先用 PCL2 或 HMCL 启动器安装对应版本的 Fabric,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。运行环境:仅客户端。

评论

登录后评论和评分

getharlik 的其他作品

查看全部 →