Skip to content

Ponder JS API

Ponder 脚本环境的完整 JavaScript API 参考。Ponder 脚本仅在客户端执行,用于创建交互式教程场景。


Quick Start

js
// 注册标签
Ponder.tags(tags => {
  tags.createTag("rpg:forge", "minecraft:anvil", "锻造", "演示锻造流程")
})

// 注册场景
Ponder.registry(reg => {
  reg.create("minecraft:anvil")
    .scene("rpg:forge", "锻造流程", (scene, util) => {
      scene.configureBasePlate(0, 0, 5)
      scene.showBasePlate()

      const base = util.select().fromToXYZ(0, 0, 0, 2, 0, 2)
      scene.world().showSection(base, Direction.UP)
      scene.idle(20)

      const top = util.vector().topOfXYZ(1, 1, 1)
      scene.overlay().showText(40).text("放入矿石").pointAt(top)
      scene.idle(40)

      scene.effects().indicateSuccess(top)
      scene.particles().simple(20, "smoke", top).density(3).scale(0.8)
      scene.idle(20)
    })
})

TIP

所有接受 pos / position 参数的方法同时支持 BlockPosVec3PonderVec3Wrapper[x,y,z] 数组等类型。 所有接受 direction / face 参数的方法同时支持 Direction 常量字符串(如 "up""north")。


1. 全局对象与常量

1.1 Ponder

场景与标签注册入口。

方法说明
Ponder.registry(callback)注册场景,callback 接收 PonderRegistryEventWrapper
Ponder.tags(callback)注册标签,callback 接收 PonderTagEventWrapper

1.2 PonderPalette

颜色调色板常量与工具方法。

常量(String 类型):

常量
WHITE"white"
BLACK"black"
RED"red"
GREEN"green"
BLUE"blue"
SLOW"slow"
MEDIUM"medium"
FAST"fast"
INPUT"input"
OUTPUT"output"

方法:

方法返回类型说明
fromString(name)String?根据名称获取调色板颜色
parseHex(hex)Int解析十六进制颜色字符串

1.3 PonderGuiTextures

GUI 图标/纹理常量。

常量说明
LOGOPonder Logo
SPEECH_TOOLTIP_BACKGROUND语音气泡背景
SPEECH_TOOLTIP_COLOR语音气泡颜色
ICON_PONDER_LEFT / ICON_PONDER_CLOSE / ICON_PONDER_RIGHT导航图标
ICON_PONDER_IDENTIFY / ICON_PONDER_REPLAY功能图标
ICON_PONDER_USER_MODE / ICON_PONDER_SLOW_MODE模式图标
ICON_CONFIG_UNLOCKED / ICON_CONFIG_LOCKED配置锁定图标
ICON_CONFIG_DISCARD / ICON_CONFIG_SAVE / ICON_CONFIG_RESET配置操作图标
ICON_CONFIG_BACK / ICON_CONFIG_PREV / ICON_CONFIG_NEXT配置导航图标
ICON_DISABLE / ICON_CONFIG_OPEN / ICON_CONFIRM其他操作图标
ICON_LMB / ICON_SCROLL / ICON_RMB鼠标按键图标

1.4 Direction / Facing

方向常量(DirectionFacing 指向同一对象 PonderDirectionJS)。

常量
DOWN"down"
UP"up"
NORTH"north"
SOUTH"south"
WEST"west"
EAST"east"

1.5 PonderPointing

指向常量。

常量
DOWN"down"
LEFT"left"
RIGHT"right"
UP"up"

1.6 Block

方块工具对象。

方法返回类型说明
Block.id(value)PonderBlockStateWrapper解析方块 ID 并返回默认状态
js
const stone = Block.id("minecraft:stone")
const lit = Block.id("minecraft:furnace").with("lit", "true")

1.7 Vec3

向量构造器(通过 new 创建)。

js
const v = new Vec3(1.0, 2.5, 3.0)

1.8 ParrotElement / PonderInput

TIP

ParrotElementPonderInput(别名 PonderInputWindowElement)作为类型暴露到全局作用域,但通常不需要直接构造,而是通过 scene.special().createBirb()scene.showControls() 获取。


2. Wrapper API 参考

