From efd5bae13b06a4487382fdc843253901614bbe62 Mon Sep 17 00:00:00 2001
From: OnlyBMan <27742182+OnlyBMan@users.noreply.github.com>
Date: Sun, 22 Dec 2019 12:35:22 -0500
Subject: [PATCH 1/2] Fix baby animal sizes

This should fix most baby animal sizes including Rabbits and their adult sizes!
---
 .../entity/living/AgeableEntity.java          |  9 ++++--
 .../connector/entity/living/RabbitEntity.java | 30 +++++++++++++++++++
 .../connector/entity/type/EntityType.java     |  2 +-
 3 files changed, 38 insertions(+), 3 deletions(-)
 create mode 100644 connector/src/main/java/org/geysermc/connector/entity/living/RabbitEntity.java

diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/AgeableEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/AgeableEntity.java
index 7feaacba..69c54034 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/AgeableEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/AgeableEntity.java
@@ -28,6 +28,7 @@ package org.geysermc.connector.entity.living;
 import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
 import com.github.steveice10.mc.protocol.data.game.entity.metadata.MetadataType;
 import com.nukkitx.math.vector.Vector3f;
+import com.nukkitx.protocol.bedrock.data.EntityData;
 import com.nukkitx.protocol.bedrock.data.EntityFlag;
 import org.geysermc.connector.entity.type.EntityType;
 import org.geysermc.connector.network.session.GeyserSession;
@@ -40,8 +41,12 @@ public class AgeableEntity extends CreatureEntity {
 
     @Override
     public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
-        if (entityMetadata.getId() == 15) {
-            metadata.getFlags().setFlag(EntityFlag.BABY, (boolean) entityMetadata.getValue());
+        if (entityMetadata.getId() == 15 && entityType != EntityType.RABBIT) {
+            boolean isBaby = (boolean) entityMetadata.getValue();
+            metadata.getFlags().setFlag(EntityFlag.BABY, isBaby);
+            if (isBaby) {
+                metadata.put(EntityData.SCALE, .55f);
+            }
         }
 
         super.updateBedrockMetadata(entityMetadata, session);
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/RabbitEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/RabbitEntity.java
new file mode 100644
index 00000000..9b9dd583
--- /dev/null
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/RabbitEntity.java
@@ -0,0 +1,30 @@
+package org.geysermc.connector.entity.living;
+
+import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
+import com.nukkitx.math.vector.Vector3f;
+import com.nukkitx.protocol.bedrock.data.EntityData;
+import com.nukkitx.protocol.bedrock.data.EntityFlag;
+import org.geysermc.connector.entity.type.EntityType;
+import org.geysermc.connector.network.session.GeyserSession;
+
+public class RabbitEntity extends AnimalEntity {
+    public RabbitEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
+        super(entityId, geyserId, entityType, position, motion, rotation);
+    }
+
+    @Override
+    public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
+        if (entityMetadata.getId() == 15) {
+            boolean isBaby = (boolean) entityMetadata.getValue();
+            metadata.getFlags().setFlag(EntityFlag.BABY, isBaby);
+            if(isBaby) {
+                metadata.put(EntityData.SCALE, .35f);
+            }
+            else {
+                metadata.put(EntityData.SCALE, .55f);
+            }
+        }
+
+        super.updateBedrockMetadata(entityMetadata, session);
+    }
+}
\ No newline at end of file
diff --git a/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java b/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java
index 1179617d..3fc79ed1 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java
@@ -44,7 +44,7 @@ public enum EntityType {
     VILLAGER(AbstractMerchantEntity.class, 15, 1.8f, 0.6f, 0.6f, 1.62f),
     MOOSHROOM(AnimalEntity.class, 16, 1.4f, 0.9f),
     SQUID(WaterEntity.class, 17, 0.8f),
-    RABBIT(AnimalEntity.class, 18, 0.5f, 0.4f),
+    RABBIT(RabbitEntity.class, 18, 0.5f, 0.4f),
     BAT(AmbientEntity.class, 19, 0.9f, 0.5f),
     IRON_GOLEM(GolemEntity.class, 20, 2.7f, 1.4f),
     SNOW_GOLEM(GolemEntity.class, 21, 1.9f, 0.7f),

From 0f70ad087c96ea8124b4929303e77f7e7fca02c2 Mon Sep 17 00:00:00 2001
From: OnlyBMan <27742182+OnlyBMan@users.noreply.github.com>
Date: Tue, 24 Dec 2019 11:07:36 -0500
Subject: [PATCH 2/2] Added scaling for Zombies, Villagers, and Armor Stands

Fixed code a bit and added support for new mobs.
---
 .../entity/living/AgeableEntity.java          |  4 +--
 .../entity/living/ArmorStandEntity.java       | 29 +++++++++++++++++++
 .../connector/entity/living/RabbitEntity.java |  9 ++----
 .../entity/living/monster/ZombieEntity.java   | 16 ++++++++++
 .../connector/entity/type/EntityType.java     |  2 +-
 5 files changed, 51 insertions(+), 9 deletions(-)
 create mode 100644 connector/src/main/java/org/geysermc/connector/entity/living/ArmorStandEntity.java

diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/AgeableEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/AgeableEntity.java
index 69c54034..89de32d6 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/AgeableEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/AgeableEntity.java
@@ -41,11 +41,11 @@ public class AgeableEntity extends CreatureEntity {
 
     @Override
     public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
-        if (entityMetadata.getId() == 15 && entityType != EntityType.RABBIT) {
+        if (entityMetadata.getId() == 15) {
             boolean isBaby = (boolean) entityMetadata.getValue();
-            metadata.getFlags().setFlag(EntityFlag.BABY, isBaby);
             if (isBaby) {
                 metadata.put(EntityData.SCALE, .55f);
+                metadata.getFlags().setFlag(EntityFlag.BABY, true);
             }
         }
 
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/ArmorStandEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/ArmorStandEntity.java
new file mode 100644
index 00000000..5829cc32
--- /dev/null
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/ArmorStandEntity.java
@@ -0,0 +1,29 @@
+package org.geysermc.connector.entity.living;
+
+import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
+import com.github.steveice10.mc.protocol.data.game.entity.metadata.MetadataType;
+import com.nukkitx.math.vector.Vector3f;
+import com.nukkitx.protocol.bedrock.data.EntityData;
+import com.nukkitx.protocol.bedrock.data.EntityFlag;
+import org.geysermc.connector.entity.LivingEntity;
+import org.geysermc.connector.entity.living.MonsterEntity;
+import org.geysermc.connector.entity.type.EntityType;
+import org.geysermc.connector.network.session.GeyserSession;
+
+public class ArmorStandEntity extends LivingEntity {
+
+    public ArmorStandEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
+        super(entityId, geyserId, entityType, position, motion, rotation);
+    }
+
+    @Override
+    public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
+        if (entityMetadata.getType() == MetadataType.BYTE) {
+            byte xd = (byte) entityMetadata.getValue();
+            if((xd & 0x01) == 0x01) {
+                metadata.put(EntityData.SCALE, .55f);
+            }
+        }
+        super.updateBedrockMetadata(entityMetadata, session);
+    }
+}
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/RabbitEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/RabbitEntity.java
index 9b9dd583..093d3c13 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/RabbitEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/RabbitEntity.java
@@ -14,17 +14,14 @@ public class RabbitEntity extends AnimalEntity {
 
     @Override
     public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
+        super.updateBedrockMetadata(entityMetadata, session);
         if (entityMetadata.getId() == 15) {
+            metadata.put(EntityData.SCALE, .55f);
             boolean isBaby = (boolean) entityMetadata.getValue();
-            metadata.getFlags().setFlag(EntityFlag.BABY, isBaby);
             if(isBaby) {
                 metadata.put(EntityData.SCALE, .35f);
-            }
-            else {
-                metadata.put(EntityData.SCALE, .55f);
+                metadata.getFlags().setFlag(EntityFlag.BABY, true);
             }
         }
-
-        super.updateBedrockMetadata(entityMetadata, session);
     }
 }
