Compare commits

...
Author SHA1 Message Date
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
13 changed files with 105 additions and 32 deletions

No files matched your search

+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-9-GTNH
mod_version=2.0.0-beta-2-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();
+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) {
+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);
+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();
}