server.player.skin
Constants #
const default_geometry = 'geometry.humanoid.custom'
default_geometry is the geometry a skin falls back to when it carries no model of its own.
fn decode_model_config #
fn decode_model_config(patch string) !ModelConfig
decode_model_config reads a ModelConfig back from a resource patch. It fails if the patch is not valid JSON.
fn new #
fn new(width int, height int) Skin
new returns a Skin of the size passed, with its pixels allocated so it can be written to right away. Bedrock accepts 64x32, 64x64 and 128x128 skins.
fn new_animation #
fn new_animation(width int, height int, expression int, typ AnimationType) Animation
new_animation returns an Animation of the size and type passed, with its pixels allocated and a single frame.
fn new_cape #
fn new_cape(width int, height int) Cape
new_cape returns a Cape of the size passed, with its pixels allocated so it can be written to right away.
fn new_model_config #
fn new_model_config() ModelConfig
new_model_config returns a ModelConfig pointing at the standard humanoid geometry.
fn AnimationType.from #
fn AnimationType.from[W](input W) !AnimationType
enum AnimationType #
enum AnimationType {
// head is an animation played over the head of the skin.
head
// body_32x32 is an animation played over the body of a 32x32 skin, the
// usual size for body animations.
body_32x32
// body_128x128 is an animation played over the body of a 128x128 skin.
body_128x128
}
AnimationType is the part of the body an Animation is drawn over.
struct Animation #
struct Animation {
width int
height int
typ AnimationType
pub mut:
// pix holds the RGBA pixel data of every frame, four bytes per pixel.
pix []u8
// frame_count is how many frames pix holds.
frame_count int = 1
// expression is the player expression the animation belongs to.
expression int
}
Animation is a sequence of frames played over part of a Skin. The ModelConfig of the skin decides when it is shown.
fn (Animation) width #
fn (a &Animation) width() int
width returns the width of a frame in pixels.
fn (Animation) height #
fn (a &Animation) height() int
height returns the height of a frame in pixels.
fn (Animation) typ #
fn (a &Animation) typ() AnimationType
typ returns the part of the body the Animation is drawn over.
struct Cape #
struct Cape {
width int
height int
pub mut:
// id is the identifier the client caches the cape under. It is empty for a
// cape that holds no image.
id string
// pix holds the RGBA pixel data of the cape, four bytes per pixel.
pix []u8
}
Cape is the cape worn behind a Skin. A cape is either empty or holds one image, stored the same way a Skin stores its pixels.
fn (Cape) width #
fn (c &Cape) width() int
width returns the width of the Cape in pixels.
fn (Cape) height #
fn (c &Cape) height() int
height returns the height of the Cape in pixels.
fn (Cape) exists #
fn (c &Cape) exists() bool
exists reports whether the Cape holds an image at all.
fn (Cape) at #
fn (c &Cape) at(x int, y int) !Colour
at returns the RGBA colour at the coordinates passed. It fails if the coordinates fall outside the Cape.
struct Colour #
struct Colour {
pub:
r u8
g u8
b u8
a u8
}
Colour is a single RGBA pixel of a Skin or Cape.
struct ModelConfig #
struct ModelConfig {
pub mut:
// default_model is the geometry the skin is drawn with at all times, unless
// an animation replaces it.
default_model string = default_geometry
// animated_face is the geometry of an animation played over the face,
// empty if the skin has none.
animated_face string
}
ModelConfig points at the geometry inside a Skin's model that each state of the skin uses. The names refer to models present in the JSON of that model.
fn (ModelConfig) encode #
fn (cfg &ModelConfig) encode() string
encode returns the resource patch of the ModelConfig, which is the form the client expects it in.
struct Skin #
struct Skin {
width int
height int
pub mut:
// id is the identifier the client caches the skin under, and full_id is
// that identifier combined with the cape's.
id string
full_id string
// play_fab_id is the PlayFab account the skin belongs to, empty for a skin
// the server made up.
play_fab_id string
// persona reports whether the skin comes from the persona system rather
// than from a plain texture.
persona bool
// pix holds the RGBA pixel data of the skin, four bytes per pixel.
pix []u8
// model holds the raw JSON geometry of the skin. An empty model means the
// client falls back to the standard humanoid geometry.
model []u8
// model_config points at the geometry inside model that each state of the
// skin uses.
model_config ModelConfig
// cape is the cape worn behind the skin, empty unless one was set.
cape Cape
// animations holds the animations the model_config may point at.
animations []Animation
}
Skin is the appearance a player has been given: the texture itself, the geometry it is mapped onto, the animations that geometry may play, and the cape worn behind it.
fn (Skin) width #
fn (s &Skin) width() int
width returns the width of the Skin in pixels.
fn (Skin) height #
fn (s &Skin) height() int
height returns the height of the Skin in pixels.
fn (Skin) at #
fn (s &Skin) at(x int, y int) !Colour
at returns the RGBA colour at the coordinates passed. It fails if the coordinates fall outside the Skin.
fn (Skin) fill #
fn (mut s Skin) fill(c Colour)
fill paints every pixel of the Skin the colour passed.