WARNING

以下方法签名中,标注为 Any 类型的参数均支持多种类型输入(BlockPos / Vec3 / PonderVec3Wrapper / ResourceLocation / String / 数组等),引擎会自动转换。标注为"可链式调用"的方法返回 this,支持 .method1().method2() 写法。

PonderBlockStateWrapper

调整方块状态属性。

方法参数返回类型说明
with(property, value)property: String, value: StringPonderBlockStateWrapper设置方块状态属性,可链式调用
unwrap()-BlockState获取底层 Minecraft BlockState
js
const state = Block.id("minecraft:furnace").with("lit", "true").with("facing", "north")

PonderRegistryEventWrapper

场景注册事件入口(Ponder.registry(reg => { ... })reg 参数)。

方法参数返回类型说明
create(...components)vararg components: AnyPonderSceneRegistrationBuilderWrapper为指定组件创建场景注册器
forComponents(...components)vararg components: AnyPonderMultiSceneBuilderWrapper为多个组件批量注册场景
withKeyFunction()-PonderSceneRegistrationHelper获取底层注册器(高级用法)
printParticleNames()-void在日志中输出所有可用的简单粒子类型名称

PonderSceneRegistrationBuilderWrapper

基于组件注册场景。

方法参数返回类型说明
tag(...tags)vararg tags: Anythis为后续场景添加默认标签,可链式调用
scene(sceneId, title, callback, ...tags)sceneId: String, title: String, callback: Function, vararg tags: AnyPonderStoryBoardEntryWrapper注册场景,callback 接收 (scene, util)
scene(sceneId, title, schematic, callback, ...tags)sceneId: String, title: String, schematic: Any, callback: Function, vararg tags: AnyPonderStoryBoardEntryWrapper指定结构文件注册场景
sceneWithSchematic(sceneId, title, schematic, callback, ...tags)同上PonderStoryBoardEntryWrapper同上(显式命名版本)
js
reg.create("minecraft:anvil")
  .tag("rpg:guide")
  .scene("rpg:forge", "锻造流程", (scene, util) => {
    // scene: PonderSceneBuilderWrapper
    // util: PonderSceneBuildingUtilWrapper
  })

PonderMultiSceneBuilderWrapper

批量注册多个场景。

方法参数返回类型说明
addStoryBoard(schematic, callback)schematic: Any, callback: Functionthis添加场景
addStoryBoardWithTags(schematic, callback, ...tags)schematic: Any, callback: Function, vararg tags: Anythis添加场景并关联标签
addStoryBoardWithExtras(schematic, callback, extras)schematic: Any, callback: Function, extras: Functionthis添加场景并自定义 StoryBoardEntry
addStoryBoardByPath(schematicPath, callback)schematicPath: String, callback: Functionthis按路径添加场景
addStoryBoardByPathWithTags(schematicPath, callback, ...tags)schematicPath: String, callback: Function, vararg tags: Anythis按路径添加场景并关联标签
addStoryBoardByPathWithExtras(schematicPath, callback, extras)schematicPath: String, callback: Function, extras: Functionthis按路径添加场景并自定义 StoryBoardEntry
unwrap()-MultiSceneBuilder获取底层构建器

PonderStoryBoardEntryWrapper

场景条目排序与标签管理。

方法参数返回类型说明
orderBefore(otherSceneId)otherSceneId: Stringthis排序:排在另一场景之前
orderBeforeWithNamespace(namespace, otherSceneId)namespace: String, otherSceneId: Stringthis排序:指定命名空间
orderAfter(otherSceneId)otherSceneId: Stringthis排序:排在另一场景之后
orderAfterWithNamespace(namespace, otherSceneId)namespace: String, otherSceneId: Stringthis排序:指定命名空间
highlightTag(tag)tag: Anythis高亮一个标签
highlightTags(...tags)vararg tags: Anythis高亮多个标签
highlightAllTags()-this高亮所有标签
getComponent()-ResourceLocation获取关联的组件 ID
unwrap()-StoryBoardEntry获取底层条目

PonderSceneBuilderWrapper

场景构建主入口(scene 参数)。

TIP

