Skip to content

Commit

Permalink
Implement trinket sorting in all sorters.
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed Oct 25, 2023
1 parent c0a04e3 commit 44da331
Show file tree
Hide file tree
Showing 8 changed files with 254 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import appeng.api.stacks.AEKey;
import appeng.client.gui.me.common.Repo;
import appeng.menu.me.common.GridInventoryEntry;
import iskallia.vault.gear.data.AttributeGearData;
import iskallia.vault.gear.data.VaultGearData;
import iskallia.vault.init.ModItems;
import iskallia.vault.item.crystal.CrystalData;
Expand Down Expand Up @@ -158,6 +159,38 @@ else if (leftWhat.getId() == ModItems.VAULT_CRYSTAL.getRegistryName())
ascending);
};
}
else if (leftWhat.getId() == ModItems.TRINKET.getRegistryName())
{
AttributeGearData leftData = CustomVaultGearData.read(leftWhat.toTag().getCompound("tag"));
AttributeGearData rightData = CustomVaultGearData.read(rightWhat.toTag().getCompound("tag"));

return switch (sortOrder) {
case NAME -> SortingHelper.compareTrinkets(leftName,
leftData,
leftWhat.toTag().getCompound("tag"),
rightName,
rightData,
rightWhat.toTag().getCompound("tag"),
VaultJewelSorting.CONFIGURATION.getTrinketSortingByName(),
ascending);
case AMOUNT -> SortingHelper.compareTrinkets(leftName,
leftData,
leftWhat.toTag().getCompound("tag"),
rightName,
rightData,
rightWhat.toTag().getCompound("tag"),
VaultJewelSorting.CONFIGURATION.getTrinketSortingByAmount(),
ascending);
case MOD -> SortingHelper.compareTrinkets(leftName,
leftData,
leftWhat.toTag().getCompound("tag"),
rightName,
rightData,
rightWhat.toTag().getCompound("tag"),
VaultJewelSorting.CONFIGURATION.getTrinketSortingByMod(),
ascending);
};
}
else
{
VaultGearData leftData = CustomVaultGearData.read(leftWhat.toTag().getCompound("tag"));
Expand Down Expand Up @@ -212,6 +245,7 @@ private static boolean isSortable(ResourceLocation id)
id.equals(ModItems.WAND.getRegistryName()) ||
id.equals(ModItems.MAGNET.getRegistryName()) ||
id.equals(ModItems.INSCRIPTION.getRegistryName()) ||
id.equals(ModItems.VAULT_CRYSTAL.getRegistryName());
id.equals(ModItems.VAULT_CRYSTAL.getRegistryName()) ||
id.equals(ModItems.TRINKET.getRegistryName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@

import java.util.Comparator;

import iskallia.vault.gear.data.AttributeGearData;
import iskallia.vault.gear.data.VaultGearData;
import iskallia.vault.gear.item.VaultGearItem;
import iskallia.vault.item.InscriptionItem;
import iskallia.vault.item.crystal.CrystalData;
import iskallia.vault.item.crystal.VaultCrystalItem;
import iskallia.vault.item.data.InscriptionData;
import iskallia.vault.item.gear.TrinketItem;
import iskallia.vault.item.tool.JewelItem;
import iskallia.vault.item.tool.ToolItem;
import lv.id.bonne.vaultjewelsorting.VaultJewelSorting;
import lv.id.bonne.vaultjewelsorting.utils.CustomVaultGearData;
import lv.id.bonne.vaultjewelsorting.utils.SortingHelper;
import mekanism.common.inventory.ISlotClickHandler;
import mekanism.common.inventory.container.QIOItemViewerContainer;
Expand Down Expand Up @@ -194,6 +197,42 @@ else if (firstItem.getItem() instanceof VaultCrystalItem &&
true);
};
}
else if (firstItem.getItem() instanceof TrinketItem &&
secondItem.getItem() instanceof TrinketItem)
{
String leftName = firstItem.getDisplayName().getString();
String rightName = secondItem.getDisplayName().getString();
AttributeGearData leftData = AttributeGearData.read(firstItem);
AttributeGearData rightData = AttributeGearData.read(secondItem);

return switch (instance)
{
case NAME -> SortingHelper.compareTrinkets(leftName,
leftData,
firstItem.getTag(),
rightName,
rightData,
secondItem.getTag(),
VaultJewelSorting.CONFIGURATION.getTrinketSortingByName(),
true);
case SIZE -> SortingHelper.compareTrinkets(leftName,
leftData,
firstItem.getTag(),
rightName,
rightData,
secondItem.getTag(),
VaultJewelSorting.CONFIGURATION.getTrinketSortingByAmount(),
true);
case MOD -> SortingHelper.compareTrinkets(leftName,
leftData,
firstItem.getTag(),
rightName,
rightData,
secondItem.getTag(),
VaultJewelSorting.CONFIGURATION.getTrinketSortingByMod(),
true);
};
}
else
{
return 0;
Expand Down Expand Up @@ -343,6 +382,41 @@ else if (firstItem.getItem() instanceof VaultCrystalItem &&
false);
};
}
else if (firstItem.getItem() instanceof TrinketItem &&
secondItem.getItem() instanceof TrinketItem)
{
String leftName = firstItem.getDisplayName().getString();
String rightName = secondItem.getDisplayName().getString();
AttributeGearData leftData = AttributeGearData.read(firstItem);
AttributeGearData rightData = AttributeGearData.read(secondItem);

return switch (instance) {
case NAME -> SortingHelper.compareTrinkets(leftName,
leftData,
firstItem.getTag(),
rightName,
rightData,
secondItem.getTag(),
VaultJewelSorting.CONFIGURATION.getTrinketSortingByName(),
false);
case SIZE -> SortingHelper.compareTrinkets(leftName,
leftData,
firstItem.getTag(),
rightName,
rightData,
secondItem.getTag(),
VaultJewelSorting.CONFIGURATION.getTrinketSortingByAmount(),
false);
case MOD -> SortingHelper.compareTrinkets(leftName,
leftData,
firstItem.getTag(),
rightName,
rightData,
secondItem.getTag(),
VaultJewelSorting.CONFIGURATION.getTrinketSortingByMod(),
false);
};
}
else
{
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import iskallia.vault.gear.data.AttributeGearData;
import iskallia.vault.gear.data.VaultGearData;
import iskallia.vault.gear.item.VaultGearItem;
import iskallia.vault.item.InscriptionItem;
import iskallia.vault.item.crystal.CrystalData;
import iskallia.vault.item.crystal.VaultCrystalItem;
import iskallia.vault.item.data.InscriptionData;
import iskallia.vault.item.gear.TrinketItem;
import iskallia.vault.item.tool.JewelItem;
import iskallia.vault.item.tool.ToolItem;
import lv.id.bonne.vaultjewelsorting.VaultJewelSorting;
Expand Down Expand Up @@ -129,6 +131,24 @@ else if (stack1.getItem() instanceof VaultCrystalItem &&
callbackInfoReturnable.cancel();
}
}
else if (stack1.getItem() instanceof TrinketItem &&
stack2.getItem() instanceof TrinketItem)
{
if (!VaultJewelSorting.CONFIGURATION.getTrinketSortingByName().isEmpty())
{
callbackInfoReturnable.setReturnValue(
SortingHelper.compareTrinkets(stack1.getDisplayName().getString(),
AttributeGearData.read(stack1),
stack1.getTag(),
stack2.getDisplayName().getString(),
AttributeGearData.read(stack2),
stack2.getTag(),
VaultJewelSorting.CONFIGURATION.getTrinketSortingByName(),
true));

callbackInfoReturnable.cancel();
}
}
}


