Skip to content

Commit 9966c66

Browse files
committed
Skip unused cramping index
1 parent bacf810 commit 9966c66

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

common/src/main/java/com/loohp/interactionvisualizer/entities/DroppedItemDisplay.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,13 @@ private void tickAll() {
257257
return;
258258
}
259259

260-
DroppedItemSpatialIndex itemIndex = new DroppedItemSpatialIndex();
261-
for (TrackedItem tracked : validItems) {
262-
Location location = tracked.location();
263-
itemIndex.addItem(tracked.item().getWorld().getUID(),
264-
location.getX(), location.getY(), location.getZ());
260+
DroppedItemSpatialIndex itemIndex = cramp > 0 ? new DroppedItemSpatialIndex() : null;
261+
if (itemIndex != null) {
262+
for (TrackedItem tracked : validItems) {
263+
Location location = tracked.location();
264+
itemIndex.addItem(tracked.item().getWorld().getUID(),
265+
location.getX(), location.getY(), location.getZ());
266+
}
265267
}
266268
for (TrackedItem tracked : validItems) {
267269
update(tracked, itemIndex, viewerIndex);
@@ -294,7 +296,7 @@ private void update(TrackedItem tracked, DroppedItemSpatialIndex itemIndex,
294296
int ticksLeft = despawnTicks - item.getTicksLived();
295297
if (stack.isEmpty() || blacklist.matches(matchingName, stack.getType(), customItemId)
296298
|| item.getPickupDelay() >= Short.MAX_VALUE || ticksLeft <= 0
297-
|| (cramp > 0 && itemIndex.exceedsItemLimit(item.getWorld().getUID(),
299+
|| (itemIndex != null && itemIndex.exceedsItemLimit(item.getWorld().getUID(),
298300
itemLocation.getX(), itemLocation.getY(), itemLocation.getZ(), cramp))) {
299301
removeLabel(item.getUniqueId());
300302
return;

0 commit comments

Comments
 (0)