scene 对象的子模块同时支持方法调用和属性访问两种方式:

  • 方法:scene.world() / scene.overlay() / scene.effects() / scene.special() / scene.debug() / scene.getParticles()
  • 属性:scene.world / scene.overlay / scene.effects / scene.special / scene.debug / scene.particles

子模块访问:

方法/属性返回类型说明
util() / utilPonderSceneBuildingUtilWrapper构建工具
overlay() / overlayPonderOverlayInstructionsWrapper覆盖层指令(文本/线条/轮廓)
world() / worldPonderWorldInstructionsWrapper世界操作指令(方块/实体)
effects() / effectsPonderEffectInstructionsWrapper特效指令(粒子/光效)
special() / specialPonderSpecialInstructionsWrapper特殊元素指令(鹦鹉/矿车)
debug() / debugPonderDebugInstructionsWrapper调试指令
getParticles() / particlesPonderParticleInstructionsWrapper粒子指令(高级粒子系统)

场景配置:

方法参数返回类型说明
title(sceneId, title)sceneId: String, title: Stringvoid设置场景标题
configureBasePlate(xOffset, zOffset, basePlateSize)xOffset: Int, zOffset: Int, basePlateSize: Intvoid配置底板
scaleSceneView(factor)factor: Floatvoid缩放场景视图
removeShadow()-void移除阴影
setSceneOffsetY(yOffset)yOffset: Floatvoid设置场景 Y 偏移
showBasePlate()-void显示底板

流程控制:

方法参数返回类型说明
idle(ticks)ticks: Intvoid等待指定 tick
idleSeconds(seconds)seconds: Intvoid等待指定秒数
markAsFinished()-void标记场景结束
setNextUpEnabled(isEnabled)isEnabled: Booleanvoid启用/禁用"下一步"按钮
addKeyframe()-void添加关键帧
addLazyKeyframe()-void添加懒加载关键帧

相机与结构:

方法参数返回类型说明
rotateCameraY(degrees)degrees: Floatvoid旋转相机 Y 轴
showStructure()-void显示整个结构
showStructureHeight(height)height: Intvoid显示结构到指定高度
encapsulateBounds(size)size: Anyvoid扩展场景边界

快捷方法:

方法参数返回类型说明
text(duration, text, position?)duration: Int, text: String, position?: AnyPonderTextElementBuilderWrapper快捷显示文本
textSimple(duration, text)duration: Int, text: StringPonderTextElementBuilderWrapper快捷显示文本(无定位)
showControls(duration, position, direction)duration: Int, position: Any, direction: AnyPonderInputElementBuilderWrapper快捷显示输入控件
playSound(sound)sound: Anyvoid播放音效(默认音量 1.0、音调 1.0)
playSound(sound, volume)sound: Any, volume: Numbervoid播放音效(默认音调 1.0)
playSound(sound, volume, pitch)sound: Any, volume: Number, pitch: Numbervoid播放音效

底层访问:

方法参数返回类型说明
getScene()-PonderScene获取底层 PonderScene
addInstruction(instruction)instruction: PonderInstructionvoid添加原始指令
addInstructionCallback(callback)callback: Functionvoid添加回调指令,callback 接收 PonderScene
unwrap()-SceneBuilder获取底层 SceneBuilder

PonderSceneBuildingUtilWrapper

构建工具(util 参数)。

TIP

util 对象的子模块同时支持方法调用和属性访问两种方式:

  • 方法:util.select() / util.vector() / util.grid()
  • 属性:util.select / util.vector / util.grid
方法/属性返回类型说明
select() / selectPonderSelectionUtilWrapper选择器工具
vector() / vectorPonderVectorUtilWrapper向量工具
grid() / gridPonderPositionUtilWrapper位置工具
unwrap()SceneBuildingUtil获取底层工具

PonderSelectionUtilWrapper

选择器工具(创建 Selection 对象)。

