Seam
用于 Perspective 和 Luminance 的共享类与资源。
Seam 目前正处于开发阶段
部分功能在开发过程中可能会发生变化。
请在我们的 Issues 页面报告错误并提出功能建议。
或者,您可以在我的 Fluxer 或 Discord 服务器的 #bug reports 频道告知我们,我们会为您创建相应的 Issue。
如果您需要任何帮助,也可以使用 #modding chat 频道!
如果您是玩家,除非有模组明确要求您安装,否则您 不需要 安装此内容。大多数使用 Seam 的模组都应已将其捆绑;您仍然可以单独安装 Seam,Fabric 将使用最新版本。
以下信息仅供模组开发者参考,以帮助他们了解如何使用 Seam。
事件 (Events)
Seam 包含多个事件注册表,以帮助简化开发工作。
这些主要是围绕 Luminance 和 Perspective 设计的,但欢迎其他模组使用它们!
本描述并不详尽,建议您查看我们的源代码!
客户端事件 (Client Events)
以下客户端事件注册表位于 dev.dannytaylor.perspective.seam.client.events.SeamClientEvents 类中:
CustomBadges
- 建议使用
SeamClientEvents.registerCustomBadge(Identifier badgeId, int outlineColor, int fillColor, int textColor); 函数来注册自定义徽章,请参阅下方 ModMenu Badges 部分的示例。
ModBadges
- 建议使用
SeamClientEvents.registerModBadge(String modId, Identifier customBadgeId); 函数来注册模组徽章,请参阅下方 ModMenu Badges 部分的示例。
IconOverrides
- 建议使用
SeamClientEvents.registerIconOverride(String modId, IconOverride iconOverride); 函数来注册图标覆盖。
ProfiledDebugEntries
- 建议使用
SeamClientEvents.registerProfiledDebugEntry(Identifier identifier, DebugScreenEntry debugScreenEntry, DebugScreenProfile profile, DebugScreenEntryStatus status); 函数来注册带分析数据的调试条目。
ClientResourceReloaders
net.minecraft.resources.Identifier 到 net.minecraft.server.packs.resources.PreparableReloadListener 的映射,在客户端初始化时注册,并在客户端资源重载时执行。
AfterClientResourceReload
net.minecraft.resources.Identifier 到 java.lang.Runnable 的映射,在客户端资源重载后执行。
BeforeGuiRender
net.minecraft.resources.Identifier 到 dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.GuiRender 的映射,在 GUI 渲染之前执行。
AfterGuiRender
net.minecraft.resources.Identifier 到 dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.GuiRender 的映射,在 GUI 渲染之后执行。
BeforeGameRender
net.minecraft.resources.Identifier 到 java.lang.Runnable 的映射,在游戏渲染之前执行。
AfterPanoramaRender
net.minecraft.resources.Identifier 到 dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.PanoramaRender 的映射,在主菜单全景图渲染之后执行。
AfterVanillaPostEffectRender
net.minecraft.resources.Identifier 到 dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.GameRender 的映射,在原版后期处理着色器渲染之后执行。
BeforeUiRender
net.minecraft.resources.Identifier 到 dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.GameRender 的映射,在当前屏幕渲染之前执行。
AfterUiBackgroundRender
net.minecraft.resources.Identifier 到 dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.GameRender 的映射,在当前屏幕背景渲染之后执行。
AfterUiRender
net.minecraft.resources.Identifier 到 dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.GameRender 的映射,在所有内容渲染之后执行。
OnResized
net.minecraft.resources.Identifier 到 dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.OnResized 的映射,在窗口调整大小时执行。
OnMouseScroll
net.minecraft.resources.Identifier 到 dev.dannytaylor.perspective.seam.client.events.SeamClientCallables.OnMouseScroll 的映射,在鼠标滚轮滚动时执行。
OnMouseButton
net.minecraft.resources.Identifier 到 dev.dannytaylor.perspective.seam.client.events.SeamClientCallables.OnMouseButton 的映射,在处理鼠标按键时执行。
OnJoinWorld
net.minecraft.resources.Identifier 到 java.lang.Runnable 的映射,在客户端加入世界时执行。
OnLeaveWorld
net.minecraft.resources.Identifier 到 java.lang.Runnable 的映射,在客户端离开世界时执行。
OnStartItemUse
net.minecraft.resources.Identifier 到 dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.UseItem 的映射,在使用物品时执行(仅限客户端)。
OnFinishItemUse
net.minecraft.resources.Identifier 到 dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.FinishUsingItem 的映射,在完成物品使用时执行(仅限客户端)。
消息栏 (Message Bar)
Seam 会在屏幕顶部中央添加一个消息栏。
有关如何从服务器发送消息,请参阅通用事件 (Common Events)。
您可以通过以下函数更新消息栏(在客户端):
dev.dannytaylor.perspective.seam.client.events.SeamClientEvents.sendToMessageBar(Component.literal("this is an example message!"));
图标覆盖 (Icon Overrides)
您可以向 Seam 注册自定义图标覆盖。
这将自动通过 Mod Menu 更新您的模组图标。如果您将此功能与其他模组(如 Sodium)一起使用,则需要手动实现此功能。
以下是一个注册仅在 4 月 1 日生效的图标覆盖的示例。
import net.fabricmc.api.ClientModInitializer;
import net.minecraft.resources.Identifier;
import dev.dannytaylor.perspective.seam.client.events.SeamClientEvents;
import dev.dannytaylor.perspective.seam.common.util.DateHelper;
import dev.dannytaylor.perspective.seam.client.events.IconOverride;
public class MyClientInitializer implements ClientModInitializer {
@Override
public void onInitializeClient() {
SeamClientEvents.registerIconOverride("modId", new IconOverride(Identifier.parse("modid:textures/icon2.png"), DateHelper::isAprilFools));
}
}
ModMenu 徽章
您可以使用 Seam 注册自定义 ModMenu 徽章。
注册自定义徽章不需要安装 ModMenu。
以下是一个注册自定义 ModMenu 徽章的示例。
import net.fabricmc.api.ClientModInitializer;
import net.minecraft.resources.Identifier;
import dev.dannytaylor.perspective.seam.client.events.SeamClientEvents;
public class MyClientInitializer implements ClientModInitializer {
public static final Identifier EXAMPLE_BADGE = SeamClientEvents.registerCustomBadge(
Identifier.parse("modid:example_badge"), // 徽章标识符
0xFFAAAAAA, // 轮廓颜色
0xFF808080, // 填充颜色
0xFFFFFFFF // 文本颜色
);
@Override
public void onInitializeClient() {
SeamClientEvents.registerModBadge("modId", EXAMPLE_BADGE);
}
}
您还需要在语言文件中添加以下键(/assets/<namespace>/lang/en_us.json)。
{
"gui.modid.custom_badge.example_badge": "Example"
}
语言键格式为:gui.<namespace>.custom_badge.<path>。
内置徽章
Seam 包含两个内置徽章。
Perspective
由 Perspective 旗下的模组使用,表示它们属于 Perspective 系列。
Luminance
适用于使用 Luminance 的模组,表示支持 Luminance 光影。
以下是一个将 Luminance 徽章添加到您的模组的示例。
import net.fabricmc.api.ClientModInitializer;
import dev.dannytaylor.perspective.seam.client.events.Badges;
public class MyClientInitializer implements ClientModInitializer {
@Override
public void onInitializeClient() {
Badges.luminance("modId");
}
}
公共事件
Seam 当前不包含任何公共或仅服务器端的注册表。
但它包含一些公共函数和类。
dev.dannytaylor.perspective.seam.common.data.FabricMod 存储模组 ID、名称并创建日志记录器。
您还可以通过 dev.dannytaylor.perspective.seam.common.data.log.SeamLog 向日志记录器发送消息,只需在函数参数中指定您的 FabricMod 即可(info、warn、error 和 debug 均接受以下参数:(AbstractMod mod, String message, Object... args))。
dev.dannytaylor.perspective.seam.common.events.SeamEvents 包含 tryRun 和 onInitialize 函数。这些函数会在运行指定的 Runnable 时捕获并记录错误。onInitialize 函数还会记录其正在初始化的内容。
消息栏
如果您正在制作客户端模组,请参阅上面的“客户端事件”部分。这些方法应用于服务端模组。
您可以使用 dev.dannytaylor.perspective.seam.common.events.SeamEvents.sendToMessageBar(ServerPlayer player, Component message); 向客户端的消息栏发送消息。
您还可以使用 dev.dannytaylor.perspective.seam.common.events.SeamEvents.sendToMessageBar(ServerPlayer player, Component message, float ticks); 发送带有自定义持续时间的消息。
根据 LGPL-3.0 许可
Seam
Shared classes and resources for Perspective and Luminance.
Seam is currently under development
Some features may change throughout the development process.
Please report bugs, and suggest feature requests on our Issues page.
Alternatively, you can let us know on the #bug reports channel on my Fluxer or Discord server, and we'll make an issue for you.
You can also use the #modding chat channel if you need any help!
If you are a player, you shouldn't need to install this, unless a mod has asked you to. Most mods that use Seam should have it bundled; You can still install Seam alongside, and Fabric will use the most up-to-date one.
The following information is for mod developers, to help them understand how to use Seam.
Events
Seam contains several event registries, to help develop things easier.
These have been primarily designed around Luminance and Perspective, however other mods are welcome to use them!
This description isn't extensive, I recommend looking at our source code!
Client Events
The following client event registries are located in the dev.dannytaylor.perspective.seam.client.events.SeamClientEvents class:
CustomBadges
- It is recommended to use the
SeamClientEvents.registerCustomBadge(Identifier badgeId, int outlineColor, int fillColor, int textColor); function to register custom badges, see example in the ModMenu Badges section below.
ModBadges
- It is recommended to use the
SeamClientEvents.registerModBadge(String modId, Identifier customBadgeId); function to register mod badges, see example in the ModMenu Badges section below.
IconOverrides
- It is recommended to use the
SeamClientEvents.registerIconOverride(String modId, IconOverride iconOverride); function to register icon overrides.
ProfiledDebugEntries
- It is recommended to use the
SeamClientEvents.registerProfiledDebugEntry(Identifier identifier, DebugScreenEntry debugScreenEntry, DebugScreenProfile profile, DebugScreenEntryStatus status); function to register profiled debug entries.
ClientResourceReloaders
- Map of
net.minecraft.resources.Identifier, net.minecraft.server.packs.resources.PreparableReloadListener, which gets registered on client initialize, and executes on client resource reload.
AfterClientResourceReload
- Map of
net.minecraft.resources.Identifier, java.lang.Runnable, which executes after client resources have reloaded.
BeforeGuiRender
- Map of
net.minecraft.resources.Identifier, dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.GuiRender, which renders before the gui.
AfterGuiRender
- Map of
net.minecraft.resources.Identifier, dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.GuiRender, which renders after the gui.
BeforeGameRender
- Map of
net.minecraft.resources.Identifier, java.lang.Runnable, which executes before the game is rendered.
AfterPanoramaRender
- Map of
net.minecraft.resources.Identifier, dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.PanoramaRender, which renders after the menu panorama.
AfterVanillaPostEffectRender
- Map of
net.minecraft.resources.Identifier, dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.GameRender, which renders after the vanilla post-effect shader.
BeforeUiRender
- Map of
net.minecraft.resources.Identifier, dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.GameRender, which renders before the current screen.
AfterUiBackgroundRender
- Map of
net.minecraft.resources.Identifier, dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.GameRender, which renders after the current screen's background.
AfterUiRender
- Map of
net.minecraft.resources.Identifier, dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.GameRender, which renders after everything.
OnResized
- Map of
net.minecraft.resources.Identifier, dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.OnResized, which executes when the window is resized.
OnMouseScroll
- Map of
net.minecraft.resources.Identifier, dev.dannytaylor.perspective.seam.client.events.SeamClientCallables.OnMouseScroll, which executes when the mouse is scrolled.
OnMouseButton
- Map of
net.minecraft.resources.Identifier, dev.dannytaylor.perspective.seam.client.events.SeamClientCallables.OnMouseButton, which executes when the mouse handles a button.
OnJoinWorld
- Map of
net.minecraft.resources.Identifier, java.lang.Runnable, which executes when the client joins a world.
OnLeaveWorld
- Map of
net.minecraft.resources.Identifier, java.lang.Runnable, which executes when the client leaves a world.
OnStartItemUse
- Map of
net.minecraft.resources.Identifier, dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.UseItem, which executes when the item is used (client-side only).
OnFinishItemUse
- Map of
net.minecraft.resources.Identifier, dev.dannytaylor.perspective.seam.client.events.SeamClientRunnables.FinishUsingItem, which executes when the item is finished being used (client-side only).
Message Bar
Seam adds a message bar to the top-center of the screen.
See Common Events for how to send messages from the server.
You can update the Message Bar (on the client-side) by using the following function:
dev.dannytaylor.perspective.seam.client.events.SeamClientEvents.sendToMessageBar(Component.literal("this is an example message!"));
Icon Overrides
You can register a custom icon override with Seam.
This will automatically update your mod's icon with Mod Menu. If you are using this with another mod (such as Sodium), you will have to implement this manually.
Here is an example of how to register an icon override that only changes on April 1st.
import net.fabricmc.api.ClientModInitializer;
import net.minecraft.resources.Identifier;
import dev.dannytaylor.perspective.seam.client.events.SeamClientEvents;
import dev.dannytaylor.perspective.seam.common.util.DateHelper;
import dev.dannytaylor.perspective.seam.client.events.IconOverride;
public class MyClientInitializer implements ClientModInitializer {
@Override
public void onInitializeClient() {
SeamClientEvents.registerIconOverride("modId", new IconOverride(Identifier.parse("modid:textures/icon2.png"), DateHelper::isAprilFools));
}
}
ModMenu Badges
You can register custom mod menu badges with Seam.
Registering custom badges doesn't require mod menu to be installed.
Here is an example of how to register a custom mod menu badge.
import net.fabricmc.api.ClientModInitializer;
import net.minecraft.resources.Identifier;
import dev.dannytaylor.perspective.seam.client.events.SeamClientEvents;
public class MyClientInitializer implements ClientModInitializer {
public static final Identifier EXAMPLE_BADGE = SeamClientEvents.registerCustomBadge(
Identifier.parse("modid:example_badge"), // badge identifier
0xFFAAAAAA, // outline colour
0xFF808080, // fill colour
0xFFFFFFFF // text colour
);
@Override
public void onInitializeClient() {
SeamClientEvents.registerModBadge("modId", EXAMPLE_BADGE);
}
}
You'll also need to add the following key to your language file (/assets/<namespace>/lang/en_us.json).
{
"gui.modid.custom_badge.example_badge": "Example"
}
The language key format is: gui.<namespace>.custom_badge.<path>.
Included Badges
Seam contains two built-in badges.
Perspective
Used by Perspective's mods, indicating they are part of Perspective.
Luminance
Should be used by mods that use Luminance, indicating support for luminance shaders.
Here is an example of how to add the luminance badge to your mod.
import net.fabricmc.api.ClientModInitializer;
import dev.dannytaylor.perspective.seam.client.events.Badges;
public class MyClientInitializer implements ClientModInitializer {
@Override
public void onInitializeClient() {
Badges.luminance("modId");
}
}
Common Events
Seam doesn't currently contain any common or server-only registries.
It does however contain some common functions, and classes.
dev.dannytaylor.perspective.seam.common.data.FabricMod, stores the mod id, name, and creates a logger.
You can also send messages to your logger via dev.dannytaylor.perspective.seam.common.data.log.SeamLog by specifying your FabricMod in the function arguments (info, warn, error, and debug all take the following arguments: (AbstractMod mod, String message, Object... args)).
dev.dannytaylor.perspective.seam.common.events.SeamEvents contains tryRun and onInitialize functions. These functions catch and log errors when running the specified runnable. The onInitialize functions also log what they are initializing.
Message Bar
If you're making a client mod, see the Client Events section above. These should be used for server-side mods.
You can send a message to a client's message bar by using dev.dannytaylor.perspective.seam.common.events.SeamEvents.sendToMessageBar(ServerPlayer player, Component message);.
You can also send a message with a custom tick length by using dev.dannytaylor.perspective.seam.common.events.SeamEvents.sendToMessageBar(ServerPlayer player, Component message, float ticks);.
Licenced under LGPL-3.0
评论 0
登录后参与评分
还没有评论,来抢沙发吧