mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-27 05:05:14 +01:00
5f55124016
This update had major internal changes, which took us 8 hours to figure out and resolve all things untill we have a successful build. YatopiaMC members wish you happy playing using Yatopia for your server software MAKE A BACKUP OF YOUR WORLD BEFORE RUNNING IT ON YOUR SERVER. YOU HAVE BEEN WARNED. People have reported to paper that after upgrading villagers are gone. There could be even more issues we are unknown of. MAKE A BACKUP OF YOUR WORLD BEFORE RUNNING IT ON YOUR SERVER. YOU HAVE BEEN WARNED. Co-authored-by: Ovydux <68059159+Ovydux@users.noreply.github.com> Co-authored-by: Simon Gardling <Titaniumtown@gmail.com> Co-authored-by: budgidiere <sgidiere@gmail.com>
199 lines
5.5 KiB
Diff
199 lines
5.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: JellySquid <jellysquid+atwork@protonmail.com>
|
|
Date: Fri, 31 Jul 2020 21:46:32 -0500
|
|
Subject: [PATCH] lithium MixinBiome
|
|
|
|
Original code by JellySquid, licensed under GNU Lesser General Public License v3.0
|
|
you can find the original code on https://github.com/jellysquid3/lithium-fabric/tree/1.16.x/fabric (Yarn mappings)
|
|
|
|
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/collections/HashedList.java b/src/main/java/me/jellysquid/mods/lithium/common/util/collections/HashedList.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..15cc7232e4edf6803e4b831ff094a748f95e1f9a
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/jellysquid/mods/lithium/common/util/collections/HashedList.java
|
|
@@ -0,0 +1,171 @@
|
|
+package me.jellysquid.mods.lithium.common.util.collections;
|
|
+
|
|
+import java.util.Collection;
|
|
+import java.util.HashSet;
|
|
+import java.util.Iterator;
|
|
+import java.util.List;
|
|
+import java.util.ListIterator;
|
|
+import java.util.Set;
|
|
+
|
|
+/**
|
|
+ * Wraps a {@link List} with a hash table which provides O(1) lookups for {@link Collection#contains(Object)}.
|
|
+ *
|
|
+ * @see <a href="https://github.com/jellysquid3/lithium-fabric/blob/1.16.x/fabric/src/main/java/me/jellysquid/mods/lithium/common/util/collections/HashedList.java">HashedList</a>
|
|
+ */
|
|
+public class HashedList<T> implements List<T> {
|
|
+ private final List<T> list;
|
|
+ private final Set<T> set;
|
|
+
|
|
+ private HashedList(List<T> list, Set<T> set) {
|
|
+ this.list = list;
|
|
+ this.set = set;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public int size() {
|
|
+ return this.list.size();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isEmpty() {
|
|
+ return this.list.isEmpty();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean contains(Object o) {
|
|
+ return this.set.contains(o);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Iterator<T> iterator() {
|
|
+ return this.list.iterator();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Object[] toArray() {
|
|
+ return this.list.toArray();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public <T1> T1[] toArray(T1[] a) {
|
|
+ return this.list.toArray(a);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean add(T t) {
|
|
+ this.set.add(t);
|
|
+
|
|
+ return this.list.add(t);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean remove(Object o) {
|
|
+ this.set.remove(o);
|
|
+
|
|
+ return this.list.remove(o);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean containsAll(Collection<?> c) {
|
|
+ return this.set.containsAll(c);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean addAll(Collection<? extends T> c) {
|
|
+ this.set.addAll(c);
|
|
+
|
|
+ return this.list.addAll(c);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean addAll(int index, Collection<? extends T> c) {
|
|
+ this.set.addAll(c);
|
|
+
|
|
+ return this.list.addAll(index, c);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean removeAll(Collection<?> c) {
|
|
+ this.set.removeAll(c);
|
|
+
|
|
+ return this.list.removeAll(c);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean retainAll(Collection<?> c) {
|
|
+ this.set.retainAll(c);
|
|
+
|
|
+ return this.list.retainAll(c);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void clear() {
|
|
+ this.set.clear();
|
|
+ this.list.clear();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public T get(int index) {
|
|
+ return this.list.get(index);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public T set(int index, T element) {
|
|
+ T prev = this.list.set(index, element);
|
|
+
|
|
+ if (prev != null) {
|
|
+ this.set.remove(prev);
|
|
+ }
|
|
+
|
|
+ this.set.add(element);
|
|
+
|
|
+ return prev;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void add(int index, T element) {
|
|
+ this.set.add(element);
|
|
+
|
|
+ this.list.add(index, element);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public T remove(int index) {
|
|
+ T prev = this.list.remove(index);
|
|
+
|
|
+ if (prev != null) {
|
|
+ this.set.remove(prev);
|
|
+ }
|
|
+
|
|
+ return prev;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public int indexOf(Object o) {
|
|
+ return this.list.indexOf(o);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public int lastIndexOf(Object o) {
|
|
+ return this.list.lastIndexOf(o);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public ListIterator<T> listIterator() {
|
|
+ return this.list.listIterator();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public ListIterator<T> listIterator(int index) {
|
|
+ return this.list.listIterator(index);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public List<T> subList(int fromIndex, int toIndex) {
|
|
+ return this.list.subList(fromIndex, toIndex);
|
|
+ }
|
|
+
|
|
+ public static <T> HashedList<T> wrapper(List<T> list) {
|
|
+ return new HashedList<>(list, new HashSet<>(list)); // Yatopia - use hashset
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/server/BiomeSettingsMobs.java b/src/main/java/net/minecraft/server/BiomeSettingsMobs.java
|
|
index a18ca3f0001a771f21012bd39711f581efb2fef0..0f88b7b38b6191c3adbebdee82427275640c4197 100644
|
|
--- a/src/main/java/net/minecraft/server/BiomeSettingsMobs.java
|
|
+++ b/src/main/java/net/minecraft/server/BiomeSettingsMobs.java
|
|
@@ -113,7 +113,7 @@ public class BiomeSettingsMobs {
|
|
private final Map<EnumCreatureType, List<BiomeSettingsMobs.c>> a = (Map) Stream.of(EnumCreatureType.values()).collect(Maps.toImmutableEnumMap((enumcreaturetype) -> {
|
|
return enumcreaturetype;
|
|
}, (enumcreaturetype) -> {
|
|
- return new MobList(); // Use MobList instead of ArrayList
|
|
+ return me.jellysquid.mods.lithium.common.util.collections.HashedList.wrapper(new MobList()); // Use MobList instead of ArrayList // Yatopia - hashedlist
|
|
}));
|
|
// Paper end
|
|
private final Map<EntityTypes<?>, BiomeSettingsMobs.b> b = Maps.newLinkedHashMap();
|