方法参数返回类型说明
everywhere()-Selection选中整个场景
position(pos)pos: AnySelection选中单个方块位置
positionXYZ(x, y, z)x: Int, y: Int, z: IntSelection选中单个方块位置
fromTo(pos1, pos2)pos1: Any, pos2: AnySelection选中两点间的区域
fromToXYZ(x, y, z, x2, y2, z2)x~z: Int, x2~z2: IntSelection选中两点间的区域
column(x, z)x: Int, z: IntSelection选中指定列
layer(y)y: IntSelection选中指定层
layersFrom(y)y: IntSelection选中从 y 层开始往上的所有层
layers(y, height)y: Int, height: IntSelection选中从 y 层开始的 height 层
cuboid(origin, size)origin: Any, size: AnySelection选中长方体区域
unwrap()-SelectionUtil获取底层工具
js
const base = util.select().fromToXYZ(0, 0, 0, 4, 0, 4)
const single = util.select().positionXYZ(1, 1, 1)
const all = util.select().everywhere()

PonderVectorUtilWrapper

向量工具(创建 PonderVec3Wrapper 对象)。

方法参数返回类型说明
centerOf(pos)pos: AnyPonderVec3Wrapper方块中心
centerOfXYZ(x, y, z)x: Int, y: Int, z: IntPonderVec3Wrapper方块中心
topOf(pos)pos: AnyPonderVec3Wrapper方块顶部中心
topOfXYZ(x, y, z)x: Int, y: Int, z: IntPonderVec3Wrapper方块顶部中心
blockSurface(pos, face)pos: Any, face: AnyPonderVec3Wrapper方块指定面的中心
blockSurfaceWithMargin(pos, face, margin)pos: Any, face: Any, margin: FloatPonderVec3Wrapper方块指定面的中心(带边距)
of(x, y, z)x: Double, y: Double, z: DoublePonderVec3Wrapper创建任意向量
unwrap()-VectorUtil获取底层工具

PonderPositionUtilWrapper

位置工具(创建 BlockPos 对象)。

方法参数返回类型说明
at(x, y, z)x: Int, y: Int, z: IntBlockPos创建方块位置
zero()-BlockPos返回原点 (0,0,0)
unwrap()-PositionUtil获取底层工具

PonderVec3Wrapper

向量对象封装。

方法参数返回类型说明
x()-Double获取 X 分量
y()-Double获取 Y 分量
z()-Double获取 Z 分量
add(other)other: AnyPonderVec3Wrapper向量加法
add(x, y, z)x: Double, y: Double, z: DoublePonderVec3Wrapper向量加法
addXYZ(x, y, z)x: Double, y: Double, z: DoublePonderVec3Wrapper向量加法(别名)
subtract(other)other: AnyPonderVec3Wrapper向量减法
subtract(x, y, z)x: Double, y: Double, z: DoublePonderVec3Wrapper向量减法
scale(factor)factor: DoublePonderVec3Wrapper向量缩放
unwrap()-Vec3获取底层 Minecraft Vec3
js
const v = new Vec3(1, 2, 3)
const moved = v.add(0, 1, 0).scale(2.0)

PonderOverlayInstructionsWrapper

覆盖层指令(文本/线条/轮廓)。通过 scene.overlay()scene.overlay 获取。

方法参数返回类型说明
showText(duration)duration: IntPonderTextElementBuilderWrapper显示文本,返回可链式配置的构建器
showOutlineWithText(selection, duration)selection: Any, duration: IntPonderTextElementBuilderWrapper显示带轮廓的文本
showControls(sceneSpace, direction, duration)sceneSpace: Any, direction: Any, duration: IntPonderInputElementBuilderWrapper显示输入控件
chaseBoundingBoxOutline(color, slot, boundingBox, duration)color: Any, slot: Any?, boundingBox: Any, duration: Intvoid追踪显示包围盒轮廓
showCenteredScrollInput(pos, side, duration)pos: Any, side: Any, duration: Intvoid显示居中滚动输入
showScrollInput(location, side, duration)location: Any, side: Any, duration: Intvoid显示滚动输入
showRepeaterScrollInput(pos, duration)pos: Any, duration: Intvoid显示中继器滚动输入
showFilterSlotInput(location, duration)location: Any, duration: Intvoid显示过滤槽输入
showFilterSlotInputWithSide(location, side, duration)location: Any, side: Any, duration: Intvoid显示带方向的过滤槽输入
showLine(color, start, end, duration)color: Any, start: Any, end: Any, duration: Intvoid显示线条
showBigLine(color, start, end, duration)color: Any, start: Any, end: Any, duration: Intvoid显示粗线条
showOutline(color, slot, selection, duration)color: Any, slot: Any?, selection: Any, duration: Intvoid显示选区轮廓
unwrap()-OverlayInstructions获取底层

