dev.polymodloader.api.client
This page is generated from the source's Javadoc by ./gradlew apiReference. Do not edit it; fix the source comment and generate it again.
| Type | Kind | Description |
|---|---|---|
BlockEntityCanvas | interface | Draws in the world relative to a block: (0, 0, 0) is the block's lowest corner and (1, 1, 1) its highest. |
BlockEntityPainter | functional interface | 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). |
CameraPerspective | enum | Where the camera is, as cycled with F5. |
ClientConnectionListener | functional interface | Listener for ClientEvents.JOINED_WORLD and ClientEvents.LEFT_WORLD. |
ClientEvents | class | Client events; fired on the client thread, only on the client. |
ClientRegistrar | interface | Client-only registrations. |
ClientTickListener | functional interface | Listener for ClientEvents.TICK. |
ClientView | interface | The client's state during a callback. |
DynamicTexture | interface | A texture whose pixels the mod sets while the game runs, for example a minimap. |
FovModifier | functional interface | Listener for ClientEvents.FIELD_OF_VIEW. |
HudCanvas | interface | Drawing surface in GUI-scaled pixels; (0, 0) is the top-left corner. |
HudLayer | functional interface | Draws over the in-game HUD. |
ItemTooltipListener | functional interface | Listener for ClientEvents.ITEM_TOOLTIP. |
KeyBinding | interface | A rebindable key. |
KeyCodes | class | Keyboard key codes for default key bindings (the GLFW codes the game uses). |
ModScreen | interface | A full-screen menu made by a mod: labels, buttons, and text inputs placed in init, plus free drawing in render. |
ScreenBuilder | interface | Places widgets on a ModScreen, in GUI-scaled pixels from the top-left corner. |
ShaderPipeline | record | A declared shader pipeline, used with WorldCanvas.quads and BlockEntityCanvas.quads. |
ShaderPipelineDefinition | record | 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. |
ShaderPipelineDefinition.Blend | enum | How a pipeline's colours mix with the scene. |
ShaderPipelineDefinition.Builder | class | Builds a ShaderPipelineDefinition. |
ShaderUniform | record | One value a mod passes to its own shader pipeline, declared with ShaderPipelineDefinition.Builder.uniform. |
ShaderUniform.Source | functional interface | Gives a uniform's value; called once per frame on the render thread. |
ShaderUniform.Type | enum | The GLSL type of a uniform. |
TextInput | interface | A text input placed by ScreenBuilder.textInput. |
TooltipLines | interface | The lines of one item tooltip, first line the item's name. |
VertexSink | interface | Takes the vertices of quads drawn with a ShaderPipeline: four per quad, in order around it. |
WorldCanvas | interface | Draws in the world for one frame, in world coordinates, valid only during WorldPainter.paint. |
WorldPainter | functional interface | 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. |
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.
| Parameter | Type | Description |
|---|---|---|
item | ResourceId | — |
x | double | — |
y | double | — |
z | double | — |
scale | float | 1 is a full block |
yawDegrees | float | turn 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.
| Parameter | Type | Description |
|---|---|---|
text | String | — |
x | double | — |
y | double | — |
z | double | — |
scale | float | a line of text is 9 × scale blocks high (0.025 makes a small label) |
argb | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
block | ResourceId | — |
x | double | — |
y | double | — |
z | double | — |
scale | float | — |
yawDegrees | float | — |
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.
| Parameter | Type | Description |
|---|---|---|
state | BlockStateView | — |
x | double | — |
y | double | — |
z | double | — |
scale | float | — |
yawDegrees | float | — |
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).
| Parameter | Type | Description |
|---|---|---|
block | ResourceId | — |
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).
| Parameter | Type | Description |
|---|---|---|
pipeline | ShaderPipeline | — |
vertices | Consumer<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.
| Parameter | Type | Description |
|---|---|---|
entity | BlockEntityView | — |
canvas | BlockEntityCanvas | — |
CameraPerspective
enum · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public enum CameraPerspective
Where the camera is, as cycled with F5.
| Constant | Description |
|---|---|
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.
| Parameter | Type | Description |
|---|---|---|
view | ClientView | — |
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 field | Type | Description |
|---|---|---|
TICK | EventKey<ClientTickListener> | The client finished a tick (20 per second, also on the title screen). |
FIELD_OF_VIEW | EventKey<FovModifier> | The field of view of the next frame, after the game's own changes (sprinting, underwater); called every frame, keep it cheap. |
JOINED_WORLD | EventKey<ClientConnectionListener> | The client joined a world (single player or a server) and has its player and world; fired once per connection. |
LEFT_WORLD | EventKey<ClientConnectionListener> | The client is leaving the world; the player and world are still available. |
ITEM_TOOLTIP | EventKey<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>.
| Parameter | Type | Description |
|---|---|---|
path | String | binding name inside the mod's namespace |
defaultKey | int | default 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.
| Parameter | Type | Description |
|---|---|---|
path | String | — |
layer | HudLayer | — |
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.
| Parameter | Type | Description |
|---|---|---|
block | ResourceId | — |
painter | BlockEntityPainter | — |
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>.
| Parameter | Type | Description |
|---|---|---|
path | String | — |
width | int | — |
height | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
path | String | — |
painter | WorldPainter | — |
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.
| Parameter | Type | Description |
|---|---|---|
path | String | — |
definition | ShaderPipelineDefinition | — |
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.
| Parameter | Type | Description |
|---|---|---|
client | ClientView | — |
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).
| Parameter | Type | Description |
|---|---|---|
text | String | — |
openScreen(ModScreen)
void openScreen(ModScreen screen)
Since 0.1.0-alpha.4 or earlier
Opens screen, replacing any open screen.
| Parameter | Type | Description |
|---|---|---|
screen | ModScreen | — |
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.
| Parameter | Type | Description |
|---|---|---|
perspective | CameraPerspective | — |
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).
| Parameter | Type | Description |
|---|---|---|
effect | ResourceId | — |
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.
| Parameter | Type | Description |
|---|---|---|
x | int | — |
y | int | — |
argb | int | — |
fill(int)
void fill(int argb)
Since 0.1.0-alpha.4 or earlier
Sets every pixel.
| Parameter | Type | Description |
|---|---|---|
argb | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
fov | float | — |
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.
| Parameter | Type | Description |
|---|---|---|
text | String | — |
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.
| Parameter | Type | Description |
|---|---|---|
text | String | — |
x | int | — |
y | int | — |
argb | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
x1 | int | — |
y1 | int | — |
x2 | int | — |
y2 | int | — |
argb | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
texture | ResourceId | — |
x | int | — |
y | int | — |
width | int | — |
height | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
canvas | HudCanvas | — |
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.
| Parameter | Type | Description |
|---|---|---|
stack | ItemStackRef | the item stack; read it, do not change it (it is the client's copy) |
lines | TooltipLines | the tooltip lines to read and change |
advanced | boolean | whether 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 field | Type | Description |
|---|---|---|
UNBOUND | int | No default key; the player must bind one. |
A | int | — |
B | int | — |
G | int | — |
H | int | — |
J | int | — |
K | int | — |
L | int | — |
M | int | — |
N | int | — |
O | int | — |
P | int | — |
R | int | — |
U | int | — |
V | int | — |
X | int | — |
Y | int | — |
Z | int | — |
F6 | int | — |
F7 | int | — |
F8 | int | — |
F9 | int | — |
F10 | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
screen | ScreenBuilder | — |
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.
| Parameter | Type | Description |
|---|---|---|
canvas | HudCanvas | — |
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.
| Parameter | Type | Description |
|---|---|---|
text | String | — |
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.
| Parameter | Type | Description |
|---|---|---|
text | String | — |
x | int | — |
y | int | — |
argb | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
label | String | — |
x | int | — |
y | int | — |
width | int | — |
height | int | — |
onPress | Runnable | — |
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.
| Parameter | Type | Description |
|---|---|---|
x | int | — |
y | int | — |
width | int | — |
initialValue | String | — |
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.
| Component | Type | Description |
|---|---|---|
id | ResourceId | the 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.
| Component | Type | Description |
|---|---|---|
shader | ResourceId | the shader files' location without extension, for example my_mod:core/glow |
blend | ShaderPipelineDefinition.Blend | how the quads mix with what is behind them |
cull | boolean | whether quads facing away from the camera are skipped |
depthTest | boolean | whether blocks in front hide the quads |
depthWrite | boolean | whether the quads hide what is drawn behind them later |
textures | List<ResourceId> | the textures bound as Sampler0 onwards, at most MAX_TEXTURES |
uniforms | List<ShaderUniform> | the fields of ModUniforms in order, at most MAX_UNIFORMS, with unique names |
| Constant or field | Type | Description |
|---|---|---|
MAX_TEXTURES | int | The most textures one pipeline binds. |
MAX_UNIFORMS | int | The 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.
| Parameter | Type | Description |
|---|---|---|
shader | ResourceId | — |
blend | ShaderPipelineDefinition.Blend | — |
cull | boolean | — |
depthTest | boolean | — |
depthWrite | boolean | — |
textures | List<ResourceId> | — |
uniforms | List<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.
| Parameter | Type | Description |
|---|---|---|
shader | ResourceId | — |
blend | ShaderPipelineDefinition.Blend | — |
cull | boolean | — |
depthTest | boolean | — |
depthWrite | boolean | — |
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.
| Parameter | Type | Description |
|---|---|---|
shader | ResourceId | — |
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.
| Constant | Description |
|---|---|
OPAQUE | Replaces what is behind; alpha is ignored. |
TRANSLUCENT | Mixes by alpha, like stained glass. |
ADDITIVE | Adds 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.
| Parameter | Type | Description |
|---|---|---|
blend | ShaderPipelineDefinition.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)).
| Parameter | Type | Description |
|---|---|---|
texture | ResourceId | a 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.
| Parameter | Type | Description |
|---|---|---|
name | String | — |
type | ShaderUniform.Type | — |
source | ShaderUniform.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.
| Component | Type | Description |
|---|---|---|
name | String | the field name in GLSL: letters, digits and _, not starting with a digit or gl_ |
type | ShaderUniform.Type | the GLSL type |
source | ShaderUniform.Source | gives 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.
| Constant | Description |
|---|---|
FLOAT | float. |
VEC2 | vec2. |
VEC3 | vec3. |
VEC4 | vec4. |
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.
| Parameter | Type | Description |
|---|---|---|
value | String | — |
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.
| Parameter | Type | Description |
|---|---|---|
index | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
line | String | — |
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.
| Parameter | Type | Description |
|---|---|---|
index | int | — |
line | String | — |
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.
| Parameter | Type | Description |
|---|---|---|
index | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
x | double | — |
y | double | — |
z | double | — |
u | float | — |
v | float | — |
argb | int | — |
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).
| Parameter | Type | Description |
|---|---|---|
x | double | — |
y | double | — |
z | double | — |
argb | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
x1 | double | — |
y1 | double | — |
z1 | double | — |
x2 | double | — |
y2 | double | — |
z2 | double | — |
argb | int | — |
width | float | — |
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.
| Parameter | Type | Description |
|---|---|---|
minX | double | — |
minY | double | — |
minZ | double | — |
maxX | double | — |
maxY | double | — |
maxZ | double | — |
strokeArgb | int | — |
width | float | — |
fillArgb | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
pos | BlockPos | — |
argb | int | — |
width | float | — |
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.
| Parameter | Type | Description |
|---|---|---|
x | double | — |
y | double | — |
z | double | — |
argb | int | — |
size | float | — |
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.
| Parameter | Type | Description |
|---|---|---|
text | String | — |
x | double | — |
y | double | — |
z | double | — |
argb | int | — |
scale | float | — |
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.
| Parameter | Type | Description |
|---|---|---|
pipeline | ShaderPipeline | — |
vertices | Consumer<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.
| Parameter | Type | Description |
|---|---|---|
canvas | WorldCanvas | — |