diff --git a/gradle.properties b/gradle.properties index 0a057ac..228e8ce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -51,6 +51,6 @@ sophisticated_backpacks_version=4637292 # The version of Sophisticated Backpacks Mod storage_network_version=3868680 # The mod version. See https://semver.org/ -mod_version=2.3.0 +mod_version=2.3.1 # The change Log changelog=Initial Release \ No newline at end of file diff --git a/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/ae2/mixin/MixinRepo.java b/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/ae2/mixin/MixinRepo.java index deb0d27..a551811 100644 --- a/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/ae2/mixin/MixinRepo.java +++ b/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/ae2/mixin/MixinRepo.java @@ -67,16 +67,26 @@ public final void comparator(SortOrder sortOrder, String leftName = leftWhat.getDisplayName().getString(); String rightName = rightWhat.getDisplayName().getString(); - if (!leftWhat.getId().equals(rightWhat.getId()) || + if (!leftWhat.getModId().equals(rightWhat.getModId())) + { + // some small cleanup. We want to sort only vault items. + return String.CASE_INSENSITIVE_ORDER.compare( + leftWhat.getModId(), + rightWhat.getModId()); + } + + int registryOrder = SortingHelper.compareRegistryNames( + leftWhat.getId(), + rightWhat.getId(), + ascending); + + if (registryOrder != 0 || !MixinRepo.isSortable(leftWhat.getId())) { // Use default string comparing - return ascending ? - String.CASE_INSENSITIVE_ORDER.compare(leftName, rightName) : - String.CASE_INSENSITIVE_ORDER.compare(rightName, leftName); + return registryOrder; } - - if (leftWhat.getId() == ModItems.JEWEL.getRegistryName()) + else if (leftWhat.getId() == ModItems.JEWEL.getRegistryName()) { CompoundTag leftTag = leftWhat.toTag().getCompound("tag"); CompoundTag rightTag = rightWhat.toTag().getCompound("tag"); diff --git a/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/qio/mixin/MixinQIOItemViewerContainerListSortType.java b/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/qio/mixin/MixinQIOItemViewerContainerListSortType.java index 385c2fb..886d714 100644 --- a/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/qio/mixin/MixinQIOItemViewerContainerListSortType.java +++ b/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/qio/mixin/MixinQIOItemViewerContainerListSortType.java @@ -13,7 +13,6 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; - import java.util.Comparator; import iskallia.vault.gear.data.AttributeGearData; @@ -74,8 +73,25 @@ private Comparator redirectAscending(QIOItemV ItemStack firstItem = stack1.getItem().getStack(); ItemStack secondItem = stack2.getItem().getStack(); - // if shift is down, or sorting by mod, then skip everything. - if (firstItem.getItem() instanceof JewelItem && + if (!stack1.getModID().equals(stack2.getModID())) + { + // some small cleanup. We want to sort only vault items. + return String.CASE_INSENSITIVE_ORDER.compare( + stack1.getModID(), + stack2.getModID()); + } + + int registryOrder = SortingHelper.compareRegistryNames( + firstItem.getItem().getRegistryName(), + secondItem.getItem().getRegistryName(), + true); + + if (registryOrder != 0) + { + // Use default string comparing + return registryOrder; + } + else if (firstItem.getItem() instanceof JewelItem && secondItem.getItem() instanceof JewelItem) { String leftName = firstItem.getDisplayName().getString(); @@ -259,8 +275,25 @@ private Comparator redirectDescending(QIOItem ItemStack firstItem = stack1.getItem().getStack(); ItemStack secondItem = stack2.getItem().getStack(); - // if shift is down, or sorting by mod, then skip everything. - if (firstItem.getItem() instanceof JewelItem && + if (!stack1.getModID().equals(stack2.getModID())) + { + // some small cleanup. We want to sort only vault items. + return String.CASE_INSENSITIVE_ORDER.compare( + stack2.getModID(), + stack1.getModID()); + } + + int registryOrder = SortingHelper.compareRegistryNames( + firstItem.getItem().getRegistryName(), + secondItem.getItem().getRegistryName(), + false); + + if (registryOrder != 0) + { + // Use default string comparing + return registryOrder; + } + else if (firstItem.getItem() instanceof JewelItem && secondItem.getItem() instanceof JewelItem) { String leftName = firstItem.getDisplayName().getString(); diff --git a/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/refinedstorage/mixin/MixinIdGridSorter.java b/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/refinedstorage/mixin/MixinIdGridSorter.java index e243703..e71af04 100644 --- a/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/refinedstorage/mixin/MixinIdGridSorter.java +++ b/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/refinedstorage/mixin/MixinIdGridSorter.java @@ -63,7 +63,17 @@ public void compare(IGridStack left, if (left.getIngredient() instanceof ItemStack leftStack && right.getIngredient() instanceof ItemStack rightStack) { - if (leftStack.getItem() instanceof JewelItem && + int registryOrder = SortingHelper.compareRegistryNames( + leftStack.getItem().getRegistryName(), + rightStack.getItem().getRegistryName(), + sortingDirection == SortingDirection.ASCENDING); + + if (registryOrder != 0) + { + // If registry order is not 0, then return it. + callbackInfoReturnable.setReturnValue(registryOrder); + } + else if (leftStack.getItem() instanceof JewelItem && rightStack.getItem() instanceof JewelItem) { if (!VaultJewelSorting.CONFIGURATION.getJewelSortingByMod().isEmpty()) diff --git a/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/refinedstorage/mixin/MixinQuantityGridSorter.java b/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/refinedstorage/mixin/MixinQuantityGridSorter.java index 61949c6..abca86a 100644 --- a/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/refinedstorage/mixin/MixinQuantityGridSorter.java +++ b/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/refinedstorage/mixin/MixinQuantityGridSorter.java @@ -60,10 +60,30 @@ public void compare(IGridStack left, return; } + if (!left.getModId().equals(right.getModId())) + { + // some small cleanup. We want to sort only vault items. + callbackInfoReturnable.setReturnValue( + String.CASE_INSENSITIVE_ORDER.compare(left.getModId(), right.getModId())); + return; + } + if (left.getIngredient() instanceof ItemStack leftStack && right.getIngredient() instanceof ItemStack rightStack) { - if (leftStack.getItem() instanceof JewelItem && + // Get item registry names. + + int registryOrder = SortingHelper.compareRegistryNames( + leftStack.getItem().getRegistryName(), + rightStack.getItem().getRegistryName(), + sortingDirection == SortingDirection.ASCENDING); + + if (registryOrder != 0) + { + // If registry order is not 0, then return it. + callbackInfoReturnable.setReturnValue(registryOrder); + } + else if (leftStack.getItem() instanceof JewelItem && rightStack.getItem() instanceof JewelItem) { if (!VaultJewelSorting.CONFIGURATION.getJewelSortingByAmount().isEmpty()) @@ -75,7 +95,6 @@ public void compare(IGridStack left, GearDataCache.of(rightStack), VaultJewelSorting.CONFIGURATION.getJewelSortingByAmount(), sortingDirection == SortingDirection.ASCENDING)); - callbackInfoReturnable.cancel(); } } else if (leftStack.getItem() instanceof ToolItem && @@ -100,7 +119,6 @@ else if (leftStack.getItem() instanceof VaultGearItem && VaultGearData.read(rightStack), VaultJewelSorting.CONFIGURATION.getGearSortingByAmount(), sortingDirection == SortingDirection.ASCENDING)); - callbackInfoReturnable.cancel(); } } else if (leftStack.getItem() instanceof InscriptionItem && @@ -114,7 +132,6 @@ else if (leftStack.getItem() instanceof InscriptionItem && InscriptionData.from(rightStack), VaultJewelSorting.CONFIGURATION.getInscriptionSortingByAmount(), sortingDirection == SortingDirection.ASCENDING)); - callbackInfoReturnable.cancel(); } } else if (leftStack.getItem() instanceof VaultCrystalItem && @@ -129,7 +146,6 @@ else if (leftStack.getItem() instanceof VaultCrystalItem && CrystalData.read(rightStack), VaultJewelSorting.CONFIGURATION.getVaultCrystalSortingByAmount(), sortingDirection == SortingDirection.ASCENDING)); - callbackInfoReturnable.cancel(); } } else if (leftStack.getItem() instanceof TrinketItem && @@ -146,7 +162,6 @@ else if (leftStack.getItem() instanceof TrinketItem && rightStack.getTag(), VaultJewelSorting.CONFIGURATION.getTrinketSortingByAmount(), sortingDirection == SortingDirection.ASCENDING)); - callbackInfoReturnable.cancel(); } } } diff --git a/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/sophisticatedcore/mixin/MixinInventorySorter.java b/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/sophisticatedcore/mixin/MixinInventorySorter.java index dc57a03..e5ff874 100644 --- a/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/sophisticatedcore/mixin/MixinInventorySorter.java +++ b/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/sophisticatedcore/mixin/MixinInventorySorter.java @@ -31,7 +31,17 @@ private static Comparator> compareJewels(Compar { return original.thenComparing((first, second) -> { - if (first.getKey().getStack().getItem() instanceof JewelItem && + int registryOrder = SortingHelper.compareRegistryNames( + first.getKey().getStack().getItem().getRegistryName(), + second.getKey().getStack().getItem().getRegistryName(), + true); + + if (registryOrder != 0) + { + // Use default string comparing + return registryOrder; + } + else if (first.getKey().getStack().getItem() instanceof JewelItem && second.getKey().getStack().getItem() instanceof JewelItem) { return SortingHelper.compareJewels( @@ -110,7 +120,17 @@ else if (first.getKey().getStack().getItem() instanceof TrinketItem && { return original.thenComparing((first, second) -> { - if (first.getKey().getStack().getItem() instanceof JewelItem && + int registryOrder = SortingHelper.compareRegistryNames( + first.getKey().getStack().getItem().getRegistryName(), + second.getKey().getStack().getItem().getRegistryName(), + true); + + if (registryOrder != 0) + { + // Use default string comparing + return registryOrder; + } + else if (first.getKey().getStack().getItem() instanceof JewelItem && second.getKey().getStack().getItem() instanceof JewelItem) { return SortingHelper.compareJewels( diff --git a/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/storagenetwork/mixin/MixinNetworkWidget.java b/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/storagenetwork/mixin/MixinNetworkWidget.java index 51d242a..657424f 100644 --- a/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/storagenetwork/mixin/MixinNetworkWidget.java +++ b/src/main/java/lv/id/bonne/vaulthunters/jewelsorting/storagenetwork/mixin/MixinNetworkWidget.java @@ -57,8 +57,17 @@ private Comparator sortStackWrappersJewelCompare(Comparator SortingHelper.compareString(leftName, rightName); case LEVEL -> Integer.compare(leftData.getLevel(), rightData.getLevel()); - case TYPE -> leftData.getObjective().getClass().getName(). - compareTo(rightData.getObjective().getClass().getName()); + case TYPE -> SortingHelper.compareString( + leftData.getObjective().getClass().getName(), + rightData.getObjective().getClass().getName()); }; } @@ -334,8 +358,9 @@ public static int compareTrinkets(String leftName, if (leftValue.isPresent() && rightValue.isPresent()) { - yield leftValue.get().getTrinketConfig().getName(). - compareTo(rightValue.get().getTrinketConfig().getName()); + yield SortingHelper.compareString( + leftValue.get().getTrinketConfig().getName(), + rightValue.get().getTrinketConfig().getName()); } else { @@ -351,8 +376,9 @@ public static int compareTrinkets(String leftName, { if (leftValue.get().getConfig().hasCuriosSlot() && rightValue.get().getConfig().hasCuriosSlot()) { - yield leftValue.get().getConfig().getCuriosSlot(). - compareTo(rightValue.get().getConfig().getCuriosSlot()); + yield SortingHelper.compareString( + leftValue.get().getConfig().getCuriosSlot(), + rightValue.get().getConfig().getCuriosSlot()); } else { @@ -620,7 +646,7 @@ private static int compareRarity(VaultGearData leftData, VaultGearData rightData if (leftIndex == rightIndex) { // sort by name - return leftRoll.compareTo(rightRoll); + return SortingHelper.compareString(leftRoll, rightRoll); } else { @@ -1049,4 +1075,28 @@ public enum TrinketOptions * The name of the cache. */ public static final String EXTRA_GEAR_LEVEL = "extra_gear_level"; + + public static final Set VAULT_GEAR_SET = new HashSet<>(); + + // Put all vault gear items into the set. + static + { + VAULT_GEAR_SET.add(ModItems.HELMET.getRegistryName()); + VAULT_GEAR_SET.add(ModItems.CHESTPLATE.getRegistryName()); + VAULT_GEAR_SET.add(ModItems.LEGGINGS.getRegistryName()); + VAULT_GEAR_SET.add(ModItems.BOOTS.getRegistryName()); + + VAULT_GEAR_SET.add(ModItems.SWORD.getRegistryName()); + VAULT_GEAR_SET.add(ModItems.AXE.getRegistryName()); + + VAULT_GEAR_SET.add(ModItems.WAND.getRegistryName()); + VAULT_GEAR_SET.add(ModItems.SHIELD.getRegistryName()); + + VAULT_GEAR_SET.add(ModItems.MAGNET.getRegistryName()); + + VAULT_GEAR_SET.add(ModItems.IDOL_BENEVOLENT.getRegistryName()); + VAULT_GEAR_SET.add(ModItems.IDOL_OMNISCIENT.getRegistryName()); + VAULT_GEAR_SET.add(ModItems.IDOL_TIMEKEEPER.getRegistryName()); + VAULT_GEAR_SET.add(ModItems.IDOL_MALEVOLENCE.getRegistryName()); + } }