Compare commits

...
Author SHA1 Message Date
Jason Mitchell 4375a91220 bump version 2020-02-02 10:45:05 -08:00
Jason Mitchell bb7a9c51f7 Slightly better fix. 2020-02-02 10:44:48 -08:00
Jason Mitchell 1d66a2a015 Create README.md 2020-02-02 10:06:24 -08:00
Jason Mitchell bb40acc7a3 Fix clicking on items in the bookmark panel. Thanks @monatann for contributing 2020-02-02 09:50:22 -08:00
Jason Mitchell abd1b38870 Avoid divide by zero error 2020-01-21 20:20:45 -08:00
Jason Mitchell 2c0292c3e7 Add back in ItemPanel.items as static
* Fixes crash in ThermalDyanmics [probably]
2020-01-20 09:42:39 -08:00
Jason Mitchell 3c5e180f9a Beta-1 2020-01-11 20:20:16 -08:00
Martin Robertz 88d6937d11 Merge pull request #7 from GTNewHorizons/new_features
Experimental - Don't load items every inventory load.
2020-01-10 20:59:19 +01:00
Jason Mitchell bc1aa9e97e Stop running the LoadItem task on every inventory open (which also re-ran the search and caused lag on every inventory open).
Unclear if this breaks anything -- it works with simple testing.
2020-01-08 21:32:53 -08:00
Martin Robertz e84ce8b9f4 Merge pull request #6 from GTNewHorizons/new_features
Fix TCON workbench compat
2020-01-07 20:53:47 +01:00
Jason Mitchell 64ad0f826e Fix TCON workbench compat 2020-01-07 11:15:03 -08:00
Jason Mitchell 7e4eec1410 Merge pull request #5 from GTNewHorizons/new_features
Save string ids instead of int ids.
2020-01-05 12:33:08 -08:00
Jason Mitchell 935a82d079 Save string ids instead of int ids. 2020-01-05 12:13:50 -08:00
Martin Robertz f40272fe43 Merge pull request #4 from GTNewHorizons/new_features
Add hotkeys to move around recipes
2020-01-03 15:57:54 +01:00
Jason Mitchell 8364eaef6f Add hotkeys to move around recipes 2020-01-02 21:00:34 -08:00
Martin Robertz 9ed2314f08 Merge pull request #3 from GTNewHorizons/new_features
Fixes and stuff
2020-01-02 21:28:52 +01:00
Jason Mitchell 9359df3031 Workaround missing font renderer causing OptionTextField crash 2020-01-02 11:30:24 -08:00
18 changed files with 171 additions and 43 deletions

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
# NotEnoughItems - GTNH
A continuation of NotEnoughItems for 1.7.10 by the developers of Gregtech: New Horizons modpack, with features either inspired and/or backported from JustEnoughItems
We've tested this against all of the mods included in GTNH, as well as a limited set of other mods (like Reika's mods). Every effort has been made to maintain backwards compatibility, however the focus is on the mods contained in the GTNH modpack.
## New Features:
* Speed - Uses a parallel stream to search the item list over multiple cores, resulting in 2-6x faster searches on average [Feels instantaneous]
* A textbox for search with most of the features you'd expect - moving forward, backwards, selection, etc
* Bookmarks! What are you in the process of crafting? Bookmark it using either 'A' or configure your own key.
* Utility/Cheat buttons line up and wrap based on GUI size
* ItemList is no longer regenerated from the ItemRegistry on every inventory load
## Other items of note:
* Licensed under LGPL - Use this however you want, but please give back any modifications
* Remove TMI style
* Removed inventory Load/Save state
+1 -1
View File
@@ -2,4 +2,4 @@ mc_version=1.7.10
forge_version=10.13.4.1614-1.7.10
ccl_version=1.1.3.138
ccc_version=1.0.7.+
mod_version=2.0.0-pre-8-GTNH
mod_version=2.0.0-beta-5-GTNH
+7 -3
View File
@@ -66,10 +66,14 @@ nei.options.keys.gui.recipe=Recipe
nei.options.keys.gui.usage=Usage
nei.options.keys.gui.enchant=Enchantments
nei.options.keys.gui.potion=Potions
nei.options.keys.gui.back=Prev Recipe
nei.options.keys.gui.prev=Prev Page
nei.options.keys.gui.next=Next Page
nei.options.keys.gui.back=Back to last Recipe
nei.options.keys.gui.prev=Prev Item Panel Page
nei.options.keys.gui.next=Next Item Panel Page
nei.options.keys.gui.hide=Toggle NEI Visibility
nei.options.keys.gui.next_recipe=Next Recipe
nei.options.keys.gui.prev_recipe=Prev Recipe
nei.options.keys.gui.next_machine=Next Machine
nei.options.keys.gui.prev_machine=Prev Machine
nei.options.keys.gui.search=Focus Search Bar
nei.options.keys.gui.bookmark=Add Bookmark
nei.options.keys.world=World
+35 -3
View File
@@ -1,6 +1,8 @@
package codechicken.nei;
import cpw.mods.fml.common.registry.GameData;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTException;
@@ -24,8 +26,13 @@ public class BookmarkPanel extends ItemPanel {
super.init();
}
@Override
protected void setItems() {
realItems = _items;
}
public String getLabelText() {
return super.getLabelText() + " [" + items.size() + "]";
return super.getLabelText() + " [" + realItems.size() + "]";
}
public void addOrRemoveItem(ItemStack item) {
@@ -36,10 +43,35 @@ public class BookmarkPanel extends ItemPanel {
saveBookmarks();
}
public static NBTTagCompound itemStackToNBT(ItemStack stack, NBTTagCompound nbTag)
{
String strId = Item.itemRegistry.getNameForObject(stack.getItem());
nbTag.setString("strId", strId);
nbTag.setByte("Count", (byte)stack.stackSize);
nbTag.setShort("Damage", (short)stack.getItemDamage());
if (stack.stackTagCompound != null)
{
nbTag.setTag("tag", stack.stackTagCompound);
}
return nbTag;
}
public static ItemStack loadFromNBT(NBTTagCompound nbtTag)
{
if (!nbtTag.hasKey("id")) {
final short id = (short)GameData.getItemRegistry().getId(nbtTag.getString("strId"));
nbtTag.setShort("id", id);
}
ItemStack stack = ItemStack.loadItemStackFromNBT(nbtTag);
return stack;
}
public void saveBookmarks() {
List<String> strings = new ArrayList<>();
for (ItemStack item:_items) {
strings.add(item.writeToNBT(new NBTTagCompound()).toString());
strings.add(itemStackToNBT(item, new NBTTagCompound()).toString());
}
File file = NEIClientConfig.bookmarkFile;
if(file != null) {
@@ -68,7 +100,7 @@ public class BookmarkPanel extends ItemPanel {
for (String itemStr: itemStrings) {
try {
NBTTagCompound itemStackNBT = (NBTTagCompound)JsonToNBT.func_150315_a(itemStr);
ItemStack itemStack = ItemStack.loadItemStackFromNBT(itemStackNBT);
ItemStack itemStack = loadFromNBT(itemStackNBT);
if (itemStack != null) {
_items.add(itemStack);
} else {
+2
View File
@@ -182,6 +182,7 @@ public class ItemList
@Override
public void execute() {
// System.out.println("Executing NEI Item Loading");
ThreadOperationTimer timer = getTimer(500);
LinkedList<ItemStack> items = new LinkedList<>();
@@ -243,6 +244,7 @@ public class ItemList
{
@Override
public void execute() {
// System.out.println("Executing NEI Item Filtering");
ArrayList<ItemStack> filtered = new ArrayList<>();
ItemFilter filter = getItemListFilter();
+24 -12
View File
@@ -17,17 +17,22 @@ import static codechicken.lib.gui.GuiDraw.drawRect;
import static codechicken.nei.NEIClientConfig.canPerformAction;
public class ItemPanel extends Widget {
/**
* Backwards compat :-/
*/
public static ArrayList<ItemStack> items = new ArrayList<>();
/**
* Should not be externally modified, use updateItemList
*/
public ArrayList<ItemStack> items = new ArrayList<>();
public ArrayList<ItemStack> realItems = new ArrayList<>();
/**
* Swapped into visible items on update
*/
protected ArrayList<ItemStack> _items = items;
protected ArrayList<ItemStack> _items = realItems;
public ArrayList<ItemStack> getItems() {
return items;
return realItems;
}
public static void updateItemList(ArrayList<ItemStack> newItems) {
@@ -40,7 +45,7 @@ public class ItemPanel extends Widget {
public int slotIndex;
public ItemPanelSlot(int index) {
item = items.get(index);
item = realItems.get(index);
slotIndex = index;
}
}
@@ -145,8 +150,15 @@ public class ItemPanel extends Widget {
return pageLabel.text = "(" + getPage() + "/" + getNumPages() + ")";
}
protected void setItems() {
realItems = _items;
// Backwards compat
ItemPanels.itemPanel._items = _items;
}
public void resize(GuiContainer gui) {
items = _items;
setItems();
final int buttonHeight = 16;
final int buttonWidth = 16;
@@ -185,9 +197,9 @@ public class ItemPanel extends Widget {
if (itemsPerPage == 0)
numPages = 0;
else
numPages = (int) Math.ceil((float) items.size() / (float) itemsPerPage);
numPages = (int) Math.ceil((float) realItems.size() / (float) itemsPerPage);
if (firstIndex >= items.size())
if (firstIndex >= realItems.size())
firstIndex = 0;
if (numPages == 0)
@@ -236,13 +248,13 @@ public class ItemPanel extends Widget {
GuiContainerManager.enableMatrixStackLogging();
int index = firstIndex;
for (int i = 0; i < rows * columns && index < items.size(); i++) {
for (int i = 0; i < rows * columns && index < realItems.size(); i++) {
if (validSlotMap[i]) {
Rectangle4i rect = getSlotRect(i);
if (rect.contains(mousex, mousey))
drawRect(rect.x, rect.y, rect.w, rect.h, 0xee555555);//highlight
GuiContainerManager.drawItem(rect.x + 1, rect.y + 1, items.get(index));
GuiContainerManager.drawItem(rect.x + 1, rect.y + 1, realItems.get(index));
index++;
}
@@ -416,7 +428,7 @@ public class ItemPanel extends Widget {
public ItemPanelSlot getSlotMouseOver(int mousex, int mousey) {
int index = firstIndex;
for (int i = 0; i < rows * columns && index < items.size(); i++)
for (int i = 0; i < rows * columns && index < realItems.size(); i++)
if (validSlotMap[i]) {
if (getSlotRect(i).contains(mousex, mousey))
return new ItemPanelSlot(index);
@@ -430,13 +442,13 @@ public class ItemPanel extends Widget {
if (itemsPerPage != 0) {
int oldIndex = firstIndex;
firstIndex += i * itemsPerPage;
if (firstIndex >= items.size())
if (firstIndex >= realItems.size())
firstIndex = 0;
if (firstIndex < 0)
if (oldIndex > 0)
firstIndex = 0;
else
firstIndex = (items.size() - 1) / itemsPerPage * itemsPerPage;
firstIndex = (realItems.size() - 1) / itemsPerPage * itemsPerPage;
calculatePage();
}
+5 -1
View File
@@ -100,6 +100,7 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
public static HashMap<Integer, LayoutStyle> layoutStyles = new HashMap<>();
public static boolean ftbUtilsLoaded = false;
public static boolean itemsLoaded = false;
public static void load() {
ftbUtilsLoaded = Loader.isModLoaded("FTBU");
@@ -559,7 +560,10 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
if (isEnabled()) {
setInputFocused(null);
ItemList.loadItems.restart();
if(!itemsLoaded) {
ItemList.loadItems.restart();
itemsLoaded = true;
}
overlayRenderer = null;
getLayoutStyle().init();
@@ -61,7 +61,7 @@ public class LayoutStyleMinecraft extends LayoutStyle
//leftSize = ((gui.width - gui.xSize) / 2) - 3;
leftSize = ItemPanels.bookmarkPanel.getWidth(gui);
numButtons = leftSize / 18;
numButtons = Math.max(leftSize / 18, 1);
delete.state = 0x4;
if (NEIController.getDeleteMode())
+4
View File
@@ -160,6 +160,10 @@ public class NEIClientConfig
API.addKeyBind("gui.potion", Keyboard.KEY_P);
API.addKeyBind("gui.prev", Keyboard.KEY_PRIOR);
API.addKeyBind("gui.next", Keyboard.KEY_NEXT);
API.addKeyBind("gui.prev_machine", Keyboard.KEY_UP);
API.addKeyBind("gui.next_machine", Keyboard.KEY_DOWN);
API.addKeyBind("gui.prev_recipe", Keyboard.KEY_LEFT);
API.addKeyBind("gui.next_recipe", Keyboard.KEY_RIGHT);
API.addKeyBind("gui.hide", Keyboard.KEY_O);
API.addKeyBind("gui.search", Keyboard.KEY_F);
API.addKeyBind("gui.bookmark", Keyboard.KEY_A);
+2 -2
View File
@@ -64,7 +64,7 @@ public class SearchField extends TextField implements ItemFilterProvider
@Override
public int getTextColour() {
if(ItemPanels.itemPanel.items.size() == 0) {
if(ItemPanels.itemPanel.realItems.size() == 0) {
return focused() ? 0xFFcc3300 : 0xFF993300;
} else {
return focused() ? 0xFFE0E0E0 : 0xFF909090;
@@ -101,7 +101,7 @@ public class SearchField extends TextField implements ItemFilterProvider
public void onTextChange(String oldText) {
final String newText = text();
if( newText.length() > 0)
NEIClientConfig.logger.info("Searching for " + text());
NEIClientConfig.logger.debug("Searching for " + text());
NEIClientConfig.setSearchExpression(newText);
ItemList.updateFilter.restart();
+3 -1
View File
@@ -388,7 +388,6 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
updateState.stop();
synchronized (root) {
root.addTag(tag);
NEIClientConfig.logger.info("Adding Tag {}", tag.displayName());
updateState.reallocate();
}
}
@@ -519,12 +518,15 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
}
public synchronized void reallocate() {
// System.out.println("NEI Subset - Reallocate");
// Thread.dumpStack();
reallocate = true;
restart();
}
@Override
public void execute() {
// System.out.println("Executing NEI Subset Item Allocation");
HashMap<String, SubsetState> state = new HashMap<>();
List<SubsetTag> tags = new LinkedList<>();
synchronized (root) {
+24 -6
View File
@@ -6,7 +6,7 @@ import org.lwjgl.input.Keyboard;
public abstract class TextField extends Widget
{
protected final GuiTextField field;
protected GuiTextField field;
private static final int maxSearchLength = 256;
@@ -15,11 +15,15 @@ public abstract class TextField extends Widget
private boolean previousKeyboardRepeatEnabled;
public TextField(String ident) {
identifier = ident;
protected void initInternalTextField() {
field = new GuiTextField(Minecraft.getMinecraft().fontRenderer, 0, 0, 0, 0);
field.setMaxStringLength(maxSearchLength);
field.setCursorPositionZero();
}
public TextField(String ident) {
identifier = ident;
initInternalTextField();
// Keyboard.enableRepeatEvents(true);
}
@@ -27,15 +31,29 @@ public abstract class TextField extends Widget
return focused() ? 0xFFE0E0E0 : 0xFF909090;
}
@Override
public void draw(int mousex, int mousey) {
protected void setDimensionsAndColor() {
field.xPosition = this.x + 2;
field.yPosition = this.y + 2;
field.width = this.w - 4;
field.height = this.h - 4;
field.setTextColor(getTextColour());
}
field.drawTextBox();
@Override
public void draw(int mousex, int mousey) {
try {
setDimensionsAndColor();
field.drawTextBox();
} catch(NullPointerException npe) {
// Hack to deal with a null font renderer... recreate the field and it should work
GuiTextField oldField = field;
initInternalTextField();
setDimensionsAndColor();
field.setText(oldField.getText());
field.drawTextBox();
}
}
@Override
+4
View File
@@ -28,7 +28,11 @@ public class VisiblityData
*/
public boolean showNEI = true;
public boolean enableDeleteMode = true;
// Deprecated -- left in for campatability with other mods that mess with this
public boolean showStateButtons = false;
public void translateDependancies()
{
if(!showNEI)
@@ -100,10 +100,10 @@ public class GuiItemIconDumper extends GuiScreen
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glColor4f(1, 1, 1, 1);
for(int i = 0; drawIndex < ItemPanels.itemPanel.items.size() && i < fit; drawIndex++, i++) {
for(int i = 0; drawIndex < ItemPanels.itemPanel.realItems.size() && i < fit; drawIndex++, i++) {
int x = i%cols * 18;
int y = i/cols * 18;
GuiContainerManager.drawItem(x+1, y+1, ItemPanels.itemPanel.items.get(drawIndex));
GuiContainerManager.drawItem(x+1, y+1, ItemPanels.itemPanel.realItems.get(drawIndex));
}
GL11.glFlush();
@@ -114,13 +114,13 @@ public class GuiItemIconDumper extends GuiScreen
int rows = img.getHeight() / boxSize;
int cols = img.getWidth() / boxSize;
int fit = rows*cols;
for(int i = 0; parseIndex < ItemPanels.itemPanel.items.size() && i < fit; parseIndex++, i++) {
for(int i = 0; parseIndex < ItemPanels.itemPanel.realItems.size() && i < fit; parseIndex++, i++) {
int x = i%cols * boxSize;
int y = i/cols * boxSize;
exportImage(dir, img.getSubimage(x+borderSize, y+borderSize, iconSize, iconSize), ItemPanels.itemPanel.items.get(parseIndex));
exportImage(dir, img.getSubimage(x+borderSize, y+borderSize, iconSize, iconSize), ItemPanels.itemPanel.realItems.get(parseIndex));
}
if(parseIndex >= ItemPanels.itemPanel.items.size())
if(parseIndex >= ItemPanels.itemPanel.realItems.size())
returnScreen(new ChatComponentTranslation(opt.fullName()+".icon.dumped", "dumps/itempanel_icons"));
}
@@ -36,7 +36,7 @@ public class ItemPanelDumper extends DataDumper
@Override
public Iterable<String[]> dump(int mode) {
LinkedList<String[]> list = new LinkedList<>();
for (ItemStack stack : ItemPanels.itemPanel.items)
for (ItemStack stack : ItemPanels.itemPanel.realItems)
list.add(new String[]{
Item.itemRegistry.getNameForObject(stack.getItem()),
Integer.toString(Item.getIdFromItem(stack.getItem())),
@@ -123,7 +123,7 @@ public class ItemPanelDumper extends DataDumper
public void dumpNBT(File file) throws IOException {
NBTTagList list = new NBTTagList();
for (ItemStack stack : ItemPanels.itemPanel.items)
for (ItemStack stack : ItemPanels.itemPanel.realItems)
list.appendTag(stack.writeToNBT(new NBTTagCompound()));
NBTTagCompound tag = new NBTTagCompound();
@@ -134,7 +134,7 @@ public class ItemPanelDumper extends DataDumper
public void dumpJson(File file) throws IOException {
PrintWriter p = new PrintWriter(file);
for (ItemStack stack : ItemPanels.itemPanel.items) {
for (ItemStack stack : ItemPanels.itemPanel.realItems) {
NBTTagCompound tag = stack.writeToNBT(new NBTTagCompound());
tag.removeTag("Count");
p.println(tag);
@@ -12,9 +12,8 @@ import static codechicken.lib.gui.GuiDraw.getStringWidth;
public class OptionTextField extends Option
{
private boolean focused = false;
private final TextField textField = new TextField("")
private TextField textField = new TextField("test")
{
@Override
public void onTextChange(String oldText) {
if(focused() && isValidValue(text()))
+10 -1
View File
@@ -18,6 +18,7 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import java.awt.Point;
@@ -76,7 +77,7 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
@Override
public void keyTyped(char c, int i) {
if (i == 1)//esc
if (i == Keyboard.KEY_ESCAPE) //esc
{
mc.displayGuiScreen(firstGui);
return;
@@ -93,6 +94,14 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
mc.displayGuiScreen(firstGui);
else if (i == NEIClientConfig.getKeyBinding("gui.back"))
mc.displayGuiScreen(prevGui);
else if (i == NEIClientConfig.getKeyBinding("gui.prev_machine"))
prevType();
else if (i == NEIClientConfig.getKeyBinding("gui.next_machine"))
nextType();
else if (i == NEIClientConfig.getKeyBinding("gui.prev_recipe"))
prevPage();
else if (i == NEIClientConfig.getKeyBinding("gui.next_recipe"))
nextPage();
}
@@ -35,9 +35,24 @@ public class RecipeItemInputHandler implements IContainerInputHandler
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button)
{
ItemStack stackover = GuiContainerManager.getStackMouseOver(gui);
if(stackover == null || !(gui instanceof GuiRecipe))
if(stackover == null)
return false;
if(mousex < ItemPanels.bookmarkPanel.w) {
if (NEIClientConfig.canCheatItem(stackover))
NEIClientUtils.cheatItem(stackover, button, -1);
else {
if (button == 0)
return GuiCraftingRecipe.openRecipeGui("item", stackover.copy());
if (button == 1)
return GuiUsageRecipe.openRecipeGui("item", stackover.copy());
}
}
if (!(gui instanceof GuiRecipe))
return false;
if(button == 0)
return GuiCraftingRecipe.openRecipeGui("item", stackover.copy());