Skip to main content
Version: Minecraft 26.2

dev.polymodloader.api.client

Generated

This page is generated from the source's Javadoc by ./gradlew apiReference. Do not edit it; fix the source comment and generate it again.

TypeKindDescription
BlockEntityCanvasinterfaceDraws in the world relative to a block: (0, 0, 0) is the block's lowest corner and (1, 1, 1) its highest.
BlockEntityPainterfunctional interfaceDraws extra things for a mod block entity every frame, on the client (render) thread, from the client's copy of the block entity (use syncToClients for data the drawing needs).
CameraPerspectiveenumWhere the camera is, as cycled with F5.
ClientConnectionListenerfunctional interfaceListener for ClientEvents.JOINED_WORLD and ClientEvents.LEFT_WORLD.
ClientEventsclassClient events; fired on the client thread, only on the client.
ClientRegistrarinterfaceClient-only registrations.
ClientTickListenerfunctional interfaceListener for ClientEvents.TICK.
ClientViewinterfaceThe client's state during a callback.
DynamicTextureinterfaceA texture whose pixels the mod sets while the game runs, for example a minimap.
FovModifierfunctional interfaceListener for ClientEvents.FIELD_OF_VIEW.
HudCanvasinterfaceDrawing surface in GUI-scaled pixels; (0, 0) is the top-left corner.
HudLayerfunctional interfaceDraws over the in-game HUD.
ItemTooltipListenerfunctional interfaceListener for ClientEvents.ITEM_TOOLTIP.
KeyBindinginterfaceA rebindable key.
KeyCodesclassKeyboard key codes for default key bindings (the GLFW codes the game uses).
ModScreeninterfaceA full-screen menu made by a mod: labels, buttons, and text inputs placed in init, plus free drawing in render.
ScreenBuilderinterfacePlaces widgets on a ModScreen, in GUI-scaled pixels from the top-left corner.
ShaderPipelinerecordA declared shader pipeline, used with WorldCanvas.quads and BlockEntityCanvas.quads.
ShaderPipelineDefinitionrecordA render pipeline with a mod's own core shader: GLSL files assets/<namespace>/shaders/<path>.vsh and .fsh in the mod's resources, for quads with a position and a colour per vertex, and a texture coordinate when the pipeline has textures.
ShaderPipelineDefinition.BlendenumHow a pipeline's colours mix with the scene.
ShaderPipelineDefinition.BuilderclassBuilds a ShaderPipelineDefinition.
ShaderUniformrecordOne value a mod passes to its own shader pipeline, declared with ShaderPipelineDefinition.Builder.uniform.
ShaderUniform.Sourcefunctional interfaceGives a uniform's value; called once per frame on the render thread.
ShaderUniform.TypeenumThe GLSL type of a uniform.
TextInputinterfaceA text input placed by ScreenBuilder.textInput.
TooltipLinesinterfaceThe lines of one item tooltip, first line the item's name.
VertexSinkinterfaceTakes the vertices of quads drawn with a ShaderPipeline: four per quad, in order around it.
WorldCanvasinterfaceDraws in the world for one frame, in world coordinates, valid only during WorldPainter.paint.
WorldPainterfunctional interfaceDraws extra shapes in the world every frame while the client is in a world, on the render thread: area markers, paths, debug views, glowing effects.

BlockEntityCanvas​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface BlockEntityCanvas

Draws in the world relative to a block: (0, 0, 0) is the block's lowest corner and (1, 1, 1) its highest. Valid only during BlockEntityPainter.paint.

item(ResourceId, double, double, double, float, float)​

void item(ResourceId item, double x, double y, double z, float scale, float yawDegrees)

Since 0.1.0-alpha.4 or earlier

Draws an item as in an item frame.

ParameterTypeDescription
itemResourceId—
xdouble—
ydouble—
zdouble—
scalefloat1 is a full block
yawDegreesfloatturn around the vertical axis

Throws IllegalArgumentException — for an unknown item

text(String, double, double, double, float, int)​

void text(String text, double x, double y, double z, float scale, int argb)

Since 0.1.0-alpha.4 or earlier

Draws text centred at the position, facing the camera.

ParameterTypeDescription
textString—
xdouble—
ydouble—
zdouble—
scalefloata line of text is 9 × scale blocks high (0.025 makes a small label)
argbint—

animationTime()​

float animationTime()

Since 0.1.0-alpha.4 or earlier

World time plus the partial tick, for smooth animation.

Returns float

block(ResourceId, double, double, double, float, float)​

