More perf improvements to grid
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
# Refined Storage Changelog
|
# Refined Storage Changelog
|
||||||
|
|
||||||
|
### 0.8.17
|
||||||
|
**Bugfixes**
|
||||||
|
- Fixed Grid causing sorting lag on the client
|
||||||
|
|
||||||
### 0.8.16
|
### 0.8.16
|
||||||
**Bugfixes**
|
**Bugfixes**
|
||||||
- Fixed issue with IC2 integration causing console spam
|
- Fixed issue with IC2 integration causing console spam
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package refinedstorage.gui.grid;
|
package refinedstorage.gui.grid;
|
||||||
|
|
||||||
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.client.gui.GuiTextField;
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
@@ -36,10 +38,10 @@ public class GuiGrid extends GuiBase {
|
|||||||
public static final GridSortingQuantity SORTING_QUANTITY = new GridSortingQuantity();
|
public static final GridSortingQuantity SORTING_QUANTITY = new GridSortingQuantity();
|
||||||
public static final GridSortingName SORTING_NAME = new GridSortingName();
|
public static final GridSortingName SORTING_NAME = new GridSortingName();
|
||||||
|
|
||||||
public static List<ClientStack> ITEMS = new ArrayList<>();
|
public static Multimap<Item, ClientStack> ITEMS = ArrayListMultimap.create();
|
||||||
public static List<ClientStack> SORTED_ITEMS = new ArrayList<>();
|
public static List<ClientStack> SORTED_ITEMS = new ArrayList<>();
|
||||||
|
|
||||||
public static boolean markedForSorting;
|
private static boolean markedForSorting;
|
||||||
|
|
||||||
private GuiTextField searchField;
|
private GuiTextField searchField;
|
||||||
|
|
||||||
@@ -48,6 +50,10 @@ public class GuiGrid extends GuiBase {
|
|||||||
|
|
||||||
private int slotNumber;
|
private int slotNumber;
|
||||||
|
|
||||||
|
public static void markForSorting() {
|
||||||
|
markedForSorting = true;
|
||||||
|
}
|
||||||
|
|
||||||
public GuiGrid(ContainerGrid container, IGrid grid) {
|
public GuiGrid(ContainerGrid container, IGrid grid) {
|
||||||
super(container, 227, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 247 : 208);
|
super(container, 227, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 247 : 208);
|
||||||
|
|
||||||
@@ -95,7 +101,7 @@ public class GuiGrid extends GuiBase {
|
|||||||
List<ClientStack> sortedItems = new ArrayList<>();
|
List<ClientStack> sortedItems = new ArrayList<>();
|
||||||
|
|
||||||
if (grid.isConnected()) {
|
if (grid.isConnected()) {
|
||||||
sortedItems.addAll(ITEMS);
|
sortedItems.addAll(ITEMS.values());
|
||||||
|
|
||||||
String query = searchField.getText().trim().toLowerCase();
|
String query = searchField.getText().trim().toLowerCase();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package refinedstorage.network;
|
package refinedstorage.network;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
@@ -39,22 +40,24 @@ public class MessageGridDelta implements IMessage, IMessageHandler<MessageGridDe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMessage onMessage(MessageGridDelta message, MessageContext ctx) {
|
public IMessage onMessage(MessageGridDelta message, MessageContext ctx) {
|
||||||
for (ClientStack stack : GuiGrid.ITEMS) {
|
Item item = message.clientStack.getStack().getItem();
|
||||||
|
|
||||||
|
for (ClientStack stack : GuiGrid.ITEMS.get(item)) {
|
||||||
if (stack.equals(message.clientStack)) {
|
if (stack.equals(message.clientStack)) {
|
||||||
if (stack.getStack().stackSize + message.delta == 0 && !message.clientStack.isCraftable()) {
|
if (stack.getStack().stackSize + message.delta == 0 && !message.clientStack.isCraftable()) {
|
||||||
GuiGrid.ITEMS.remove(stack);
|
GuiGrid.ITEMS.remove(item, stack);
|
||||||
} else {
|
} else {
|
||||||
stack.getStack().stackSize += message.delta;
|
stack.getStack().stackSize += message.delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiGrid.markedForSorting = true;
|
GuiGrid.markForSorting();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiGrid.ITEMS.add(message.clientStack);
|
GuiGrid.ITEMS.put(item, message.clientStack);
|
||||||
GuiGrid.markedForSorting = true;
|
GuiGrid.markForSorting();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,8 +43,13 @@ public class MessageGridUpdate implements IMessage, IMessageHandler<MessageGridU
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMessage onMessage(MessageGridUpdate message, MessageContext ctx) {
|
public IMessage onMessage(MessageGridUpdate message, MessageContext ctx) {
|
||||||
GuiGrid.ITEMS = message.items;
|
GuiGrid.ITEMS.clear();
|
||||||
GuiGrid.markedForSorting = true;
|
|
||||||
|
for (ClientStack item : message.items) {
|
||||||
|
GuiGrid.ITEMS.put(item.getStack().getItem(), item);
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiGrid.markForSorting();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,8 +51,7 @@ public class TileGrid extends TileNode implements IGrid {
|
|||||||
tile.markDirty();
|
tile.markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, parameter ->
|
}, parameter -> GuiGrid.markForSorting());
|
||||||
GuiGrid.markedForSorting = true);
|
|
||||||
|
|
||||||
public static final TileDataParameter<Integer> SORTING_DIRECTION = new TileDataParameter<>(DataSerializers.VARINT, 0, new ITileDataProducer<Integer, TileGrid>() {
|
public static final TileDataParameter<Integer> SORTING_DIRECTION = new TileDataParameter<>(DataSerializers.VARINT, 0, new ITileDataProducer<Integer, TileGrid>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -68,7 +67,7 @@ public class TileGrid extends TileNode implements IGrid {
|
|||||||
tile.markDirty();
|
tile.markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, parameter -> GuiGrid.markedForSorting = true);
|
}, parameter -> GuiGrid.markForSorting());
|
||||||
|
|
||||||
public static final TileDataParameter<Integer> SORTING_TYPE = new TileDataParameter<>(DataSerializers.VARINT, 0, new ITileDataProducer<Integer, TileGrid>() {
|
public static final TileDataParameter<Integer> SORTING_TYPE = new TileDataParameter<>(DataSerializers.VARINT, 0, new ITileDataProducer<Integer, TileGrid>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -84,7 +83,7 @@ public class TileGrid extends TileNode implements IGrid {
|
|||||||
tile.markDirty();
|
tile.markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, parameter -> GuiGrid.markedForSorting = true);
|
}, parameter -> GuiGrid.markForSorting());
|
||||||
|
|
||||||
public static final TileDataParameter<Integer> SEARCH_BOX_MODE = new TileDataParameter<>(DataSerializers.VARINT, 0, new ITileDataProducer<Integer, TileGrid>() {
|
public static final TileDataParameter<Integer> SEARCH_BOX_MODE = new TileDataParameter<>(DataSerializers.VARINT, 0, new ITileDataProducer<Integer, TileGrid>() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ public class WirelessGrid implements IGrid {
|
|||||||
|
|
||||||
this.viewType = type;
|
this.viewType = type;
|
||||||
|
|
||||||
GuiGrid.markedForSorting = true;
|
GuiGrid.markForSorting();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -125,7 +125,7 @@ public class WirelessGrid implements IGrid {
|
|||||||
|
|
||||||
this.sortingType = type;
|
this.sortingType = type;
|
||||||
|
|
||||||
GuiGrid.markedForSorting = true;
|
GuiGrid.markForSorting();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -134,7 +134,7 @@ public class WirelessGrid implements IGrid {
|
|||||||
|
|
||||||
this.sortingDirection = direction;
|
this.sortingDirection = direction;
|
||||||
|
|
||||||
GuiGrid.markedForSorting = true;
|
GuiGrid.markForSorting();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user