Skip to content

Commit

Permalink
Merge pull request #29 from sweetrpg/feature/27-sort-items
Browse files Browse the repository at this point in the history
#27 Sort items in craft queue and shopping list
  • Loading branch information
paulyhedral authored Nov 28, 2024
2 parents 60ae82c + a8ee876 commit cc7cede
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG/1.18/current.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- `[NEW]` Items in the queue and shopping list are now sorted by name
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ public class CraftQueueOverlay {
CraftTracker.LOGGER.trace("CRAFT_QUEUE");

var mgr = CraftingQueueManager.INSTANCE;
var products = mgr.getEndProducts();
var products = mgr.getEndProducts().stream().sorted((i1, i2) -> {
var item1 = ForgeRegistries.ITEMS.getValue(i1.getItemId());
var item2 = ForgeRegistries.ITEMS.getValue(i2.getItemId());
return item1.getDescription().getString().compareTo(item2.getDescription().getString());
}).toList();

switch(CTRuntime.INSTANCE.queueOverlayRequestedState) {
case SHOW:
Expand Down Expand Up @@ -129,8 +133,13 @@ public class CraftQueueOverlay {
CraftTracker.LOGGER.trace("yPos (after intermediates title): {}", yPos);

// items
for(int i = 0; i < mgr.getIntermediates().size(); i++) {
var inter = mgr.getIntermediates().get(i);
var sortedIntermediates = mgr.getIntermediates().stream().sorted((i1, i2) -> {
var item1 = ForgeRegistries.ITEMS.getValue(i1.getItemId());
var item2 = ForgeRegistries.ITEMS.getValue(i2.getItemId());
return item1.getDescription().getString().compareTo(item2.getDescription().getString());
}).toList();
for(int i = 0; i < sortedIntermediates.size(); i++) {
var inter = sortedIntermediates.get(i);

var item = ForgeRegistries.ITEMS.getValue(inter.getItemId());
var stack = item.getDefaultInstance();
Expand Down Expand Up @@ -179,8 +188,13 @@ public class CraftQueueOverlay {
CraftTracker.LOGGER.trace("yPos (after materials title): {}", yPos);

// items
for(int i = 0; i < mgr.getRawMaterials().size(); i++) {
var m = mgr.getRawMaterials().get(i);
var sortedMaterials = mgr.getRawMaterials().stream().sorted((i1, i2) -> {
var item1 = ForgeRegistries.ITEMS.getValue(i1.getItemId());
var item2 = ForgeRegistries.ITEMS.getValue(i2.getItemId());
return item1.getDescription().getString().compareTo(item2.getDescription().getString());
}).toList();
for(int i = 0; i < sortedMaterials.size(); i++) {
var m = sortedMaterials.get(i);

var item = ForgeRegistries.ITEMS.getValue(m.getItemId());
var stack = item.getDefaultInstance();
Expand Down Expand Up @@ -229,8 +243,13 @@ public class CraftQueueOverlay {
CraftTracker.LOGGER.trace("yPos: {}", yPos);

// items
for(int i = 0; i < mgr.getFuel().size(); i++) {
var f = mgr.getFuel().get(i);
var sortedFuels = mgr.getFuel().stream().sorted((i1, i2) -> {
var item1 = ForgeRegistries.ITEMS.getValue(i1.getItemId());
var item2 = ForgeRegistries.ITEMS.getValue(i2.getItemId());
return item1.getDescription().getString().compareTo(item2.getDescription().getString());
}).toList();
for(int i = 0; i < sortedFuels.size(); i++) {
var f = sortedFuels.get(i);

var item = ForgeRegistries.ITEMS.getValue(f.getItemId());
var stack = item.getDefaultInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,13 @@ public class ShoppingListOverlay {
var inventory = Minecraft.getInstance().player.getInventory();

// items
for(int i = 0; i < mgr.getItems().size(); i++) {
var m = mgr.getItems().get(i);
var sortedItems = mgr.getItems().stream().sorted((i1, i2) -> {
var item1 = ForgeRegistries.ITEMS.getValue(i1.getItemId());
var item2 = ForgeRegistries.ITEMS.getValue(i2.getItemId());
return item1.getDescription().getString().compareTo(item2.getDescription().getString());
}).toList();
for(int i = 0; i < sortedItems.size(); i++) {
var m = sortedItems.get(i);

var item = ForgeRegistries.ITEMS.getValue(m.getItemId());
var stack = item.getDefaultInstance();
Expand Down

0 comments on commit cc7cede

Please sign in to comment.