Skip to content

Commit

Permalink
Checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
paulyhedral committed Dec 4, 2024
1 parent 682696c commit 6cd0e6c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public class CraftQueueOverlay {
var mgr = CraftingQueueManager.INSTANCE;
var products = mgr.getEndProducts().stream().sorted((i1, i2) -> {
var item1 = ForgeRegistries.ITEMS.getValue(i1.getProductId());
if(item1 == null) return 0;
var item2 = ForgeRegistries.ITEMS.getValue(i2.getProductId());
if(item2 == null) return 0;
return item1.getDescription().getString().compareTo(item2.getDescription().getString());
}).toList();

Expand Down Expand Up @@ -103,6 +105,9 @@ public class CraftQueueOverlay {
var p = products.get(i);

var item = ForgeRegistries.ITEMS.getValue(p.getProductId());
if(item == null) {
continue;
}
var stack = item.getDefaultInstance();
var selectedRecipe = p.getRecipes().get(p.getIndex());
var amountProduced = selectedRecipe.getResultItem().getCount() * p.getIterations();
Expand Down Expand Up @@ -136,7 +141,9 @@ public class CraftQueueOverlay {
// items
var sortedIntermediates = mgr.getIntermediates().stream().sorted((i1, i2) -> {
var item1 = ForgeRegistries.ITEMS.getValue(i1.getItemId());
if(item1 == null) return 0;
var item2 = ForgeRegistries.ITEMS.getValue(i2.getItemId());
if(item2 == null) return 0;
return item1.getDescription().getString().compareTo(item2.getDescription().getString());
}).toList();
for(int i = 0; i < sortedIntermediates.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.nio.file.StandardOpenOption;
import java.text.MessageFormat;
import java.util.*;
import java.util.stream.Collectors;

public class CraftingQueueManager {

Expand Down Expand Up @@ -96,31 +95,30 @@ public void save(Player player) {
}

public List<CraftingQueueProduct> getEndProducts() {
return endProducts.entrySet()
return endProducts.values()
.stream()
.map(e -> e.getValue())
.toList();
}

public List<QueueItem> getIntermediates() {
return intermediateProducts.entrySet()
.stream()
.map(e -> new QueueItem(e.getKey(), e.getValue()))
.collect(Collectors.toUnmodifiableList());
.map(e -> new QueueItem(e.getKey(), false, e.getValue()))
.toList();
}

public List<QueueItem> getRawMaterials() {
return rawMaterials.entrySet()
.stream()
.map(e -> new QueueItem(e.getKey(), e.getValue()))
.collect(Collectors.toUnmodifiableList());
.map(e -> new QueueItem(e.getKey(), false, e.getValue()))
.toList();
}

public List<QueueItem> getFuel() {
return fuel.entrySet()
.stream()
.map(e -> new QueueItem(e.getKey(), e.getValue()))
.collect(Collectors.toUnmodifiableList());
.map(e -> new QueueItem(e.getKey(), false, e.getValue()))
.toList();
}

public void addProduct(Player player, ResourceLocation itemId, int quantity) {
Expand All @@ -130,7 +128,7 @@ public void addProduct(Player player, ResourceLocation itemId, int quantity) {

var recipes = RecipeUtil.getRecipesFor(itemId);

if(recipes.size() > 0) {
if(!recipes.isEmpty()) {
CraftTracker.LOGGER.debug("recipes: {}", recipes.stream().map(DebugUtil::printRecipe));

var product = new CraftingQueueProduct(itemId, recipes, quantity);
Expand Down Expand Up @@ -410,9 +408,10 @@ ComputedRecipe computeRecipe(Recipe<?> recipe, int iterations, int depth) {

public class QueueItem {
private ResourceLocation itemId;
private boolean tag;
private int quantity;

public QueueItem(ResourceLocation itemId, int quantity) {
public QueueItem(ResourceLocation itemId, boolean tag, int quantity) {
this.itemId = itemId;
this.quantity = quantity;
}
Expand All @@ -425,6 +424,14 @@ public void setItemId(ResourceLocation itemId) {
this.itemId = itemId;
}

public boolean isTag() {
return tag;
}

public void setTag(boolean tag) {
this.tag = tag;
}

public int getQuantity() {
return quantity;
}
Expand Down

0 comments on commit 6cd0e6c

Please sign in to comment.