From 03c611224bddecd0ce4201362d3fd30940e7c03b Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Tue, 7 Apr 2020 19:38:44 -0400 Subject: [PATCH] Add llama decoration support --- .../living/animal/horse/LlamaEntity.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/LlamaEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/LlamaEntity.java index b4c958904..e7e2f7825 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/LlamaEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/LlamaEntity.java @@ -47,6 +47,24 @@ public class LlamaEntity extends ChestedHorseEntity { if (entityMetadata.getId() == 19) { metadata.put(EntityData.STRENGTH, entityMetadata.getValue()); } + // Color equipped on the llama + if (entityMetadata.getId() == 20) { + // Bedrock treats llama decoration as armor + MobArmorEquipmentPacket equipmentPacket = new MobArmorEquipmentPacket(); + equipmentPacket.setRuntimeEntityId(getGeyserId()); + if ((int) entityMetadata.getValue() != -1) { + // The damage value is the dye color that Java sends us + // Always going to be a carpet so we can hardcode 171 + // The int then short conversion is required or we get a ClassCastException + equipmentPacket.setChestplate(ItemData.of(171, (short)((int) entityMetadata.getValue()), 1)); + } else equipmentPacket.setChestplate(ItemData.of(0, (short) 0, 0)); + // Required to fill out the rest of the equipment or Bedrock ignores it + equipmentPacket.setBoots(ItemData.of(0, (short) 0, 0)); + equipmentPacket.setHelmet(ItemData.of(0, (short) 0, 0)); + equipmentPacket.setLeggings(ItemData.of(0, (short) 0, 0)); + + session.getUpstream().sendPacket(equipmentPacket); + } // Color of the llama if (entityMetadata.getId() == 21) { metadata.put(EntityData.VARIANT, entityMetadata.getValue());