9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-26 18:39:23 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0247-Use-HashedList-on-WeightedList.patch
Dreeam 3c25377465 Drop some unused patches
ClassInstanceMultiMap belongs to Minecraft vanilla entity storage.
And is unused, since replaced by spottedleaf's entity storage (rewrite chunk system).
However these patches might be useful for vanilla entity storage if is used.
2025-07-09 04:20:02 +08:00

36 lines
1.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Tue, 13 May 2025 20:41:07 +0200
Subject: [PATCH] Use HashedList on WeightedList
diff --git a/net/minecraft/util/random/WeightedList.java b/net/minecraft/util/random/WeightedList.java
index daab145028c59c07049a2cf75c4f159e4c5073dc..4bb07ffde3674dc8d09b858ec0bd1ebc8a83bff1 100644
--- a/net/minecraft/util/random/WeightedList.java
+++ b/net/minecraft/util/random/WeightedList.java
@@ -19,6 +19,7 @@ public class WeightedList<E> { // Paper - non-final
private final List<Weighted<E>> items;
@Nullable
private final WeightedList.Selector<E> selector;
+ private List<Weighted<E>> entryHashList; // Leaf - Use HashedList on WeightedList
protected WeightedList(List<? extends Weighted<E>> items) { // Paper - protected
this.items = List.copyOf(items);
@@ -30,6 +31,7 @@ public class WeightedList<E> { // Paper - non-final
} else {
this.selector = new WeightedList.Compact<>(this.items);
}
+ this.entryHashList = this.items.size() > 4 ? this.items : java.util.Collections.unmodifiableList(new org.dreeam.leaf.util.list.HashedReferenceList<>(this.items)); // Leaf - Use HashedList on WeightedList
}
public static <E> WeightedList<E> of() {
@@ -80,7 +82,7 @@ public class WeightedList<E> { // Paper - non-final
}
public List<Weighted<E>> unwrap() {
- return this.items;
+ return this.entryHashList; // Leaf - Use HashedList on WeightedList
}
public static <E> Codec<WeightedList<E>> codec(Codec<E> elementCodec) {