Skip to content

Commit

Permalink
Made some tricks to improve performance in digital storages
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed Oct 26, 2023
1 parent 80cd05d commit 5f28126
Show file tree
Hide file tree
Showing 38 changed files with 804 additions and 138 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ mixin {
config "mixins.${mod_id}.rs.json"
config "mixins.${mod_id}.sophisticatedcore.json"
config "mixins.${mod_id}.storagenetwork.json"
config "mixins.${mod_id}.vaulthunters.json"
}

// Include resources generated by data generators.
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ mapping_version=1.18.2

# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
# Must match the String constant located in the main mod class annotated with @Mod.
mod_id=vaulthunters_jewel_sorting
mod_id=vault_hunters_jewel_sorting
# The human-readable display name for the mod.
mod_name=VaultHunters Jewel Sorting
mod_name=Vault Hunters Jewel Sorting
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=ECPL-2.0
mod_license=GNU-3.0
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
mod_group_id=lv.id.bonne.vaultjewelsorting
mod_group_id=lv.id.bonne.vaulthunters.jewelsorting
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
mod_authors=BONNe1704
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
Expand All @@ -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.2.0
mod_version=2.3.0
# The change Log
changelog=Initial Release
3 changes: 2 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ pluginManagement {
name = 'MinecraftForge'
url = 'https://maven.minecraftforge.net/'
}
maven { url "https://cursemaven.com" }
}
}

plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
}

rootProject.name = 'vaulthunters_jewel_sorting'
rootProject.name = 'vault_hunters_jewel_sorting'
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package lv.id.bonne.vaultjewelsorting;
package lv.id.bonne.vaulthunters.jewelsorting;


import com.mojang.logging.LogUtils;
import org.slf4j.Logger;

import iskallia.vault.gear.attribute.VaultGearAttribute;
import lv.id.bonne.vaultjewelsorting.config.Configuration;
import lv.id.bonne.vaultjewelsorting.utils.AttributeHelper;
import lv.id.bonne.vaulthunters.jewelsorting.utils.AttributeHelper;
import lv.id.bonne.vaulthunters.jewelsorting.config.Configuration;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.EventPriority;
Expand All @@ -13,13 +15,11 @@
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;

import org.slf4j.Logger;


/**
* The main class for Vault Jewels Sorting mod.
*/
@Mod("vaulthunters_jewel_sorting")
@Mod("vault_hunters_jewel_sorting")
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class VaultJewelSorting
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
//


package lv.id.bonne.vaultjewelsorting.ae2;
package lv.id.bonne.vaulthunters.jewelsorting.ae2;


import lv.id.bonne.vaultjewelsorting.config.MixinConfigPlugin;
import lv.id.bonne.vaulthunters.jewelsorting.config.MixinConfigPlugin;
import net.minecraftforge.fml.loading.LoadingModList;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//


package lv.id.bonne.vaultjewelsorting.ae2.mixin;
package lv.id.bonne.vaulthunters.jewelsorting.ae2.mixin;


import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -24,10 +24,11 @@
import iskallia.vault.init.ModItems;
import iskallia.vault.item.crystal.CrystalData;
import iskallia.vault.item.data.InscriptionData;
import lv.id.bonne.vaultjewelsorting.VaultJewelSorting;
import lv.id.bonne.vaultjewelsorting.utils.CustomVaultGearData;
import lv.id.bonne.vaultjewelsorting.utils.SortingHelper;
import lv.id.bonne.vaulthunters.jewelsorting.VaultJewelSorting;
import lv.id.bonne.vaulthunters.jewelsorting.utils.CustomVaultGearData;
import lv.id.bonne.vaulthunters.jewelsorting.utils.SortingHelper;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;


