mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
Ability to get Tile Entities from chunks without snapshots
Also make Timings use said new feature and not create snapshots on it reading data
This commit is contained in:
parent
45df85fc40
commit
c235889d4a
3 changed files with 90 additions and 0 deletions
|
@ -0,0 +1,37 @@
|
|||
From 0000000000000000000000000000000000000000 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
|
||||
@@ -0,0 +0,0 @@ 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.
|
||||
--
|
|
@ -0,0 +1,20 @@
|
|||
From 0000000000000000000000000000000000000000 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
|
||||
@@ -0,0 +0,0 @@ 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;
|
||||
--
|
|
@ -0,0 +1,33 @@
|
|||
From 0000000000000000000000000000000000000000 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
|
||||
@@ -0,0 +0,0 @@ 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();
|
||||
|
||||
@@ -0,0 +0,0 @@ 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;
|
||||
--
|
Loading…
Reference in a new issue