Skip to content

Commit 89abaad

Browse files
szuendDream-Master
authored andcommitted
fix: Drastically reduce number of display lists when transporting fluids (#45)
LogisticsNewPipeItemBoxRenderer has a display list cache for rendering fluids. Unfortunately there is a small bug/typo where a `FluidStack` is used as the key for lookup, but a `FluidIdentifier` is used for writing the cached display list array. Essentially, the cache is unused and we create a fresh display list for every traveling liquid box in every frame. To fix, we simply use the FluidIdentifier consistently. This should help with FPS in networks with lots of (vsibily) traveling fluids. (cherry picked from commit 3848737)
1 parent 03d7d99 commit 89abaad

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/main/java/logisticspipes/renderer/newpipe/LogisticsNewPipeItemBoxRenderer.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,8 @@ public void doRenderItem(ItemIdentifierStack itemIdentifierStack, float light, d
7171
}
7272

7373
private int getRenderListFor(FluidStack fluid) {
74-
FluidIdentifier ident = FluidIdentifier.get(fluid);
75-
int[] array = LogisticsNewPipeItemBoxRenderer.renderLists.get(fluid);
76-
if (array == null) {
77-
array = new int[LogisticsNewPipeItemBoxRenderer.RENDER_SIZE];
78-
LogisticsNewPipeItemBoxRenderer.renderLists.put(ident, array);
79-
}
74+
int[] array = LogisticsNewPipeItemBoxRenderer.renderLists
75+
.computeIfAbsent(FluidIdentifier.get(fluid), k -> new int[LogisticsNewPipeItemBoxRenderer.RENDER_SIZE]);
8076
int pos = Math.min(
8177
(int) (((Math.min(fluid.amount, 5000) * 1.0F) * LogisticsNewPipeItemBoxRenderer.RENDER_SIZE) / 5000),
8278
LogisticsNewPipeItemBoxRenderer.RENDER_SIZE - 1);

0 commit comments

Comments
 (0)