Actionbar (v0.4.1)#

A small library that helps to coordinate actionbar usage across various data packs

#smithed.actionbar:message#

Input Name

Input Type

Input Source

Input Objective/Path

'Raw Message'

storage

message.raw

smithed.actionbar:input

'JSON Message'

storage

message.json

smithed.actionbar:input

'Priority Level'

storage

message.priority

smithed.actionbar:input

'Message Duration'

storage

message.freeze

smithed.actionbar:input

Instead of using /title to display the message, set up the input storage and run the following command:

function #smithed.actionbar:message

Message#

Messages can be set as strings or as json objects. To set a string, use raw, and to set a JSON object, use json. Below are examples for both types of messages. If both fields are set, the json object is shown.

Example of Raw Message#

data modify storage smithed.actionbar:input message set value {
   raw: 'hello world',
   priority: 'persistent'
}

Example of JSON Message#

data modify storage smithed.actionbar:input message set value {
  json: '{"text": "You cannot complete this action!", "color": "red"}',
  priority: 'notification'
}

Priority#

Priorities are set via specific strings. The list below shows the priority in descending order, so for example notifications will show over conditional messages.

  • override: This is the highest priority and will always override the current message, no matter what.

  • notification: This is for brief, non-repeating, notification type messages, such as the vanilla "You can't sleep now" message.

  • conditional: This should be used for any message which will display constantly on a condition. A good example is displaying a compass HUD while you hold a compass or showcasing the amount of XP in a nearby tank. This doesn't include any persistent messages which toggle via a config option!

  • persistent: This is the lowest priority message and is designated for messages which always displays (or displays continously if a config value is set). You can think of this as a custom ui display such as in Manic or even the Vanilla Tweaks coordinate HUD which always displays.

Message Duration#

Additionally, you can also set a freeze field in the storage space. This will deteremine how many ticks your message should be protected against other messages with the same priority. By default, this field is set to 20, which corresponds to 1 second.

data modify storage smithed.actionbar:message input set value {
  raw: 'Random Event!',
  priority: 'notification',
  freeze: 30
}

The freeze value has a minimum value of 0 and a maximum value of 50.

Events / Extras#

#smithed.actionbar:event/player/on_click_locked_container#

Locked containers will send an event before allowing the vanilla message to show You can add locked container events by adding your function to the tag #smithed.actionbar:event/player/on_click_locked_container.
This library tracks the full block data of the clicked locked container in data storage smithed.actionbar:data block.

Example Implementation#

function: example:clicked_locked_container

# ignore blocks with the a specific lock
execute if data storage smithed.actionbar:data block{Lock:"Ignore Me!"} run data remove storage smithed.actionbar:input message
# alternate way to ignore blocks (this time with a custom name)
execute if data storage smithed.actionbar:data block{CustomName:'{"text":"Custom Block"}'} run scoreboard players set $locked smithed.actionbar.temp 0
# send a custom lock message (in this example to send a reason that it's locked)
execute if data storage smithed.actionbar:data block{CustomName:'{"text":"Custom Block"}'} run data modify storage smithed.actionbar:input message set value {json:'{"text":"Someone is currently using this block!"}',priority:'notification',freeze:20}

tag: #smithed.actionbar:event/player/on_click_locked_container

{
  "values": [
      "example:clicked_locked_container"
  ]    
}