TIP

duration 参数的单位均为 tick(1 秒 = 20 tick)。color 参数接受 PonderPalette 常量字符串。


PonderTextElementBuilderWrapper

文本元素构建器(可链式调用)。

方法参数返回类型说明
colored(color)color: Anythis设置文本颜色(PonderPalette 名称或颜色值)
pointAt(pos)pos: Anythis指向某个位置
independent(y?)y: Int = 0this独立定位(不跟随场景元素)
text(text)text: Stringthis设置文本内容
textWithParams(text, ...params)text: String, vararg params: Anythis设置带参数的文本内容
placeNearTarget()-this将文本放置在目标附近
attachKeyFrame()-this附加关键帧
unwrap()-TextElementBuilder获取底层
js
scene.overlay().showText(60)
  .text("这是一条提示")
  .pointAt(util.vector().topOfXYZ(1, 1, 1))
  .colored(PonderPalette.GREEN)
  .placeNearTarget()
  .attachKeyFrame()

PonderInputElementBuilderWrapper

输入提示构建器(可链式调用)。

方法参数返回类型说明
withItem(item)item: Anythis显示物品图标
leftClick()-this显示左键图标
rightClick()-this显示右键图标
scroll()-this显示滚轮图标
showing(icon)icon: Anythis显示指定图标(PonderGuiTextures 名称或对象)
whileSneaking()-this标记为"潜行时"
whileCTRL()-this标记为"按住 CTRL 时"
unwrap()-InputElementBuilder获取底层
js
scene.showControls(40, util.vector().topOfXYZ(1, 1, 1), Direction.UP)
  .rightClick()
  .withItem("minecraft:diamond")

PonderWorldInstructionsWrapper

世界/方块/实体操作指令。通过 scene.world()scene.world 获取。

区段显示/隐藏:

方法参数返回类型说明
showSection(selection, fadeInDirection)selection: Any, fadeInDirection: Anyvoid显示选区
showSectionAndMerge(selection, fadeInDirection, link)selection: Any, fadeInDirection: Any, link: Anyvoid显示选区并合并到已有链接
glueBlockOnto(position, fadeInDirection, link)position: Any, fadeInDirection: Any, link: Anyvoid将方块粘贴到已有链接
showIndependentSection(selection, fadeInDirection)selection: Any, fadeInDirection: AnyPonderElementLinkWrapper显示独立区段(可移动/旋转)
showIndependentSectionImmediately(selection)selection: AnyPonderElementLinkWrapper立即显示独立区段
hideSection(selection, fadeOutDirection)selection: Any, fadeOutDirection: Anyvoid隐藏选区
hideIndependentSection(link, fadeOutDirection)link: Any, fadeOutDirection: Anyvoid隐藏独立区段
restoreBlocks(selection)selection: Anyvoid恢复选区内的方块
makeSectionIndependent(selection)selection: AnyPonderElementLinkWrapper将选区转为独立区段

区段变换:

方法参数返回类型说明
rotateSection(link, xRotation, yRotation, zRotation, duration)link: Any, x/y/zRotation: Double, duration: Intvoid旋转区段
configureCenterOfRotation(link, anchor)link: Any, anchor: Anyvoid配置旋转中心
configureStabilization(link, anchor)link: Any, anchor: Anyvoid配置稳定化锚点
moveSection(link, offset, duration)link: Any, offset: Any, duration: Intvoid移动区段

方块操作:

