limit the amount of dropped items rendered exactly to the config value (#973)

This commit is contained in:
Alexdoru authored and GitHub committed 2025-06-16 07:55:28 +02:00
1 parent 30a35ef25e
commit 891715b113
1 file changed
+8 -3
@@ -17,16 +17,19 @@ public class MixinRenderGlobal_ItemRenderDist {
@Unique private static final int[] sodium$entityItemCount = new int[256];
@Unique private static int sodium$itemRenderDist = 255;
@Unique private static int sodium$itemRenderedCount;
@Unique private static int sodium$itemLimit = Integer.MAX_VALUE;
@Inject(method = "renderEntities", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/RenderGlobal;countEntitiesRendered:I", ordinal = 0))
private void sodium$resetEntitycount(CallbackInfo ci) {
sodium$itemRenderedCount = 0;
int entityCount = 0;
boolean reachedLimit = false;
final int itemLimit = AngelicaConfig.droppedItemLimit == 2048 ? Integer.MAX_VALUE : AngelicaConfig.droppedItemLimit;
sodium$itemLimit = AngelicaConfig.droppedItemLimit == 2048 ? Integer.MAX_VALUE : AngelicaConfig.droppedItemLimit;
for (int i = 0; i < sodium$entityItemCount.length; i++) {
entityCount += sodium$entityItemCount[i];
sodium$entityItemCount[i] = 0;
if (!reachedLimit && entityCount > itemLimit) {
if (!reachedLimit && entityCount > sodium$itemLimit) {
reachedLimit = true;
sodium$itemRenderDist = i == 0 ? 1 : i;
}
@@ -45,7 +48,9 @@ public class MixinRenderGlobal_ItemRenderDist {
if (flag && entity instanceof EntityItem) {
final int i = Math.min((int) (entity.getDistanceSq(d0, d1, d2) / 4.0D), 255);
sodium$entityItemCount[i]++;
return i <= sodium$itemRenderDist;
final boolean doRender = i <= sodium$itemRenderDist && sodium$itemRenderedCount < sodium$itemLimit;
if (doRender) sodium$itemRenderedCount++;
return doRender;
}
return flag;
}