From 5b6faf9cfbc52f7e0afe1854060cc3abced8e9e5 Mon Sep 17 00:00:00 2001 From: oryxel1 Date: Mon, 15 Dec 2025 20:01:08 +0700 Subject: [PATCH] Fixed equipping armour/saddle cause the player to mount. --- .../org/geysermc/geyser/entity/type/Entity.java | 2 ++ .../geyser/entity/type/LivingEntity.java | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/Entity.java b/core/src/main/java/org/geysermc/geyser/entity/type/Entity.java index 90ee99e5f..abdb987af 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/Entity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/Entity.java @@ -71,6 +71,8 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEn import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEntityMetadata; import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand; import org.geysermc.mcprotocollib.protocol.data.game.entity.type.EntityType; +import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentTypes; +import org.geysermc.mcprotocollib.protocol.data.game.item.component.Equippable; import java.util.Collections; import java.util.EnumMap; diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/LivingEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/LivingEntity.java index 10207bbd4..a7d132e32 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/LivingEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/LivingEntity.java @@ -353,6 +353,13 @@ public class LivingEntity extends Entity { } } + final Equippable equippable = itemStack.getComponent(DataComponentTypes.EQUIPPABLE); + if (equippable != null && equippable.equipOnInteract() && this.isAlive()) { + if (isEquippableInSlot(itemStack, equippable.slot()) && getItemInSlot(equippable.slot()).isEmpty()) { + return InteractionResult.SUCCESS; + } + } + return super.interact(hand); } @@ -555,6 +562,15 @@ public class LivingEntity extends Entity { return false; } + public final boolean isEquippableInSlot(GeyserItemStack item, EquipmentSlot var2) { + Equippable equippable = item.getComponent(DataComponentTypes.EQUIPPABLE); + if (equippable == null) { + return var2 == EquipmentSlot.MAIN_HAND && this.canUseSlot(EquipmentSlot.MAIN_HAND); + } else { + return var2 == equippable.slot() && this.canUseSlot(equippable.slot()) && EntityUtils.equipmentUsableByEntity(session, equippable, this.definition.entityType()); + } + } + protected boolean canUseSlot(EquipmentSlot slot) { return true; }