default void block(ResourceId block, double x, double y, double z, float scale, float yawDegrees)

Since 0.1.0-alpha.4 or earlier

Draws the block model of block's default state, centred on x, y, z and turned yawDegrees around the vertical axis; scale 1 is full block size.

ParameterTypeDescription
blockResourceId—
xdouble—
ydouble—
zdouble—
scalefloat—
yawDegreesfloat—

Throws IllegalArgumentException — if block is not a block

block(BlockStateView, double, double, double, float, float)​

void block(BlockStateView state, double x, double y, double z, float scale, float yawDegrees)

Since 0.1.0-alpha.4 or earlier

Draws the block model of state, for example a lamp that is lit, placed like block(ResourceId, double, double, double, float, float). Get a state from defaultState or WorldView.stateAt, and change it with BlockStateView.with.

ParameterTypeDescription
stateBlockStateView—
xdouble—
ydouble—
zdouble—
scalefloat—
yawDegreesfloat—

defaultState(ResourceId)​

BlockStateView defaultState(ResourceId block)

Since 0.1.0-alpha.4 or earlier

The default state of block, to change with BlockStateView.with and draw with block(BlockStateView, double, double, double, float, float).

ParameterTypeDescription
blockResourceId—

Returns BlockStateView

Throws IllegalArgumentException — if block is not a block

quads(ShaderPipeline, Consumer<VertexSink>)​

void quads(ShaderPipeline pipeline, Consumer<VertexSink> vertices)

Since 0.1.0-alpha.4 or earlier

