Skip to content

Commit

Permalink
feat: add info, proper structure
Browse files Browse the repository at this point in the history
  • Loading branch information
rootEnginear committed Nov 8, 2023
1 parent 6120150 commit eaf3ffe
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 48 deletions.
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
<img align="right" height="128" width="128" alt="" loading="lazy" decoding="async" src="./src/main/resources/icon.png"/>

# Playground
# Sort Chest

This is the beginning of awesome mods!
Organize your chests instantly with a single keystroke

> **Important**
> Required [Babric](https://github.com/Turnip-Labs/babric-instance-repo/releases) to run the mod.
## Features
## How to use

- Feature #1
- Feature #2
- Feature #3
1. Open a chest
2. Press a key:
- `S`: Sort (will also auto merge)
- `M`: Merge (try to merge stacks together)

## FAQ

### Server?

**Yes**, you can use the sort chest mod on a server. However, the item might jump for a while after sorting because the mod will emulate mouse clicks rather than directly changing the inventory data.

### How does the sort chest mod sort items?

Items are sorted by their item ID (ascending), followed by its metadata (like wool color code, ascending), and finally by its stack size (descending).
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ loader_version=0.14.19-babric.1-bta
# halplibe_version=2.3.0

# Mod
mod_version=1.0.0
mod_version=0.1.0
mod_group=rootenginear
mod_name=playground
mod_name=sortchest
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package rootenginear.playground;
package rootenginear.sortchest;

import net.fabricmc.api.ModInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Playground implements ModInitializer {
public class SortChest implements ModInitializer {
public static final String MOD_ID = "playground";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package rootenginear.playground.mixin;
package rootenginear.sortchest.mixin;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiChest;
Expand All @@ -13,9 +13,9 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import rootenginear.playground.Playground;
import rootenginear.playground.mixin.accessor.GuiChestAccessor;
import rootenginear.playground.mixin.accessor.GuiScreenAccessor;
import rootenginear.sortchest.SortChest;
import rootenginear.sortchest.mixin.accessor.GuiChestAccessor;
import rootenginear.sortchest.mixin.accessor.GuiScreenAccessor;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -95,20 +95,20 @@ private void sortItems(GuiContainer containerThis) {

int aMeta = a.getMetadata();
int zMeta = z.getMetadata();
Playground.LOGGER.info("Comparing " + a + " to " + z);
Playground.LOGGER.info("A meta: " + aMeta + ", Z meta: " + zMeta);
SortChest.LOGGER.info("Comparing " + a + " to " + z);
SortChest.LOGGER.info("A meta: " + aMeta + ", Z meta: " + zMeta);
if (aMeta != zMeta) return aMeta - zMeta;

Playground.LOGGER.info("Comparing " + a + " to " + z);
Playground.LOGGER.info("A size: " + a.stackSize + ", Z size: " + z.stackSize);
SortChest.LOGGER.info("Comparing " + a + " to " + z);
SortChest.LOGGER.info("A size: " + a.stackSize + ", Z size: " + z.stackSize);
return z.stackSize - a.stackSize;
}).collect(Collectors.toList());

for (int i = 0; i < countInvSlots; i++) {
ItemStack sortedItem = sorted.get(i);
if (sortedItem == null) break;

Playground.LOGGER.info(String.valueOf(sortedItem.stackSize));
SortChest.LOGGER.info(String.valueOf(sortedItem.stackSize));
}
for (int i = 0; i < countInvSlots; i++) {
ItemStack sortedItem = sorted.get(i);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package rootenginear.playground.mixin.accessor;
package rootenginear.sortchest.mixin.accessor;

import net.minecraft.client.gui.GuiChest;
import org.spongepowered.asm.mixin.Mixin;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package rootenginear.playground.mixin.accessor;
package rootenginear.sortchest.mixin.accessor;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
Expand Down
52 changes: 26 additions & 26 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
{
"schemaVersion": 1,
"id": "playground",
"version": "${version}",
"name": "Playground",
"description": "This is the beginning of awesome mods!",
"authors": [
"rootEnginear"
],
"schemaVersion": 1,
"id": "sortchest",
"version": "${version}",
"name": "Sort Chest",
"description": "Organize your chests instantly with a single keystroke",
"authors": [
"rootEnginear"
],
"icon": "icon.png",
"contact": {
"homepage": "https://github.com/rootEnginear/bta-rootenginear-mods",
"sources": "https://github.com/rootEnginear/bta-rootenginear-mods",
"issues": "https://github.com/rootEnginear/bta-rootenginear-mods/issues"
},
"license": "CC0-1.0",
"environment": "*",
"entrypoints": {
"main": [
"rootenginear.playground.Playground"
]
},
"mixins": [
"playground.mixins.json"
],
"depends": {
"fabricloader": ">=0.13.3"
}
"contact": {
"homepage": "https://github.com/rootEnginear/bta-rootenginear-mods",
"sources": "https://github.com/rootEnginear/bta-rootenginear-mods",
"issues": "https://github.com/rootEnginear/bta-rootenginear-mods/issues"
},
"license": "CC0-1.0",
"environment": "*",
"entrypoints": {
"main": [
"rootenginear.sortchest.SortChest"
]
},
"mixins": [
"playground.mixins.json"
],
"depends": {
"fabricloader": ">=0.13.3"
}
}
2 changes: 1 addition & 1 deletion src/main/resources/playground.mixins.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"required": true,
"minVersion": "0.8",
"package": "rootenginear.playground.mixin",
"package": "rootenginear.sortchest.mixin",
"compatibilityLevel": "JAVA_8",
"client": [
"GuiContainerMixin",
Expand Down

0 comments on commit eaf3ffe

Please sign in to comment.