mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-12 00:17:51 +00:00
Change Permutation Filter (#598)
Co-authored-by: slprime <history-21@yandex.ru>
This commit is contained in:
1 parent
af55a6b191
commit
0bbb889f39
21 files changed
+453
-251
No files matched your search
@@ -9,6 +9,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -222,6 +223,19 @@ public class ItemStackMap<T> {
|
||||
map.put(key, value);
|
||||
}
|
||||
|
||||
public T computeIfAbsent(ItemStack key, Function<ItemStack, ? extends T> mappingFunction) {
|
||||
T value;
|
||||
if ((value = get(key)) == null) {
|
||||
T newValue;
|
||||
if ((newValue = mappingFunction.apply(key)) != null) {
|
||||
put(key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
itemMap.clear();
|
||||
size = 0;
|
||||
|
||||
Reference in new issue
Block a user