Expand All @@ -141,6 +161,8 @@ else if (stack1.getItem() instanceof VaultCrystalItem &&
private static boolean hasCustomComparison(ItemStack stack)
{
return stack.getItem() instanceof VaultGearItem ||
stack.getItem() instanceof InscriptionItem;
stack.getItem() instanceof InscriptionItem ||
stack.getItem() instanceof VaultCrystalItem ||
stack.getItem() instanceof TrinketItem;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import iskallia.vault.gear.data.AttributeGearData;
import iskallia.vault.gear.data.VaultGearData;
import iskallia.vault.gear.item.VaultGearItem;
import iskallia.vault.item.InscriptionItem;
import iskallia.vault.item.crystal.CrystalData;
import iskallia.vault.item.crystal.VaultCrystalItem;
import iskallia.vault.item.data.InscriptionData;
import iskallia.vault.item.gear.TrinketItem;
import iskallia.vault.item.tool.JewelItem;
import iskallia.vault.item.tool.ToolItem;
import lv.id.bonne.vaultjewelsorting.VaultJewelSorting;
Expand Down Expand Up @@ -127,6 +129,23 @@ else if (leftStack.getItem() instanceof VaultCrystalItem &&
callbackInfoReturnable.cancel();
}
}
else if (leftStack.getItem() instanceof TrinketItem &&
rightStack.getItem() instanceof TrinketItem)
{
if (!VaultJewelSorting.CONFIGURATION.getTrinketSortingByMod().isEmpty())
{
callbackInfoReturnable.setReturnValue(
SortingHelper.compareTrinkets(leftStack.getDisplayName().getString(),
AttributeGearData.read(leftStack),
leftStack.getTag(),
rightStack.getDisplayName().getString(),
AttributeGearData.read(rightStack),
rightStack.getTag(),
VaultJewelSorting.CONFIGURATION.getTrinketSortingByMod(),
sortingDirection == SortingDirection.ASCENDING));
callbackInfoReturnable.cancel();
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import iskallia.vault.gear.data.AttributeGearData;
import iskallia.vault.gear.data.VaultGearData;
import iskallia.vault.gear.item.VaultGearItem;
import iskallia.vault.item.InscriptionItem;
import iskallia.vault.item.crystal.CrystalData;
import iskallia.vault.item.crystal.VaultCrystalItem;
import iskallia.vault.item.data.InscriptionData;
import iskallia.vault.item.gear.TrinketItem;
import iskallia.vault.item.tool.JewelItem;
import iskallia.vault.item.tool.ToolItem;
import lv.id.bonne.vaultjewelsorting.VaultJewelSorting;
Expand Down Expand Up @@ -127,6 +129,23 @@ else if (leftStack.getItem() instanceof VaultCrystalItem &&
callbackInfoReturnable.cancel();
}
}
else if (leftStack.getItem() instanceof TrinketItem &&
rightStack.getItem() instanceof TrinketItem)
{
if (!VaultJewelSorting.CONFIGURATION.getTrinketSortingByName().isEmpty())
{
callbackInfoReturnable.setReturnValue(
SortingHelper.compareTrinkets(leftStack.getDisplayName().getString(),
AttributeGearData.read(leftStack),
leftStack.getTag(),
rightStack.getDisplayName().getString(),
AttributeGearData.read(rightStack),
rightStack.getTag(),
VaultJewelSorting.CONFIGURATION.getTrinketSortingByName(),
sortingDirection == SortingDirection.ASCENDING));
callbackInfoReturnable.cancel();
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import iskallia.vault.gear.data.AttributeGearData;
import iskallia.vault.gear.data.VaultGearData;
import iskallia.vault.gear.item.VaultGearItem;
import iskallia.vault.item.InscriptionItem;
import iskallia.vault.item.crystal.CrystalData;
import iskallia.vault.item.crystal.VaultCrystalItem;
import iskallia.vault.item.data.InscriptionData;
import iskallia.vault.item.gear.TrinketItem;
import iskallia.vault.item.tool.JewelItem;
import iskallia.vault.item.tool.ToolItem;
import lv.id.bonne.vaultjewelsorting.VaultJewelSorting;
Expand Down Expand Up @@ -129,6 +131,23 @@ else if (leftStack.getItem() instanceof VaultCrystalItem &&
callbackInfoReturnable.cancel();
}
}
else if (leftStack.getItem() instanceof TrinketItem &&
rightStack.getItem() instanceof TrinketItem)
{
if (!VaultJewelSorting.CONFIGURATION.getTrinketSortingByAmount().isEmpty())
{
callbackInfoReturnable.setReturnValue(
SortingHelper.compareTrinkets(leftStack.getDisplayName().getString(),
AttributeGearData.read(leftStack),
leftStack.getTag(),
rightStack.getDisplayName().getString(),
AttributeGearData.read(rightStack),
rightStack.getTag(),
VaultJewelSorting.CONFIGURATION.getTrinketSortingByAmount(),
sortingDirection == SortingDirection.ASCENDING));
callbackInfoReturnable.cancel();
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import com.refinedmods.refinedstorage.screen.grid.sorting.SortingDirection;

import iskallia.vault.gear.data.AttributeGearData;
import iskallia.vault.gear.data.VaultGearData;
import iskallia.vault.gear.item.VaultGearItem;
import iskallia.vault.item.InscriptionItem;
import iskallia.vault.item.crystal.CrystalData;
import iskallia.vault.item.crystal.VaultCrystalItem;
import iskallia.vault.item.data.InscriptionData;
import iskallia.vault.item.gear.TrinketItem;
import iskallia.vault.item.tool.JewelItem;
import iskallia.vault.item.tool.ToolItem;
import lv.id.bonne.vaultjewelsorting.VaultJewelSorting;
Expand Down Expand Up @@ -87,6 +89,21 @@ else if (first.getKey().getStack().getItem() instanceof VaultCrystalItem &&
true);
}
}
else if (first.getKey().getStack().getItem() instanceof TrinketItem &&
second.getKey().getStack().getItem() instanceof TrinketItem)
{
if (!VaultJewelSorting.CONFIGURATION.getTrinketSortingByAmount().isEmpty())
{
return SortingHelper.compareTrinkets(first.getKey().getStack().getDisplayName().getString(),
AttributeGearData.read(first.getKey().getStack()),
first.getKey().getStack().getTag(),
second.getKey().getStack().getDisplayName().getString(),
AttributeGearData.read(second.getKey().getStack()),
second.getKey().getStack().getTag(),
VaultJewelSorting.CONFIGURATION.getTrinketSortingByAmount(),
true);
}
}

return 0;
});
Expand Down Expand Up @@ -151,6 +168,21 @@ else if (first.getKey().getStack().getItem() instanceof VaultCrystalItem &&
true);
}
}
else if (first.getKey().getStack().getItem() instanceof TrinketItem &&
second.getKey().getStack().getItem() instanceof TrinketItem)
{
if (!VaultJewelSorting.CONFIGURATION.getTrinketSortingByName().isEmpty())
{
return SortingHelper.compareTrinkets(first.getKey().getStack().getDisplayName().getString(),
AttributeGearData.read(first.getKey().getStack()),
first.getKey().getStack().getTag(),
second.getKey().getStack().getDisplayName().getString(),
AttributeGearData.read(second.getKey().getStack()),
second.getKey().getStack().getTag(),
VaultJewelSorting.CONFIGURATION.getTrinketSortingByName(),
true);
}
}

return 0;
});
Expand Down
Loading

0 comments on commit 44da331

Please sign in to comment.