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
6 changed files with 40 additions and 23 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-beta-1-GTNH
mod_version=2.0.0-beta-2-GTNH
+6 -1
View File
@@ -26,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) {
+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();
}
+1 -1
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;
@@ -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);