Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
YHDiamond committed Jun 14, 2024
1 parent ca37ac2 commit 4657c79
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public final class ItemTranslator {
* The order of these slots is their display order on Java Edition clients
*/
private static final EnumMap<ItemAttributeModifiers.EquipmentSlotGroup, String> SLOT_NAMES;
private static final ItemAttributeModifiers.EquipmentSlotGroup[] ARMOR_SLOT_NAMES = new ItemAttributeModifiers.EquipmentSlotGroup[] {
ItemAttributeModifiers.EquipmentSlotGroup.HEAD,
ItemAttributeModifiers.EquipmentSlotGroup.CHEST,
ItemAttributeModifiers.EquipmentSlotGroup.LEGS,
ItemAttributeModifiers.EquipmentSlotGroup.FEET
};
private static final DecimalFormat ATTRIBUTE_FORMAT = new DecimalFormat("0.#####");

static {
Expand Down Expand Up @@ -216,10 +222,9 @@ private static void addAttributeLore(ItemAttributeModifiers modifiers, BedrockIt
ItemAttributeModifiers.EquipmentSlotGroup slotGroup = entry.getSlot();
if (slotGroup == ItemAttributeModifiers.EquipmentSlotGroup.ARMOR) {
// modifier applies to all armor slots
slotsToModifiers.computeIfAbsent(ItemAttributeModifiers.EquipmentSlotGroup.HEAD, s -> new ArrayList<>()).add(loreEntry);
slotsToModifiers.computeIfAbsent(ItemAttributeModifiers.EquipmentSlotGroup.CHEST, s -> new ArrayList<>()).add(loreEntry);
slotsToModifiers.computeIfAbsent(ItemAttributeModifiers.EquipmentSlotGroup.LEGS, s -> new ArrayList<>()).add(loreEntry);
slotsToModifiers.computeIfAbsent(ItemAttributeModifiers.EquipmentSlotGroup.FEET, s -> new ArrayList<>()).add(loreEntry);
for (ItemAttributeModifiers.EquipmentSlotGroup slot : ARMOR_SLOT_NAMES) {
slotsToModifiers.computeIfAbsent(slot, s -> new ArrayList<>()).add(loreEntry);
}
} else if (slotGroup == ItemAttributeModifiers.EquipmentSlotGroup.ANY) {
// modifier applies to all slots implicitly
for (var slot : SLOT_NAMES.keySet()) {
Expand Down

0 comments on commit 4657c79

Please sign in to comment.