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 e4823b51e..1db5d2529 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/Entity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/Entity.java @@ -364,12 +364,6 @@ public class Entity { metadata.put(EntityData.PLAYER_FLAGS, (byte) 0); } break; - case 7: // blocking - if (entityMetadata.getType() == MetadataType.BYTE) { - byte xd = (byte) entityMetadata.getValue(); - metadata.getFlags().setFlag(EntityFlag.BLOCKING, (xd & 0x01) == 0x01); - } - break; } } diff --git a/connector/src/main/java/org/geysermc/connector/entity/LivingEntity.java b/connector/src/main/java/org/geysermc/connector/entity/LivingEntity.java index 01bd90423..ae9eaee5f 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/LivingEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/LivingEntity.java @@ -29,6 +29,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadat import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.AttributeData; import com.nukkitx.protocol.bedrock.data.entity.EntityData; +import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; import com.nukkitx.protocol.bedrock.data.inventory.ContainerId; import com.nukkitx.protocol.bedrock.data.inventory.ItemData; import com.nukkitx.protocol.bedrock.packet.MobArmorEquipmentPacket; @@ -39,6 +40,7 @@ import lombok.Setter; import org.geysermc.connector.entity.attribute.AttributeType; import org.geysermc.connector.entity.type.EntityType; import org.geysermc.connector.network.session.GeyserSession; +import org.geysermc.connector.network.translators.item.ItemRegistry; import org.geysermc.connector.utils.AttributeUtils; import java.util.ArrayList; @@ -63,6 +65,16 @@ public class LivingEntity extends Entity { @Override public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { switch (entityMetadata.getId()) { + case 7: // blocking + byte xd = (byte) entityMetadata.getValue(); + + //blocking gets triggered when using a bow, but if we set USING_ITEM for all items, it may look like + //you're "mining" with ex. a shield. + boolean isUsingShield = (getHand().getId() == ItemRegistry.SHIELD.getBedrockId() || + getHand().equals(ItemData.AIR) && getOffHand().getId() == ItemRegistry.SHIELD.getBedrockId()); + metadata.getFlags().setFlag(EntityFlag.USING_ITEM, (xd & 0x01) == 0x01 && !isUsingShield); + metadata.getFlags().setFlag(EntityFlag.BLOCKING, (xd & 0x01) == 0x01); + break; case 8: metadata.put(EntityData.HEALTH, entityMetadata.getValue()); break; diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/AbstractSkeletonEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/AbstractSkeletonEntity.java index ff98d3134..ff48d347f 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/monster/AbstractSkeletonEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/AbstractSkeletonEntity.java @@ -25,12 +25,25 @@ 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.entity.EntityData; import org.geysermc.connector.entity.type.EntityType; +import org.geysermc.connector.network.session.GeyserSession; public class AbstractSkeletonEntity extends MonsterEntity { public AbstractSkeletonEntity(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() == 14) { + byte xd = (byte) entityMetadata.getValue(); + // A bit of a loophole so the hands get raised - set the target ID to its own ID + metadata.put(EntityData.TARGET_EID, (xd == 4) ? geyserId : 0); + } + super.updateBedrockMetadata(entityMetadata, session); + } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java index d0597ebd3..6fc564729 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java @@ -55,13 +55,21 @@ public class ItemRegistry { public static final List ITEMS = new ArrayList<>(); public static final Int2ObjectMap ITEM_ENTRIES = new Int2ObjectOpenHashMap<>(); - // Boat ID, used in BedrockInventoryTransactionTranslator.java + /** + * Boat item entry, used in BedrockInventoryTransactionTranslator.java + */ public static ItemEntry BOAT; - // Gold ID, used in BedrockInventoryTransactionTranslator.java + /** + * Bucket item entry, used in BedrockInventoryTransactionTranslator.java + */ public static ItemEntry BUCKET; - // Gold ID, used in PiglinEntity.java + /** + * Gold item entry, used in PiglinEntity.java + */ public static ItemEntry GOLD; - // Shield ID, used in Entity.java + /** + * Shield item entry, used in Entity.java and LivingEntity.java + */ public static ItemEntry SHIELD; public static int BARRIER_INDEX = 0;