mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-06 02:42:34 +01:00
66 lines
3.5 KiB
Diff
66 lines
3.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: tr7zw <tr7zw@live.de>
|
|
Date: Wed, 5 Aug 2020 08:08:44 -0500
|
|
Subject: [PATCH] Optimize TileEntity loading
|
|
|
|
|
|
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
|
|
index c2c19a6fbfa2a4aba21aa71789071c69a6246556..7dfd36e22a896ae440bbda6db0628c44493b44d2 100644
|
|
--- 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
|
|
@@ -1,12 +1,10 @@
|
|
package me.jellysquid.mods.lithium.common.util.collections;
|
|
|
|
-import it.unimi.dsi.fastutil.objects.ObjectArraySet;
|
|
-
|
|
import java.util.*;
|
|
|
|
/**
|
|
* Wraps a {@link List} with a hash table which provides O(1) lookups for {@link Collection#contains(Object)}.
|
|
- *
|
|
+ * Uses a hashset so some issues can happen if the same entry get's added multiple times! (Doesn't matter for this usecase)
|
|
* @see https://github.com/jellysquid3/lithium-fabric/blob/1.16.x/fabric/src/main/java/me/jellysquid/mods/lithium/common/util/collections/HashedList.java
|
|
*/
|
|
public class HashedList<T> implements List<T> {
|
|
@@ -163,6 +161,6 @@ public class HashedList<T> implements List<T> {
|
|
}
|
|
|
|
public static <T> HashedList<T> wrapper(List<T> list) {
|
|
- return new HashedList<>(list, new ObjectArraySet<>(list));
|
|
+ return new HashedList<>(list, new HashSet<>(list));
|
|
}
|
|
}
|
|
\ No newline at end of file
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index 44af511da96b265a8441052cc87e356e630699a6..847a245606c5bb98a8821a9dcd677d7eb2e81e45 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -2,6 +2,8 @@ package net.minecraft.server;
|
|
|
|
import co.aikar.timings.Timing;
|
|
import co.aikar.timings.Timings;
|
|
+import me.jellysquid.mods.lithium.common.util.collections.HashedList;
|
|
+
|
|
import com.destroystokyo.paper.antixray.ChunkPacketBlockController; // Paper - Anti-Xray
|
|
import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray; // Paper - Anti-Xray
|
|
import com.destroystokyo.paper.event.server.ServerExceptionEvent;
|
|
@@ -11,6 +13,7 @@ import com.google.common.collect.Lists;
|
|
import com.mojang.serialization.Codec;
|
|
import com.proximyst.rainforest.RainforestWorldConfig;
|
|
import java.io.IOException;
|
|
+import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
@@ -43,8 +46,8 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
|
public static final ResourceKey<World> THE_END = ResourceKey.a(IRegistry.ae, new MinecraftKey("the_end"));
|
|
private static final EnumDirection[] a = EnumDirection.values();
|
|
//public final List<TileEntity> tileEntityList = Lists.newArrayList(); // Paper - remove unused list
|
|
- public final List<TileEntity> tileEntityListTick = Lists.newArrayList();
|
|
- protected final List<TileEntity> tileEntityListPending = Lists.newArrayList();
|
|
+ public final List<TileEntity> tileEntityListTick = HashedList.wrapper(Lists.newArrayList()); // Yatopia
|
|
+ protected final List<TileEntity> tileEntityListPending = HashedList.wrapper(Lists.newArrayList()); // Yatopia
|
|
protected final java.util.Set<TileEntity> tileEntityListUnload = com.google.common.collect.Sets.newHashSet();
|
|
public final Thread serverThread;
|
|
private final boolean debugWorld;
|