-
Notifications
You must be signed in to change notification settings - Fork 2
Creating Trophy Variants
Starting in version 2.0, you can now define mob variants in the trophy json. There are 2 ways to do this.
Using the variants array allows you to define variants based on entity data. Most variants of mobs are dependent on some
sort of tag being a certain value to change their appearance. You can read all about the various entity data for vanilla
mobs here. I will be using the Axolotl as an example here.
Axolotls change their texture based on what their Variant
tag is set to. This tag is a number somewhere between 0 and
4, with 0 being the pink (lucy) version, 1 being the brown (wild) version, and so on. Using this knowledge, we can
create a list of variants like so:
"variants": [
{
"Variant": 0
},
{
"Variant": 1
},
{
"Variant": 2
},
{
"Variant": 3
},
{
"Variant": 4
}
]
This will add a trophy variant for every Axolotl color. I'm sure this looks kind of messy, with the curly brackets and everything, but there's very good reason for doing this: it allows you to define multiple data tags per variant! You normally don't need to do this, but one mob in particular I use this in vanilla for is the Panda.
Variants are direct NBT data, meaning that you can use ints, doubles, floats, strings, list tags, or even additional compound tags.
Some mobs are interesting in that their variants are actually their own registry, such as cats or frogs. Unlike using the variant array above, this method allows you to dynamically add more variant trophies if other mods add variants for the entity in question! Setting this up is simple:
"variant_registry": {
"key": "variant",
"registry": "minecraft:cat_variant"
}
Variants are normally stored in entity data just like the variants above. key
is the tag the registry name is saved
to. registry
is the name of the registry in question. Currently vanilla has 2 registries: minecraft:cat_variant
and minecraft:frog_variant
.
You may notice villagers use this system for their profession registry. Unfortunately this one is special cased as the
way villager data is saved is a bit wonky. However, if you have an entity that implements VillagerDataHolder
(this is
a vanilla class, don't worry!) you can add the profession registry block to your mob trophy, and it will automatically
add all profession variants to your mob!
"variant_registry": {
"key": "profession",
"registry": "minecraft:villager_profession"
}
Starting in version 3.0, you can add additional data to a trophy that every single trophy variant will have. This data will not be checked for when calculating the trophy drop, it just allows you to further customize your trophy with things like armor. Example:
"default_variant": {
"ArmorItems": [
{},
{},
{},
{
"Count": 1,
"id": "minecraft:iron_helmet"
}
],
"HandItems": [
{
"Count": 1,
"id": "minecraft:cookie"
},
{}
]
},
Adding this to a trophy json will put an iron helmet on their head and a cookie in their main hand. You can read more about entity and item data tags here if you're interested.