跳到正文

Calyren’s Utils

作者:Calyren

我在其他模组中使用的一个实用工具/前置库模组。

收藏

介绍

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

CXD’s Utilities

Instalation

build.gradle:

repositories {
	exclusiveContent {
		forRepository {
			maven {
				name = "Modrinth"
				url = "https://api.modrinth.com/maven"
			}
		}
		filter {
			includeGroup "maven.modrinth"
		}
	}
}

dependencies {
    implementation "maven.modrinth:t9HzrmQg:<version_id>"
}

Replace with an actual Version ID. (Ex. For 1.0-26.2, the Version ID is “2k1jbG7k”)


Q: Where do I find the Version ID?

A: Go to the version you want install and then click on “Developer information”. You should find the Version ID there.

Version ID

Mob Effects

CXD’s Utils adds 3 classes related to Mob Effects:

  • CustomEffectDuration
  • CustomEffectTooltip
  • StatusEffectBackground

CustomEffectDuration

CustomEffectDuration lets you set a custom duration text for Mob Effects.

public class YourMobEffect extends MobEffect implements CustomEffectDuration {
<...>

    @Override
    public Component getDurationText(MobEffectInstance instance) {
        return Component.literal("Hi!!! This is an Example!")
                .withStyle(style -> style.withColor(0xFFFFFF));
    }

}

Instead of showing how long the effect lasts, it will display:

Hi!!! This is an Example!

CustomEffectTooltip

CustomEffectTooltip lets you add a custom tooltip to Mob Effects.

public class YourMobEffect extends MobEffect implements CustomEffectTooltip {
<...>

    @Override
    public List<Component> getTooltipLines(MobEffectInstance instance) {
        return List.of(
                Component.literal("This Text will appear when you hover over the Effect!")
                        .withStyle(ChatFormatting.WHITE),
                Component.literal("It also supports multiple lines!")
                        .withStyle(ChatFormatting.WHITE)
        );
    }

}

When hovering over the Mob Effect, the custom tooltip text will appear.


StatusEffectBackground

CustomEffectTooltip lets you add a custom texture to your MobEffect’s background.

public class YourMobEffect extends MobEffect implements StatusEffectBackground {
<...>

    @Override
    public Identifier inventorySprite() {
        return Identifier.fromNamespaceAndPath(YourMod.MOD_ID, "container/inventory/
effect_background");
    }
    @Override
    public Identifier ambientInventorySprite() {
        return Identifier.fromNamespaceAndPath(YourMod.MOD_ID, "container/inventory/
effect_background_ambient");
    }

}

Check https://mcasset.cloud/26.1.2/assets/minecraft/textures/gui/sprites/container/inventory to see how Minecraft does the effect backgrounds. This uses the same logic.

常见问题

Calyren’s Utils 支持哪些 Minecraft 版本?

Calyren’s Utils 支持 Minecraft Java 版 26.2–26.3,共 2 个版本,可用的加载器:Fabric。下载时注意选择和你游戏版本一致的文件。

Calyren’s Utils 怎么安装?

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

评论

登录后评论和评分

Calyren 的其他作品

查看全部 →