Performance improvements to grids
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
- Fixed going out of crafting GUI not restoring state (scrollbar and search term)
|
- Fixed going out of crafting GUI not restoring state (scrollbar and search term)
|
||||||
- Fixed not being able to create a pattern in disconnected Pattern Grid
|
- Fixed not being able to create a pattern in disconnected Pattern Grid
|
||||||
- Fixed not being able to place cake or string
|
- Fixed not being able to place cake or string
|
||||||
|
- Performance improvements to Grids
|
||||||
|
|
||||||
### 0.7
|
### 0.7
|
||||||
**Bugfixes**
|
**Bugfixes**
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class GuiGrid extends GuiBase {
|
|||||||
while (t.hasNext()) {
|
while (t.hasNext()) {
|
||||||
ItemGroup group = t.next();
|
ItemGroup group = t.next();
|
||||||
|
|
||||||
if (!group.toStack().getDisplayName().toLowerCase().contains(searchField.getText().toLowerCase())) {
|
if (!group.toCachedStack().getDisplayName().toLowerCase().contains(searchField.getText().toLowerCase())) {
|
||||||
t.remove();
|
t.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,9 +110,9 @@ public class GuiGrid extends GuiBase {
|
|||||||
@Override
|
@Override
|
||||||
public int compare(ItemGroup left, ItemGroup right) {
|
public int compare(ItemGroup left, ItemGroup right) {
|
||||||
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
||||||
return right.toStack().getDisplayName().compareTo(left.toStack().getDisplayName());
|
return right.toCachedStack().getDisplayName().compareTo(left.toCachedStack().getDisplayName());
|
||||||
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
||||||
return left.toStack().getDisplayName().compareTo(right.toStack().getDisplayName());
|
return left.toCachedStack().getDisplayName().compareTo(right.toCachedStack().getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -259,7 +259,7 @@ public class GuiGrid extends GuiBase {
|
|||||||
text = String.valueOf(qty);
|
text = String.valueOf(qty);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawItem(x, y, items.get(slot).toStack(), true, text);
|
drawItem(x, y, items.get(slot).toCachedStack(), true, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inBounds(x, y, 16, 16, mouseX, mouseY) || !grid.isConnected()) {
|
if (inBounds(x, y, 16, 16, mouseX, mouseY) || !grid.isConnected()) {
|
||||||
@@ -287,7 +287,7 @@ public class GuiGrid extends GuiBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isHoveringOverItemInSlot()) {
|
if (isHoveringOverItemInSlot()) {
|
||||||
drawTooltip(mouseX, mouseY, items.get(hoveringSlot).toStack());
|
drawTooltip(mouseX, mouseY, items.get(hoveringSlot).toCachedStack());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isHoveringOverClear(mouseX, mouseY)) {
|
if (isHoveringOverClear(mouseX, mouseY)) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public class ItemGroup {
|
|||||||
private NBTTagCompound tag;
|
private NBTTagCompound tag;
|
||||||
// Used clientside
|
// Used clientside
|
||||||
private int id;
|
private int id;
|
||||||
|
private ItemStack cachedStack;
|
||||||
|
|
||||||
public ItemGroup(ByteBuf buf) {
|
public ItemGroup(ByteBuf buf) {
|
||||||
this.id = buf.readInt();
|
this.id = buf.readInt();
|
||||||
@@ -165,4 +166,12 @@ public class ItemGroup {
|
|||||||
|
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemStack toCachedStack() {
|
||||||
|
if (cachedStack == null) {
|
||||||
|
cachedStack = toStack();
|
||||||
|
}
|
||||||
|
|
||||||
|
return cachedStack;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user