Skip to content

Rework horse variant component to match vanilla - #2996

Merged
kermandev merged 4 commits into
Minestom:masterfrom
mudkjp:horse-variant-fix
Jul 10, 2026
Merged

kermandev merged 4 commits into
Minestom:masterfrom
mudkjp:horse-variant-fix

Conversation

@mudkjp

@mudkjp mudkjp commented Dec 14, 2025 •

Copy link
Copy Markdown
Contributor
  • Renamed HorseMeta.Color to HorseMeta.Variant, matching vanilla's color-only variant enum
  • HORSE_VARIANT now serializes identically to vanilla (string in NBT, var-int id on the network)
  • Removed the marking + color Variant wrapper class and getVariantID/getVariantFromID
  • setVariant only changes the color and preserves the marking, like vanilla
  • Added getMarking, setMarking, and setVariantAndMarking to HorseMeta
  • Fixed the component get/set overrides using the marking where the color was expected
  • Targets next due to breaking API changes

@kermandev kermandev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if im wrong, but..

public static final DataComponent<RegistryKey<ChickenVariant>> CHICKEN_VARIANT = register("chicken/variant", ChickenVariant.NETWORK_TYPE, ChickenVariant.CODEC);
public static final DataComponent<RegistryKey<FrogVariant>> FROG_VARIANT = register("frog/variant", FrogVariant.NETWORK_TYPE, FrogVariant.CODEC);
public static final DataComponent<HorseMeta.Color> HORSE_VARIANT = register("horse/variant", HorseMeta.Color.NETWORK_TYPE, HorseMeta.Color.NBT_TYPE);
public static final DataComponent<HorseMeta.Variant> HORSE_VARIANT = register("horse/variant", HorseMeta.Variant.NETWORK_TYPE, HorseMeta.Variant.CODEC);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Color is actually correct here. The markings is determined by the horse metadata (annoying right?)

protected <T> @Nullable T get(DataComponent<T> component) {
if (component == DataComponents.HORSE_VARIANT)
return (T) getVariant().getMarking();
return (T) getVariant();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm it seems the original was wrong should be getColor

variant.setMarking((Marking) value);
setVariant(variant);
} else super.set(component, value);
setVariant((Variant) value);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be Color, we probably should retain the marking though

import net.minestom.server.codec.StructCodec;
import org.jetbrains.annotations.Nullable;

public class HorseMeta extends AbstractHorseMeta {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No clue why the original setVariant was deprecated (as marking needs to be set), to be fair there should be little reason to have a Variant builder class and Color should become Variant. Maybe a change you would want to target next instead.

So HoreMeta would have

set(Variant, etc...)
setVariantAndMarking(Variant variant, Marking marking)
setMarking(Marking)

getMarking()

I agree its a little weird, but horse variant is probably a weird oversight from mojang that havent bothered to fix it yet.

var meta = (HorseMeta) horse.getEntityMeta();
meta.setBaby(baby);
meta.setVariant(new HorseMeta.Variant(marking, color));
horse.set(DataComponents.HORSE_VARIANT, new HorseMeta.Variant(marking, color));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly this component could only ever change the color, not the marking.

@mudkjp mudkjp Dec 19, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not true, in my screenshot you can see it's setting the marking correctly. The PR is correct as Minecraft represents markings + color as a single entity component named 'variant'.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes cause the data component is incorrectly implemented. If you were to use this data component generically it would be incorrect

@mudkjp
mudkjp force-pushed the horse-variant-fix branch from bfd4b95 to d08989d Compare July 7, 2026 19:49
@mudkjp
mudkjp requested a review from a team as a code owner July 7, 2026 19:49
@mudkjp mudkjp changed the title Fix horse variant component to match vanilla Rework horse variant component to match vanilla Jul 7, 2026
@mudkjp
mudkjp changed the base branch from master to next July 7, 2026 19:50
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Binary Compatibility

This Pull Request has introduced binary incompatible changes compared to the next branch.

What is Binary Compatibility?
Binary compatibility ensures that libraries compiled against Minestom can upgrade between versions without needing recompilation.

What should you do?

  • If unintentional, please restore the compatibility. Feel free to ask for help if you are unsure how to proceed.
  • If intentional, a maintainer will review them and label your PR as breaking, which will bypass this check. Please refer to CONTRIBUTING.md for requirements regarding breaking changes.
View offending signatures
Class removed or made package-private: net/minestom/server/entity/metadata/animal/HorseMeta$Color
Public/protected method removed or signature changed: net/minestom/server/entity/metadata/animal/HorseMeta$Variant#<init>(Lnet/minestom/server/entity/metadata/animal/HorseMeta$Marking;Lnet/minestom/server/entity/metadata/animal/HorseMeta$Color;)V
Public/protected method removed or signature changed: net/minestom/server/entity/metadata/animal/HorseMeta$Variant#getMarking()Lnet/minestom/server/entity/metadata/animal/HorseMeta$Marking;
Public/protected method removed or signature changed: net/minestom/server/entity/metadata/animal/HorseMeta$Variant#setMarking(Lnet/minestom/server/entity/metadata/animal/HorseMeta$Marking;)V
Public/protected method removed or signature changed: net/minestom/server/entity/metadata/animal/HorseMeta$Variant#getColor()Lnet/minestom/server/entity/metadata/animal/HorseMeta$Color;
Public/protected method removed or signature changed: net/minestom/server/entity/metadata/animal/HorseMeta$Variant#setColor(Lnet/minestom/server/entity/metadata/animal/HorseMeta$Color;)V
Public/protected method removed or signature changed: net/minestom/server/entity/metadata/animal/HorseMeta#getVariantID(Lnet/minestom/server/entity/metadata/animal/HorseMeta$Marking;Lnet/minestom/server/entity/metadata/animal/HorseMeta$Color;)I
Public/protected method removed or signature changed: net/minestom/server/entity/metadata/animal/HorseMeta#getVariantFromID(I)Lnet/minestom/server/entity/metadata/animal/HorseMeta$Variant;

@kermandev kermandev added the breaking Contains API breaking changes label Jul 7, 2026
@kermandev
kermandev changed the base branch from next to master July 7, 2026 20:50
@kermandev

Copy link
Copy Markdown
Member

@mudkipdev you missed ba3873e when swapping

@mudkjp
mudkjp force-pushed the horse-variant-fix branch from d08989d to dbf6fe5 Compare July 8, 2026 22:10
@kermandev
kermandev enabled auto-merge July 10, 2026 16:22
@kermandev
kermandev added this pull request to the merge queue Jul 10, 2026
Merged via the queue into Minestom:master with commit 964ba6a Jul 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Contains API breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants