-
Notifications
You must be signed in to change notification settings - Fork 551
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix AContainer can't find recipes with similar items
- Loading branch information
1 parent
45601c8
commit 004cbc7
Showing
2 changed files
with
59 additions
and
19 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/main/java/io/github/thebusybiscuit/slimefun4/utils/ItemUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.github.thebusybiscuit.slimefun4.utils; | ||
|
||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; | ||
import org.bukkit.Material; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class ItemUtils { | ||
public static int getAllItemAmount(@Nonnull ItemStack... itemStacks) { | ||
int amount = 0; | ||
for (ItemStack itemStack : itemStacks) { | ||
if (itemStack == null || itemStack.getType().isAir()) continue; | ||
amount += itemStack.getAmount(); | ||
} | ||
|
||
return amount; | ||
} | ||
|
||
public static int getAllItemTypeAmount(@Nonnull ItemStack... itemStacks) { | ||
Set<SlimefunItem> sfitems = new HashSet<>(); | ||
Set<Material> materials = new HashSet<>(); | ||
|
||
for (ItemStack itemStack : itemStacks) { | ||
if (itemStack == null || itemStack.getType().isAir()) continue; | ||
SlimefunItem sfitem = SlimefunItem.getByItem(itemStack); | ||
if (sfitem != null) sfitems.add(sfitem); | ||
else materials.add(itemStack.getType()); | ||
} | ||
|
||
return sfitems.size() + materials.size(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters