Beta
Beta
Beta
Optional
hudElements: HudElement[]Beta
Beta
New value for the action bar text.
Beta
Whether to set the HUD element to invisible, or to reset it back to its default.
Optional
hudElements: HudElement[]Optional list of HUD elements to configure visibility for.
Beta
Optional
options: TitleDisplayOptionsWill cause a title to show up on the player's on screen display. Will clear the title if set to empty string. You can optionally specify an additional subtitle as well as fade in, stay and fade out times.
This function can't be called in read-only mode.
import { world } from '@minecraft/server';
world.afterEvents.playerSpawn.subscribe((event) => {
event.player.onScreenDisplay.setTitle('§o§6You respawned!§r');
});
import { world } from '@minecraft/server';
world.afterEvents.playerSpawn.subscribe((event) => {
event.player.onScreenDisplay.setTitle('You respawned', {
stayDuration: 100,
fadeInDuration: 2,
fadeOutDuration: 4,
subtitle: 'Try not to die next time!',
});
});
import { world, system } from '@minecraft/server';
world.afterEvents.playerSpawn.subscribe(event => {
event.player.onScreenDisplay.setTitle('Get ready!', {
stayDuration: 220,
fadeInDuration: 2,
fadeOutDuration: 4,
subtitle: '10',
});
let countdown = 10;
const intervalId = system.runInterval(() => {
countdown--;
event.player.onScreenDisplay.updateSubtitle(countdown.toString());
if (countdown == 0) {
system.clearRun(intervalId);
}
}, 20);
});
Beta
Contains information about user interface elements that are showing up on the screen.
Example: setTitle.ts
Example: setTitleAndSubtitle.ts
Example: titleCountdown.ts