mcdex 0.1.0.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcdex/__init__.py +281 -0
- mcdex/advancements/__init__.py +16 -0
- mcdex/advancements/_mc_advancements.py +3558 -0
- mcdex/advancements/advancements.json +12101 -0
- mcdex/attributes/__init__.py +16 -0
- mcdex/attributes/_mc_attributes.py +83 -0
- mcdex/attributes/attributes.json +289 -0
- mcdex/banner_patterns/__init__.py +16 -0
- mcdex/banner_patterns/_mc_banner_patterns.py +86 -0
- mcdex/banner_patterns/banner_patterns.json +310 -0
- mcdex/base/__init__.py +146 -0
- mcdex/base/_advancement_id.py +22 -0
- mcdex/base/_attribute_id.py +22 -0
- mcdex/base/_banner_pattern_id.py +26 -0
- mcdex/base/_biome_id.py +22 -0
- mcdex/base/_block_entity_id.py +22 -0
- mcdex/base/_block_id.py +35 -0
- mcdex/base/_cat_sound_variant_id.py +23 -0
- mcdex/base/_cat_variant_id.py +22 -0
- mcdex/base/_catalogue_meta.py +38 -0
- mcdex/base/_chicken_sound_variant_id.py +23 -0
- mcdex/base/_chicken_variant_id.py +23 -0
- mcdex/base/_cow_sound_variant_id.py +23 -0
- mcdex/base/_cow_variant_id.py +22 -0
- mcdex/base/_damage_type_id.py +21 -0
- mcdex/base/_dimension_id.py +21 -0
- mcdex/base/_effect_id.py +21 -0
- mcdex/base/_enchantment_id.py +22 -0
- mcdex/base/_entity_id.py +35 -0
- mcdex/base/_equipment_slot.py +34 -0
- mcdex/base/_frog_variant_id.py +22 -0
- mcdex/base/_game_id.py +88 -0
- mcdex/base/_game_rule_id.py +21 -0
- mcdex/base/_item_id.py +98 -0
- mcdex/base/_mc_thing.py +289 -0
- mcdex/base/_mc_version.py +140 -0
- mcdex/base/_music_id.py +25 -0
- mcdex/base/_not_in_version.py +68 -0
- mcdex/base/_painting_variant_id.py +23 -0
- mcdex/base/_particle_id.py +21 -0
- mcdex/base/_pig_sound_variant_id.py +23 -0
- mcdex/base/_pig_variant_id.py +22 -0
- mcdex/base/_potion_id.py +25 -0
- mcdex/base/_potion_modifier.py +30 -0
- mcdex/base/_sound_id.py +21 -0
- mcdex/base/_statistic_id.py +22 -0
- mcdex/base/_structure_id.py +21 -0
- mcdex/base/_trim_material_id.py +26 -0
- mcdex/base/_trim_pattern_id.py +25 -0
- mcdex/base/_version.py +188 -0
- mcdex/base/_villager_profession_id.py +24 -0
- mcdex/base/_villager_type_id.py +25 -0
- mcdex/base/_wolf_sound_variant_id.py +23 -0
- mcdex/base/_wolf_variant_id.py +22 -0
- mcdex/base/_zombie_nautilus_variant_id.py +23 -0
- mcdex/biomes/__init__.py +16 -0
- mcdex/biomes/_mc_biomes.py +137 -0
- mcdex/biomes/biomes.json +652 -0
- mcdex/block_entities/__init__.py +16 -0
- mcdex/block_entities/_mc_block_entities.py +95 -0
- mcdex/block_entities/block_entities.json +331 -0
- mcdex/blocks/__init__.py +16 -0
- mcdex/blocks/_mc_blocks.py +1338 -0
- mcdex/blocks/blocks.json +7770 -0
- mcdex/cat_sound_variants/__init__.py +16 -0
- mcdex/cat_sound_variants/_mc_cat_sound_variants.py +47 -0
- mcdex/cat_sound_variants/cat_sound_variants.json +25 -0
- mcdex/cat_variants/__init__.py +16 -0
- mcdex/cat_variants/_mc_cat_variants.py +54 -0
- mcdex/cat_variants/cat_variants.json +91 -0
- mcdex/chicken_sound_variants/__init__.py +17 -0
- mcdex/chicken_sound_variants/_mc_chicken_sound_variants.py +48 -0
- mcdex/chicken_sound_variants/chicken_sound_variants.json +24 -0
- mcdex/chicken_variants/__init__.py +16 -0
- mcdex/chicken_variants/_mc_chicken_variants.py +47 -0
- mcdex/chicken_variants/chicken_variants.json +30 -0
- mcdex/cow_sound_variants/__init__.py +16 -0
- mcdex/cow_sound_variants/_mc_cow_sound_variants.py +47 -0
- mcdex/cow_sound_variants/cow_sound_variants.json +24 -0
- mcdex/cow_variants/__init__.py +16 -0
- mcdex/cow_variants/_mc_cow_variants.py +47 -0
- mcdex/cow_variants/cow_variants.json +30 -0
- mcdex/damage_types/__init__.py +16 -0
- mcdex/damage_types/_mc_damage_types.py +94 -0
- mcdex/damage_types/damage_types.json +317 -0
- mcdex/dimensions/__init__.py +16 -0
- mcdex/dimensions/_mc_dimensions.py +46 -0
- mcdex/dimensions/dimensions.json +29 -0
- mcdex/effects/__init__.py +16 -0
- mcdex/effects/_mc_effects.py +83 -0
- mcdex/effects/effects.json +251 -0
- mcdex/enchantments/__init__.py +16 -0
- mcdex/enchantments/_mc_enchantments.py +86 -0
- mcdex/enchantments/enchantments.json +270 -0
- mcdex/entities/__init__.py +16 -0
- mcdex/entities/_mc_entities.py +206 -0
- mcdex/entities/entities.json +1042 -0
- mcdex/frog_variants/__init__.py +16 -0
- mcdex/frog_variants/_mc_frog_variants.py +47 -0
- mcdex/frog_variants/frog_variants.json +29 -0
- mcdex/game_rules/__init__.py +16 -0
- mcdex/game_rules/_mc_game_rules.py +110 -0
- mcdex/game_rules/game_rules.json +436 -0
- mcdex/items/__init__.py +16 -0
- mcdex/items/_mc_items.py +1842 -0
- mcdex/items/items.json +20060 -0
- mcdex/music/__init__.py +16 -0
- mcdex/music/_music.py +65 -0
- mcdex/music/music.json +143 -0
- mcdex/painting_variants/__init__.py +16 -0
- mcdex/painting_variants/_mc_painting_variants.py +96 -0
- mcdex/painting_variants/painting_variants.json +369 -0
- mcdex/particles/__init__.py +16 -0
- mcdex/particles/_mc_particles.py +184 -0
- mcdex/particles/particles.json +917 -0
- mcdex/pig_sound_variants/__init__.py +16 -0
- mcdex/pig_sound_variants/_mc_pig_sound_variants.py +48 -0
- mcdex/pig_sound_variants/pig_sound_variants.json +30 -0
- mcdex/pig_variants/__init__.py +16 -0
- mcdex/pig_variants/_mc_pig_variants.py +46 -0
- mcdex/pig_variants/pig_variants.json +30 -0
- mcdex/potions/__init__.py +20 -0
- mcdex/potions/_mc_potions.py +101 -0
- mcdex/potions/_modified_potion.py +129 -0
- mcdex/potions/potions.json +297 -0
- mcdex/py.typed +0 -0
- mcdex/sounds/__init__.py +16 -0
- mcdex/sounds/_mc_sounds.py +2395 -0
- mcdex/sounds/sounds.json +13077 -0
- mcdex/statistics/__init__.py +16 -0
- mcdex/statistics/_mc_statistics.py +123 -0
- mcdex/statistics/statistics.json +521 -0
- mcdex/structures/__init__.py +16 -0
- mcdex/structures/_mc_structures.py +99 -0
- mcdex/structures/structures.json +367 -0
- mcdex/trim_materials/__init__.py +16 -0
- mcdex/trim_materials/_mc_trim_materials.py +54 -0
- mcdex/trim_materials/trim_materials.json +77 -0
- mcdex/trim_patterns/__init__.py +16 -0
- mcdex/trim_patterns/_mc_trim_patterns.py +61 -0
- mcdex/trim_patterns/trim_patterns.json +119 -0
- mcdex/villager_professions/__init__.py +17 -0
- mcdex/villager_professions/_mc_villager_professions.py +61 -0
- mcdex/villager_professions/villager_professions.json +125 -0
- mcdex/villager_types/__init__.py +16 -0
- mcdex/villager_types/_mc_villager_types.py +52 -0
- mcdex/villager_types/villager_types.json +54 -0
- mcdex/wolf_sound_variants/__init__.py +17 -0
- mcdex/wolf_sound_variants/_mc_wolf_sound_variants.py +53 -0
- mcdex/wolf_sound_variants/wolf_sound_variants.json +54 -0
- mcdex/wolf_variants/__init__.py +16 -0
- mcdex/wolf_variants/_mc_wolf_variants.py +53 -0
- mcdex/wolf_variants/wolf_variants.json +66 -0
- mcdex/zombie_nautilus_variants/__init__.py +17 -0
- mcdex/zombie_nautilus_variants/_mc_zombie_nautilus_variants.py +48 -0
- mcdex/zombie_nautilus_variants/zombie_nautilus_variants.json +23 -0
- mcdex-0.1.0.dev0.dist-info/METADATA +1285 -0
- mcdex-0.1.0.dev0.dist-info/RECORD +161 -0
- mcdex-0.1.0.dev0.dist-info/WHEEL +5 -0
- mcdex-0.1.0.dev0.dist-info/licenses/LICENSE +201 -0
- mcdex-0.1.0.dev0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ChickenSoundVariantId pairs a chicken sound variant's unique name with the id a
|
|
3
|
+
version of the game needs to identify it.
|
|
4
|
+
"""
|
|
5
|
+
# Apache-2.0 license
|
|
6
|
+
# Copyright (c) 2026 Asger Jon Vistisen
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from . import GameId
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ChickenSoundVariantId(GameId):
|
|
13
|
+
"""
|
|
14
|
+
The id of a chicken sound variant in one version: its 'uniqueName', the same
|
|
15
|
+
in every version, and its 'minecraftId', what /summon takes for a chicken of
|
|
16
|
+
that sound variant in that version.
|
|
17
|
+
|
|
18
|
+
Implementation
|
|
19
|
+
--------------
|
|
20
|
+
|
|
21
|
+
All of it is 'GameId's: a 'ChickenSoundVariantId' is equal only to a
|
|
22
|
+
'ChickenSoundVariantId'.
|
|
23
|
+
"""
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ChickenVariantId pairs a chicken variant's unique name with the id a version of
|
|
3
|
+
the game needs to identify it.
|
|
4
|
+
"""
|
|
5
|
+
# Apache-2.0 license
|
|
6
|
+
# Copyright (c) 2026 Asger Jon Vistisen
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from . import GameId
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ChickenVariantId(GameId):
|
|
13
|
+
"""
|
|
14
|
+
The id of a chicken variant in one version: its 'uniqueName', the same in
|
|
15
|
+
every version, and its 'minecraftId', what /summon takes for a chicken of
|
|
16
|
+
that variant in that version.
|
|
17
|
+
|
|
18
|
+
Implementation
|
|
19
|
+
--------------
|
|
20
|
+
|
|
21
|
+
All of it is 'GameId's: a 'ChickenVariantId' is equal only to a
|
|
22
|
+
'ChickenVariantId'.
|
|
23
|
+
"""
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""
|
|
2
|
+
CowSoundVariantId pairs a cow sound variant's unique name with the id a version
|
|
3
|
+
of the game needs to identify it.
|
|
4
|
+
"""
|
|
5
|
+
# Apache-2.0 license
|
|
6
|
+
# Copyright (c) 2026 Asger Jon Vistisen
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from . import GameId
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CowSoundVariantId(GameId):
|
|
13
|
+
"""
|
|
14
|
+
The id of a cow sound variant in one version: its 'uniqueName', the same in
|
|
15
|
+
every version, and its 'minecraftId', what /summon takes for a cow of that
|
|
16
|
+
sound variant in that version.
|
|
17
|
+
|
|
18
|
+
Implementation
|
|
19
|
+
--------------
|
|
20
|
+
|
|
21
|
+
All of it is 'GameId's: a 'CowSoundVariantId' is equal only to a
|
|
22
|
+
'CowSoundVariantId'.
|
|
23
|
+
"""
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""
|
|
2
|
+
CowVariantId pairs a cow variant's unique name with the id a version of the
|
|
3
|
+
game needs to identify it.
|
|
4
|
+
"""
|
|
5
|
+
# Apache-2.0 license
|
|
6
|
+
# Copyright (c) 2026 Asger Jon Vistisen
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from . import GameId
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CowVariantId(GameId):
|
|
13
|
+
"""
|
|
14
|
+
The id of a cow variant in one version: its 'uniqueName', the same in every
|
|
15
|
+
version, and its 'minecraftId', what /summon takes for a cow of that variant
|
|
16
|
+
in that version.
|
|
17
|
+
|
|
18
|
+
Implementation
|
|
19
|
+
--------------
|
|
20
|
+
|
|
21
|
+
All of it is 'GameId's: a 'CowVariantId' is equal only to a 'CowVariantId'.
|
|
22
|
+
"""
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""
|
|
2
|
+
DamageTypeId pairs a damage type's unique name with the id a version of the
|
|
3
|
+
game needs to identify it.
|
|
4
|
+
"""
|
|
5
|
+
# Apache-2.0 license
|
|
6
|
+
# Copyright (c) 2026 Asger Jon Vistisen
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from . import GameId
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class DamageTypeId(GameId):
|
|
13
|
+
"""
|
|
14
|
+
The id of a damage type in one version: its 'uniqueName', the same in
|
|
15
|
+
every version, and its 'minecraftId', what /damage takes in that version.
|
|
16
|
+
|
|
17
|
+
Implementation
|
|
18
|
+
--------------
|
|
19
|
+
|
|
20
|
+
All of it is 'GameId's: a 'DamageTypeId' is equal only to a 'DamageTypeId'.
|
|
21
|
+
"""
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""
|
|
2
|
+
DimensionId pairs a dimension's unique name with the id a version of the game
|
|
3
|
+
needs to identify it.
|
|
4
|
+
"""
|
|
5
|
+
# Apache-2.0 license
|
|
6
|
+
# Copyright (c) 2026 Asger Jon Vistisen
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from . import GameId
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class DimensionId(GameId):
|
|
13
|
+
"""
|
|
14
|
+
The id of a dimension in one version: its 'uniqueName', the same in
|
|
15
|
+
every version, and its 'minecraftId', what /execute in takes in that version.
|
|
16
|
+
|
|
17
|
+
Implementation
|
|
18
|
+
--------------
|
|
19
|
+
|
|
20
|
+
All of it is 'GameId's: a 'DimensionId' is equal only to a 'DimensionId'.
|
|
21
|
+
"""
|
mcdex/base/_effect_id.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""
|
|
2
|
+
EffectId pairs an effect's unique name with the id a version of the game
|
|
3
|
+
needs to identify it.
|
|
4
|
+
"""
|
|
5
|
+
# Apache-2.0 license
|
|
6
|
+
# Copyright (c) 2026 Asger Jon Vistisen
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from . import GameId
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class EffectId(GameId):
|
|
13
|
+
"""
|
|
14
|
+
The id of an effect in one version: its 'uniqueName', the same in
|
|
15
|
+
every version, and its 'minecraftId', what '/effect' takes in that version.
|
|
16
|
+
|
|
17
|
+
Implementation
|
|
18
|
+
--------------
|
|
19
|
+
|
|
20
|
+
All of it is 'GameId's: an 'EffectId' is equal only to an 'EffectId'.
|
|
21
|
+
"""
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""
|
|
2
|
+
EnchantmentId pairs an enchantment's unique name with the id a version of the
|
|
3
|
+
game needs to identify it.
|
|
4
|
+
"""
|
|
5
|
+
# Apache-2.0 license
|
|
6
|
+
# Copyright (c) 2026 Asger Jon Vistisen
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from . import GameId
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class EnchantmentId(GameId):
|
|
13
|
+
"""
|
|
14
|
+
The id of an enchantment in one version: its 'uniqueName', the same in
|
|
15
|
+
every version, and its 'minecraftId', what '/enchant' takes in that version.
|
|
16
|
+
|
|
17
|
+
Implementation
|
|
18
|
+
--------------
|
|
19
|
+
|
|
20
|
+
All of it is 'GameId's: an 'EnchantmentId' is equal only to an
|
|
21
|
+
'EnchantmentId'.
|
|
22
|
+
"""
|
mcdex/base/_entity_id.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""
|
|
2
|
+
EntityId pairs an entity's unique name with the id a version of the game
|
|
3
|
+
needs to identify it.
|
|
4
|
+
"""
|
|
5
|
+
# Apache-2.0 license
|
|
6
|
+
# Copyright (c) 2026 Asger Jon Vistisen
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from . import GameId
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class EntityId(GameId):
|
|
13
|
+
"""
|
|
14
|
+
A user of mcdex names an entity once, by its unique name, as
|
|
15
|
+
'wither_skeleton', and each version of the game needs its own id for
|
|
16
|
+
it: what '/summon' takes. 'EntityId' holds the two: 'uniqueName', the
|
|
17
|
+
same in every version, and 'minecraftId', all that one version needs
|
|
18
|
+
to identify the entity, as one string in the notation of its era:
|
|
19
|
+
|
|
20
|
+
EntityId('creeper', 'Creeper') # 1.7.2 to 1.10.2
|
|
21
|
+
EntityId('creeper', 'minecraft:creeper') # since 1.11
|
|
22
|
+
|
|
23
|
+
Where an old version told entities apart by their data, the id carries
|
|
24
|
+
that data after the name, as /summon takes it: the wither skeleton of
|
|
25
|
+
1.10.2 is a skeleton of type 1, 'Skeleton{SkeletonType:1}', and a
|
|
26
|
+
spruce boat before 1.21.2 'minecraft:boat{Type:"spruce"}'.
|
|
27
|
+
|
|
28
|
+
An 'EntityId' is never an 'ItemId', even where the two have the same
|
|
29
|
+
text: the pig and its spawn egg are different things.
|
|
30
|
+
|
|
31
|
+
Implementation
|
|
32
|
+
--------------
|
|
33
|
+
|
|
34
|
+
All of it is 'GameId's: an 'EntityId' is equal only to an 'EntityId'.
|
|
35
|
+
"""
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""
|
|
2
|
+
EquipmentSlot enumerates the slots an entity wears or holds an item in.
|
|
3
|
+
"""
|
|
4
|
+
# Apache-2.0 license
|
|
5
|
+
# Copyright (c) 2026 Asger Jon Vistisen
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from worktoy.keenum import KeeNum, Kee
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class EquipmentSlot(KeeNum):
|
|
12
|
+
"""
|
|
13
|
+
An item goes to one slot when an entity equips it: the elytra to the
|
|
14
|
+
chest, a helmet to the head, a shield to the offhand, horse armor to a
|
|
15
|
+
horse's body, a saddle to its saddle, and every other item to the main
|
|
16
|
+
hand. EquipmentSlot enumerates those slots, in the order of the game's
|
|
17
|
+
own enumeration as of 26.3, each holding the name the game serializes
|
|
18
|
+
it by:
|
|
19
|
+
|
|
20
|
+
EquipmentSlot('chest') is EquipmentSlot.CHEST
|
|
21
|
+
|
|
22
|
+
The offhand arrived in 1.9, the body in 1.20.5 and the saddle in
|
|
23
|
+
1.21.5; before each, an item that would go there went to the main
|
|
24
|
+
hand.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
MAINHAND = Kee[str]('mainhand')
|
|
28
|
+
OFFHAND = Kee[str]('offhand')
|
|
29
|
+
FEET = Kee[str]('feet')
|
|
30
|
+
LEGS = Kee[str]('legs')
|
|
31
|
+
CHEST = Kee[str]('chest')
|
|
32
|
+
HEAD = Kee[str]('head')
|
|
33
|
+
BODY = Kee[str]('body')
|
|
34
|
+
SADDLE = Kee[str]('saddle')
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""
|
|
2
|
+
FrogVariantId pairs a frog variant's unique name with the id a version of the
|
|
3
|
+
game needs to identify it.
|
|
4
|
+
"""
|
|
5
|
+
# Apache-2.0 license
|
|
6
|
+
# Copyright (c) 2026 Asger Jon Vistisen
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from . import GameId
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class FrogVariantId(GameId):
|
|
13
|
+
"""
|
|
14
|
+
The id of a frog variant in one version: its 'uniqueName', the same in every
|
|
15
|
+
version, and its 'minecraftId', what /summon takes for a frog of that variant
|
|
16
|
+
in that version.
|
|
17
|
+
|
|
18
|
+
Implementation
|
|
19
|
+
--------------
|
|
20
|
+
|
|
21
|
+
All of it is 'GameId's: a 'FrogVariantId' is equal only to a 'FrogVariantId'.
|
|
22
|
+
"""
|
mcdex/base/_game_id.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""
|
|
2
|
+
GameId pairs a thing's unique name with the id a version of the game
|
|
3
|
+
needs to identify it: the shared code of each kind's own id class.
|
|
4
|
+
"""
|
|
5
|
+
# Apache-2.0 license
|
|
6
|
+
# Copyright (c) 2026 Asger Jon Vistisen
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import TYPE_CHECKING
|
|
10
|
+
|
|
11
|
+
from worktoy.dispatch import overload
|
|
12
|
+
from worktoy.desc import FixBox
|
|
13
|
+
from worktoy.mcls import BaseObject
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING: # pragma: no cover, no mutate
|
|
16
|
+
from typing import Any, TypeAlias
|
|
17
|
+
|
|
18
|
+
Key: TypeAlias = tuple[str, str]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class GameId(BaseObject):
|
|
22
|
+
"""
|
|
23
|
+
The id of one thing of the game in one version: its 'uniqueName', the
|
|
24
|
+
same in every version, and its 'minecraftId', all that version needs
|
|
25
|
+
to identify it, as one string in the notation of its era. Each kind of
|
|
26
|
+
thing has its own subclass, as 'EntityId' and 'BlockId', and an id of
|
|
27
|
+
one kind is never equal to an id of another, even with the same text:
|
|
28
|
+
the pig and its spawn egg are different things.
|
|
29
|
+
|
|
30
|
+
Implementation
|
|
31
|
+
--------------
|
|
32
|
+
|
|
33
|
+
'uniqueName' and 'minecraftId' are 'FixBox[str]', written once by the
|
|
34
|
+
constructor, which refuses an empty one with 'ValueError'. The text of
|
|
35
|
+
an id is its 'minecraftId'. Equality and hash compare the class and
|
|
36
|
+
both strings; anything but an id of the same class compares as
|
|
37
|
+
'NotImplemented'.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
41
|
+
# NAMESPACE # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
42
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
43
|
+
|
|
44
|
+
# Public Variables
|
|
45
|
+
uniqueName = FixBox[str]()
|
|
46
|
+
minecraftId = FixBox[str]()
|
|
47
|
+
|
|
48
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
49
|
+
# Python API # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
50
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
51
|
+
|
|
52
|
+
def __str__(self, ) -> str:
|
|
53
|
+
"""The 'minecraftId', as 'minecraft:wool:6'."""
|
|
54
|
+
return self.minecraftId
|
|
55
|
+
|
|
56
|
+
def __repr__(self, ) -> str:
|
|
57
|
+
""""BlockId('pink_wool', 'minecraft:wool:6')", which evaluates back."""
|
|
58
|
+
return '%s(%r, %r)' % (type(self).__name__, *self._key())
|
|
59
|
+
|
|
60
|
+
def __eq__(self, other: Any) -> bool:
|
|
61
|
+
if type(other) is type(self):
|
|
62
|
+
return self._key() == other._key()
|
|
63
|
+
return NotImplemented
|
|
64
|
+
|
|
65
|
+
def __hash__(self, ) -> int:
|
|
66
|
+
return hash((type(self).__name__,) + self._key())
|
|
67
|
+
|
|
68
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
69
|
+
# CONSTRUCTORS # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
70
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
71
|
+
|
|
72
|
+
@overload(str, str)
|
|
73
|
+
def __init__(self, uniqueName: str, minecraftId: str) -> None:
|
|
74
|
+
for name_, value_ in (('uniqueName', uniqueName),
|
|
75
|
+
('minecraftId', minecraftId)):
|
|
76
|
+
if not value_:
|
|
77
|
+
infoSpec = """%s() received an empty '%s'"""
|
|
78
|
+
raise ValueError(infoSpec % (type(self).__name__, name_))
|
|
79
|
+
self.uniqueName = uniqueName
|
|
80
|
+
self.minecraftId = minecraftId
|
|
81
|
+
|
|
82
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
83
|
+
# DOMAIN SPECIFIC # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
84
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
85
|
+
|
|
86
|
+
def _key(self, ) -> Key:
|
|
87
|
+
"""The unique name and the minecraft id, for comparisons and hash."""
|
|
88
|
+
return (self.uniqueName, self.minecraftId)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""
|
|
2
|
+
GameRuleId pairs a game rule's unique name with the id a version of the game
|
|
3
|
+
needs to identify it.
|
|
4
|
+
"""
|
|
5
|
+
# Apache-2.0 license
|
|
6
|
+
# Copyright (c) 2026 Asger Jon Vistisen
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from . import GameId
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class GameRuleId(GameId):
|
|
13
|
+
"""
|
|
14
|
+
The id of a game rule in one version: its 'uniqueName', the same in
|
|
15
|
+
every version, and its 'minecraftId', what '/gamerule' takes in that version.
|
|
16
|
+
|
|
17
|
+
Implementation
|
|
18
|
+
--------------
|
|
19
|
+
|
|
20
|
+
All of it is 'GameId's: a 'GameRuleId' is equal only to a 'GameRuleId'.
|
|
21
|
+
"""
|
mcdex/base/_item_id.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ItemId pairs an item's unique name with the id a version of the game
|
|
3
|
+
needs to identify it.
|
|
4
|
+
"""
|
|
5
|
+
# Apache-2.0 license
|
|
6
|
+
# Copyright (c) 2026 Asger Jon Vistisen
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import TYPE_CHECKING
|
|
10
|
+
|
|
11
|
+
from worktoy.dispatch import overload
|
|
12
|
+
from worktoy.desc import FixBox
|
|
13
|
+
from worktoy.mcls import BaseObject
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING: # pragma: no cover, no mutate
|
|
16
|
+
from typing import Any, TypeAlias
|
|
17
|
+
|
|
18
|
+
Key: TypeAlias = tuple[str, str]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ItemId(BaseObject):
|
|
22
|
+
"""
|
|
23
|
+
A user of mcdex names an item once, by its unique name, as
|
|
24
|
+
'pink_wool', and each version of the game needs its own id for it.
|
|
25
|
+
'ItemId' holds the two: 'uniqueName', the same in every version, and
|
|
26
|
+
'minecraftId', all that one version needs to identify the item, as
|
|
27
|
+
one string in the notation of its era:
|
|
28
|
+
|
|
29
|
+
ItemId('pink_wool', '35:6') # before 1.7.2
|
|
30
|
+
ItemId('pink_wool', 'minecraft:wool:6') # 1.7.2 to 1.12.2
|
|
31
|
+
ItemId('pink_wool', 'minecraft:pink_wool') # since 1.13
|
|
32
|
+
|
|
33
|
+
Before 1.7.2 the game had only numbers, the id and the meta value;
|
|
34
|
+
then names, with the meta where it told items apart; and since 1.13
|
|
35
|
+
the name alone. A meta that is only damage, as the elytra's was, is no
|
|
36
|
+
part of the id. A registry name has no ':' in its path, so a trailing
|
|
37
|
+
':6' is always the meta. An item the game told apart by NBT carries it
|
|
38
|
+
after the name, as the /give command takes it: a creeper spawn egg of
|
|
39
|
+
1.12.2 is 'minecraft:spawn_egg{EntityTag:{id:"minecraft:creeper"}}'.
|
|
40
|
+
|
|
41
|
+
Implementation
|
|
42
|
+
--------------
|
|
43
|
+
|
|
44
|
+
'uniqueName' and 'minecraftId' are 'FixBox[str]', written once by the
|
|
45
|
+
constructor, which refuses an empty one with 'ValueError'. The text of
|
|
46
|
+
an id is its 'minecraftId'. Equality and hash compare both strings;
|
|
47
|
+
anything but an 'ItemId' compares as 'NotImplemented'.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
51
|
+
# NAMESPACE # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
52
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
53
|
+
|
|
54
|
+
# Public Variables
|
|
55
|
+
uniqueName = FixBox[str]()
|
|
56
|
+
minecraftId = FixBox[str]()
|
|
57
|
+
|
|
58
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
59
|
+
# Python API # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
60
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
61
|
+
|
|
62
|
+
def __str__(self, ) -> str:
|
|
63
|
+
"""The 'minecraftId', as 'minecraft:wool:6'."""
|
|
64
|
+
return self.minecraftId
|
|
65
|
+
|
|
66
|
+
def __repr__(self, ) -> str:
|
|
67
|
+
""""ItemId('pink_wool', 'minecraft:wool:6')", which evaluates back."""
|
|
68
|
+
return '%s(%r, %r)' % (type(self).__name__, *self._key())
|
|
69
|
+
|
|
70
|
+
def __eq__(self, other: Any) -> bool:
|
|
71
|
+
if isinstance(other, ItemId):
|
|
72
|
+
return self._key() == other._key()
|
|
73
|
+
return NotImplemented
|
|
74
|
+
|
|
75
|
+
def __hash__(self, ) -> int:
|
|
76
|
+
return hash(self._key())
|
|
77
|
+
|
|
78
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
79
|
+
# CONSTRUCTORS # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
80
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
81
|
+
|
|
82
|
+
@overload(str, str)
|
|
83
|
+
def __init__(self, uniqueName: str, minecraftId: str) -> None:
|
|
84
|
+
for name_, value_ in (('uniqueName', uniqueName),
|
|
85
|
+
('minecraftId', minecraftId)):
|
|
86
|
+
if not value_:
|
|
87
|
+
infoSpec = """%s() received an empty '%s'"""
|
|
88
|
+
raise ValueError(infoSpec % (type(self).__name__, name_))
|
|
89
|
+
self.uniqueName = uniqueName
|
|
90
|
+
self.minecraftId = minecraftId
|
|
91
|
+
|
|
92
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
93
|
+
# DOMAIN SPECIFIC # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
94
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
95
|
+
|
|
96
|
+
def _key(self, ) -> Key:
|
|
97
|
+
"""The unique name and the minecraft id, for comparisons and hash."""
|
|
98
|
+
return (self.uniqueName, self.minecraftId)
|