Skip to content

Commit

Permalink
Implemented Antique sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed Aug 16, 2024
1 parent 8abb6d4 commit 95ab945
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,13 @@ else if (leftId == ModItems.BOOSTER_PACK.getRegistryName())
rightWhat.toTag().getCompound("tag"),
ascending);
}
else if (leftId == ModItems.ANTIQUE.getRegistryName())
{
return SortingHelper.compareAntique(
leftWhat.toTag().getCompound("tag"),
rightWhat.toTag().getCompound("tag"),
ascending);
}
else
{
VaultGearData leftData = CustomVaultGearData.read(leftWhat.toTag().getCompound("tag"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,13 @@ else if (firstItem.getItem() == ModItems.BOOSTER_PACK)
secondItem.getTag(),
ascending);
}
else if (firstItem.getItem() == ModItems.ANTIQUE)
{
return SortingHelper.compareAntique(
firstItem.getTag(),
secondItem.getTag(),
ascending);
}
else
{
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,14 @@ else if (stack1.getItem() == ModItems.CARD)

callbackInfoReturnable.cancel();
}
else if (stack1.getItem() == ModItems.ANTIQUE)
{
callbackInfoReturnable.setReturnValue(
SortingHelper.compareAntique(stack1.getTag(),
stack2.getTag(),
true));

callbackInfoReturnable.cancel();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@ else if (leftStack.getItem() == ModItems.BOOSTER_PACK)
rightStack.getTag(),
sortingDirection == SortingDirection.ASCENDING));
}
else if (leftStack.getItem() == ModItems.ANTIQUE)
{
callbackInfoReturnable.setReturnValue(
SortingHelper.compareAntique(
leftStack.getTag(),
rightStack.getTag(),
sortingDirection == SortingDirection.ASCENDING));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@ else if (leftStack.getItem() == ModItems.BOOSTER_PACK)
rightStack.getTag(),
sortingDirection == SortingDirection.ASCENDING));
}
else if (leftStack.getItem() == ModItems.ANTIQUE)
{
callbackInfoReturnable.setReturnValue(
SortingHelper.compareAntique(
leftStack.getTag(),
rightStack.getTag(),
sortingDirection == SortingDirection.ASCENDING));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,14 @@ else if (leftStack.getItem() == ModItems.BOOSTER_PACK)
rightStack.getTag(),
sortingDirection == SortingDirection.ASCENDING));
}
else if (leftStack.getItem() == ModItems.ANTIQUE)
{
callbackInfoReturnable.setReturnValue(
SortingHelper.compareAntique(
leftStack.getTag(),
rightStack.getTag(),
sortingDirection == SortingDirection.ASCENDING));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ else if (firstStack.getItem() == ModItems.BOOSTER_PACK)
secondStack.getTag(),
true);
}
else if (firstStack.getItem() == ModItems.ANTIQUE)
{
return SortingHelper.compareAntique(
firstStack.getTag(),
secondStack.getTag(),
true);
}

return 0;
});
Expand Down Expand Up @@ -383,6 +390,13 @@ else if (firstStack.getItem() == ModItems.BOOSTER_PACK)
secondStack.getTag(),
true);
}
else if (firstStack.getItem() == ModItems.ANTIQUE)
{
return SortingHelper.compareAntique(
firstStack.getTag(),
secondStack.getTag(),
true);
}

return 0;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ else if (first.getItem() == ModItems.BOOSTER_PACK)
{
return SortingHelper.compareBoosterPacks(first.getTag(), second.getTag(), true);
}
else if (first.getItem() == ModItems.ANTIQUE)
{
return SortingHelper.compareAntique(first.getTag(), second.getTag(), true);
}

return 0;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ else if (leftStack.getItem() == ModItems.BOOSTER_PACK)
rightStack.getTag(),
!this.reversed));
}
else if (leftStack.getItem() == ModItems.ANTIQUE)
{
callbackInfoReturnable.setReturnValue(
SortingHelper.compareAntique(
leftStack.getTag(),
rightStack.getTag(),
!this.reversed));
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,14 @@ else if (leftStack.getItem() == ModItems.BOOSTER_PACK)
rightStack.getTag(),
!this.reversed));
}
else if (leftStack.getItem() == ModItems.ANTIQUE)
{
callbackInfoReturnable.setReturnValue(
SortingHelper.compareAntique(
leftStack.getTag(),
rightStack.getTag(),
!this.reversed));
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,37 @@ else if (leftTag != null && leftTag.contains(DATA, Tag.TAG_COMPOUND))
}


/**
* This method compares antiques by their "id" tag value.
* @param leftTag The left tag of antique
* @param rightTag The right tag of antique
* @param ascending the order of sort
* @return the comparison of two given antiques tags.
*/
public static int compareAntique(CompoundTag leftTag, CompoundTag rightTag, boolean ascending)
{
int returnValue;

if (leftTag != null && rightTag != null)
{
returnValue = SortingHelper.compareString(
leftTag.getString(ANTIQUE),
rightTag.getString(ANTIQUE));
}
else if (leftTag != null)
{
returnValue = 1;

}
else
{
returnValue = -1;
}

return ascending ? returnValue : -returnValue;
}


// ---------------------------------------------------------------------
// Section: Internal Sorting Methods
// ---------------------------------------------------------------------
Expand Down Expand Up @@ -1802,6 +1833,11 @@ public enum CardOptions
*/
public static final String DATA = "data";

/**
* The antique variable
*/
public static final String ANTIQUE = "antique";

/**
* The name of the cache.
*/
Expand Down Expand Up @@ -1884,5 +1920,7 @@ public enum CardOptions
CUSTOM_SORTING.add(ModItems.CARD.getRegistryName());
CUSTOM_SORTING.add(ModItems.CARD_DECK.getRegistryName());
CUSTOM_SORTING.add(ModItems.BOOSTER_PACK.getRegistryName());

CUSTOM_SORTING.add(ModItems.ANTIQUE.getRegistryName());
}
}

0 comments on commit 95ab945

Please sign in to comment.