Skip to content
Merged
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
22 changes: 20 additions & 2 deletions src/main/java/betterquesting/questing/party/PartyInventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.github.bsideup.jabel.Desugar;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -100,8 +102,24 @@ public PartyInventory(EntityPlayer mainPlayer, List<EntityPlayer> party) {
public ItemMatchContext getItemCountFor(BigItemStack req, boolean taskConsumes, boolean ignoreNBT, boolean partialMatch) {
var gatheredStacks = taskConsumes ? playerStacks : partyStacks;

// The stacks matched by Item
var subStacks = gatheredStacks.get(req.getHashKey());
List<IndexedItemStack> subStacks;
if (req.hasOreDict()) {
// Stacks matched by any ore-dict item
subStacks = new ArrayList<>();
var checkedHashes = new IntOpenHashSet();
for (ItemStack oreStack : req.getOreIngredient().getMatchingStacks()) {
int itemHash = BigItemStack.getHashKey(oreStack);
if (checkedHashes.add(itemHash)) {
var matchedSubStacks = gatheredStacks.get(itemHash);
if (matchedSubStacks != null) {
subStacks.addAll(matchedSubStacks);
}
}
}
} else {
// Stacks matched by base item
subStacks = gatheredStacks.get(req.getHashKey());
}
if (subStacks == null || subStacks.isEmpty()) {
return ItemMatchContext.EMPTY;
}
Expand Down