Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| da39d81d5f |
@@ -319,6 +319,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
this.searchField.setText(memoryText);
|
||||
this.searchField.selectAll();
|
||||
this.repo.setSearchString(memoryText);
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
@@ -380,6 +381,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
if (btn == 1 && this.searchField.isMouseIn(xCoord, yCoord)) {
|
||||
this.searchField.setText("");
|
||||
this.repo.setSearchString("");
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
@@ -474,6 +476,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
|
||||
if (this.searchField.textboxKeyTyped(character, key)) {
|
||||
this.repo.setSearchString(this.searchField.getText());
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
// tell forge the key event is handled and should not be sent out
|
||||
this.keyHandled = mouseInGui;
|
||||
|
||||
@@ -37,7 +37,7 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -45,7 +45,7 @@ import java.util.regex.Pattern;
|
||||
public class ItemRepo {
|
||||
|
||||
private final IItemList<IAEItemStack> list = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
private List<IAEItemStack> view = new ArrayList<>();
|
||||
private final ArrayList<IAEItemStack> view = new ArrayList<>();
|
||||
private final IScrollSource src;
|
||||
private final ISortSource sortSrc;
|
||||
|
||||
@@ -56,16 +56,6 @@ public class ItemRepo {
|
||||
private String innerSearch = "";
|
||||
private boolean hasPower;
|
||||
|
||||
private Enum lastView;
|
||||
private Enum lastSearchMode;
|
||||
private Enum lastSortBy;
|
||||
private Enum lastSortDir;
|
||||
private String lastSearch = "";
|
||||
|
||||
private boolean resort = true;
|
||||
private boolean changed = false;
|
||||
|
||||
|
||||
public ItemRepo(final IScrollSource src, final ISortSource sortSrc) {
|
||||
this.src = src;
|
||||
this.sortSrc = sortSrc;
|
||||
@@ -93,8 +83,6 @@ public class ItemRepo {
|
||||
} else {
|
||||
this.list.add(is);
|
||||
}
|
||||
|
||||
changed = true;
|
||||
}
|
||||
|
||||
public long getItemCount(final IAEItemStack is) {
|
||||
@@ -108,84 +96,18 @@ public class ItemRepo {
|
||||
}
|
||||
|
||||
public void updateView() {
|
||||
this.view.clear();
|
||||
|
||||
this.view.ensureCapacity(this.list.size());
|
||||
|
||||
final Enum viewMode = this.sortSrc.getSortDisplay();
|
||||
|
||||
if (lastView != viewMode) {
|
||||
resort = true;
|
||||
lastView = viewMode;
|
||||
}
|
||||
|
||||
final Enum searchMode = AEConfig.instance().getConfigManager().getSetting(Settings.SEARCH_MODE);
|
||||
if (lastSearchMode != searchMode) {
|
||||
resort = true;
|
||||
lastSearchMode = searchMode;
|
||||
}
|
||||
final boolean needsZeroCopy = viewMode == ViewItems.CRAFTABLE;
|
||||
|
||||
if (searchMode == SearchBoxMode.JEI_AUTOSEARCH || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH || searchMode == SearchBoxMode.JEI_AUTOSEARCH_KEEP || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH_KEEP) {
|
||||
this.updateJEI(this.searchString);
|
||||
}
|
||||
|
||||
if (!lastSearch.equals(searchString)) {
|
||||
resort = true;
|
||||
lastSearch = searchString;
|
||||
}
|
||||
|
||||
final Enum sortBy = this.sortSrc.getSortBy();
|
||||
final Enum sortDir = this.sortSrc.getSortDir();
|
||||
|
||||
if (lastSortBy != sortBy) {
|
||||
resort = true;
|
||||
lastSortBy = sortBy;
|
||||
}
|
||||
|
||||
if (lastSortDir != sortDir) {
|
||||
resort = true;
|
||||
lastSortDir = sortDir;
|
||||
}
|
||||
|
||||
if (changed || resort) {
|
||||
changed = false;
|
||||
resort = false;
|
||||
|
||||
view = new ArrayList<>();
|
||||
|
||||
ItemSorters.setDirection((appeng.api.config.SortDir) sortDir);
|
||||
ItemSorters.init();
|
||||
|
||||
Comparator<IAEItemStack> c = getComparator(sortBy);
|
||||
|
||||
for (IAEItemStack is : this.list) {
|
||||
addIAE(is, viewMode);
|
||||
}
|
||||
|
||||
view.sort(c);
|
||||
}
|
||||
}
|
||||
|
||||
private static Comparator<IAEItemStack> getComparator(Enum sortBy) {
|
||||
Comparator<IAEItemStack> c;
|
||||
|
||||
if (sortBy == SortOrder.MOD) {
|
||||
c = ItemSorters.CONFIG_BASED_SORT_BY_MOD;
|
||||
} else if (sortBy == SortOrder.AMOUNT) {
|
||||
c = ItemSorters.CONFIG_BASED_SORT_BY_SIZE;
|
||||
} else if (sortBy == SortOrder.INVTWEAKS) {
|
||||
if (InventoryBogoSortModule.isLoaded()) {
|
||||
c = InventoryBogoSortModule.COMPARATOR;
|
||||
} else {
|
||||
c = ItemSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS;
|
||||
}
|
||||
} else {
|
||||
c = ItemSorters.CONFIG_BASED_SORT_BY_NAME;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
private void addIAE(IAEItemStack is, Enum viewMode) {
|
||||
|
||||
final boolean needsZeroCopy = viewMode == ViewItems.CRAFTABLE;
|
||||
|
||||
final boolean terminalSearchToolTips = AEConfig.instance().getConfigManager().getSetting(Settings.SEARCH_TOOLTIPS) != YesNo.NO;
|
||||
|
||||
boolean searchMod = false;
|
||||
@@ -207,52 +129,76 @@ public class ItemRepo {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.myPartitionList != null) {
|
||||
if (!this.myPartitionList.isListed(is)) {
|
||||
return;
|
||||
boolean notDone = false;
|
||||
for (IAEItemStack is : this.list) {
|
||||
if (this.myPartitionList != null) {
|
||||
if (!this.myPartitionList.isListed(is)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) {
|
||||
return;
|
||||
}
|
||||
if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (viewMode == ViewItems.STORED && is.getStackSize() == 0) {
|
||||
return;
|
||||
}
|
||||
if (viewMode == ViewItems.STORED && is.getStackSize() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String dspName = (searchMod ? Platform.getModId(is) : Platform.getItemDisplayName(is)).toLowerCase();
|
||||
boolean foundMatchingItemStack = true;
|
||||
final String dspName = (searchMod ? Platform.getModId(is) : Platform.getItemDisplayName(is)).toLowerCase();
|
||||
boolean foundMatchingItemStack = true;
|
||||
|
||||
for (String term : innerSearch.split(" ")) {
|
||||
if (term.length() > 1 && (term.startsWith("-") || term.startsWith("!"))) {
|
||||
term = term.substring(1);
|
||||
if (dspName.contains(term)) {
|
||||
for (String term : innerSearch.split(" ")) {
|
||||
if (term.length() > 1 && (term.startsWith("-") || term.startsWith("!"))) {
|
||||
term = term.substring(1);
|
||||
if (dspName.contains(term)) {
|
||||
foundMatchingItemStack = false;
|
||||
break;
|
||||
}
|
||||
} else if (!dspName.contains(term)) {
|
||||
foundMatchingItemStack = false;
|
||||
break;
|
||||
}
|
||||
} else if (!dspName.contains(term)) {
|
||||
foundMatchingItemStack = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (terminalSearchToolTips && !foundMatchingItemStack) {
|
||||
final List<String> tooltip = Platform.getTooltip(is);
|
||||
for (final String line : tooltip) {
|
||||
if (m.matcher(line).find()) {
|
||||
foundMatchingItemStack = true;
|
||||
break;
|
||||
if (terminalSearchToolTips && !foundMatchingItemStack) {
|
||||
final List<String> tooltip = Platform.getTooltip(is);
|
||||
for (final String line : tooltip) {
|
||||
if (m.matcher(line).find()) {
|
||||
foundMatchingItemStack = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundMatchingItemStack) {
|
||||
if (needsZeroCopy) {
|
||||
is = is.copy();
|
||||
is.setStackSize(0);
|
||||
}
|
||||
|
||||
this.view.add(is);
|
||||
}
|
||||
}
|
||||
|
||||
if (foundMatchingItemStack) {
|
||||
if (needsZeroCopy) {
|
||||
is = is.copy();
|
||||
is.setStackSize(0);
|
||||
final Enum SortBy = this.sortSrc.getSortBy();
|
||||
final Enum SortDir = this.sortSrc.getSortDir();
|
||||
|
||||
ItemSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||
ItemSorters.init();
|
||||
|
||||
if (SortBy == SortOrder.MOD) {
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_MOD);
|
||||
} else if (SortBy == SortOrder.AMOUNT) {
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_SIZE);
|
||||
} else if (SortBy == SortOrder.INVTWEAKS) {
|
||||
if (InventoryBogoSortModule.isLoaded()) {
|
||||
Collections.sort(this.view, InventoryBogoSortModule.COMPARATOR);
|
||||
} else {
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
|
||||
}
|
||||
this.view.add(is);
|
||||
} else {
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
JEIMissingItem(Container container, @Nonnull IRecipeLayout recipeLayout) {
|
||||
if (container instanceof ContainerMEMonitorable) {
|
||||
IItemList<IAEItemStack> ir = ((ContainerMEMonitorable) container).items;
|
||||
|
||||
|
||||
IItemList<IAEItemStack> available = mergeInventories(ir, (ContainerMEMonitorable) container);
|
||||
|
||||
boolean found;
|
||||
@@ -57,7 +57,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
IItemList<IAEItemStack> used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) {
|
||||
found = false;
|
||||
if (i.isInput() && i.getAllIngredients().size() > 0) {
|
||||
if (i.isInput() && !i.getAllIngredients().isEmpty()) {
|
||||
List<?> allIngredients = i.getAllIngredients();
|
||||
for (Object allIngredient : allIngredients) {
|
||||
if (allIngredient instanceof ItemStack) {
|
||||
@@ -66,7 +66,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
IAEItemStack search = AEItemStack.fromItemStack(stack);
|
||||
if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) {
|
||||
Collection<IAEItemStack> fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL);
|
||||
if (fuzzy.size() > 0) {
|
||||
if (!fuzzy.isEmpty()) {
|
||||
for (IAEItemStack itemStack : fuzzy) {
|
||||
if (itemStack.getStackSize() > 0) {
|
||||
if (Platform.isGTDamageableItem(stack.getItem())) {
|
||||
@@ -145,7 +145,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) {
|
||||
found = false;
|
||||
craftable = false;
|
||||
ArrayList<ItemStack> valid = new ArrayList<>();
|
||||
IItemList<IAEItemStack> valid = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
if (i.isInput()) {
|
||||
List<?> allIngredients = i.getAllIngredients();
|
||||
for (Object allIngredient : allIngredients) {
|
||||
@@ -155,7 +155,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
IAEItemStack search = AEItemStack.fromItemStack(stack);
|
||||
if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) {
|
||||
Collection<IAEItemStack> fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL);
|
||||
if (fuzzy.size() > 0) {
|
||||
if (!fuzzy.isEmpty()) {
|
||||
for (IAEItemStack itemStack : fuzzy) {
|
||||
if (itemStack.getStackSize() > 0) {
|
||||
if (Platform.isGTDamageableItem(stack.getItem())) {
|
||||
@@ -165,7 +165,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
}
|
||||
found = true;
|
||||
used.add(itemStack.copy().setStackSize(1));
|
||||
valid.add(itemStack.copy().setStackSize(1).createItemStack());
|
||||
valid.add(itemStack.copy().setStackSize(1));
|
||||
} else {
|
||||
if (itemStack.isCraftable()) {
|
||||
craftable = true;
|
||||
@@ -180,12 +180,12 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
if (ext.getStackSize() > 0 && (usedStack == null || usedStack.getStackSize() < ext.getStackSize())) {
|
||||
used.add(ext.copy().setStackSize(1));
|
||||
if (craftable) {
|
||||
valid.clear();
|
||||
valid = null;
|
||||
}
|
||||
valid.add(ext.copy().setStackSize(1).createItemStack());
|
||||
valid.add(ext.copy().setStackSize(1));
|
||||
found = true;
|
||||
} else if (ext.isCraftable()) {
|
||||
valid.add(ext.copy().setStackSize(1).createItemStack());
|
||||
valid.add(ext.copy().setStackSize(1));
|
||||
craftable = true;
|
||||
}
|
||||
}
|
||||
@@ -195,21 +195,29 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i.getAllIngredients().size() == 0) {
|
||||
if (i.getAllIngredients().isEmpty()) {
|
||||
found = true;
|
||||
}
|
||||
ArrayList<ItemStack> validStacks = new ArrayList<>();
|
||||
if (valid != null) {
|
||||
valid.forEach(v -> {
|
||||
ItemStack validStack = v.createItemStack();
|
||||
validStack.setCount(1);
|
||||
validStacks.add(validStack);
|
||||
});
|
||||
}
|
||||
if (!found) {
|
||||
if (craftable) {
|
||||
i.drawHighlight(minecraft, new Color(0.0f, 0.0f, 1.0f, 0.4f), recipeX, recipeY);
|
||||
this.craftableSlots.add(currentSlot);
|
||||
recipeLayout.getItemStacks().set(currentSlot, valid);
|
||||
recipeLayout.getItemStacks().set(currentSlot, validStacks);
|
||||
} else {
|
||||
i.drawHighlight(minecraft, new Color(1.0f, 0.0f, 0.0f, 0.4f), recipeX, recipeY);
|
||||
}
|
||||
this.errored = true;
|
||||
} else {
|
||||
this.foundSlots.add(currentSlot);
|
||||
recipeLayout.getItemStacks().set(currentSlot, valid);
|
||||
recipeLayout.getItemStacks().set(currentSlot, validStacks);
|
||||
}
|
||||
}
|
||||
currentSlot++;
|
||||
|
||||
Reference in New Issue
Block a user