Quads drawn with a mod shader pipeline, four vertices per quad, in the same coordinates as the other draws (the block's lowest corner is 0, 0, 0).

ParameterTypeDescription
pipelineShaderPipeline—
verticesConsumer<VertexSink>—

BlockEntityPainter​

functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface BlockEntityPainter

Draws extra things for a mod block entity every frame, on the client (render) thread, from the client's copy of the block entity (use syncToClients for data the drawing needs). The block's own model is drawn by the game as usual.

paint(BlockEntityView, BlockEntityCanvas)​

void paint(BlockEntityView entity, BlockEntityCanvas canvas)

Since 0.1.0-alpha.4 or earlier

Draws for one block entity; canvas is placed at the block's lowest corner.

ParameterTypeDescription
entityBlockEntityView—
canvasBlockEntityCanvas—

CameraPerspective​

enum · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public enum CameraPerspective

Where the camera is, as cycled with F5.

ConstantDescription
FIRST_PERSON—
THIRD_PERSON_BACK—
THIRD_PERSON_FRONT—

ClientConnectionListener​

functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface ClientConnectionListener

Listener for ClientEvents.JOINED_WORLD and ClientEvents.LEFT_WORLD.

onConnection(ClientView)​

void onConnection(ClientView view)

Since 0.1.0-alpha.4 or earlier

Called on the client thread when the client joins or leaves a world.

ParameterTypeDescription
viewClientView—

ClientEvents​

class · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public final class ClientEvents

Client events; fired on the client thread, only on the client.

Constant or fieldTypeDescription
TICKEventKey<ClientTickListener>The client finished a tick (20 per second, also on the title screen).
FIELD_OF_VIEWEventKey<FovModifier>The field of view of the next frame, after the game's own changes (sprinting, underwater); called every frame, keep it cheap.
JOINED_WORLDEventKey<ClientConnectionListener>The client joined a world (single player or a server) and has its player and world; fired once per connection.
LEFT_WORLDEventKey<ClientConnectionListener>The client is leaving the world; the player and world are still available.
ITEM_TOOLTIPEventKey<ItemTooltipListener>The game built an item's tooltip; listeners may add, insert, or remove lines. Not fired for items whose tooltip the game hides. Fabric API: ItemTooltipCallback; NeoForge: ItemTooltipEvent.

ClientRegistrar​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface ClientRegistrar

Client-only registrations. Obtain it in client entrypoints; on a dedicated server ModContext.client() throws.

keyBinding(String, int)​

KeyBinding keyBinding(String path, int defaultKey)

Since 0.1.0-alpha.4 or earlier

Declares a key binding that players can rebind in Controls. Its name is translated from key.<mod id>.<path>; it is listed under the category key.category.<mod id>.

ParameterTypeDescription
pathStringbinding name inside the mod's namespace
defaultKeyintdefault key, one of KeyCodes

Returns KeyBinding

Throws IllegalStateException — after registration closed (POLY-CLIENT-002)

hudLayer(String, HudLayer)​

void hudLayer(String path, HudLayer layer)

Since 0.1.0-alpha.4 or earlier

Adds a layer drawn over the game's HUD every frame, after the game's own layers, in registration order.

ParameterTypeDescription
pathString—
layerHudLayer—

Throws IllegalStateException — after registration closed (POLY-CLIENT-002)

blockEntityRenderer(ResourceId, BlockEntityPainter)​

void blockEntityRenderer(ResourceId block, BlockEntityPainter painter)

Since 0.1.0-alpha.4 or earlier

Draws extra things for a mod block that has a block entity.

ParameterTypeDescription
blockResourceId—
painterBlockEntityPainter—

Throws IllegalArgumentException — for a block that is not one of this mod's, or a second painter

dynamicTexture(String, int, int)​

DynamicTexture dynamicTexture(String path, int width, int height)

Since 0.1.0-alpha.4 or earlier

Declares a texture with pixels set by code, <mod id>:dynamic/<path>.

ParameterTypeDescription
pathString—
widthint—
heightint—

Returns DynamicTexture

worldPainter(String, WorldPainter)​

void worldPainter(String path, WorldPainter painter)

Since 0.1.0-alpha.4 or earlier

Draws in the world every frame with painter.

ParameterTypeDescription
pathString—
painterWorldPainter—

Throws IllegalArgumentException — for an invalid or used path (POLY-CLIENT-002)

shaderPipeline(String, ShaderPipelineDefinition)​

ShaderPipeline shaderPipeline(String path, ShaderPipelineDefinition definition)

Since 0.1.0-alpha.4 or earlier

Declares render pipeline <mod id>:<path> using the mod's own core shader, for WorldCanvas.quads and BlockEntityCanvas.quads.

ParameterTypeDescription
pathString—
definitionShaderPipelineDefinition—

Returns ShaderPipeline

Throws IllegalArgumentException — for an invalid or used path (POLY-CLIENT-002)

ClientTickListener​

functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface ClientTickListener

Listener for ClientEvents.TICK.

onClientTick(ClientView)​

void onClientTick(ClientView client)

Since 0.1.0-alpha.4 or earlier

Called at the end of each client tick.

ParameterTypeDescription
clientClientView—

ClientView​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface ClientView

The client's state during a callback. Valid only during the call, on the client thread.

player()​

Optional<PlayerView> player()

Since 0.1.0-alpha.4 or earlier

The local player, when in a world.

Returns Optional<PlayerView>

world()​

Optional<WorldView> world()

Since 0.1.0-alpha.4 or earlier

The client's copy of the current world, when in one.

Returns Optional<WorldView>

showActionBar(String)​

void showActionBar(String text)

Since 0.1.0-alpha.4 or earlier

Shows a message above the hotbar (the action bar).

ParameterTypeDescription
textString—

openScreen(ModScreen)​

void openScreen(ModScreen screen)

Since 0.1.0-alpha.4 or earlier

Opens screen, replacing any open screen.

ParameterTypeDescription
screenModScreen—

closeScreen()​

void closeScreen()

Since 0.1.0-alpha.4 or earlier

Closes the open screen, if any, returning to the game.

isScreenOpen()​

boolean isScreenOpen()

Since 0.1.0-alpha.4 or earlier

Whether any screen (menu, inventory, chat, mod screen) is open.

Returns boolean

cameraPerspective()​

CameraPerspective cameraPerspective()

Since 0.1.0-alpha.4 or earlier

The camera perspective.

Returns CameraPerspective

setCameraPerspective(CameraPerspective)​

void setCameraPerspective(CameraPerspective perspective)

Since 0.1.0-alpha.4 or earlier

Changes the camera perspective, as F5 does.

ParameterTypeDescription
perspectiveCameraPerspective—

setPostEffect(ResourceId)​

boolean setPostEffect(ResourceId effect)

Since 0.1.0-alpha.4 or earlier

Applies a full-screen post effect from assets/<namespace>/post_effect/<path>.json, with its shaders, until cleared. The game also replaces it when the camera entity or perspective changes (as when spectating a creeper).

ParameterTypeDescription
effectResourceId—

Returns boolean — whether the effect loaded; failures are logged by the game

clearPostEffect()​

void clearPostEffect()

Since 0.1.0-alpha.4 or earlier

Removes the post effect.

postEffect()​

Optional<ResourceId> postEffect()

Since 0.1.0-alpha.4 or earlier

The active post effect, if any.

Returns Optional<ResourceId>

leaveWorld()​

void leaveWorld()

Since 0.1.0-alpha.4 or earlier

Leaves the world like "Save and Quit to Title" (single player) or "Disconnect" (servers). Call it from a tick, not while drawing.

DynamicTexture​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface DynamicTexture

A texture whose pixels the mod sets while the game runs, for example a minimap. Draw it with HudCanvas.drawTexture. Use it on the client thread; changes appear after upload().

id()​

ResourceId id()

Since 0.1.0-alpha.4 or earlier

The texture's ID, <mod id>:dynamic/<path>.

Returns ResourceId

width()​

int width()

Since 0.1.0-alpha.4 or earlier

Width in pixels.

Returns int

height()​

int height()

Since 0.1.0-alpha.4 or earlier

Height in pixels.

Returns int

setPixel(int, int, int)​

void setPixel(int x, int y, int argb)

Since 0.1.0-alpha.4 or earlier

Sets one pixel, 0xAARRGGBB.

ParameterTypeDescription
xint—
yint—
argbint—

fill(int)​

void fill(int argb)

Since 0.1.0-alpha.4 or earlier

Sets every pixel.

ParameterTypeDescription
argbint—

upload()​

void upload()

Since 0.1.0-alpha.4 or earlier

Sends the pixels to the graphics card.

FovModifier​

functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface FovModifier

Listener for ClientEvents.FIELD_OF_VIEW.

modifyFov(float)​

float modifyFov(float fov)

Since 0.1.0-alpha.4 or earlier

Returns the field of view in degrees to use instead of fov; listeners chain.

ParameterTypeDescription
fovfloat—

Returns float

HudCanvas​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface HudCanvas

Drawing surface in GUI-scaled pixels; (0, 0) is the top-left corner. Colours are ARGB (0xFFFFFFFF is opaque white). Valid only during HudLayer.render(HudCanvas).

width()​

int width()

Since 0.1.0-alpha.4 or earlier

Width of the screen in GUI pixels.

Returns int

height()​

int height()

Since 0.1.0-alpha.4 or earlier

Height of the screen in GUI pixels.

Returns int

textWidth(String)​

int textWidth(String text)

Since 0.1.0-alpha.4 or earlier

Width of text in the game font.

ParameterTypeDescription
textString—

Returns int

drawText(String, int, int, int)​

void drawText(String text, int x, int y, int argb)

Since 0.1.0-alpha.4 or earlier

Draws text with a shadow.

ParameterTypeDescription
textString—
xint—
yint—
argbint—

fill(int, int, int, int, int)​

void fill(int x1, int y1, int x2, int y2, int argb)

Since 0.1.0-alpha.4 or earlier

Fills the rectangle from (x1, y1) inclusive to (x2, y2) exclusive.

ParameterTypeDescription
x1int—
y1int—
x2int—
y2int—
argbint—

drawTexture(ResourceId, int, int, int, int)​

void drawTexture(ResourceId texture, int x, int y, int width, int height)

Since 0.1.0-alpha.4 or earlier

Draws a whole texture, such as my_mod:textures/gui/icon.png or a DynamicTexture, stretched to width × height.

ParameterTypeDescription
textureResourceId—
xint—
yint—
widthint—
heightint—

HudLayer​

functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface HudLayer

Draws over the in-game HUD. Called every frame on the client (render) thread while in a world.

render(HudCanvas)​

void render(HudCanvas canvas)

Since 0.1.0-alpha.4 or earlier

Draws the layer. Keep it fast: it runs every frame. Exceptions are logged once (POLY-CLIENT-003) and the layer is disabled.

ParameterTypeDescription
canvasHudCanvas—

ItemTooltipListener​

functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface ItemTooltipListener

Listener for ClientEvents.ITEM_TOOLTIP.

onItemTooltip(ItemStackRef, TooltipLines, boolean)​

void onItemTooltip(ItemStackRef stack, TooltipLines lines, boolean advanced)

Since 0.1.0-alpha.4 or earlier

Called on the client thread whenever the game builds an item's tooltip (every frame the tooltip is shown, and for the creative search), after the game's own lines. Keep it cheap.

ParameterTypeDescription
stackItemStackRefthe item stack; read it, do not change it (it is the client's copy)
linesTooltipLinesthe tooltip lines to read and change
advancedbooleanwhether advanced tooltips are on (F3+H)

KeyBinding​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface KeyBinding

A rebindable key. Query it on the client thread, for example from ClientEvents.TICK.

id()​

ResourceId id()

Since 0.1.0-alpha.4 or earlier

The binding's ID.

Returns ResourceId

isDown()​

boolean isDown()

Since 0.1.0-alpha.4 or earlier

Whether the key is held now.

Returns boolean

consumeClick()​

boolean consumeClick()

Since 0.1.0-alpha.4 or earlier

Returns true once per press since the last call, so no press is lost between ticks.

Returns boolean

KeyCodes​

class · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public final class KeyCodes

Keyboard key codes for default key bindings (the GLFW codes the game uses).

Constant or fieldTypeDescription
UNBOUNDintNo default key; the player must bind one.
Aint—
Bint—
Gint—
Hint—
Jint—
Kint—
Lint—
Mint—
Nint—
Oint—
Pint—
Rint—
Uint—
Vint—
Xint—
Yint—
Zint—
F6int—
F7int—
F8int—
F9int—
F10int—

ModScreen​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface ModScreen

A full-screen menu made by a mod: labels, buttons, and text inputs placed in init, plus free drawing in render. Open it with ClientView.openScreen(ModScreen). All methods run on the client (render) thread.

title()​

String title()

Since 0.1.0-alpha.4 or earlier

Title used for narration and the window title.

Returns String

init(ScreenBuilder)​

void init(ScreenBuilder screen)

Since 0.1.0-alpha.4 or earlier

Places widgets. Called when the screen opens and again when the window is resized, with a fresh builder each time.

ParameterTypeDescription
screenScreenBuilder—

render(HudCanvas)​

default void render(HudCanvas canvas)

Since 0.1.0-alpha.4 or earlier

Draws extra content every frame, above the background and below the widgets.

ParameterTypeDescription
canvasHudCanvas—

pausesGame()​

default boolean pausesGame()

Since 0.1.0-alpha.4 or earlier

Whether the game pauses while the screen is open (single player only).

Returns boolean

onClosed()​

default void onClosed()

Since 0.1.0-alpha.4 or earlier

The screen was closed, by the player (Esc) or by code.

ScreenBuilder​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface ScreenBuilder

Places widgets on a ModScreen, in GUI-scaled pixels from the top-left corner.

width()​

int width()

Since 0.1.0-alpha.4 or earlier

Screen width.

Returns int

height()​

int height()

Since 0.1.0-alpha.4 or earlier

Screen height.

Returns int

textWidth(String)​

int textWidth(String text)

Since 0.1.0-alpha.4 or earlier

Width of text in the game font.

ParameterTypeDescription
textString—

Returns int

label(String, int, int, int)​

void label(String text, int x, int y, int argb)

Since 0.1.0-alpha.4 or earlier

Text drawn every frame.

ParameterTypeDescription
textString—
xint—
yint—
argbint—

button(String, int, int, int, int, Runnable)​

void button(String label, int x, int y, int width, int height, Runnable onPress)

Since 0.1.0-alpha.4 or earlier

A clickable button; onPress runs on the client thread.

ParameterTypeDescription
labelString—
xint—
yint—
widthint—
heightint—
onPressRunnable—

textInput(int, int, int, String)​

TextInput textInput(int x, int y, int width, String initialValue)

Since 0.1.0-alpha.4 or earlier

A single-line text input, 20 pixels high.

ParameterTypeDescription
xint—
yint—
widthint—
initialValueString—

Returns TextInput

close()​

void close()

Since 0.1.0-alpha.4 or earlier

Closes this screen.

ShaderPipeline​

record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public record ShaderPipeline(ResourceId id)

A declared shader pipeline, used with WorldCanvas.quads and BlockEntityCanvas.quads.

ComponentTypeDescription
idResourceIdthe pipeline's ID, <mod id>:<path>

ShaderPipelineDefinition​

record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public record ShaderPipelineDefinition(ResourceId shader, ShaderPipelineDefinition.Blend blend, boolean cull, boolean depthTest, boolean depthWrite, List<ResourceId> textures, List<ShaderUniform> uniforms)

A render pipeline with a mod's own core shader: GLSL files assets/<namespace>/shaders/<path>.vsh and .fsh in the mod's resources, for quads with a position and a colour per vertex, and a texture coordinate when the pipeline has textures.

The vertex shader receives in vec3 Position and in vec4 Color, plus in vec2 UV0 when the pipeline has textures. Use the game's uniform blocks for the transforms and time, as the game's core/position_color shader does: #moj_import <minecraft:dynamictransforms.glsl> and <minecraft:projection.glsl> for ModelViewMat, ProjMat and ColorModulator, and <minecraft:globals.glsl> for GameTime.

Textures are bound in order as uniform sampler2D Sampler0, Sampler1, and so on. Each is a texture file such as my_mod:textures/effect/noise.png or a DynamicTexture; a missing file shows the game's missing-texture pattern. The mod's own values are the uniform block ModUniforms (see ShaderUniform).

A shader that fails to compile is reported in the log (POLY-CLIENT-006), and its quads are skipped.

ComponentTypeDescription
shaderResourceIdthe shader files' location without extension, for example my_mod:core/glow
blendShaderPipelineDefinition.Blendhow the quads mix with what is behind them
cullbooleanwhether quads facing away from the camera are skipped
depthTestbooleanwhether blocks in front hide the quads
depthWritebooleanwhether the quads hide what is drawn behind them later
texturesList<ResourceId>the textures bound as Sampler0 onwards, at most MAX_TEXTURES
uniformsList<ShaderUniform>the fields of ModUniforms in order, at most MAX_UNIFORMS, with unique names
Constant or fieldTypeDescription
MAX_TEXTURESintThe most textures one pipeline binds.
MAX_UNIFORMSintThe most fields in one pipeline's ModUniforms block.

ShaderPipelineDefinition(ResourceId, ShaderPipelineDefinition.Blend, boolean, boolean, boolean, List<ResourceId>, List<ShaderUniform>)​

public ShaderPipelineDefinition(ResourceId shader, ShaderPipelineDefinition.Blend blend, boolean cull, boolean depthTest, boolean depthWrite, List<ResourceId> textures, List<ShaderUniform> uniforms)

Since 0.1.0-alpha.4 or earlier

Validates the definition.

ParameterTypeDescription
shaderResourceId—
blendShaderPipelineDefinition.Blend—
cullboolean—
depthTestboolean—
depthWriteboolean—
texturesList<ResourceId>—
uniformsList<ShaderUniform>—

Throws IllegalArgumentException — with POLY-CLIENT-002 for too many textures or uniforms, or two uniforms with the same name

ShaderPipelineDefinition(ResourceId, ShaderPipelineDefinition.Blend, boolean, boolean, boolean)​

public ShaderPipelineDefinition(ResourceId shader, ShaderPipelineDefinition.Blend blend, boolean cull, boolean depthTest, boolean depthWrite)

Since 0.1.0-alpha.4 or earlier

A pipeline without textures or mod uniforms.

ParameterTypeDescription
shaderResourceId—
blendShaderPipelineDefinition.Blend—
cullboolean—
depthTestboolean—
depthWriteboolean—

textured()​

public boolean textured()

Since 0.1.0-alpha.4 or earlier

Whether the vertices carry texture coordinates (UV0).

Returns boolean

builder(ResourceId)​

public static ShaderPipelineDefinition.Builder builder(ResourceId shader)

Since 0.1.0-alpha.4 or earlier

A translucent, double-sided pipeline that blocks hide and that hides nothing.

ParameterTypeDescription
shaderResourceId—

Returns ShaderPipelineDefinition.Builder

ShaderPipelineDefinition.Blend​

enum · Since 0.1.0-alpha.4 or earlier

public static enum Blend

How a pipeline's colours mix with the scene.

ConstantDescription
OPAQUEReplaces what is behind; alpha is ignored.
TRANSLUCENTMixes by alpha, like stained glass.
ADDITIVEAdds light, for glows.

ShaderPipelineDefinition.Builder​

class · Since 0.1.0-alpha.4 or earlier

public static final class Builder

Builds a ShaderPipelineDefinition.

blend(ShaderPipelineDefinition.Blend)​

public ShaderPipelineDefinition.Builder blend(ShaderPipelineDefinition.Blend blend)

Since 0.1.0-alpha.4 or earlier

How colours mix; Blend.TRANSLUCENT by default.

ParameterTypeDescription
blendShaderPipelineDefinition.Blend—

Returns ShaderPipelineDefinition.Builder

cull()​

public ShaderPipelineDefinition.Builder cull()

Since 0.1.0-alpha.4 or earlier

Skips quads facing away from the camera.

Returns ShaderPipelineDefinition.Builder

noDepthTest()​

public ShaderPipelineDefinition.Builder noDepthTest()

Since 0.1.0-alpha.4 or earlier

Draws the quads in front of blocks.

Returns ShaderPipelineDefinition.Builder

depthWrite()​

public ShaderPipelineDefinition.Builder depthWrite()

Since 0.1.0-alpha.4 or earlier

The quads hide what is drawn behind them later, like solid geometry.

Returns ShaderPipelineDefinition.Builder

texture(ResourceId)​

public ShaderPipelineDefinition.Builder texture(ResourceId texture)

Since 0.1.0-alpha.4 or earlier

Binds a texture as the next sampler: the first call is Sampler0. Its vertices then need texture coordinates (VertexSink.vertex(double, double, double, float, float, int)).

ParameterTypeDescription
textureResourceIda texture file, for example my_mod:textures/effect/noise.png, or a DynamicTexture.id()

Returns ShaderPipelineDefinition.Builder

uniform(String, ShaderUniform.Type, ShaderUniform.Source)​

public ShaderPipelineDefinition.Builder uniform(String name, ShaderUniform.Type type, ShaderUniform.Source source)

Since 0.1.0-alpha.4 or earlier

Adds a field to the pipeline's ModUniforms block, after the ones added before.

ParameterTypeDescription
nameString—
typeShaderUniform.Type—
sourceShaderUniform.Source—

Returns ShaderPipelineDefinition.Builder

Throws IllegalArgumentException — for an invalid name (POLY-CLIENT-002)

build()​

public ShaderPipelineDefinition build()

Since 0.1.0-alpha.4 or earlier

Creates the definition.

Returns ShaderPipelineDefinition

Throws IllegalArgumentException — for too many textures or uniforms, or a repeated uniform name (POLY-CLIENT-002)

ShaderUniform​

record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public record ShaderUniform(String name, ShaderUniform.Type type, ShaderUniform.Source source)

One value a mod passes to its own shader pipeline, declared with ShaderPipelineDefinition.Builder.uniform. A pipeline's values form the uniform block ModUniforms, in declaration order:

layout(std140) uniform ModUniforms {
float Strength;
vec4 Tint;
};

Poly Mod Loader asks Source.values() once per frame on the render thread, before the world is drawn, and uploads the result. A source that throws or returns the wrong number of values is reported once (POLY-CLIENT-007); the pipeline then keeps its last good values, which start as zeros.

ComponentTypeDescription
nameStringthe field name in GLSL: letters, digits and _, not starting with a digit or gl_
typeShaderUniform.Typethe GLSL type
sourceShaderUniform.Sourcegives the value each frame

ShaderUniform.Source​

functional interface · Since 0.1.0-alpha.4 or earlier

public static interface Source

Gives a uniform's value; called once per frame on the render thread.

values()​

float[] values()

Since 0.1.0-alpha.4 or earlier

The value: exactly Type.components() floats.

Returns float[]

ShaderUniform.Type​

enum · Since 0.1.0-alpha.4 or earlier

public static enum Type

The GLSL type of a uniform.

ConstantDescription
FLOATfloat.
VEC2vec2.
VEC3vec3.
VEC4vec4.

components()​

public int components()

Since 0.1.0-alpha.4 or earlier

How many floats Source.values() must return.

Returns int

TextInput​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface TextInput

A text input placed by ScreenBuilder.textInput.

value()​

String value()

Since 0.1.0-alpha.4 or earlier

The current text.

Returns String

setValue(String)​

void setValue(String value)

Since 0.1.0-alpha.4 or earlier

Replaces the text.

ParameterTypeDescription
valueString—

TooltipLines​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface TooltipLines

The lines of one item tooltip, first line the item's name. Lines are plain text; section-sign formatting codes (for example "§7" for grey) are drawn as colours. Lines the game or other mods added keep their formatting unless they are removed. Valid only during the listener call.

size()​

int size()

Since 0.1.0-alpha.4 or earlier

Number of lines, the name included.

Returns int

get(int)​

String get(int index)

Since 0.1.0-alpha.4 or earlier

The text of line index without formatting.

ParameterTypeDescription
indexint—

Returns String

Throws IndexOutOfBoundsException — for an index outside [0, size())

add(String)​

void add(String line)

Since 0.1.0-alpha.4 or earlier

Adds a line at the end.

ParameterTypeDescription
lineString—

add(int, String)​

void add(int index, String line)

Since 0.1.0-alpha.4 or earlier

Inserts a line before line index; size() appends.

ParameterTypeDescription
indexint—
lineString—

Throws IndexOutOfBoundsException — for an index outside [0, size()]

remove(int)​

void remove(int index)

Since 0.1.0-alpha.4 or earlier

Removes line index.

ParameterTypeDescription
indexint—

Throws IndexOutOfBoundsException — for an index outside [0, size())

VertexSink​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface VertexSink

Takes the vertices of quads drawn with a ShaderPipeline: four per quad, in order around it.

vertex(double, double, double, float, float, int)​

VertexSink vertex(double x, double y, double z, float u, float v, int argb)

Since 0.1.0-alpha.4 or earlier

Adds a vertex with a texture coordinate and a colour 0xAARRGGBB; the shader receives them as Position, UV0 and Color. The coordinate is used only by pipelines with textures; (0, 0) is the texture's top left corner and (1, 1) its bottom right.

ParameterTypeDescription
xdouble—
ydouble—
zdouble—
ufloat—
vfloat—
argbint—

Returns VertexSink

vertex(double, double, double, int)​

default VertexSink vertex(double x, double y, double z, int argb)

Since 0.1.0-alpha.4 or earlier

Adds a vertex with a colour 0xAARRGGBB and texture coordinate (0, 0).

ParameterTypeDescription
xdouble—
ydouble—
zdouble—
argbint—

Returns VertexSink

WorldCanvas​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface WorldCanvas

Draws in the world for one frame, in world coordinates, valid only during WorldPainter.paint. Lines, boxes, points and text are hidden behind blocks unless drawn through onTop(). Colours are 0xAARRGGBB; an alpha of 0 draws nothing.

cameraX()​

double cameraX()

Since 0.1.0-alpha.4 or earlier

Camera x this frame.

Returns double

cameraY()​

double cameraY()

Since 0.1.0-alpha.4 or earlier

Camera y this frame.

Returns double

cameraZ()​

double cameraZ()

Since 0.1.0-alpha.4 or earlier

Camera z this frame.

Returns double

animationTime()​

float animationTime()

Since 0.1.0-alpha.4 or earlier

Game time in ticks plus the partial tick, for smooth animation.

Returns float

line(double, double, double, double, double, double, int, float)​

void line(double x1, double y1, double z1, double x2, double y2, double z2, int argb, float width)

Since 0.1.0-alpha.4 or earlier

A line from one point to another, width pixels wide.

ParameterTypeDescription
x1double—
y1double—
z1double—
x2double—
y2double—
z2double—
argbint—
widthfloat—

box(double, double, double, double, double, double, int, float, int)​

void box(double minX, double minY, double minZ, double maxX, double maxY, double maxZ, int strokeArgb, float width, int fillArgb)

Since 0.1.0-alpha.4 or earlier

A box between two corners: its edges in strokeArgb (width pixels wide) and its faces filled with fillArgb; pass 0 for either to leave it out.

ParameterTypeDescription
minXdouble—
minYdouble—
minZdouble—
maxXdouble—
maxYdouble—
maxZdouble—
strokeArgbint—
widthfloat—
fillArgbint—

blockOutline(BlockPos, int, float)​

default void blockOutline(BlockPos pos, int argb, float width)

Since 0.1.0-alpha.4 or earlier

The edges of one block.

ParameterTypeDescription
posBlockPos—
argbint—
widthfloat—

point(double, double, double, int, float)​

void point(double x, double y, double z, int argb, float size)

Since 0.1.0-alpha.4 or earlier

A square dot size pixels wide.

ParameterTypeDescription
xdouble—
ydouble—
zdouble—
argbint—
sizefloat—

text(String, double, double, double, int, float)​

void text(String text, double x, double y, double z, int argb, float scale)

Since 0.1.0-alpha.4 or earlier

Text facing the camera, centred on the point; scale 1 is the game's label size.

ParameterTypeDescription
textString—
xdouble—
ydouble—
zdouble—
argbint—
scalefloat—

quads(ShaderPipeline, Consumer<VertexSink>)​

void quads(ShaderPipeline pipeline, Consumer<VertexSink> vertices)

Since 0.1.0-alpha.4 or earlier

Quads drawn with a mod shader pipeline: four vertices per quad, in world coordinates. Unlike the other shapes, these follow the pipeline's depth settings.

ParameterTypeDescription
pipelineShaderPipeline—
verticesConsumer<VertexSink>—

onTop()​

WorldCanvas onTop()

Since 0.1.0-alpha.4 or earlier

This canvas, drawing lines, boxes, points and text in front of blocks.

Returns WorldCanvas

WorldPainter​

functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface WorldPainter

Draws extra shapes in the world every frame while the client is in a world, on the render thread: area markers, paths, debug views, glowing effects. Keep it fast; it runs every frame.

paint(WorldCanvas)​

void paint(WorldCanvas canvas)

Since 0.1.0-alpha.4 or earlier

Draws this frame's shapes on canvas.

ParameterTypeDescription
canvasWorldCanvas—
Buy me a coffee