Ability to get Tile Entities from chunks without snapshots
Also make Timings use said new feature and not create snapshots on it reading data
Dieser Commit ist enthalten in:
Ursprung
ac87790299
Commit
36e6c991af
@ -0,0 +1,39 @@
|
||||
From cf321e2bc3a1fdb44194e62e0976849571f04387 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 15 Aug 2018 01:04:58 -0400
|
||||
Subject: [PATCH] Ability to get Tile Entities from a chunk without snapshots
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Chunk.java b/src/main/java/org/bukkit/Chunk.java
|
||||
index c75bce07a..dc847340f 100644
|
||||
--- a/src/main/java/org/bukkit/Chunk.java
|
||||
+++ b/src/main/java/org/bukkit/Chunk.java
|
||||
@@ -76,12 +76,24 @@ public interface Chunk {
|
||||
*/
|
||||
Entity[] getEntities();
|
||||
|
||||
+ // Paper start
|
||||
/**
|
||||
* Get a list of all tile entities in the chunk.
|
||||
*
|
||||
* @return The tile entities.
|
||||
*/
|
||||
- BlockState[] getTileEntities();
|
||||
+ default BlockState[] getTileEntities() {
|
||||
+ return getTileEntities(true);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get a list of all tile entities in the chunk.
|
||||
+ *
|
||||
+ * @param useSnapshot Take snapshots or direct references
|
||||
+ * @return The tile entities.
|
||||
+ */
|
||||
+ BlockState[] getTileEntities(boolean useSnapshot);
|
||||
+ // Paper end
|
||||
|
||||
/**
|
||||
* Checks if the chunk is loaded.
|
||||
--
|
||||
2.18.0
|
||||
|
@ -0,0 +1,22 @@
|
||||
From 65a6244ec0d4bddeda62628e2edc621f0f448ed9 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 15 Aug 2018 01:19:37 -0400
|
||||
Subject: [PATCH] Don't use snapshots for Timings Tile Entity reports
|
||||
|
||||
|
||||
diff --git a/src/main/java/co/aikar/timings/TimingHistory.java b/src/main/java/co/aikar/timings/TimingHistory.java
|
||||
index c2c2fb838..769facd80 100644
|
||||
--- a/src/main/java/co/aikar/timings/TimingHistory.java
|
||||
+++ b/src/main/java/co/aikar/timings/TimingHistory.java
|
||||
@@ -118,7 +118,7 @@ public class TimingHistory {
|
||||
data.entityCounts.get(entity.getType()).increment();
|
||||
}
|
||||
|
||||
- for (BlockState tileEntity : chunk.getTileEntities()) {
|
||||
+ for (BlockState tileEntity : chunk.getTileEntities(false)) {
|
||||
if (tileEntity == null) {
|
||||
Bukkit.getLogger().warning("Null tileentity detected in chunk at position x: " + chunk.getX() + ", z: " + chunk.getZ());
|
||||
continue;
|
||||
--
|
||||
2.18.0
|
||||
|
@ -0,0 +1,35 @@
|
||||
From 80f6f47ba434a4b53b71411540bedeb56cdbf512 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 15 Aug 2018 01:16:34 -0400
|
||||
Subject: [PATCH] Ability to get Tile Entities from a chunk without snapshots
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
||||
index 0a47353b48..3238ca7420 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
||||
@@ -96,7 +96,12 @@ public class CraftChunk implements Chunk {
|
||||
return entities;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
public BlockState[] getTileEntities() {
|
||||
+ return getTileEntities(true);
|
||||
+ }
|
||||
+ public BlockState[] getTileEntities(boolean useSnapshot) {
|
||||
+ // Paper end
|
||||
int index = 0;
|
||||
net.minecraft.server.Chunk chunk = getHandle();
|
||||
|
||||
@@ -108,7 +113,7 @@ public class CraftChunk implements Chunk {
|
||||
}
|
||||
|
||||
BlockPosition position = (BlockPosition) obj;
|
||||
- entities[index++] = worldServer.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()).getState();
|
||||
+ entities[index++] = worldServer.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()).getState(useSnapshot); // Paper
|
||||
}
|
||||
|
||||
return entities;
|
||||
--
|
||||
2.18.0
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren