mirror of
https://github.com/GeyserMC/Geyser.git
synced 2025-12-19 14:59:27 +00:00
Fixed equipping armour/saddle cause the player to mount.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user