\ No newline at end of file
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/ZombieEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/ZombieEntity.java
index 162c2272..c0d2c239 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/monster/ZombieEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/ZombieEntity.java
@@ -25,13 +25,29 @@
 
 package org.geysermc.connector.entity.living.monster;
 
+import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
 import com.nukkitx.math.vector.Vector3f;
+import com.nukkitx.protocol.bedrock.data.EntityData;
+import com.nukkitx.protocol.bedrock.data.EntityFlag;
 import org.geysermc.connector.entity.living.MonsterEntity;
 import org.geysermc.connector.entity.type.EntityType;
+import org.geysermc.connector.network.session.GeyserSession;
 
 public class ZombieEntity extends MonsterEntity {
 
     public ZombieEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
         super(entityId, geyserId, entityType, position, motion, rotation);
     }
+
+    @Override
+    public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
+        if (entityMetadata.getId() == 15) {
+            boolean isBaby = (boolean) entityMetadata.getValue();
+            if (isBaby) {
+                metadata.put(EntityData.SCALE, .55f);
+                metadata.getFlags().setFlag(EntityFlag.BABY, true);
+            }
+        }
+        super.updateBedrockMetadata(entityMetadata, session);
+    }
 }
diff --git a/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java b/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java
index 3fc79ed1..f7a4b843 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java
@@ -90,7 +90,7 @@ public enum EntityType {
     PHANTOM(FlyingEntity.class, 58, 0.5f, 0.9f, 0.9f, 0.6f),
     RAVAGER(RaidParticipantEntity.class, 59, 1.9f, 1.2f),
 
-    ARMOR_STAND(LivingEntity.class, 61, 0f),
+    ARMOR_STAND(ArmorStandEntity.class, 61, 0f),
     TRIPOD_CAMERA(Entity.class, 62, 0f),
     PLAYER(PlayerEntity.class, 63, 1.8f, 0.6f, 0.6f, 1.62f),
     ITEM(ItemEntity.class, 64, 0.25f, 0.25f),