From f9ee569cd54e952faade0db1e623e1b4a943b529 Mon Sep 17 00:00:00 2001 From: rtm516 Date: Mon, 11 May 2020 06:09:16 +0100 Subject: [PATCH] Various entity fixes (#529) * Fixed invisible entities nametags being displayed * Fixed most entity collision boxes * Fixed area effect cloud not displaying * Fixed armour stand size and marker * Fix baby collision boxes * Fixed squid animation (rotation still broken) * Fix Guardian beam for local player * Fixed armour stand invisibility * Fixed Wither boss data * Fixed fishing line attach to entities --- .../entity/AreaEffectCloudEntity.java | 61 +++++++++++++ .../org/geysermc/connector/entity/Entity.java | 40 +++++---- .../connector/entity/FishingHookEntity.java | 17 ++++ .../entity/living/AbstractFishEntity.java | 10 --- .../entity/living/AgeableEntity.java | 3 + .../entity/living/ArmorStandEntity.java | 25 +++++- .../connector/entity/living/SquidEntity.java | 36 ++++++++ .../connector/entity/living/WaterEntity.java | 3 + .../entity/living/monster/GuardianEntity.java | 4 + .../entity/living/monster/WitherEntity.java | 89 +++++++++++++++++++ .../connector/entity/type/EntityType.java | 52 +++++------ 11 files changed, 287 insertions(+), 53 deletions(-) create mode 100644 connector/src/main/java/org/geysermc/connector/entity/AreaEffectCloudEntity.java create mode 100644 connector/src/main/java/org/geysermc/connector/entity/living/SquidEntity.java create mode 100644 connector/src/main/java/org/geysermc/connector/entity/living/monster/WitherEntity.java diff --git a/connector/src/main/java/org/geysermc/connector/entity/AreaEffectCloudEntity.java b/connector/src/main/java/org/geysermc/connector/entity/AreaEffectCloudEntity.java new file mode 100644 index 000000000..2808b093c --- /dev/null +++ b/connector/src/main/java/org/geysermc/connector/entity/AreaEffectCloudEntity.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @author GeyserMC + * @link https://github.com/GeyserMC/Geyser + */ + +package org.geysermc.connector.entity; + +import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; +import com.github.steveice10.mc.protocol.data.game.world.particle.Particle; +import com.nukkitx.math.vector.Vector3f; +import com.nukkitx.protocol.bedrock.data.EntityData; +import org.geysermc.connector.entity.type.EntityType; +import org.geysermc.connector.network.session.GeyserSession; +import org.geysermc.connector.utils.EffectUtils; + +public class AreaEffectCloudEntity extends Entity { + + public AreaEffectCloudEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) { + super(entityId, geyserId, entityType, position, motion, rotation); + + // Without this the cloud doesn't appear, + metadata.put(EntityData.AREA_EFFECT_CLOUD_DURATION, 600); + + // This disabled client side shrink of the cloud + metadata.put(EntityData.AREA_EFFECT_CLOUD_RADIUS_PER_TICK, 0.0f); + } + + @Override + public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { + if (entityMetadata.getId() == 7) { + metadata.put(EntityData.AREA_EFFECT_CLOUD_RADIUS, (float) entityMetadata.getValue()); + metadata.put(EntityData.BOUNDING_BOX_WIDTH, 2.0f * (float) entityMetadata.getValue()); + } else if (entityMetadata.getId() == 10) { + Particle particle = (Particle) entityMetadata.getValue(); + metadata.put(EntityData.AREA_EFFECT_CLOUD_PARTICLE_ID, EffectUtils.getParticleString(particle.getType())); + } else if (entityMetadata.getId() == 8) { + metadata.put(EntityData.POTION_COLOR, entityMetadata.getValue()); + } + super.updateBedrockMetadata(entityMetadata, session); + } +} diff --git a/connector/src/main/java/org/geysermc/connector/entity/Entity.java b/connector/src/main/java/org/geysermc/connector/entity/Entity.java index 186c0ae8f..d911ff7ac 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/Entity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/Entity.java @@ -35,24 +35,28 @@ import com.github.steveice10.mc.protocol.data.message.TextMessage; import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket; import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerUseItemPacket; import com.nukkitx.math.vector.Vector3f; -import com.nukkitx.protocol.bedrock.data.*; +import com.nukkitx.protocol.bedrock.data.EntityData; +import com.nukkitx.protocol.bedrock.data.EntityDataMap; +import com.nukkitx.protocol.bedrock.data.EntityFlag; +import com.nukkitx.protocol.bedrock.data.EntityFlags; import com.nukkitx.protocol.bedrock.packet.*; - import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import it.unimi.dsi.fastutil.longs.LongSet; - import lombok.Getter; import lombok.Setter; - import org.geysermc.connector.entity.attribute.Attribute; import org.geysermc.connector.entity.attribute.AttributeType; +import org.geysermc.connector.entity.living.ArmorStandEntity; import org.geysermc.connector.entity.type.EntityType; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.item.ItemTranslator; import org.geysermc.connector.utils.AttributeUtils; import org.geysermc.connector.utils.MessageUtils; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; @Getter @Setter @@ -205,6 +209,16 @@ public class Entity { metadata.getFlags().setFlag(EntityFlag.SWIMMING, (xd & 0x10) == 0x10); metadata.getFlags().setFlag(EntityFlag.GLIDING, (xd & 0x80) == 0x80); + metadata.put(EntityData.SCALE, scale); + + if ((xd & 0x20) == 0x20) { + if (this.is(ArmorStandEntity.class)) { + metadata.put(EntityData.SCALE, 0.0f); + } else { + metadata.getFlags().setFlag(EntityFlag.INVISIBLE, true); + } + } + // Shield code if (session.getPlayerEntity().getEntityId() == entityId && metadata.getFlags().getFlag(EntityFlag.SNEAKING)) { if ((session.getInventory().getItemInHand() != null && session.getInventory().getItemInHand().getId() == ItemTranslator.SHIELD) || @@ -221,16 +235,11 @@ public class Entity { session.sendDownstreamPacket(useItemPacket); } } else if (session.getPlayerEntity().getEntityId() == entityId && !metadata.getFlags().getFlag(EntityFlag.SNEAKING) && metadata.getFlags().getFlag(EntityFlag.BLOCKING)) { - metadata.getFlags().setFlag(EntityFlag.BLOCKING, false); - metadata.getFlags().setFlag(EntityFlag.DISABLE_BLOCKING, true); - ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, new Position(0,0,0), BlockFace.DOWN); - session.sendDownstreamPacket(releaseItemPacket); - } - // metadata.getFlags().setFlag(EntityFlag.INVISIBLE, (xd & 0x20) == 0x20); - if ((xd & 0x20) == 0x20) - metadata.put(EntityData.SCALE, 0.0f); - else - metadata.put(EntityData.SCALE, scale); + metadata.getFlags().setFlag(EntityFlag.BLOCKING, false); + metadata.getFlags().setFlag(EntityFlag.DISABLE_BLOCKING, true); + ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, new Position(0, 0, 0), BlockFace.DOWN); + session.sendDownstreamPacket(releaseItemPacket); + } } break; case 2: // custom name @@ -270,6 +279,7 @@ public class Entity { /** * x = Pitch, y = HeadYaw, z = Yaw + * * @return the bedrock rotation */ public Vector3f getBedrockRotation() { diff --git a/connector/src/main/java/org/geysermc/connector/entity/FishingHookEntity.java b/connector/src/main/java/org/geysermc/connector/entity/FishingHookEntity.java index abd522929..8d8d5ef24 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/FishingHookEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/FishingHookEntity.java @@ -25,6 +25,7 @@ package org.geysermc.connector.entity; +import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.type.object.ProjectileData; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.EntityData; @@ -44,4 +45,20 @@ public class FishingHookEntity extends Entity { } } } + + @Override + public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { + if (entityMetadata.getId() == 7) { + Entity entity = session.getEntityCache().getEntityByJavaId((Integer) entityMetadata.getValue() - 1); + if (entity == null && session.getPlayerEntity().getEntityId() == (Integer) entityMetadata.getValue() - 1) { + entity = session.getPlayerEntity(); + } + + if (entity != null) { + metadata.put(EntityData.TARGET_EID, entity.getGeyserId()); + } + } + + super.updateBedrockMetadata(entityMetadata, session); + } } diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/AbstractFishEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/AbstractFishEntity.java index 54443825a..de5fa1b5b 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/AbstractFishEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/AbstractFishEntity.java @@ -25,28 +25,18 @@ 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 AbstractFishEntity extends WaterEntity { public AbstractFishEntity(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) { metadata.getFlags().setFlag(EntityFlag.CAN_SWIM, true); metadata.getFlags().setFlag(EntityFlag.BREATHING, true); metadata.getFlags().setFlag(EntityFlag.CAN_CLIMB, false); metadata.getFlags().setFlag(EntityFlag.HAS_GRAVITY, false); - - metadata.put(EntityData.AIR, (short) 400); - - super.updateBedrockMetadata(entityMetadata, session); } } 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 634f06743..b90983f78 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 @@ -44,6 +44,9 @@ public class AgeableEntity extends CreatureEntity { boolean isBaby = (boolean) entityMetadata.getValue(); metadata.put(EntityData.SCALE, isBaby ? .55f : 1f); metadata.getFlags().setFlag(EntityFlag.BABY, isBaby); + + metadata.put(EntityData.BOUNDING_BOX_HEIGHT, entityType.getHeight() * (isBaby ? 0.55f : 1f)); + metadata.put(EntityData.BOUNDING_BOX_WIDTH, entityType.getWidth() * (isBaby ? 0.55f : 1f)); } super.updateBedrockMetadata(entityMetadata, session); 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 index 1beb8ab8f..3c05933f2 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/ArmorStandEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/ArmorStandEntity.java @@ -29,6 +29,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadat 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 org.geysermc.connector.GeyserConnector; import org.geysermc.connector.entity.LivingEntity; import org.geysermc.connector.entity.type.EntityType; import org.geysermc.connector.network.session.GeyserSession; @@ -43,8 +44,28 @@ public class ArmorStandEntity extends LivingEntity { public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { if (entityMetadata.getType() == MetadataType.BYTE) { byte xd = (byte) entityMetadata.getValue(); - if ((xd & 0x01) == 0x01 && (metadata.get(EntityData.SCALE) != null && !metadata.get(EntityData.SCALE).equals(0.0f))) { - metadata.put(EntityData.SCALE, .55f); + + // isSmall + if ((xd & 0x01) == 0x01) { + GeyserConnector.getInstance().getLogger().debug("S: " + metadata.get(EntityData.SCALE)); + + if (metadata.get(EntityData.SCALE) == null || (metadata.get(EntityData.SCALE) != null && !metadata.get(EntityData.SCALE).equals(0.55f))) { + metadata.put(EntityData.SCALE, 0.55f); + } + + if (metadata.get(EntityData.BOUNDING_BOX_WIDTH) != null && metadata.get(EntityData.BOUNDING_BOX_WIDTH).equals(0.5f)) { + metadata.put(EntityData.BOUNDING_BOX_WIDTH, 0.25f); + metadata.put(EntityData.BOUNDING_BOX_HEIGHT, 0.9875f); + } + } else if (metadata.get(EntityData.BOUNDING_BOX_WIDTH) != null && metadata.get(EntityData.BOUNDING_BOX_WIDTH).equals(0.25f)) { + metadata.put(EntityData.BOUNDING_BOX_WIDTH, entityType.getWidth()); + metadata.put(EntityData.BOUNDING_BOX_HEIGHT, entityType.getHeight()); + } + + // setMarker + if ((xd & 0x10) == 0x10 && (metadata.get(EntityData.BOUNDING_BOX_WIDTH) != null && !metadata.get(EntityData.BOUNDING_BOX_WIDTH).equals(0.0f))) { + metadata.put(EntityData.BOUNDING_BOX_WIDTH, 0.0f); + metadata.put(EntityData.BOUNDING_BOX_HEIGHT, 0.0f); } } super.updateBedrockMetadata(entityMetadata, session); diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/SquidEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/SquidEntity.java new file mode 100644 index 000000000..81c0eeef1 --- /dev/null +++ b/connector/src/main/java/org/geysermc/connector/entity/living/SquidEntity.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @author GeyserMC + * @link https://github.com/GeyserMC/Geyser + */ + +package org.geysermc.connector.entity.living; + +import com.nukkitx.math.vector.Vector3f; +import org.geysermc.connector.entity.type.EntityType; + +public class SquidEntity extends WaterEntity { + + public SquidEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) { + super(entityId, geyserId, entityType, position, motion, rotation); + } +} diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/WaterEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/WaterEntity.java index dc83847a1..69afd9754 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/WaterEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/WaterEntity.java @@ -26,11 +26,14 @@ package org.geysermc.connector.entity.living; import com.nukkitx.math.vector.Vector3f; +import com.nukkitx.protocol.bedrock.data.EntityData; import org.geysermc.connector.entity.type.EntityType; public class WaterEntity extends CreatureEntity { public WaterEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) { super(entityId, geyserId, entityType, position, motion, rotation); + + metadata.put(EntityData.AIR, (short) 400); } } diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/GuardianEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/GuardianEntity.java index 682b02b24..3abbebbac 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/monster/GuardianEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/GuardianEntity.java @@ -42,6 +42,10 @@ public class GuardianEntity extends MonsterEntity { public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { if (entityMetadata.getId() == 16) { Entity entity = session.getEntityCache().getEntityByJavaId((int) entityMetadata.getValue()); + if (entity == null && session.getPlayerEntity().getEntityId() == (Integer) entityMetadata.getValue()) { + entity = session.getPlayerEntity(); + } + if (entity != null) { metadata.put(EntityData.TARGET_EID, entity.getGeyserId()); } diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/WitherEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/WitherEntity.java new file mode 100644 index 000000000..062f4388d --- /dev/null +++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/WitherEntity.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @author GeyserMC + * @link https://github.com/GeyserMC/Geyser + */ + +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 org.geysermc.connector.entity.Entity; +import org.geysermc.connector.entity.attribute.Attribute; +import org.geysermc.connector.entity.attribute.AttributeType; +import org.geysermc.connector.entity.type.EntityType; +import org.geysermc.connector.network.session.GeyserSession; + +public class WitherEntity extends MonsterEntity { + + public WitherEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) { + super(entityId, geyserId, entityType, position, motion, rotation); + + // After WITHER_AERIAL_ATTACK gets fixed in NukkitX/Protocol this can be uncommented + // It hides the withers shield + //metadata.put(EntityData.WITHER_AERIAL_ATTACK, (short) 1); + } + + @Override + public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { + long targetID = -1; + + if (entityMetadata.getId() >= 15 && entityMetadata.getId() <= 17) { + Entity entity = session.getEntityCache().getEntityByJavaId((int) entityMetadata.getValue()); + if (entity == null && session.getPlayerEntity().getEntityId() == (Integer) entityMetadata.getValue()) { + entity = session.getPlayerEntity(); + } + + if (entity != null) { + targetID = entity.getGeyserId(); + } + } + + if (entityMetadata.getId() == 15) { + metadata.put(EntityData.WITHER_TARGET_1, targetID); + } else if (entityMetadata.getId() == 16) { + metadata.put(EntityData.WITHER_TARGET_2, targetID); + } else if (entityMetadata.getId() == 17) { + metadata.put(EntityData.WITHER_TARGET_3, targetID); + } else if (entityMetadata.getId() == 18) { + metadata.put(EntityData.WITHER_INVULNERABLE_TICKS, (int) entityMetadata.getValue()); + + // Show the shield for the first few seconds of spawning (like Java) + if ((int) entityMetadata.getValue() >= 175) { + //metadata.put(EntityData.WITHER_AERIAL_ATTACK, (short) 0); + } else { + //metadata.put(EntityData.WITHER_AERIAL_ATTACK, (short) 1); + } + } + + // If less than 50% health show shield + Attribute health = attributes.get(AttributeType.HEALTH); + if ((health.getValue() <= health.getMaximum() / 2) || health.getMaximum() == 300f) { + //metadata.put(EntityData.WITHER_AERIAL_ATTACK, (short) 0); + } else { + //metadata.put(EntityData.WITHER_AERIAL_ATTACK, (short) 1); + } + + 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 1173796ff..5ab4eb1ae 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 @@ -47,7 +47,7 @@ public enum EntityType { WOLF(WolfEntity.class, 14, 0.85f, 0.6f), VILLAGER(VillagerEntity.class, 15, 1.8f, 0.6f, 0.6f, 1.62f, "minecraft:villager_v2"), MOOSHROOM(AnimalEntity.class, 16, 1.4f, 0.9f), - SQUID(WaterEntity.class, 17, 0.8f), + SQUID(SquidEntity.class, 17, 0.8f), 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), @@ -83,7 +83,7 @@ public enum EntityType { GUARDIAN(GuardianEntity.class, 49, 0.85f), ELDER_GUARDIAN(GuardianEntity.class, 50, 1.9975f), NPC(PlayerEntity.class, 51, 1.8f, 0.6f, 0.6f, 1.62f), - WITHER(MonsterEntity.class, 52, 3.5f, 0.9f), + WITHER(WitherEntity.class, 52, 3.5f, 0.9f), ENDER_DRAGON(EnderDragonEntity.class, 53, 4f, 13f), SHULKER(ShulkerEntity.class, 54, 1f, 1f), ENDERMITE(MonsterEntity.class, 55, 0.3f, 0.4f), @@ -94,7 +94,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(ArmorStandEntity.class, 61, 0f), + ARMOR_STAND(ArmorStandEntity.class, 61, 1.975f, 0.5f), 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), @@ -103,41 +103,41 @@ public enum EntityType { MOVING_BLOCK(Entity.class, 67, 0f), EXPERIENCE_BOTTLE(ThrowableEntity.class, 68, 0.25f, 0.25f, 0f, 0f, "minecraft:xp_bottle"), EXPERIENCE_ORB(ExpOrbEntity.class, 69, 0f, 0f, 0f, 0f, "minecraft:xp_orb"), - EYE_OF_ENDER(Entity.class, 70, 0f), + EYE_OF_ENDER(Entity.class, 70, 0.25f), END_CRYSTAL(EnderCrystalEntity.class, 71, 0f, 0f, 0f, 0f, "minecraft:ender_crystal"), - FIREWORK_ROCKET(Entity.class, 72, 0f), + FIREWORK_ROCKET(Entity.class, 72, 0.25f), TRIDENT(ArrowEntity.class, 73, 0f), TURTLE(AnimalEntity.class, 74, 0.4f, 1.2f), CAT(CatEntity.class, 75, 0.35f, 0.3f), - SHULKER_BULLET(Entity.class, 76, 0f), + SHULKER_BULLET(Entity.class, 76, 0.3125f), FISHING_BOBBER(FishingHookEntity.class, 77, 0f, 0f, 0f, 0f, "minecraft:fishing_hook"), CHALKBOARD(Entity.class, 78, 0f), - DRAGON_FIREBALL(ItemedFireballEntity.class, 79, 0f), + DRAGON_FIREBALL(ItemedFireballEntity.class, 79, 1.0f), ARROW(ArrowEntity.class, 80, 0.25f, 0.25f), - SNOWBALL(ThrowableEntity.class, 81, 0f), - EGG(ThrowableEntity.class, 82, 0f), + SNOWBALL(ThrowableEntity.class, 81, 0.25f), + EGG(ThrowableEntity.class, 82, 0.25f), PAINTING(PaintingEntity.class, 83, 0f), - MINECART(MinecartEntity.class, 84, 0f), - FIREBALL(ItemedFireballEntity.class, 85, 0f), - POTION(ThrowableEntity.class, 86, 0f), - ENDER_PEARL(ThrowableEntity.class, 87, 0f), - LEASH_KNOT(Entity.class, 88, 0f), - WITHER_SKULL(Entity.class, 89, 0f), + MINECART(MinecartEntity.class, 84, 0.7f, 0.98f), + FIREBALL(ItemedFireballEntity.class, 85, 1.0f), + POTION(ThrowableEntity.class, 86, 0.25f), + ENDER_PEARL(ThrowableEntity.class, 87, 0.25f), + LEASH_KNOT(Entity.class, 88, 0.5f, 0.375f), + WITHER_SKULL(Entity.class, 89, 0.3125f), BOAT(Entity.class, 90, 0.7f, 1.6f, 1.6f, 0.35f), WITHER_SKULL_DANGEROUS(Entity.class, 91, 0f), LIGHTNING_BOLT(Entity.class, 93, 0f), - SMALL_FIREBALL(ItemedFireballEntity.class, 94, 0f), - AREA_EFFECT_CLOUD(Entity.class, 95, 0f), - HOPPER_MINECART(MinecartEntity.class, 96, 0f), - TNT_MINECART(MinecartEntity.class, 97, 0f), - CHEST_MINECART(MinecartEntity.class, 98, 0f), + SMALL_FIREBALL(ItemedFireballEntity.class, 94, 0.3125f), + AREA_EFFECT_CLOUD(AreaEffectCloudEntity.class, 95, 0.5f, 1.0f), + HOPPER_MINECART(MinecartEntity.class, 96, 0.7f, 0.98f), + TNT_MINECART(MinecartEntity.class, 97, 0.7f, 0.98f), + CHEST_MINECART(MinecartEntity.class, 98, 0.7f, 0.98f), - COMMAND_BLOCK_MINECART(MinecartEntity.class, 100, 0f), + COMMAND_BLOCK_MINECART(MinecartEntity.class, 100, 0.7f, 0.98f), LINGERING_POTION(ThrowableEntity.class, 101, 0f), - LLAMA_SPIT(Entity.class, 102, 0f), - EVOKER_FANGS(Entity.class, 103, 0f), - EVOKER(SpellcasterIllagerEntity.class, 104, 0f), - VEX(MonsterEntity.class, 105, 0f), + LLAMA_SPIT(Entity.class, 102, 0.25f), + EVOKER_FANGS(Entity.class, 103, 0.8f, 0.5f), + EVOKER(SpellcasterIllagerEntity.class, 104, 1.95f, 0.5f), + VEX(MonsterEntity.class, 105, 0.8f, 0.4f), ICE_BOMB(Entity.class, 106, 0f), BALLOON(Entity.class, 107, 0f), //TODO PUFFERFISH(PufferFishEntity.class, 108, 0.7f, 0.7f), @@ -163,7 +163,7 @@ public enum EntityType { private String identifier; EntityType(Class entityClass, int type, float height) { - this(entityClass, type, height, 0f); + this(entityClass, type, height, height); } EntityType(Class entityClass, int type, float height, float width) {