1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2025-12-19 14:59:27 +00:00

Reduce usage of equipment map

This commit is contained in:
Eclipse
2025-09-27 08:37:47 +00:00
parent 21bb3df7df
commit b7fe77c838
3 changed files with 11 additions and 10 deletions

View File

@@ -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

View File

@@ -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()) {

View File

@@ -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 {