3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 11:00:06 +01:00
Paper/CraftBukkit-Patches/0155-Use-Standard-List-for-EntitySlices.patch

120 Zeilen
5.5 KiB
Diff

2015-03-17 22:22:17 +01:00
From a91315b617a10e50a22eb0fd1f33433fff9834f7 Mon Sep 17 00:00:00 2001
2015-02-20 11:34:11 +01:00
From: md_5 <git@md-5.net>
Date: Fri, 20 Feb 2015 21:33:36 +1100
Subject: [PATCH] Use Standard List for EntitySlices.
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
2015-03-16 11:19:21 +01:00
index db7f6bc..2141126 100644
2015-02-20 11:34:11 +01:00
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -31,7 +31,7 @@ public class Chunk {
public final int locZ;
private boolean k;
2015-02-28 12:36:22 +01:00
public final Map<BlockPosition, TileEntity> tileEntities;
- public final EntitySlice<Entity>[] entitySlices; // CraftBukkit - public
+ public final List<Entity>[] entitySlices; // Spigot
private boolean done;
2015-02-20 11:34:11 +01:00
private boolean lit;
private boolean p;
2015-03-15 22:45:15 +01:00
@@ -80,7 +80,7 @@ public class Chunk {
2015-02-20 11:34:11 +01:00
this.tileEntities = Maps.newHashMap();
this.v = 4096;
this.w = Queues.newConcurrentLinkedQueue();
- this.entitySlices = (EntitySlice[]) (new EntitySlice[16]);
+ this.entitySlices = (List[]) (new List[16]); // Spigot
this.world = world;
this.locX = i;
this.locZ = j;
2015-03-15 22:45:15 +01:00
@@ -88,7 +88,7 @@ public class Chunk {
2015-02-20 11:34:11 +01:00
2015-03-15 22:45:15 +01:00
/* CraftBukkit start
2015-02-20 11:34:11 +01:00
for (int k = 0; k < this.entitySlices.length; ++k) {
- this.entitySlices[k] = new EntitySlice(Entity.class);
+ this.entitySlices[k] = new org.bukkit.craftbukkit.util.UnsafeList(); // Spigot
}
2015-03-15 22:45:15 +01:00
// CraftBukkit end */
2015-02-20 11:34:11 +01:00
2015-03-16 11:19:21 +01:00
@@ -926,12 +926,12 @@ public class Chunk {
2015-02-20 11:34:11 +01:00
j = MathHelper.clamp(j, 0, this.entitySlices.length - 1);
for (int k = i; k <= j; ++k) {
2015-02-28 12:36:22 +01:00
- Iterator iterator = this.entitySlices[k].c(oclass).iterator();
2015-02-20 11:34:11 +01:00
+ Iterator iterator = this.entitySlices[k].iterator(); // Spigot
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
2015-02-28 12:36:22 +01:00
- if (entity.getBoundingBox().b(axisalignedbb) && (predicate == null || predicate.apply((T) entity))) { // CraftBukkit - fix decompile error
+ if (oclass.isInstance(entity) && entity.getBoundingBox().b(axisalignedbb) && (predicate == null || predicate.apply((T) entity))) { // CraftBukkit - fix decompile error // Spigot
list.add((T) entity); // Fix decompile error
2015-02-20 11:34:11 +01:00
}
}
2015-03-16 11:19:21 +01:00
@@ -1311,7 +1311,7 @@ public class Chunk {
2015-02-20 11:34:11 +01:00
return this.tileEntities;
}
2015-02-28 12:36:22 +01:00
- public EntitySlice<Entity>[] getEntitySlices() {
+ public List<Entity>[] getEntitySlices() {
2015-02-20 11:34:11 +01:00
return this.entitySlices;
}
2015-03-15 22:45:15 +01:00
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index c143d01..4ac27d0 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -157,7 +157,7 @@ public class ChunkProviderServer implements IChunkProvider {
// CraftBukkit start - moved from Chunk.<init>
for (int k = 0; k < chunk.entitySlices.length; ++k) {
- chunk.entitySlices[k] = new EntitySlice(Entity.class);
+ chunk.entitySlices[k] = new org.bukkit.craftbukkit.util.UnsafeList(); // Spigot
}
// CraftBukkit end
chunk.addEntities();
2015-03-16 20:47:37 +01:00
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index 4e47890..1f6212e 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -402,7 +402,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
public void loadEntities(Chunk chunk, NBTTagCompound nbttagcompound, World world) {
2015-03-15 22:45:15 +01:00
// moved from Chunk.<init>
for (int k = 0; k < chunk.entitySlices.length; ++k) {
- chunk.entitySlices[k] = new EntitySlice(Entity.class);
+ chunk.entitySlices[k] = new org.bukkit.craftbukkit.util.UnsafeList(); // Spigot
}
2015-03-16 20:47:37 +01:00
// CraftBukkit end
world.timings.syncChunkLoadEntitiesTimer.startTiming(); // Spigot
2015-03-17 22:22:17 +01:00
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index d381fd7..7a1f2c7 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -268,7 +268,7 @@ public class CraftWorld implements World {
if (chunk != null) {
// moved from Chunk.<init>
for (int k = 0; k < chunk.entitySlices.length; ++k) {
- chunk.entitySlices[k] = new EntitySlice(net.minecraft.server.Entity.class);
+ chunk.entitySlices[k] = new org.bukkit.craftbukkit.util.UnsafeList();
}
world.chunkProviderServer.chunks.put(LongHash.toLong(cx, cz), chunk);
2015-02-20 11:38:01 +01:00
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
2015-02-28 12:36:22 +01:00
index 0143623..621a717 100644
2015-02-20 11:38:01 +01:00
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -141,9 +141,9 @@ public class ActivationRange
*/
private static void activateChunkEntities(Chunk chunk)
{
- for ( EntitySlice slice : chunk.entitySlices )
+ for ( List<Entity> slice : chunk.entitySlices )
{
- for ( Entity entity : (Set<Entity>) slice )
+ for ( Entity entity : slice )
{
if ( MinecraftServer.currentTick > entity.activatedTick )
{
2015-02-20 11:34:11 +01:00
--
2.1.0