sandstone-mc / sandstone

Sandstone | Next Generation Framework for Minecraft
https://sandstone.dev/
MIT License
173 stars 16 forks source link

JSON Text Components with Selector syntax #98

Closed ColinTimBarndt closed 1 year ago

ColinTimBarndt commented 3 years ago

The following example does not compile because the selector only accepts strings. It would be nice to be able to use selectors in JSON Text Components without appending .toString(). This is already implemented for score components.

import { Selector, MCFunction, tellraw } from 'sandstone'

MCFunction('hello', () => {
  const closest = Selector('@p', {distance: [.1, Infinity]})

  tellraw(Selector('@a'), {
    text: 'My closest friend is ',
    extra: [
      { selector: closest }
    ]
  })
})
ColinTimBarndt commented 3 years ago

Also, the selector component is missing the optional "separator" property, which is very useful.

Reference: https://minecraft.fandom.com/wiki/Raw_JSON_text_format#Entity_Names

MulverineX commented 1 year ago

Duplicate of #172