mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-09 04:09:54 +01:00
75f3e084ad
1) You will not hold SpigotMC responsible for any losses or damages incurred to you by using this build 2) You will report ALL bugs to SpigotMC and not other parties Thanks for all the support and all parties who made this update possible; especially the awesome Spigot community. Sorry for the delay, but we had to fix some crucial bugs. Regressions in this commit: @mikeprimm's smarter chunk ticking patch has been removed as it prevents proper redstone and other block ticking logic.
48 lines
2.0 KiB
Diff
48 lines
2.0 KiB
Diff
From 4e69548e7279f907018b2d66fb5e074be25c6ee7 Mon Sep 17 00:00:00 2001
|
|
From: Mike Primm <mike@primmhome.com>
|
|
Date: Wed, 20 Feb 2013 23:07:53 -0500
|
|
Subject: [PATCH] Optimize getTileEntities performance
|
|
|
|
Avoid traversing tile entities for every loaded chunk
|
|
---
|
|
src/main/java/net/minecraft/server/WorldServer.java | 21 ++++++++++++---------
|
|
1 file changed, 12 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
|
index 957dbd9..b250438 100644
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
|
@@ -655,17 +655,20 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
|
|
|
|
public List getTileEntities(int i, int j, int k, int l, int i1, int j1) {
|
|
ArrayList arraylist = new ArrayList();
|
|
- // CraftBukkit start - use iterator
|
|
- Iterator iterator = this.tileEntityList.iterator();
|
|
-
|
|
- while (iterator.hasNext()) {
|
|
- TileEntity tileentity = (TileEntity) iterator.next();
|
|
- // CraftBukkit end
|
|
-
|
|
- if (tileentity.x >= i && tileentity.y >= j && tileentity.z >= k && tileentity.x < l && tileentity.y < i1 && tileentity.z < j1) {
|
|
- arraylist.add(tileentity);
|
|
+ // Spigot start - check in chunks: usually just from one
|
|
+ for (int cx = (i >> 4); cx <= ((l - 1) >> 4); cx++) {
|
|
+ for (int cz = (k >> 4); cz <= ((j1 - 1) >> 4); cz++) {
|
|
+ Chunk c = getChunkAt(cx, cz);
|
|
+ if (c == null) continue;
|
|
+ for (Object te : c.tileEntities.values()) {
|
|
+ TileEntity tileentity = (TileEntity) te;
|
|
+ if ((tileentity.x >= i) && (tileentity.y >= j) && (tileentity.z >= k) && (tileentity.x < l) && (tileentity.y < i1) && (tileentity.z < j1)) {
|
|
+ arraylist.add(tileentity);
|
|
+ }
|
|
+ }
|
|
}
|
|
}
|
|
+ // Spigot end
|
|
|
|
return arraylist;
|
|
}
|
|
--
|
|
1.8.1-rc2
|
|
|