Skip to content

Commit

Permalink
Small Fixes (#536)
Browse files Browse the repository at this point in the history
* Small Fixes

* fix shift+v

* fix subset zindex

---------

Co-authored-by: slprime <[email protected]>
  • Loading branch information
slprime and slprime authored Sep 28, 2024
1 parent 82a2273 commit ee060b9
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 13 deletions.
22 changes: 13 additions & 9 deletions src/main/java/codechicken/nei/BookmarkPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,12 @@ public void setStartRowIndex(BookmarkGrid BGrid, int rowIndex) {
}

public void setEndRowIndex(BookmarkGrid BGrid, int rowIndex) {
this.endRowIndex = rowIndex;
this.endItemIndexTop = getTopItemIndex(BGrid, rowIndex);
this.endItemIndexBottom = getBottomItemIndex(BGrid, rowIndex);

if (BGrid.getRowItemIndex(rowIndex, true) >= 0) {
this.endRowIndex = rowIndex;
this.endItemIndexTop = getTopItemIndex(BGrid, rowIndex);
this.endItemIndexBottom = getBottomItemIndex(BGrid, rowIndex);
}
}

public boolean hasEndRow() {
Expand Down Expand Up @@ -226,12 +229,12 @@ public boolean equalsRecipe(BookmarkRecipeId recipeId, int groupId) {
}
}

public static enum BookmarkViewMode {
public enum BookmarkViewMode {
DEFAULT,
TODO_LIST
}

public static enum BookmarkLoadingState {
public enum BookmarkLoadingState {
LOADING,
LOADED
}
Expand Down Expand Up @@ -2726,8 +2729,9 @@ private ItemStack shiftStackSize(BookmarkGrid BGrid, int slotIndex, int shift, i
}

public boolean pullBookmarkItems(int groupId, boolean onlyIngredients) {
IBookmarkContainerHandler containerHandler = BookmarkContainerInfo
.getBookmarkContainerHandler(getGuiContainer());
final GuiContainer guiContainer = getGuiContainer();
final IBookmarkContainerHandler containerHandler = BookmarkContainerInfo
.getBookmarkContainerHandler(guiContainer);

if (containerHandler == null) {
return false;
Expand All @@ -2736,14 +2740,14 @@ public boolean pullBookmarkItems(int groupId, boolean onlyIngredients) {
final BookmarkGrid BGrid = (BookmarkGrid) grid;
final ArrayList<ItemStack> items = new ArrayList<>();
final ItemStackMap<Long> uniqueItems = new ItemStackMap<>();
final BookmarkGroup group = groupId >= 0 ? BGrid.groups.get(groupId) : null;
ItemStackMetadata meta;

for (int idx = 0; idx < BGrid.realItems.size(); idx++) {
meta = BGrid.metadata.get(idx);

if (groupId == -1 || groupId == meta.groupId) {
final ItemStack stack = BGrid.getItem(idx);
final BookmarkGroup group = BGrid.groups.get(meta.groupId);

if (!onlyIngredients || meta.ingredient && (group == null || group.crafting == null
|| group.crafting.inputs.containsKey(BGrid.realItems.get(idx)))) {
Expand All @@ -2768,7 +2772,7 @@ public boolean pullBookmarkItems(int groupId, boolean onlyIngredients) {
return false;
}

containerHandler.pullBookmarkItemsFromContainer(getGuiContainer(), items);
containerHandler.pullBookmarkItemsFromContainer(guiContainer, items);
return true;
}
}
4 changes: 4 additions & 0 deletions src/main/java/codechicken/nei/ItemZoom.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public void draw(int mx, int my) {

GL11.glPopMatrix();

GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GuiContainerManager.enable2DRender();

if (NEIClientConfig.getBooleanSetting("inventory.itemzoom.showName")) {
String dispalyName = NEIClientUtils.cropText(fontRenderer, this.displayName, this.availableAreaWidth);
drawStringC(
Expand Down Expand Up @@ -90,6 +93,7 @@ public void draw(int mx, int my) {
}
}

GL11.glPopAttrib();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/codechicken/nei/PresetsList.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

public class PresetsList {

public static enum PresetMode {
public enum PresetMode {
HIDE,
REMOVE,
GROUP;
Expand Down
23 changes: 20 additions & 3 deletions src/main/java/codechicken/nei/SearchTokenParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.Language;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;

import codechicken.nei.ItemList.AllMultiItemFilter;
Expand Down Expand Up @@ -69,6 +70,22 @@ public void clear() {
}
}

private static class IsRegisteredItemFilter implements ItemFilter {

public ItemFilter filter;

public IsRegisteredItemFilter(ItemFilter filter) {
this.filter = filter;
}

@Override
public boolean matches(ItemStack item) {
return item != null && item.getItem() != null
&& item.getItem().delegate.name() != null
&& this.filter.matches(item);
}
}

protected final List<ISearchParserProvider> searchProviders;
protected final ProvidersCache providersCache = new ProvidersCache();
protected final TCharCharMap prefixRedefinitions = new TCharCharHashMap();
Expand Down Expand Up @@ -118,15 +135,15 @@ && getRedefinedPrefix(provider.getPrefix()) == ch)

public ItemFilter getFilter(String filterText) {
final String[] parts = EnumChatFormatting.getTextWithoutFormattingCodes(filterText).toLowerCase().split("\\|");
final List<ItemFilter> searchTokens = Arrays.stream(parts).map(s -> parseSearchText(s)).filter(s -> s != null)
final List<ItemFilter> searchTokens = Arrays.stream(parts).map(this::parseSearchText).filter(s -> s != null)
.collect(Collectors.toCollection(ArrayList::new));

if (searchTokens.isEmpty()) {
return new EverythingItemFilter();
} else if (searchTokens.size() == 1) {
return searchTokens.get(0);
return new IsRegisteredItemFilter(searchTokens.get(0));
} else {
return new AnyMultiItemFilter(searchTokens);
return new IsRegisteredItemFilter(new AnyMultiItemFilter(searchTokens));
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/codechicken/nei/SubsetWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumChatFormatting;

import org.lwjgl.opengl.GL11;

import codechicken.core.gui.GuiScrollSlot;
import codechicken.lib.gui.GuiDraw;
import codechicken.lib.vec.Rectangle4i;
Expand Down Expand Up @@ -711,9 +713,14 @@ public void draw(int mx, int my) {

hoverStack = null;
if (root.isVisible()) {
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GuiContainerManager.enable2DRender();

root.resize(area.x, 0, area.y);
root.cacheState();
root.draw(mx, my);

GL11.glPopAttrib();
}
}

Expand Down

0 comments on commit ee060b9

Please sign in to comment.