EffectiveScreenImage

Base class for an image shown on a player's screen. ⚠️ Experimental. The core-shader technique, this API and its behaviour may change; not guaranteed across clients or with shader packs. Registers itself on construction under getNamespacedName (<plugin>:<name>) and refuses duplicates; its PNG is added to the plugin's generated pack as a font glyph (glyph).

The PNG may be any shape — it is padded to a square automatically. Coordinates are screen fractions from the top-left corner (0.0..1.0); getSize is the width as a fraction of the screen width.

object Logo : EffectiveScreenImage() {
override fun getNamespacedData() = ExamplePlugin.instance to "logo"
override fun getTexturePath() = "textures/screen/logo.png"
override fun getX() = 0.05f
override fun getY() = 0.05f
override fun getSize() = 0.25f
fun init() {}
}

Logo.show(player) // until hide()
Logo.show(player, durationTicks = 100)
Logo.hide(player)

Notes:

  • Rendering goes through the framework's text.vsh core shader in the plugin's pack, so the plugin must enable its pack (EffectiveResourcepack.addServerResourcepack in onEnable, after init()).

  • show uses the title slot: one element per player at a time — an image, a text or a fade replaces the previous one. To show several at once, join their getComponents into a single title.

  • Shader packs (Iris, OptiFine) replace core shaders: for those players the image lands at the raw glyph position instead. EffectiveScreenEffects fade and shake are unaffected.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The font glyph backing this image; its EffectiveGlyph.charGlyph is the character to send.

Functions

Link copied to clipboard
fun getComponent(): Component

The glyph with the default placement encoded in its color; put it in a title, action bar, boss bar, …

fun getComponent(x: Float, y: Float, size: Float): Component

The glyph with an explicit placement encoded in its color (screen fractions, top-left origin).

Link copied to clipboard
abstract fun getNamespacedData(): Pair<JavaPlugin, String>

Owning plugin and a plugin-unique id; together they form the getNamespacedName.

Link copied to clipboard

Unique identity as "<plugin-name>:<id>", both lowercased.

Link copied to clipboard
open fun getSize(): Float

Default box side (the image's larger dimension), screen fraction 0..1, quantized to 1/32.

Link copied to clipboard
abstract fun getTexturePath(): String

Resource path of the PNG inside the plugin jar.

Link copied to clipboard
open fun getX(): Float

Default left edge, screen fraction 0..1.

Link copied to clipboard
open fun getY(): Float

Default top edge, screen fraction 0..1.

Link copied to clipboard
fun hide(player: Player)

Hides whatever this element showed via a title.

Link copied to clipboard
open fun isPersistent(player: Player): Boolean

Whether the element stays on player's screen permanently (re-shown automatically on join/respawn/world change).

Link copied to clipboard
fun show(player: Player)

Shows the image to player at the default placement until hide.

fun show(player: Player, durationTicks: Int)

Shows the image to player for durationTicks.