方法参数返回类型说明
setBlock(pos, state)pos: Any, state: Anyvoid设置单个方块(带粒子)
setBlock(pos, state, spawnParticles)pos: Any, state: Any, spawnParticles: Booleanvoid设置单个方块
setBlocks(selection, state)selection: Any, state: Anyvoid批量设置方块(带粒子)
setBlocks(selection, state, spawnParticles)selection: Any, state: Any, spawnParticles: Booleanvoid批量设置方块
replaceBlocks(selection, state)selection: Any, state: Anyvoid替换方块(带粒子)
replaceBlocks(selection, state, spawnParticles)selection: Any, state: Any, spawnParticles: Booleanvoid替换方块
destroyBlock(pos)pos: Anyvoid销毁方块
modifyBlock(pos, callback)pos: Any, callback: Functionvoid修改方块状态,callback 接收 PonderBlockStateWrapper
modifyBlock(pos, callback, spawnParticles)pos: Any, callback: Function, spawnParticles: Booleanvoid修改方块状态
modifyBlocks(selection, callback)selection: Any, callback: Functionvoid批量修改方块状态
modifyBlocks(selection, callback, spawnParticles)selection: Any, callback: Function, spawnParticles: Booleanvoid批量修改方块状态
cycleBlockProperty(pos, property)pos: Any, property: Anyvoid循环切换方块属性值
toggleRedstonePower(selection)selection: Anyvoid切换红石信号
incrementBlockBreakingProgress(pos)pos: Anyvoid增加方块破坏进度

实体操作:

方法参数返回类型说明
createEntity(factory)factory: FunctionPonderElementLinkWrapper通过工厂函数创建实体,factory 接收 Level
createEntity(entityType, position)entityType: Any, position: AnyPonderElementLinkWrapper按类型创建实体
createEntity(entityType, position, callback?)entityType: Any, position: Any, callback?: FunctionPonderElementLinkWrapper按类型创建实体并配置
createEntityWithType(entityType, position, callback?)entityType: Any, position: Any, callback?: FunctionPonderElementLinkWrapper同上(显式命名版本)
createItemEntity(location, motion, stack)location: Any, motion: Any, stack: AnyPonderElementLinkWrapper创建掉落物实体
modifyEntity(link, callback)link: Any, callback: Functionvoid修改实体
modifyEntities(entityType, callback)entityType: Any, callback: Functionvoid修改所有指定类型的实体
modifyEntitiesInside(entityType, area, callback)entityType: Any, area: Any, callback: Functionvoid修改区域内指定类型的实体
removeEntity(link)link: Anyvoid移除实体

方块实体操作:

方法参数返回类型说明
modifyBlockEntityNBT(selection, callback)selection: Any, callback: Functionvoid修改方块实体 NBT(callback 接收 Map 形式的 CompoundTag)
modifyBlockEntityNBT(selection, reDrawBlocks, callback)selection: Any, reDrawBlocks: Boolean, callback: Functionvoid修改方块实体 NBT(控制是否重绘)
modifyBlockEntityNBT(selection, beType, callback)selection: Any, beType: Any, callback: Functionvoid修改指定类型的方块实体 NBT
modifyBlockEntityNBTWithRedraw(selection, beType, callback, reDrawBlocks)selection: Any, beType: Any, callback: Function, reDrawBlocks: Booleanvoid修改方块实体 NBT(完整参数版本)
modifyBlockEntity(position, beType, callback)position: Any, beType: Any, callback: Functionvoid直接修改方块实体对象
unwrap()-WorldInstructions获取底层

TIP

modifyBlockEntityNBT 的 callback 接收的是 CompoundTag 的 Map 代理对象,可以像普通 Map 一样读写 NBT 数据:

js
scene.world().modifyBlockEntityNBT(sel, (nbt) => {
  nbt["Items"] = [{ id: "minecraft:diamond", Count: 1, Slot: 0 }]
})

PonderEffectInstructionsWrapper

特效指令。通过 scene.effects()scene.effects 获取。

方法参数返回类型说明
indicateRedstone(pos)pos: Anyvoid显示红石激活效果
indicateSuccess(pos)pos: Anyvoid显示成功效果
createRedstoneParticles(pos, color, amount)pos: Any, color: Any, amount: Intvoid创建红石粒子
emitParticles(location, emitter, amountPerCycle, cycles)location: Any, emitter: ParticleEmitter, amountPerCycle: Float, cycles: Intvoid发射粒子
simpleParticleEmitter(data, motion)data: Any, motion: AnyPonderParticleEmitterWrapper?创建简单粒子发射器
particleEmitterWithinBlockSpace(data, motion)data: Any, motion: AnyPonderParticleEmitterWrapper?创建方块空间内粒子发射器
playPhotonFx(path, location)path: String, location: Anyvoid播放 Photon 粒子特效
playSnowstormFx(path, location)path: String, location: Anyvoid播放 Snowstorm 粒子特效
unwrap()-EffectInstructions获取底层

