The Head Hunter package
HeadSpec
Bases: NamedTuple
Specification of a player head
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The display name for the head |
player_name |
(str, optional)
|
The name of the skull's owner |
texture |
(str, optional)
|
The player's skin, encoded in base64. This will effectively overwrite any value that would have been set via the player name. |
note_block_sound |
(str, optional)
|
If set, when placed above a note block on a modern version of the game (1.20 and above), the note block will play the sound event specified by this string. |
rarity |
(str, optional)
|
Can be used for color-coding the item's name in modern versions of the game. See: https://minecraft.wiki/w/Rarity#Tiers |
color |
(str, optionsl)
|
The color to code the item's name. This will override any color set by rarity. See: https://minecraft.wiki/w/Formatting_codes |
italic |
(bool, optional)
|
Whether the item's name should be italicized. Default is False. |
bold |
(bool, optional)
|
Whether the item's name should be bolded. Default is False. |
underlined |
(bool, optional)
|
Whether the item's name should be bolded. Default is False. |
strikethrough |
(bool, optional)
|
Whether the item's name should be bolded. Default is False. |
obfuscated |
(bool, optional)
|
Whether the item's name should be bolded. Default is False. See: https://minecraft.wiki/w/Formatting_codes |
comment |
(str, optional)
|
An optional annotation on the head spec (that will only be used internally) for referencing, for example, a particular head variant |
Notes
This spec does not currently support lore.
Source code in head_hunter/_head_spec.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
|
dumps()
Reference serialization method. Feel free to write your own.
Returns:
Type | Description |
---|---|
str
|
1-3 lines specifying the head spec in a concise and standard format |
Source code in head_hunter/_head_spec.py
from_username(name)
classmethod
Construct a HeadSpec from a player's name alone (this will yield the head from the player's current skin)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The player's username |
required |
Returns:
Type | Description |
---|---|
LegacyHeadSpec
|
The corresponding head spec |
Raises:
Type | Description |
---|---|
ValueError
|
If the name provided is not a valid username |
Source code in head_hunter/_head_spec.py
to_component_dict(offline=False)
Generate the player head specification for use in trade lists for modern versions of the game (Minecraft 1.21 and above)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offline |
bool
|
By default, |
False
|
Returns:
Type | Description |
---|---|
str
|
The properly composited head specification suitable for including
in the |
Notes
This method is only meant for modern versions of the game (pack format
41 and above). For older datapacks, use
HeadSpec.to_player_head(pack_format=desired_pack_format)
Source code in head_hunter/_head_spec.py
to_player_head(pack_format=48, offline=False)
Generate the player head specification for use in commands and older versions of the game
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pack_format |
int
|
The data pack version (see: https://minecraft.wiki/w/Data_pack#Pack_format). Default is 48 for Minecraft 1.21 |
48
|
offline |
bool
|
By default, |
False
|
Returns:
Type | Description |
---|---|
str
|
The properly composited head specification, such that the command
|
Notes
- The proper
/give
command syntax for Minecraft versions before 1.20.5 (pack_format < 41
) is/give @s minecraft_player_head{head_spec}
(wherehead_spec
is the string returned by this method when using the correspondingpack_format
) - This head specification should work in data packs as well for
pack_format < 41
, but for modern versions of the game,HeadSpec.to_component_dict()
is the method to generate the specification for use in a trade list.
Source code in head_hunter/_head_spec.py
dumps(heads)
Serialize a list of HeadSpecs so they can be written to file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
heads |
list of LegacyHeadSpec
|
The heads to serialize |
required |
Returns:
Type | Description |
---|---|
str
|
A series of 1-3-line sections, separated by blank lines, that specify each head in a concise and standard format |
Source code in head_hunter/_head_spec.py
loads(head_list)
Deserialize a list of HeadSpecs written by dumps()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
head_list |
str
|
The serialized head specs, consisting of a series of 1-3-line sections,
delimited by blank lines, as generated by |
required |
Returns:
Type | Description |
---|---|
list of HeadSpec
|
The deserialized head specs |