Expand Down Expand Up @@ -77,29 +78,68 @@ public final void comparator(SortOrder sortOrder,

if (leftWhat.getId() == ModItems.JEWEL.getRegistryName())
{
VaultGearData leftData = CustomVaultGearData.read(leftWhat.toTag().getCompound("tag"));
VaultGearData rightData = CustomVaultGearData.read(rightWhat.toTag().getCompound("tag"));
CompoundTag leftTag = leftWhat.toTag().getCompound("tag");
CompoundTag rightTag = rightWhat.toTag().getCompound("tag");

return switch (sortOrder) {
case NAME -> SortingHelper.compareJewels(leftName,
leftData,
rightName,
rightData,
VaultJewelSorting.CONFIGURATION.getJewelSortingByName(),
ascending);
case AMOUNT -> SortingHelper.compareJewels(leftName,
leftData,
rightName,
rightData,
VaultJewelSorting.CONFIGURATION.getJewelSortingByAmount(),
ascending);
case MOD -> SortingHelper.compareJewels(leftName,
leftData,
rightName,
rightData,
VaultJewelSorting.CONFIGURATION.getJewelSortingByMod(),
ascending);
};
if (!leftTag.contains("clientCache") ||
!leftTag.getCompound("clientCache").contains(SortingHelper.EXTRA_ATTRIBUTE_INDEX) ||
!leftTag.getCompound("clientCache").contains(SortingHelper.EXTRA_ATTRIBUTE_VALUE) ||
!leftTag.getCompound("clientCache").contains(SortingHelper.EXTRA_GEAR_LEVEL) ||
!leftTag.getCompound("clientCache").contains(SortingHelper.EXTRA_JEWEL_SIZE) ||
!rightTag.contains("clientCache") ||
!rightTag.getCompound("clientCache").contains(SortingHelper.EXTRA_ATTRIBUTE_INDEX) ||
!rightTag.getCompound("clientCache").contains(SortingHelper.EXTRA_ATTRIBUTE_VALUE) ||
!rightTag.getCompound("clientCache").contains(SortingHelper.EXTRA_GEAR_LEVEL) ||
!rightTag.getCompound("clientCache").contains(SortingHelper.EXTRA_JEWEL_SIZE))
{
// Client cache is not generated. Process everything manually.
VaultGearData leftData = CustomVaultGearData.read(leftTag);
VaultGearData rightData = CustomVaultGearData.read(rightTag);

return switch (sortOrder) {
case NAME -> SortingHelper.compareJewels(leftName,
leftData,
rightName,
rightData,
VaultJewelSorting.CONFIGURATION.getJewelSortingByName(),
ascending);
case AMOUNT -> SortingHelper.compareJewels(leftName,
leftData,
rightName,
rightData,
VaultJewelSorting.CONFIGURATION.getJewelSortingByAmount(),
ascending);
case MOD -> SortingHelper.compareJewels(leftName,
leftData,
rightName,
rightData,
VaultJewelSorting.CONFIGURATION.getJewelSortingByMod(),
ascending);
};
}
else
{
return switch (sortOrder) {
case NAME -> SortingHelper.compareJewels(leftName,
leftTag.getCompound("clientCache"),
rightName,
rightTag.getCompound("clientCache"),
VaultJewelSorting.CONFIGURATION.getJewelSortingByName(),
ascending);
case AMOUNT -> SortingHelper.compareJewels(leftName,
leftTag.getCompound("clientCache"),
rightName,
rightTag.getCompound("clientCache"),
VaultJewelSorting.CONFIGURATION.getJewelSortingByAmount(),
ascending);
case MOD -> SortingHelper.compareJewels(leftName,
leftTag.getCompound("clientCache"),
rightName,
rightTag.getCompound("clientCache"),
VaultJewelSorting.CONFIGURATION.getJewelSortingByMod(),
ascending);
};
}
}
else if (leftWhat.getId() == ModItems.INSCRIPTION.getRegistryName())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
//


package lv.id.bonne.vaultjewelsorting.config;
package lv.id.bonne.vaulthunters.jewelsorting.config;


import com.google.common.base.Enums;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import lv.id.bonne.vaultjewelsorting.utils.SortingHelper;
import lv.id.bonne.vaulthunters.jewelsorting.utils.SortingHelper;
import net.minecraftforge.common.ForgeConfigSpec;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//


package lv.id.bonne.vaultjewelsorting.config;
package lv.id.bonne.vaulthunters.jewelsorting.config;


import org.objectweb.asm.tree.ClassNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
//


package lv.id.bonne.vaultjewelsorting.qio;
package lv.id.bonne.vaulthunters.jewelsorting.qio;


import lv.id.bonne.vaultjewelsorting.config.MixinConfigPlugin;
import lv.id.bonne.vaulthunters.jewelsorting.config.MixinConfigPlugin;
import net.minecraftforge.fml.loading.LoadingModList;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//


package lv.id.bonne.vaultjewelsorting.qio.mixin;
package lv.id.bonne.vaulthunters.jewelsorting.qio.mixin;


import org.objectweb.asm.Opcodes;
Expand All @@ -17,6 +17,7 @@
import java.util.Comparator;

import iskallia.vault.gear.data.AttributeGearData;
import iskallia.vault.gear.data.GearDataCache;
import iskallia.vault.gear.data.VaultGearData;
import iskallia.vault.gear.item.VaultGearItem;
import iskallia.vault.item.InscriptionItem;
Expand All @@ -26,9 +27,8 @@
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 lv.id.bonne.vaulthunters.jewelsorting.VaultJewelSorting;
import lv.id.bonne.vaulthunters.jewelsorting.utils.SortingHelper;
import mekanism.common.inventory.ISlotClickHandler;
import mekanism.common.inventory.container.QIOItemViewerContainer;
import net.minecraft.client.gui.screens.Screen;
Expand Down Expand Up @@ -80,8 +80,8 @@ private Comparator<ISlotClickHandler.IScrollableSlot> redirectAscending(QIOItemV
{
String leftName = firstItem.getDisplayName().getString();
String rightName = secondItem.getDisplayName().getString();
VaultGearData leftData = VaultGearData.read(firstItem);
VaultGearData rightData = VaultGearData.read(secondItem);
GearDataCache leftData = GearDataCache.of(firstItem);
GearDataCache rightData = GearDataCache.of(secondItem);

return switch (instance) {
case NAME -> SortingHelper.compareJewels(leftName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
//


package lv.id.bonne.vaultjewelsorting.quark;
package lv.id.bonne.vaulthunters.jewelsorting.quark;


import lv.id.bonne.vaultjewelsorting.config.MixinConfigPlugin;
import lv.id.bonne.vaulthunters.jewelsorting.config.MixinConfigPlugin;
import net.minecraftforge.fml.loading.LoadingModList;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//


package lv.id.bonne.vaultjewelsorting.quark.mixin;
package lv.id.bonne.vaulthunters.jewelsorting.quark.mixin;


import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -23,8 +23,8 @@
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.SortingHelper;
import lv.id.bonne.vaulthunters.jewelsorting.VaultJewelSorting;
import lv.id.bonne.vaulthunters.jewelsorting.utils.SortingHelper;
import net.minecraft.world.item.ItemStack;
import vazkii.quark.base.handler.SortingHandler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
//


package lv.id.bonne.vaultjewelsorting.refinedstorage;
package lv.id.bonne.vaulthunters.jewelsorting.refinedstorage;


import lv.id.bonne.vaultjewelsorting.config.MixinConfigPlugin;
import lv.id.bonne.vaulthunters.jewelsorting.config.MixinConfigPlugin;
import net.minecraftforge.fml.loading.LoadingModList;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//


package lv.id.bonne.vaultjewelsorting.refinedstorage.mixin;
package lv.id.bonne.vaulthunters.jewelsorting.refinedstorage.mixin;


import com.refinedmods.refinedstorage.screen.grid.sorting.IdGridSorter;
Expand All @@ -16,6 +16,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import iskallia.vault.gear.data.AttributeGearData;
import iskallia.vault.gear.data.GearDataCache;
import iskallia.vault.gear.data.VaultGearData;
import iskallia.vault.gear.item.VaultGearItem;
import iskallia.vault.item.InscriptionItem;
Expand All @@ -25,8 +26,8 @@
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.SortingHelper;
import lv.id.bonne.vaulthunters.jewelsorting.VaultJewelSorting;
import lv.id.bonne.vaulthunters.jewelsorting.utils.SortingHelper;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.world.item.ItemStack;

Expand Down Expand Up @@ -68,9 +69,9 @@ public void compare(IGridStack left,
if (!VaultJewelSorting.CONFIGURATION.getJewelSortingByMod().isEmpty())
{
callbackInfoReturnable.setReturnValue(SortingHelper.compareJewels(left.getName(),
VaultGearData.read(leftStack),
GearDataCache.of(leftStack),
right.getName(),
VaultGearData.read(rightStack),
GearDataCache.of(rightStack),
VaultJewelSorting.CONFIGURATION.getJewelSortingByMod(),
sortingDirection == SortingDirection.ASCENDING));
callbackInfoReturnable.cancel();
Expand Down
Loading

0 comments on commit 5f28126

Please sign in to comment.