mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-17 19:15:13 +00:00
Panel settings (#240)
* panel settings * Highlight hidden items; mark item with recipe * open gui usage with recipeId * small changes * restore gl after draw item Co-authored-by: Serghei Borovetchi <[email protected]>
This commit is contained in:
1 parent
96e4fe55e8
commit
91e9b2a5ae
22 files changed
+1334
-624
No files matched your search
@@ -0,0 +1,41 @@
|
||||
package codechicken.nei.recipe;
|
||||
|
||||
import codechicken.nei.api.INEIGuiAdapter;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
import static codechicken.nei.LayoutManager.searchField;
|
||||
|
||||
public class SearchInputDropHandler extends INEIGuiAdapter
|
||||
{
|
||||
|
||||
protected static final Pattern SPECIAL_REGEX_CHARS = Pattern.compile("[{}()\\[\\].+*?^$\\\\|]");
|
||||
|
||||
@Override
|
||||
public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button)
|
||||
{
|
||||
|
||||
if (searchField.contains(mouseX, mouseY)) {
|
||||
final FluidStack fluidStack = StackInfo.getFluid(draggedStack);
|
||||
|
||||
if (fluidStack != null) {
|
||||
searchField.setText(formattingText(fluidStack.getLocalizedName()));
|
||||
} else {
|
||||
searchField.setText(formattingText(draggedStack.getDisplayName()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected String formattingText(String displayName)
|
||||
{
|
||||
return SPECIAL_REGEX_CHARS.matcher(EnumChatFormatting.getTextWithoutFormattingCodes(displayName)).replaceAll("\\\\$0");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user