Paper/CraftBukkit-Patches/0140-Use-Standard-List-for-EntitySlices.patch

87 Zeilen
3.4 KiB
Diff

2016-03-01 01:23:45 +01:00
From 77134a53b8c718b84e50cb28cf1c24f5621763bf 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
2016-02-29 22:33:06 +01:00
index 277a6ad..f2bb134 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
2016-02-29 22:33:06 +01:00
@@ -32,7 +32,7 @@ public class Chunk {
2015-02-20 11:34:11 +01:00
public final int locZ;
2016-02-29 22:33:06 +01:00
private boolean l;
2015-02-28 12:36:22 +01:00
public final Map<BlockPosition, TileEntity> tileEntities;
- public final EntitySlice<Entity>[] entitySlices;
2015-02-28 12:36:22 +01:00
+ public final List<Entity>[] entitySlices; // Spigot
private boolean done;
2015-02-20 11:34:11 +01:00
private boolean lit;
2016-02-29 22:33:06 +01:00
private boolean q;
@@ -81,14 +81,14 @@ public class Chunk {
2015-02-20 11:34:11 +01:00
this.tileEntities = Maps.newHashMap();
2016-02-29 22:33:06 +01:00
this.w = 4096;
this.x = Queues.newConcurrentLinkedQueue();
2015-02-20 11:34:11 +01:00
- this.entitySlices = (EntitySlice[]) (new EntitySlice[16]);
+ this.entitySlices = (List[]) (new List[16]); // Spigot
this.world = world;
this.locX = i;
this.locZ = j;
2015-03-22 20:50:13 +01:00
this.heightMap = new int[256];
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
}
2016-02-29 22:33:06 +01:00
Arrays.fill(this.g, -999);
@@ -857,12 +857,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
}
}
2016-02-29 22:33:06 +01:00
@@ -1260,7 +1260,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-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
2016-02-29 22:33:06 +01:00
index 70d8ab1..d88f1b1 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
2016-02-29 22:33:06 +01:00
@@ -1,5 +1,6 @@
package org.spigotmc;
+import java.util.List;
import java.util.Set;
import net.minecraft.server.AxisAlignedBB;
import net.minecraft.server.Chunk;
@@ -140,9 +141,9 @@ public class ActivationRange
2015-02-20 11:38:01 +01:00
*/
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
--
2016-02-29 22:33:06 +01:00
2.5.0
2015-02-20 11:34:11 +01:00