Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,23 @@ on: [pull_request, push]

jobs:
build:
strategy:
matrix:
# Use these Java versions
java: [
21, # Current Java LTS
]
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v4
uses: gradle/actions/wrapper-validation@v6
- name: setup jdk
uses: actions/setup-java@v5
with:
java-version: ${{ matrix.java }}
java-version: '25'
distribution: 'microsoft'
- name: make gradle wrapper executable
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ matrix.java == '21' }} # Only upload artifacts built from latest java
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: Artifacts
path: build/libs/
25 changes: 14 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version "${loom_version}"
id 'net.fabricmc.fabric-loom' version "${loom_version}"
id 'maven-publish'
}

Expand Down Expand Up @@ -35,17 +35,14 @@ loom {
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
implementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}")
implementation("com.terraformersmc:modmenu:${project.modmenu_version}")

modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
implementation("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_version}")
}

processResources {
Expand All @@ -57,7 +54,7 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 21
it.options.release = 25
}

java {
Expand All @@ -66,8 +63,8 @@ java {
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
}

jar {
Expand All @@ -94,4 +91,10 @@ publishing {
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}
15 changes: 7 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/develop

minecraft_version=1.21.11
yarn_mappings=1.21.11+build.4
loader_version=0.18.4
loom_version=1.14-SNAPSHOT
minecraft_version=26.1.1
loader_version=0.18.6
loom_version=1.16-SNAPSHOT

# Mod Properties
mod_version=1.1.4+1.21.11
mod_version=1.1.5+26.1.1
maven_group=borknbeans.lightweightinventorysorting
archives_base_name=lightweight-inventory-sorting

# Dependencies
fabric_version=0.141.1+1.21.11
modmenu_version=17.0.0-beta.2
cloth_version=21.11.153
fabric_version=0.145.4+26.1.1
modmenu_version=18.0.0-alpha.8
cloth_version=26.1.154
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
14 changes: 7 additions & 7 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-rc-3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -1,74 +1,74 @@
package borknbeans.lightweightinventorysorting;

import borknbeans.lightweightinventorysorting.config.Config;
import com.mojang.blaze3d.platform.InputConstants;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.option.KeyBinding.Category;
import net.minecraft.client.util.InputUtil;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemGroups;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;

import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.Identifier;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.lwjgl.glfw.GLFW;

import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class LightweightInventorySortingClient implements ClientModInitializer {

private final static Map<Item, Integer> CREATIVE_INDICES = new HashMap<>();

public static KeyBinding sortKeyBind;
private final static Map<Item, Integer> CREATIVE_INDICES = new HashMap<>();
// Define the category for your mod's keybindings
private static final KeyMapping.Category CATEGORY = KeyMapping.Category.register(
Identifier.fromNamespaceAndPath("lightweight-inventory-sorting", "lightweight-inventory-sorting"));
public static KeyMapping sortKeyBind;

@Override
public void onInitializeClient() {
Config.load();
registerKeyBindings();
}

private void registerKeyBindings() {
sortKeyBind = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.lightweight-inventory-sorting.sort",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_R,
Category.create(Identifier.of("category.lightweight-inventory-sorting.title"))
));
}
public static int getCreativeIndex(ItemStack itemStack) {
if (CREATIVE_INDICES.isEmpty()) {
reloadIndices();
}
return CREATIVE_INDICES.getOrDefault(itemStack.getItem(), 0);
}

public static int getCreativeIndex(ItemStack itemStack) {
if (CREATIVE_INDICES.isEmpty()) {
reloadIndices();
}
return CREATIVE_INDICES.getOrDefault(itemStack.getItem(), 0);
}
public static void reloadIndices() {
LightweightInventorySorting.LOGGER.info("Reloading item order for Lightweight Inventory Sorter");

/**
* Saves the creative inventory index of all registered items.
* This should run after all items have been registered.
*/
public static void reloadIndices() {
LightweightInventorySorting.LOGGER.info("Reloading item order for Lightweight Inventory Sorter");
Minecraft client = Minecraft.getInstance();
CreativeModeTab.ItemDisplayParameters context = new CreativeModeTab.ItemDisplayParameters(
client.player.connection.enabledFeatures(),
false,
client.level.registryAccess()
);

// For updating the groups (thanks EMI)
MinecraftClient client = MinecraftClient.getInstance();
ItemGroup.DisplayContext context = new ItemGroup.DisplayContext(client.player.networkHandler.getEnabledFeatures(), false, client.world.getRegistryManager());
CREATIVE_INDICES.clear();
List<ItemStack> items = new ArrayList<>();

CREATIVE_INDICES.clear();
for (CreativeModeTab group : CreativeModeTabs.allTabs()) {
if (group.getType() != CreativeModeTab.Type.SEARCH) {
group.buildContents(context);
items.addAll(group.getDisplayItems());
}
}

List<ItemStack> items = new ArrayList<>();
for (int i = 0; i < items.size(); i++) {
CREATIVE_INDICES.putIfAbsent(items.get(i).getItem(), i);
}
}

for (ItemGroup group : ItemGroups.getGroups()) {
if (group.getType() != ItemGroup.Type.SEARCH) {
group.updateEntries(context);
items.addAll(group.getSearchTabStacks());
}
}
@Override
public void onInitializeClient() {
Config.load();
registerKeyBindings();
}

for (int i = 0; i < items.size(); i++) {
CREATIVE_INDICES.putIfAbsent(items.get(i).getItem(), i);
}
private void registerKeyBindings() {
sortKeyBind = new KeyMapping(
"key.lightweight-inventory-sorting.sort",
InputConstants.Type.KEYSYM,
GLFW.GLFW_KEY_R,
CATEGORY
);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package borknbeans.lightweightinventorysorting.config;

import borknbeans.lightweightinventorysorting.LightweightInventorySorting;
import net.minecraft.util.Identifier;
import net.minecraft.resources.Identifier;

public enum ButtonSize {
SMALL,
Expand All @@ -23,7 +23,7 @@ public Identifier getButtonTexture() {
case LARGE -> "sort_button_large";
};

return Identifier.of(LightweightInventorySorting.MOD_ID, fileName);
return Identifier.fromNamespaceAndPath(LightweightInventorySorting.MOD_ID, fileName);
}

public Identifier getButtonHoverTexture() {
Expand All @@ -33,6 +33,6 @@ public Identifier getButtonHoverTexture() {
case LARGE -> "sort_button_large_hover";
};

return Identifier.of(LightweightInventorySorting.MOD_ID, fileName);
return Identifier.fromNamespaceAndPath(LightweightInventorySorting.MOD_ID, fileName);
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package borknbeans.lightweightinventorysorting.config;

import borknbeans.lightweightinventorysorting.LightweightInventorySorting;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.fabricmc.loader.api.FabricLoader;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import borknbeans.lightweightinventorysorting.LightweightInventorySorting;
import net.fabricmc.loader.api.FabricLoader;

public class Config {
private static final File CONFIG_FILE = new File(FabricLoader.getInstance().getConfigDir().toFile(), "lightweight-inventory-sorting.json");
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
Expand Down
Loading