20 lines
1.2 KiB
Diff
20 lines
1.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
|
Date: Sat, 25 Jul 2026 21:07:48 +0800
|
|
Subject: [PATCH] Lithium optimized collections for WeightedList
|
|
|
|
|
|
diff --git a/net/minecraft/util/random/WeightedList.java b/net/minecraft/util/random/WeightedList.java
|
|
index a8481259e42aa116e29bccd1e30fdfd91f51a8cc..e6dd554742ab60c23afed69953e7eb6b762754d6 100644
|
|
--- a/net/minecraft/util/random/WeightedList.java
|
|
+++ b/net/minecraft/util/random/WeightedList.java
|
|
@@ -23,7 +23,7 @@ public class WeightedList<E> { // Paper - non-final
|
|
private final WeightedList.@Nullable Selector<E> selector;
|
|
|
|
protected WeightedList(final List<? extends Weighted<E>> items) { // Paper - protected
|
|
- this.items = List.copyOf(items);
|
|
+ this.items = items.size() > 4 ? new net.caffeinemc.mods.lithium.common.util.collections.HashedReferenceList(items) : new it.unimi.dsi.fastutil.objects.ReferenceArrayList<>(items); // Shiroha - Lithium optimized collections for WeightedList
|
|
this.totalWeight = WeightedRandom.getTotalWeight(items, Weighted::weight);
|
|
if (this.totalWeight == 0) {
|
|
this.selector = null;
|