Skin
The Skin
class is a fundamental component of wavy-totem-lib that handles Minecraft skin files and provides methods to access different parts of the skin.
Overview
Minecraft skins are 64x32 or 64x64 pixel images that define the appearance of a player character. The Skin
class in wavy-totem-lib loads these images and provides convenient access to different parts of the skin, such as the head, body, arms, and legs, as well as their second layers (overlays).
Creating a Skin Object
You can create a Skin
object by providing a path to a skin file:
from wavy_totem_lib import Skin
# From a local file
skin = Skin('path/to/skin.png')
# Specifying if the skin is slim (3-pixel arms) or wide (4-pixel arms)
slim_skin = Skin('path/to/skin.png', slim=True)
If you don't specify the slim
parameter, the library will attempt to detect it automatically based on the skin's pixel data.
Skin Properties
The Skin
class provides several properties and methods to access different parts of the skin:
Basic Properties
image
: The original PIL Image object of the skinis_slim
: Boolean indicating whether the skin has slim arms (3 pixels wide) or wide arms (4 pixels wide)available_second
: Boolean indicating whether the skin has a second layer (overlay)
Body Parts
The Skin
class provides methods to access different parts of the skin:
Head
head()
: Returns the head part of the skinhead_front()
: Returns the front face of the headhead_second()
: Returns the second layer of the headhead_second_front()
: Returns the front face of the second layer of the head
Body
body()
: Returns the body part of the skinbody_front()
: Returns the front of the bodybody_second()
: Returns the second layer of the bodybody_second_front()
: Returns the front of the second layer of the body
Arms
right_hand()
: Returns the right arm of the skinright_hand_front()
: Returns the front of the right armright_hand_second()
: Returns the second layer of the right armright_hand_second_front()
: Returns the front of the second layer of the right armleft_hand()
: Returns the left arm of the skinleft_hand_front()
: Returns the front of the left armleft_hand_second()
: Returns the second layer of the left armleft_hand_second_front()
: Returns the front of the second layer of the left arm
Legs
right_leg()
: Returns the right leg of the skinright_leg_front()
: Returns the front of the right legright_leg_second()
: Returns the second layer of the right legright_leg_second_front()
: Returns the front of the second layer of the right legleft_leg()
: Returns the left leg of the skinleft_leg_front()
: Returns the front of the left legleft_leg_second()
: Returns the second layer of the left legleft_leg_second_front()
: Returns the front of the second layer of the left leg
Minecraft Skin Format
Understanding the Minecraft skin format can help you better understand how the Skin
class works:
- The skin is divided into different regions that correspond to different parts of the player model
- Each part has a base layer and may have a second layer (overlay)
- The second layer is typically used for details like clothing, accessories, etc.
- Skins can be either "slim" (3-pixel arms) or "wide" (4-pixel arms)
The Skin
class handles all the complexity of extracting these parts from the skin image, so you don't have to worry about the details of the skin format.
Usage in TotemBuilder
The Skin
class is typically used as an input to the TotemBuilder
class:
from wavy_totem_lib import TotemBuilder, Skin
builder = TotemBuilder(Skin('my_skin.png'))
totem = builder.build()
The TotemBuilder
uses the Skin
object to extract the necessary parts of the skin to create a totem.