aternos/renderchest 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aternos/renderchest

Composer 安装命令:

composer require aternos/renderchest

包简介

PHP library for rendering icons for Minecraft items directly from Minecraft's assets

README 文档

README

Renderchest is a PHP library for rendering icons for Minecraft items directly from Minecraft's assets. A CSS library for using the icons in web pages is also generated.

Builtin models

While most block/item models in Minecraft are saved in Minecraft's JSON model format nowadays, some models are still hard-coded in Java (e.g. chests, shulker boxes).
These models are inaccessible to the game's resource pack system and cannot be rendered by renderchest. Renderchest therefore includes a number of built-in model files to replace these hard-coded models.

Renderchest also includes model files for the heads of most mobs. These models can be used by rendering the mobheads namespace.

Tinting

Some textures are dynamically tinted by the game (e.g. vegetation and grass blocks). This information can't be extracted from the asset files and therefore is hard-coded in renderchest.

Requirements

  • PHP 8.1+
  • ext-imagick
  • ext-pcntl (optional, allows more efficient multithreading)

Windows support

While Renderchest will generally work on Windows, it will be much slower since asynchronous tasks are not supported. It is therefore recommended to use the Windows Subsystem for Linux to run renderchest on Windows.

Usage

To use renderchest, a valid Minecraft assets directory is required. It can be extracted from a Minecraft client jar file.

CLI usage

Installation

git clone https://github.com/aternosorg/renderchest.git
cd renderchest
composer install

Rendering icons

./renderchest --assets path/to/assets/root --output path/to/output/dir --namespace minecraft
OPTIONS
  --assets, -a       Assets folder to use. Multiple assets folders are possible,
                     but a base assets folder extracted from the Minecraft jar
                     should always be included.
  --fallback         Create a set of fallback textures as PNGs. Default: false
  --format, -f       Output image format. Default: webp
  --help, -?         Display this help.
  --item-list, -i    Create a JSON file containing the names of all rendered
                     items.
  --namespace, -n    Asset namespace that the items should be rendered from.
                     Default: minecraft
  --output, -o       Output directory
  --prefix, -p       Prefix to use for CSS classes. Default: rc-
  --quality, -q      When generating very small icons, small issues (like
                     z-fighting of faces close to each other) can occur. This
                     option allows rendering images in a higher resolution and
                     scaling them down for the final icon. Default: 2
  --size, -s         Size of the generated item icons. Default: 64

Renderchest uses Taskmaster for asynchronous tasks, which can be configured using environment variables.

Using resource packs

Resource packs can be added by specifying multiple asset paths. It is also important to always include the base assets folder extracted from the Minecraft jar.

./renderchest --assets path/to/resource-pack/assets --assets path/to/assets/root --output path/to/output/dir --namespace minecraft

Make sure to use the path to the assets folder within your resource pack, not the root of the resource pack.

Using the generated CSS library

The generated CSS library can be used to display the rendered icons in web pages. All generated CSS classes are prefixed with rc- by default. Whenever a CSS class name contains a namespaced ID, the namespace is separated from the ID by an underscore (e.g. minecraft:stone -> minecraft_stone).

<div class="rc-item rc-minecraft_magma_block" style="width: 64px; height: 64px"></div>

The rc-item class is required for all icons. Additionally, a class for the item/block is required.

Enchanted items can be displayed by adding the rc-enchanted class.

<div class="rc-item rc-minecraft_diamond_sword rc-enchanted" style="width: 64px; height: 64px"></div>

Armor trims

Armor trims can be displayed by adding a rc-trim-[material] class.

<div class="rc-item rc-minecraft_diamond_helmet rc-trim-minecraft_gold" style="width: 64px; height: 64px"></div>

Decorated pots

Decorated pots can be displayed by adding rc-pot-1-[material-1] and rc-pot-2-[material-3] classes.

<div class="rc-item rc-minecraft_decorated_pot rc-pot-1-minecraft_prize_pottery_sherd rc-pot-2-minecraft_angler_pottery_sherd" style="width: 64px; height: 64px"></div>

Only the first and third material are required because the other sides of the pot are not visible.

Crossbow projectiles

Crossbow projectiles can be displayed by adding rc-projectile-[material] classes.

<div class="rc-item rc-minecraft_crossbow rc-projectile-minecraft_tipped_arrow" style="width: 64px; height: 64px"></div>

Dynamic tinting

Icons can consist of two layers, which can be separately tinted using CSS. This is necessary whenever colors can change dynamically based on item properties (e.g. dyed leather armor or potions).

Dynamic colors can be added by setting the --rc-layer-1-tint and --rc-layer-2-tint CSS variables.

<div class="rc-item rc-minecraft_leather_helmet" style="--rc-layer-1-tint: #b02e26;width: 64px; height: 64px"></div>

Using renderchest as a library

Installation

composer require aternos/renderchest

When using renderchest as a library, the ItemLibraryGenerator class can be used to replicate the functionality of the CLI tool.

ItemLibraryGenerator::fromAssetsFolders(["path/to/assets"], "path/to/output")
    ->setNamespaces(["minecraft"])
    ->setSize(64)
    ->setQuality(2)
    ->setFormat("webp")
    ->render();

It is also possible to load specific models from a resource manager instead of rendering everything.

$resourceManager = new \Aternos\Renderchest\Resource\FolderResourceManager(["path/to/assets"]);
$model = $resourceManager->getModel(new \Aternos\Renderchest\Resource\ResourceLocator("minecraft", "item/stone"));

$image = $model->render(64, 64, \Aternos\Renderchest\Vector\Matrix4::identity(), \Aternos\Renderchest\Vector\Matrix4::identity());

The $outer and $inner parameters of the render method can be used to apply transformations to the rendered model before or after the GUI display transformation is applied.

aternos/renderchest 适用场景与选型建议

aternos/renderchest 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 304 次下载、GitHub Stars 达 30, 最近一次更新时间为 2023 年 03 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「item」 「css」 「render」 「minecraft」 「icon」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 aternos/renderchest 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 aternos/renderchest 我们能提供哪些服务?
定制开发 / 二次开发

基于 aternos/renderchest 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 304
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 30
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 30
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-15