模型即时 API 和消息载荷
本页目录
本章解释 ShadowModeAPI 和 ShadowModePayloads 的全部公开方法。前者是 Stable 的即时发送入口,后者是 Experimental 的纯 JSON 构造入口。需要保存绑定、观看者重放和操作回执时优先ShadowModelAPI 运行时;这里的 send、reload、clear 不提供持久状态、事务或完整业务授权。只调用公开契约,不复制网络分片、签名或混淆实现。
发送端和返回结果
GLB 的能力与字段范围见Blender API。玩家替换资源异步准备期间保留旧绑定,完成后才发布新表;失败或过期的准备不会提交为已应用配置摘要。PENDING、RESOURCE_UNCONFIRMED 等诊断不等于画面成功,不因收到一次回执便停止观察资源结果。
send(viewer,payload) 使用 shadowmode 通道;sendArmourers 使用 AW 兼容通道;sendLegacyBbModel 是废弃的旧 bbmodel 通道,替代为 send。raw send 没有统一 Player/null/在线/能力检查,宿主未初始化也可抛运行异常;不把 void 当作最终成功。
reload/clear 发送客户端模型重载或全体模型运行态清理,不只影响自己的实例。普通附属用自己拥有的实例/规则 ID 定向解除,不用全局 clear 作为卸载步骤。绑定、动作、粒子等一般发送方法不自动获取观看者集合;viewer 是接收客户端,target 是被展示的对象。
声音和 Tooltip 的 boolean 包装方法先要求 viewer 非 null、在线并声明 model_sound 或 model_tooltip;true 仅说明提交。playSound 还要求 type=play_sound,并会原地规范化传入 sound 字段。其他 Entity/Location 重载会直接读取参数,null 不统一返回 false。固定位置包装把 NORMAL/null World 映射 0、NETHER 映射 -1、THE_END 映射 1,不区分同环境下不同 Bukkit 世界。
ShadowModeAPI 方法选择
| 方法组 | 参数含义和范围 |
|---|---|
| bindEntity / unbindEntity | 接 Entity 或实体 UUID;modelId 重载只发模型 ID,完整 binding 重载保留纹理/动画等字段。正宽/高才增加旧 hitbox 字段 |
| bindPlayerSkeleton / unbindPlayerSkeleton | target Player 的 UUID/名字或解除用 UUID;不是给 viewer 自己强制换骨架 |
| bindArmourersSkin / bindArmourersSkins / unbindArmourersSkins | AW 资源、槽位、skinSlot,数组可带 ruleId;不带 ruleId 的解除范围更宽,不当自己的局部卸载 |
| bindItem / unbindItem | item 匹配标识与模型 ID,不是 Bukkit ItemStack 的独立数据库记录 |
| bindSkullBbModel / bindSkullJavaItem | textureHash 对应模型或 Java 物品渲染;只下发规则,不在世界放方块 |
| playAction / stopAction | targetType/targetId、动画、loop、speed;不负责服务端冷却或伤害 |
| spawnClientEntity / removeClientEntity | 自有 instanceId、实体标识/类型、位置/朝向/寿命;只在客户端展示,不创建 Bukkit 实体 |
| bindEntityEffect / bindFixedEffect / unbindEffect | effectId、完整定义或 type/resource;固定版本取 Location 并编码 dimension,附着版本读 Entity UUID |
| playEffectAction / playFixedEffectAction | 指定实体或固定 effectId 的动画;不自动创建缺失效果 |
| playParticle / playFixedParticle / stopParticle | identifier、目标/位置、loop、lifetimeTicks;stopParticle 的包装传 entityUuid=null,不能假设只清一个目标 |
| playEntitySound / playFixedSound / playGlobalSound | instanceId、sound、group、循环/音量/音高、距离和 tick 寿命;全球版本不按位置衰减 |
| playEntitySoundResource / playFixedSoundResource | 与前项相同,但 source=resource,要求真实资源可用 |
| playActionWithSounds | 同一次动作附最多 16 个非 null 声音事件;不是无限事件脚本或动画完成保证 |
| playSound / stopSound / stopSoundGroup | 接完整 play_sound 载荷、单实例或组;group 应是调用方独占组,别停止他人的声音 |
| syncTooltipStyles / bindTooltipStyle / clearTooltipStyles | 同步全体/添加单样式/清全体,不是一个附属的独占样式集合 |
| transform | 生成 scale、offset 三元数组、rotation 三元数组;不验证有限值或给缩放/角度作统一裁剪 |
ShadowModePayloads 的全部构造入口
下表是构造结果,不是发送或授权。大多数字符串/UUID/资源/速度直接保存,并不验证存在性。base(type) 只有 type 字段;clear 只是 base(clear)。构造的 JSON 也不能绕过真实能力、当前会话或消费者校验。
| 方法 | 载荷和重要边界 |
|---|---|
| selectConfigSnapshot / configSnapshotStatus / commitConfigSnapshot | 配置协商的 syncId、snapshotSha256、status;不是任意更改宿主快照/已同步状态的 API,消费者仍匹配事务 |
| bindEntity / bindPlayerSkeleton | ID 重载组 type/UUID/modelId;完整对象深复制,删除 kind/match 并覆盖 type 和目标 UUID;null binding 变空对象 |
| bindItem | type=bind_item、item/modelId;构造时不校验匹配规则 |
| syncBlockModel(四个重载) | textureHash/modelId,可附 renderer;renderMode 只有 2 保留 2,其余回退 1 |
| syncBlockModels | 替换数组,null 变空且深复制;不是只追加自己的规则 |
| queryPlayerSkeletonStatus | 请求某 playerUuid 的客户端解析/渲染状态,构造本身没有收到回执 |
| tracePlayerHand | hand=null 为 mainhand,frames 裁剪 1..20;bone 非空才附,pose=rest/evaluator=reference 或 overlay 才附;短重载沿用 live/gecko |
| tracePlayerArmor | slot/attachment/bone/frames;空 attachment 为 all,frames 1..20,诊断不是生产绑定行为 |
| bindEntitySkin / bindEntitySkins / unbindEntitySkin | 单项 skin/slot,skinSlot>=0 才附;数组深复制、null 为空;非空 ruleId 才附,解除不带 ruleId 可影响更大范围 |
| playAction(两个重载) | 基本 target/animation/loop/speed;扩展重载加非负 transitionTicks 和 restart,但不统一排除浮点 NaN |
| bindEffect(两个重载) | 完整定义深复制,effectType 优先该字段、其次原 type、否则 texture;删 kind 后覆盖协议 type/effectId;不保证资源就绪 |
| bindFixedEffect(两个重载) | 在效果载荷上加 targetType=position 和 position{x,y,z,dimension};不自动创建服务器实体 |
| unbindEffect / playEffectAction / playFixedEffectAction | 自有 effectId/目标与动作,固定动作带 targetType=position |
| playParticle / playFixedParticle / stopParticle | identifier、实体或 position{x,y,z,dimension}、loop、lifetimeTicks;构造不裁剪寿命 |
| syncModelConfig | debug/traceResources/preloadResources、版本/模式/文档数;这是诊断设置载荷,不是写文件或覆盖模型文档 |
| spawnClientEntity / removeClientEntity | instanceId/entityUuid/entityType、坐标/朝向/寿命,构造不建立服务器对象 |
| syncItemBindings / syncEntityBindings / syncPlayerSkeletonBindings | 各配置层的整份替换数组,null=空,深复制;独立附属不能用自己的子集覆盖宿主所有规则 |
| syncPlayerActionBindings | 整份 bindings 和 animationResources 两个数组,null 分别为空,深复制 |
| playEntitySound / playFixedSound / playGlobalSound | play_sound 实例与组;固定声音的 dimension 在载荷顶层、坐标在 position,与固定粒子结构不同 |
| playEntitySoundResource / playFixedSoundResource | 增加 source=resource,其余声音参数原样保存,不验证格式/资源存在 |
| actionSound | 只接受 type=play_sound,深复制、移除 type、加 atTick 裁剪 0..1200;非法输入抛 IllegalArgumentException |
| playActionWithSounds | 复制最多前 16 个非 null 事件;不会再把每个事件自动校验成 actionSound |
| configureSound | 要求 play_sound,原地写 category(null 为 master)、delayTicks/repeatDelay 0..1200、priority -100..100;返回同一对象 |
| normalizeSound | null 保持 null;germmod: 前缀改 shadowui:,已有冒号的名称保留,无冒号加 shadowui:;不映射任意文件路径或检查音效注册 |
| syncTooltipStyles(两个重载) | type=sync_tooltips/action=sync;复制样式,null 为全体空列表;Iterable 忽略 null 项,没有服务端统一样式数量上限 |
| bindTooltipStyle | 复制单样式字段到 type=bind_tooltip/action=add 的对象;输入 type/action 可能覆盖保留字段,调用者避免写这些字段 |
| clearTooltipStyles / clear / base | 全局样式清理、全局模型清理或任意 type 的纯构造,不包含权限或业务收尾 |
配置定义带 kind=effect、entity 目标、particle/bedrock_particle 且未给 anchorMode 时,bindEffect 兼容补 center。旧 type/resource 重载和固定位置重载不因此统一补相同锚点。包装的复制隔离也不等于 Schema、路径、数值、模块和资源全部有效。
完整的纯构造演示
这个类只返回一个深复制的动作/声音演示载荷,不发送玩家、不扣费、不播放、不修改配置。自有声音 ID/组仅是消费示例约定,真实发送仍需宿主生命周期、能力与资源校验。
package example.wiki;
import com.google.gson.JsonObject;
import com.heartlion.shadowui.modelplugin.ShadowModePayloads;
import java.util.Collections;
public final class WikiActionPayload {
public JsonObject build(String entityUuid) {
if (entityUuid == null || entityUuid.trim().isEmpty()) {
throw new IllegalArgumentException("需要实际目标 UUID");
}
JsonObject sound = ShadowModePayloads.playEntitySound("wiki.hit", "germmod:demo.hit", "wiki.demo",
entityUuid, false, 1F, 1F, 16F, 40);
ShadowModePayloads.configureSound(sound, "player", 0, 0, 0);
return ShadowModePayloads.playActionWithSounds("entity", entityUuid, "demo.attack", false, 1F,
Collections.singletonList(ShadowModePayloads.actionSound(sound, 2)));
}
}
动作名与音效这里只是示例,未声称随客户端分发。所有参数重载、返回、源码分级与声明行见模型底层签名,声音文件与配置见模型音效。