Skip to content
YukkuriC edited this page Sep 4, 2026 · 2 revisions

highly customizable iota types

  • NBT-backed custom iotas: IotaJS.type(id) creates the type, iota data is a plain CompoundTag with codec / streamCodec auto-derived
  • overriding common iota interfaces (display, color, size, etc.) with either callbacks or constants
  • optional executability via setOperate: toggles custom execution outside / inside parens and passes an inner IotaAction (yet another ActionJS) to set operate methods on; reading action.iota for the calling iota, or directly action.data for its content

Example

let { IotaJS } = HexJS

// creating an iota type with custom display & execution
// then write the type into `this` - KJS startup script scope, for later usages
this.PotionIota = IotaJS.type('yc:potion')
    .setDisplay(iota => {
        let { data } = iota
        let [namespace, path] = data.getString('id').split(':')
        if (!path) {
            path = namespace
            namespace = 'minecraft'
        }
        let lang = Text.translate(`effect.${namespace}.${path}`)
        let amp = data.getInt('amp')

        let ret = lang
        if (amp > 0) ret = ret.append(Text.gold(` +${amp}`))
        return Text.translate('hexcasting.tooltip.yc:potion', ret).blue()
    })
    .setOperate(true, false, action => {
        action.setOperate((env, image, cont) => {
            let player = env.castingEntity
            if (!player) return
            // action.data = action.iota.data
            // action.iota is the iota being executed and taken from stack
            let { data } = action
            player.potionEffects.add(data.getString('id'), 1200, data.getInt('amp'))
        })
    })

// and the action using this custom iota type
let potionIotaCreater = ActionRegistryJS.of(
    'yc:give_me_potion',
    HexPattern.fromAnglesUnchecked('deesaaqws', 'EAST'),
).setOperate(env => {
    // taking the type declared above, passed through shared script scope
    let { PotionIota } = this
    return [
        // IotaJS is basically iotas holding NBT, with different types assigning them different abilities
        new IotaJS({ id: 'instant_health', amp: 6 }, PotionIota),
        new IotaJS({ id: 'instant_damage', amp: 12 }, PotionIota),
        new IotaJS({ id: 'resistance', amp: 4 }, PotionIota),
        new IotaJS({ id: 'bad_omen' }, PotionIota),
    ]
})

Clone this wiki locally