From 29bac6fe245f4a678b5d2370c137ada3f77744a9 Mon Sep 17 00:00:00 2001 From: Articdive <13535885+Articdive@users.noreply.github.com> Date: Thu, 10 Jun 2021 09:18:17 +0200 Subject: [PATCH] Use enum for AxolotlMeta --- .../entity/metadata/water/AxolotlMeta.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/minestom/server/entity/metadata/water/AxolotlMeta.java b/src/main/java/net/minestom/server/entity/metadata/water/AxolotlMeta.java index d1a752b21..3db210e66 100644 --- a/src/main/java/net/minestom/server/entity/metadata/water/AxolotlMeta.java +++ b/src/main/java/net/minestom/server/entity/metadata/water/AxolotlMeta.java @@ -12,13 +12,12 @@ public class AxolotlMeta extends WaterAnimalMeta { super(entity, metadata); } - //todo variant enum - public int getVariant() { - return metadata.getIndex(OFFSET, 0); + public Variant getVariant() { + return Variant.VALUES[super.metadata.getIndex(OFFSET, 0)]; } - public void setVariant(int variant) { - metadata.setIndex(variant, Metadata.VarInt(variant)); + public void setVariant(Variant variant) { + metadata.setIndex(OFFSET, Metadata.VarInt(variant.ordinal())); } public boolean isPlayingDead() { @@ -36,4 +35,14 @@ public class AxolotlMeta extends WaterAnimalMeta { public void setFromBucket(boolean fromBucket) { metadata.setIndex(OFFSET + 2, Metadata.Boolean(fromBucket)); } + + public enum Variant { + LUCY, + WILD, + GOLD, + CYAN, + BLUE; + + private final static AxolotlMeta.Variant[] VALUES = values(); + } }