Skip to content

Conversation

@ZZZank
Copy link
Collaborator

@ZZZank ZZZank commented Mar 7, 2025

This PR added custom toast support.

  • make a new notification builder via newly added binding Notification
  • send the notification to player using notification.show() (Client script only) or player.notify(notification) (Client/Server)
  • modify notification via notification.xxx(xxx), for example in client script:
Notification.ofText("wow")
    .backgroundColor(1234)
    .itemIcon("diamond")
    .duration("5s")
    .show();

@ZZZank
Copy link
Collaborator Author

ZZZank commented Apr 13, 2025

Example usage, in client_script:

Notification.ofText(
    Text.of("some looooooooooooooooooooooooooooong line").append("\nwith a, not-long, line, yeah.")
)
    .itemIcon("minecraft:bedrock")
    .outlineColor(Color.BLUE)
    .show()

server_script example:

const notif = Notification.ofText(
    Text.of("some looooooooooooooooooooooooooooong line").append("\nwith a, not-long, line, yeah.")
)
    .itemIcon("minecraft:bedrock")
    .outlineColor(Color.BLUE)

Utils.getServer()
    .players
    .forEach((/** @type {Internal.PlayerJS<any>} */ player) => player.notify(notif))

They will produce the same result:

example

@ZZZank ZZZank marked this pull request as ready for review May 28, 2025 12:25
@ZZZank ZZZank merged commit 2301d5c into Hellish-Mods:main May 28, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant