From 6359fd4e836477103401ccab3abc1c66f844aeab Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Thu, 9 Apr 2020 20:23:52 -0400 Subject: [PATCH] Use switch statement for cat variant color --- .../living/animal/tameable/CatEntity.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/CatEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/CatEntity.java index 1c160e82e..63a67a0a7 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/CatEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/CatEntity.java @@ -42,17 +42,24 @@ public class CatEntity extends TameableEntity { public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { if (entityMetadata.getId() == 18) { // Different colors in Java and Bedrock for some reason - if ((int) entityMetadata.getValue() == 0) { - metadata.put(EntityData.VARIANT, 8); - } else if ((int) entityMetadata.getValue() == 8) { - metadata.put(EntityData.VARIANT, 0); - } else if ((int) entityMetadata.getValue() == 9) { - metadata.put(EntityData.VARIANT, 10); - } else if ((int) entityMetadata.getValue() == 10) { - metadata.put(EntityData.VARIANT, 9); - } else { - metadata.put(EntityData.VARIANT, (int) entityMetadata.getValue()); + int variantColor; + switch ((int) entityMetadata.getValue()) { + case 0: + variantColor = 8; + break; + case 8: + variantColor = 0; + break; + case 9: + variantColor = 10; + break; + case 10: + variantColor = 9; + break; + default: + variantColor = (int) entityMetadata.getValue(); } + metadata.put(EntityData.VARIANT, variantColor); } if (entityMetadata.getId() == 21) { // Needed or else wild cats are a red color