mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-21 12:42:10 +00:00
Recipe Group Optimization (#1054)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
9f3697bb67
commit
a685efb3b7
11 files changed
+654
-214
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package codechicken.nei.recipe.widget;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -50,6 +51,11 @@ public class PermutationsCycler<K> {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void invalidate() {
|
||||
this.favoriteRevision = -1;
|
||||
validate();
|
||||
}
|
||||
|
||||
public boolean contains(K key) {
|
||||
validate();
|
||||
return this.permutations.containsKey(key);
|
||||
@@ -79,6 +85,11 @@ public class PermutationsCycler<K> {
|
||||
return items;
|
||||
}
|
||||
|
||||
public int getFavoriteCount(K key) {
|
||||
get(key);
|
||||
return this.favoriteCounts.getOrDefault(key, 0);
|
||||
}
|
||||
|
||||
public ItemStack getCycled(K key, int cycle) {
|
||||
final List<ItemStack> items = get(key);
|
||||
final int favoriteCount = this.favoriteCounts.getOrDefault(key, 0);
|
||||
@@ -96,4 +107,10 @@ public class PermutationsCycler<K> {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Hash key with the same equality as NEIServerUtils.areStacksSameType
|
||||
public static Object getStackKey(ItemStack stack) {
|
||||
return Arrays
|
||||
.asList(stack.getItem(), stack.getHasSubtypes() ? stack.getItemDamage() : 0, stack.stackTagCompound);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user