PonderParticleInstructionsWrapper

高级粒子系统。通过 scene.getParticles()scene.particles 获取。

TIP

所有粒子创建方法返回 PonderParticleDataBuilderWrapper,支持链式调用来配置粒子属性。

方法参数返回类型说明
simple(ticks, type, pos)ticks: Int, type: Any, pos: AnyPonderParticleDataBuilderWrapper创建简单粒子(type 为粒子 ID 字符串如 "smoke"
dust(ticks, color, pos)ticks: Int, color: Any, pos: AnyPonderParticleDataBuilderWrapper创建灰尘粒子(单色)
dust(ticks, fromColor, toColor, pos)ticks: Int, fromColor: Any, toColor: Any, pos: AnyPonderParticleDataBuilderWrapper创建灰尘粒子(颜色过渡)
item(ticks, item, pos)ticks: Int, item: Any, pos: AnyPonderParticleDataBuilderWrapper创建物品粒子
block(ticks, state, pos)ticks: Int, state: Any, pos: AnyPonderParticleDataBuilderWrapper创建方块粒子
js
scene.particles().simple(40, "minecraft:flame", pos)
  .density(5)
  .scale(1.5)
  .gravity(-0.01)
  .area(new Vec3(1, 0.5, 1))

PonderParticleDataBuilderWrapper

粒子数据构建器(可链式调用)。

方法参数返回类型说明
density(value)value: Numberthis每 tick 生成的粒子数量
gravity(value)value: Numberthis粒子重力
physics(value)value: Booleanthis是否启用物理
collision(value)value: Booleanthis是否启用碰撞
color(value)value: Anythis粒子颜色
roll(value)value: Numberthis粒子旋转
friction(value)value: Numberthis粒子摩擦力
scale(value)value: Numberthis粒子大小
lifetime(value)value: Numberthis粒子生命周期(tick)
motion(vec)vec: Anythis设置固定运动方向
speed(vec)vec: Anythis设置随机速度(高斯分布)
area(vec)vec: Anythis设置生成区域(均匀分布)
delta(vec)vec: Anythis设置位置偏移(高斯分布)
withinBlockSpace()-this限制粒子在方块空间内随机位置
transform(callback)callback: Functionthis自定义变换,callback 接收 (partialTick, position, motion) 返回 [position, motion]
transformPosition(callback)callback: Functionthis自定义位置变换,callback 接收 (partialTick, position) 返回新 position
transformMotion(callback)callback: Functionthis自定义运动变换,callback 接收 (partialTick, motion) 返回新 motion

PonderSpecialInstructionsWrapper

特殊元素指令(鹦鹉/矿车/兴趣点)。通过 scene.special()scene.special 获取。

方法参数返回类型说明
createBirb(location, pose?)location: Any, pose?: AnyPonderElementLinkWrapper<ParrotElement>创建鹦鹉
changeBirbPose(birb, pose?)birb: Any, pose?: Anyvoid改变鹦鹉姿势
movePointOfInterest(location)location: Anyvoid移动兴趣点(鹦鹉会朝向此点)
rotateParrot(link, xRotation, yRotation, zRotation, duration)link: Any, x/y/zRotation: Double, duration: Intvoid旋转鹦鹉
moveParrot(link, offset, duration)link: Any, offset: Any, duration: Intvoid移动鹦鹉
createCart(location, angle, type)location: Any, angle: Float, type: AnyPonderElementLinkWrapper<MinecartElement>创建矿车
rotateCart(link, yRotation, duration)link: Any, yRotation: Float, duration: Intvoid旋转矿车
moveCart(link, offset, duration)link: Any, offset: Any, duration: Intvoid移动矿车
hideElement(link, direction)link: Any, direction: Anyvoid隐藏动画元素
unwrap()-SpecialInstructions获取底层

PonderDebugInstructionsWrapper

调试指令。通过 scene.debug()scene.debug 获取。

方法参数返回类型说明
debugSchematic()-void调试输出结构信息
addInstructionInstance(instruction)instruction: Anyvoid添加原始指令
enqueueCallback(callback)callback: Functionvoid添加调试回调
unwrap()-DebugInstructions获取底层

元素引用句柄(用于后续操作独立区段/实体等)。

方法参数返回类型说明
getId()-UUID获取元素链接 ID
unwrap()-ElementLink<T>获取底层链接
js
const link = scene.world().showIndependentSection(sel, Direction.UP)
scene.world().moveSection(link, new Vec3(2, 0, 0), 20)
scene.idle(20)
scene.world().hideIndependentSection(link, Direction.DOWN)

PonderParticleEmitterWrapper / PonderParrotElementWrapper / PonderInputWindowElementWrapper

这些是简单的包装类型,主要用于在 Wrapper API 之间传递引用。

Wrapper方法说明
PonderParticleEmitterWrapperunwrap()获取底层 ParticleEmitter
PonderParrotElementWrapper-鹦鹉元素引用(通常不直接使用)
PonderInputWindowElementWrapper-输入窗口元素引用(通常不直接使用)

3. 标签 API

PonderTagEventWrapper

标签注册事件入口(Ponder.tags(tags => { ... })tags 参数)。

方法参数返回类型说明
registerTag(id)id: AnyPonderTagBuilderWrapper注册标签并返回构建器
createTag(id, callback)id: Any, callback: Functionvoid使用回调创建标签(callback 接收 PonderTagBuilderWrapper)
createTag(id, icon, title, description)id: Any, icon: Any, title: String, description: Stringvoid快捷创建标签
createTag(id, icon, title, description, items?)id: Any, icon: Any, title: String, description: String, items?: Anyvoid快捷创建标签并关联物品
createTagSimple(id, icon, title, description, items?)同上void同上(显式命名版本)
add(tag, components)tag: Any, components: Anyvoid将组件添加到标签
remove(tag, components)tag: Any, components: Anyvoid从标签移除组件
addToTag(...tags)vararg tags: AnyPonderMultiTagBuilderWrapper.TagWrapper批量操作入口(先指定标签,再 .add(component)
addToComponent(...components)vararg components: AnyPonderMultiTagBuilderWrapper.ComponentWrapper批量操作入口(先指定组件,再 .add(tag)
unwrap()-DefaultPonderTagRegistrationHelper获取底层
js
Ponder.tags(tags => {
  // 方式一:快捷创建
  tags.createTag("rpg:guide", "minecraft:book", "指南", "RPG 指南")

  // 方式二:使用构建器
  tags.createTag("rpg:advanced", builder => {
    builder.title("高级指南").description("进阶内容").icon("minecraft:diamond").addToIndex()
  })

  // 方式三:批量关联
  tags.addToTag("rpg:guide").add("minecraft:stone").add("minecraft:dirt")
  tags.addToComponent("minecraft:anvil").add("rpg:guide").add("rpg:advanced")
})

PonderTagBuilderWrapper

标签构建器(可链式调用)。

方法参数返回类型说明
title(title)title: Stringthis设置标题
description(description)description: Stringthis设置描述
addToIndex()-this添加到索引页
noIndex()-this不添加到索引页
addIconToItems()-this将图标物品也添加为组件
icon(icon)icon: Anythis设置图标(ResourceLocation / 物品 / 字符串)
idAsIcon()-this使用标签 ID 作为图标
item(item)item: Anythis关联物品
itemWithOptions(item, useAsIcon, useAsMainItem)item: Any, useAsIcon: Boolean, useAsMainItem: Booleanthis关联物品(带选项)
register()-void注册标签(使用 createTag(id, callback) 时自动调用)
unwrap()-TagBuilder获取底层

PonderMultiTagBuilderWrapper

批量标签/组件关联。

TagWrapper(通过 tags.addToTag(...) 获取):

方法参数返回类型说明
add(component)component: Anythis将组件添加到已指定的标签

ComponentWrapper(通过 tags.addToComponent(...) 获取):

方法参数返回类型说明
add(tag)tag: Anythis将标签关联到已指定的组件