-
Notifications
You must be signed in to change notification settings - Fork 2
TitleHelper
TitleHelper provides utilities for displaying on-screen event titles to players using Hytale's built-in title system. Event titles are large, centered text displays perfect for important announcements, quest updates, boss encounters, and zone notifications.
- Major & Minor Titles - Large prominent titles or smaller subtle notifications
- Primary & Secondary Text - Main title with optional subtitle
- Custom Icons - Display icons alongside titles
- Fade Animations - Control fade in/out timing
- Easy Presets - Convenience methods for common use cases
- Quest notifications and updates
- Boss encounter announcements
- Zone entry/discovery messages
- Achievement unlocks
- Important game events
- Player notifications
// Simple major title (3 second duration)
TitleHelper.showMajorTitle(playerEntity, "Quest Started", "Find the Ancient Sword", 3.0f);
// Boss encounter
TitleHelper.showBossTitle(playerEntity, "Ancient Dragon", "Prepare for battle!");// Subtle notification (2 second duration)
TitleHelper.showMinorTitle(playerEntity, "Item Acquired", "Ancient Key", 2.0f);
// Zone entry
TitleHelper.showZoneEntry(playerEntity, "Emerald Grove");// 1 second notification
TitleHelper.showNotification(playerEntity, "Checkpoint reached!");Show a large, prominent title to a player.
Parameters:
-
player(Entity) - The player entity -
primaryText(String) - Main title text (large) -
secondaryText(String, nullable) - Subtitle text (smaller, optional) -
durationSeconds(float) - How long to display in seconds
Returns: boolean - true if successful
Example:
TitleHelper.showMajorTitle(player, "Level Up!", "You are now level 10", 3.0f);Show a smaller, less intrusive title to a player.
Parameters:
-
player(Entity) - The player entity -
primaryText(String) - Main title text -
secondaryText(String, nullable) - Subtitle text (optional) -
durationSeconds(float) - How long to display in seconds
Returns: boolean - true if successful
Example:
TitleHelper.showMinorTitle(player, "New Area", "Ancient Ruins", 2.0f);showTitle(player, isMajor, primaryText, secondaryText, iconPath, durationSeconds, fadeInSeconds, fadeOutSeconds)
Show a title with full control over all parameters.
Parameters:
-
player(Entity) - The player entity -
isMajor(boolean) - true for major title (large), false for minor (smaller) -
primaryText(String) - Main title text -
secondaryText(String, nullable) - Subtitle text (optional) -
iconPath(String, nullable) - Path to icon asset (optional) -
durationSeconds(float) - How long to display in seconds -
fadeInSeconds(float) - Fade in duration in seconds -
fadeOutSeconds(float) - Fade out duration in seconds
Returns: boolean - true if successful
Example:
TitleHelper.showTitle(
player,
true, // Major title
"Achievement Unlocked",
"Master Explorer",
"icons/achievement_star",
4.0f, // 4 second duration
0.5f, // 0.5 second fade in
0.5f // 0.5 second fade out
);Show a title with a custom icon using default fade timings.
Parameters:
-
player(Entity) - The player entity -
isMajor(boolean) - true for major, false for minor -
primaryText(String) - Main title text -
secondaryText(String, nullable) - Subtitle text (optional) -
iconPath(String) - Path to icon asset -
durationSeconds(float) - How long to display in seconds
Returns: boolean - true if successful
Show a quick 1-second minor title notification.
Example:
TitleHelper.showNotification(player, "Checkpoint saved!");Show a 3-second major title for quest updates.
Example:
TitleHelper.showQuestUpdate(player, "The Lost Artifact", "Collect 5 Ancient Fragments");Show a 4-second major title for boss encounters.
Example:
TitleHelper.showBossTitle(player, "Shadow Lord", "Prepare yourself!");Show a 2-second minor title for zone entry.
Example:
TitleHelper.showZoneEntry(player, "Whispering Woods");Show a 3-second major title for achievement unlocks.
Example:
TitleHelper.showAchievement(player, "First Steps");Hide/clear the current title with a fade out animation.
Parameters:
-
player(Entity) - The player entity -
fadeOutSeconds(float) - Fade out duration in seconds
Returns: boolean - true if successful
Example:
TitleHelper.hideTitle(player, 0.5f);Instantly clear the current title (no fade).
Example:
TitleHelper.clearTitle(player);// Quest started
EcsEventHelper.onBlockInteract(world, (position, blockTypeId, playerEntity) -> {
if ("Quest_Board".equals(blockTypeId)) {
TitleHelper.showQuestUpdate(
playerEntity,
"The Ancient Prophecy",
"Speak to the Elder in the village"
);
}
});
// Quest completed
public void completeQuest(Entity player, String questName) {
TitleHelper.showMajorTitle(
player,
"Quest Complete!",
questName,
4.0f
);
}// Boss spawned
public void spawnBoss(World world, Vector3i position, String bossName) {
// Spawn the boss entity
Entity boss = EntityHelper.spawnNPC(world, position, "Boss_Dragon");
// Show title to all nearby players
for (Entity player : EntityHelper.getPlayersInRadius(world, position, 50.0)) {
TitleHelper.showBossTitle(player, bossName, "A powerful foe approaches!");
}
}
// Boss defeated
DeathHelper.onEntityDeath(world, (deadEntity, killerEntity, damageSource) -> {
if (EntityHelper.getEntityType(deadEntity).contains("Boss")) {
if (killerEntity != null && PlayerHelper.isPlayer(killerEntity)) {
TitleHelper.showMajorTitle(
killerEntity,
"Victory!",
"Boss Defeated",
5.0f
);
}
}
});EcsEventHelper.onZoneDiscovery(world, (discoveryInfo) -> {
Entity player = discoveryInfo.getPlayerEntity();
String zoneName = discoveryInfo.getZoneName();
// Show zone entry title
TitleHelper.showZoneEntry(player, zoneName);
// Check if it's a special zone
if (zoneName.contains("Ancient") || zoneName.contains("Forbidden")) {
WorldHelper.waitTicks(world, 60, () -> {
TitleHelper.showMinorTitle(
player,
"Danger Ahead",
"Powerful enemies lurk here",
3.0f
);
});
}
});public class AchievementManager {
private final Map<String, Set<String>> playerAchievements = new ConcurrentHashMap<>();
public void unlockAchievement(Entity player, String achievementId, String achievementName) {
String playerName = EntityHelper.getName(player);
playerAchievements.computeIfAbsent(playerName, k -> new HashSet<>());
if (playerAchievements.get(playerName).add(achievementId)) {
// First time unlocking this achievement
TitleHelper.showAchievement(player, achievementName);
// Play sound effect
SoundHelper.playSound2DToPlayer(
WorldHelper.getWorld(player),
"Achievement_Unlock",
player
);
}
}
}// Rare item drop with icon
EventHelper.onItemPickup(world, (transaction, playerEntity) -> {
String itemId = transaction.getItemId();
if (itemId != null && itemId.contains("Legendary")) {
TitleHelper.showTitleWithIcon(
playerEntity,
true, // Major title
"Legendary Item!",
itemId.replace("_", " "),
"icons/legendary_star",
4.0f
);
}
});public void showTitleSequence(World world, Entity player) {
// First title
TitleHelper.showMajorTitle(player, "Welcome", "To the Adventure", 2.0f);
// Second title after 3 seconds
WorldHelper.waitTicks(world, 60, () -> {
TitleHelper.showMinorTitle(player, "Your journey begins", "Good luck!", 2.0f);
});
// Clear after 6 seconds total
WorldHelper.waitTicks(world, 120, () -> {
TitleHelper.clearTitle(player);
});
}- FormattedMessage Creation - Converts plain text strings into Hytale's FormattedMessage format
- Packet Construction - Creates ShowEventTitle or HideEventTitle packets with timing parameters
- Packet Delivery - Sends packets via PlayerRef's PacketHandler to the client
- Client Display - Client receives packet and displays title with fade animations
- Major Titles - Large, prominent text displayed in the center of the screen
- Minor Titles - Smaller, less intrusive text for subtle notifications
- Duration - How long the title remains fully visible (in seconds)
- Fade In - Time taken to fade in from transparent to opaque (default: 0.5s)
- Fade Out - Time taken to fade out from opaque to transparent (default: 0.5s)
- All methods are thread-safe
- Can be called from any thread
- Packet sending is handled by Hytale's networking system
- Player Validation - Always returns false if entity is not a player
- Null Safety - Secondary text and icon paths are optional (can be null)
- Duration Range - Use reasonable durations (0.5 - 10 seconds recommended)
- Fade Timing - Keep fade times short (0.3 - 1.0 seconds) for best UX
- Title Overlap - New titles replace existing ones immediately
- Icon Paths - Icons must be valid asset paths in the game's resource system
- PlayerHelper - Player messaging and management
- UIHelper - Custom pages and HUD control
- WorldHelper - Timing and scheduling
- ZoneHelper - Zone discovery tracking