From b7fe77c838bc2b3ed39813d6fcf2ab32abb1f076 Mon Sep 17 00:00:00 2001 From: Eclipse Date: Sat, 27 Sep 2025 08:37:47 +0000 Subject: [PATCH] Reduce usage of equipment map --- .../geyser/entity/type/living/CopperGolemEntity.java | 7 +++---- .../org/geysermc/geyser/entity/type/living/MobEntity.java | 6 ++++-- .../entity/type/living/animal/HappyGhastEntity.java | 8 ++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/CopperGolemEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/CopperGolemEntity.java index f6b9c997f..9a83ec6d4 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/CopperGolemEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/CopperGolemEntity.java @@ -62,7 +62,7 @@ public class CopperGolemEntity extends GolemEntity { @Override protected @NonNull InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) { - if (itemInHand.isEmpty() && !equipment.get(EquipmentSlot.MAIN_HAND).isEmpty()) { + if (itemInHand.isEmpty() && !getMainHandItem().isEmpty()) { return InteractiveTag.DROP_ITEM; } else if (itemInHand.is(Items.SHEARS) && canBeSheared()) { return InteractiveTag.SHEAR; @@ -79,8 +79,7 @@ public class CopperGolemEntity extends GolemEntity { @Override protected @NonNull InteractionResult mobInteract(@NonNull Hand usedHand, @NonNull GeyserItemStack itemInHand) { - if ((itemInHand.isEmpty() && !equipment.get(EquipmentSlot.MAIN_HAND).isEmpty()) - || (itemInHand.is(Items.SHEARS) && canBeSheared())) { + if ((itemInHand.isEmpty() && !getMainHandItem().isEmpty()) || (itemInHand.is(Items.SHEARS) && canBeSheared())) { return InteractionResult.SUCCESS; } @@ -88,7 +87,7 @@ public class CopperGolemEntity extends GolemEntity { } private boolean canBeSheared() { - return isAlive() && equipment.get(EquipmentSlot.HELMET).is(session, ItemTag.SHEARABLE_FROM_COPPER_GOLEM); + return isAlive() && getItemInSlot(EquipmentSlot.HELMET).is(session, ItemTag.SHEARABLE_FROM_COPPER_GOLEM); } @Override diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/MobEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/MobEntity.java index 558bffd99..64ceff2bb 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/MobEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/MobEntity.java @@ -120,8 +120,10 @@ public class MobEntity extends LivingEntity implements Leashable { } for (EquipmentSlot slot : EquipmentSlot.values()) { - GeyserItemStack equipped = equipment.get(slot); - if (equipped == null || equipped.isEmpty()) continue; + GeyserItemStack equipped = getItemInSlot(slot); + if (equipped.isEmpty()) { + continue; + } Equippable equippable = equipped.getComponent(DataComponentTypes.EQUIPPABLE); if (equippable != null && equippable.canBeSheared()) { diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/HappyGhastEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/HappyGhastEntity.java index bdd8fe305..47932bcb0 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/HappyGhastEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/HappyGhastEntity.java @@ -123,7 +123,7 @@ public class HappyGhastEntity extends AnimalEntity implements ClientVehicle { } else { if (!itemInHand.isEmpty()) { if (session.getTagCache().is(ItemTag.HARNESSES, itemInHand)) { - if (this.equipment.get(EquipmentSlot.BODY) == null) { + if (getItemInSlot(EquipmentSlot.BODY).isEmpty()) { // Harnesses the ghast return InteractiveTag.EQUIP_HARNESS; } @@ -135,7 +135,7 @@ public class HappyGhastEntity extends AnimalEntity implements ClientVehicle { } } - if (this.equipment.get(EquipmentSlot.BODY) != null && !session.isSneaking()) { + if (!getItemInSlot(EquipmentSlot.BODY).isEmpty() && !session.isSneaking()) { // Rides happy ghast return InteractiveTag.RIDE_HORSE; } else { @@ -152,7 +152,7 @@ public class HappyGhastEntity extends AnimalEntity implements ClientVehicle { } else { if (!itemInHand.isEmpty()) { if (session.getTagCache().is(ItemTag.HARNESSES, itemInHand)) { - if (this.equipment.get(EquipmentSlot.BODY) == null) { + if (getItemInSlot(EquipmentSlot.BODY).isEmpty()) { // Harnesses the ghast return InteractionResult.SUCCESS; } @@ -164,7 +164,7 @@ public class HappyGhastEntity extends AnimalEntity implements ClientVehicle { } } - if (this.equipment.get(EquipmentSlot.BODY) == null && !session.isSneaking()) { + if (!getItemInSlot(EquipmentSlot.BODY).isEmpty() && !session.isSneaking()) { // Rides happy ghast return InteractionResult.SUCCESS; } else {