Skip to main content
The MinecraftUtils API provides a collection of general Minecraft-related utility functions to simplify common tasks in mod development.

Accessing MinecraftUtils

Get an instance using dependency injection:
import gg.essential.api.utils.MinecraftUtils
import gg.essential.api.utils.get

val minecraftUtils = get<MinecraftUtils>()

Sending chat messages

sendMessage

Queue messages to be displayed in the player’s chat, client-side only.
// Simple message with [Essential] prefix
minecraftUtils.sendMessage("Hello from Essential!")

// Custom prefix
minecraftUtils.sendMessage("§a[MyMod]", "Task completed successfully")
The simple sendMessage(String) variant prefixes messages with [Essential] and should only be used for Essential-specific information. For custom messages, use the two-parameter version or UTextComponent.

sendChatMessageAndFormat

Send messages with Minecraft’s I18n translation and formatting.
// Translate and format a message
minecraftUtils.sendChatMessageAndFormat("chat.type.text", playerName, message)

// With parameters
minecraftUtils.sendChatMessageAndFormat(
    "multiplayer.player.joined",
    "Steve"
)

Server detection

isHypixel

Check if the player is currently connected to the Hypixel server.
if (minecraftUtils.isHypixel()) {
    println("Player is on Hypixel!")
    // Enable Hypixel-specific features
}

Resource handling

getResourceImage

Load a ResourceLocation into memory as a BufferedImage for use in dynamic textures.
import net.minecraft.util.ResourceLocation

val location = ResourceLocation("essential", "textures/gui/icon.png")
val image = minecraftUtils.getResourceImage(location)

if (image != null) {
    // Use the BufferedImage
    val width = image.width
    val height = image.height
} else {
    println("Failed to load image")
}

Environment detection

isDevelopment

Check if the game is running in a development environment rather than production.
if (minecraftUtils.isDevelopment()) {
    println("Running in development mode")
    // Enable debug features
}

API reference

Methods

sendMessage
(message: String) -> Unit
Sends a message prefixed with [Essential] to the player’s chat.
sendMessage
(prefix: String, message: String) -> Unit
Sends a formatted message with a custom prefix: $prefix&r$message.
sendChatMessageAndFormat
(message: String) -> Unit
Sends a message translated and formatted using Minecraft’s I18n utility.
sendChatMessageAndFormat
(message: String, vararg parameters: Any) -> Unit
Sends a message translated with I18n using the given parameters.
isHypixel
() -> Boolean
Returns whether the player is currently on the Hypixel server.
getResourceImage
(location: ResourceLocation) -> BufferedImage?
Loads a ResourceLocation into memory as a BufferedImage. Returns null if loading fails.
isDevelopment
() -> Boolean
Returns true if the game is launched in a development environment.

Build docs developers (and LLMs) love