geforkt von Mirrors/Paper
Ability to get block entities from a chunk without snapshots
Dieser Commit ist enthalten in:
Ursprung
d178f73bb8
Commit
584836a2e4
@ -174,6 +174,13 @@ public class CraftChunk implements Chunk {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState[] getTileEntities() {
|
public BlockState[] getTileEntities() {
|
||||||
|
// Paper start
|
||||||
|
return getTileEntities(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState[] getTileEntities(boolean useSnapshot) {
|
||||||
|
// Paper end
|
||||||
if (!this.isLoaded()) {
|
if (!this.isLoaded()) {
|
||||||
this.getWorld().getChunkAt(this.x, this.z); // Transient load for this tick
|
this.getWorld().getChunkAt(this.x, this.z); // Transient load for this tick
|
||||||
}
|
}
|
||||||
@ -183,7 +190,29 @@ public class CraftChunk implements Chunk {
|
|||||||
BlockState[] entities = new BlockState[chunk.blockEntities.size()];
|
BlockState[] entities = new BlockState[chunk.blockEntities.size()];
|
||||||
|
|
||||||
for (BlockPos position : chunk.blockEntities.keySet()) {
|
for (BlockPos position : chunk.blockEntities.keySet()) {
|
||||||
entities[index++] = this.worldServer.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()).getState();
|
// Paper start
|
||||||
|
entities[index++] = this.worldServer.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()).getState(useSnapshot);
|
||||||
|
}
|
||||||
|
|
||||||
|
return entities;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<BlockState> getTileEntities(Predicate<? super Block> blockPredicate, boolean useSnapshot) {
|
||||||
|
Preconditions.checkNotNull(blockPredicate, "blockPredicate");
|
||||||
|
if (!this.isLoaded()) {
|
||||||
|
this.getWorld().getChunkAt(this.x, this.z); // Transient load for this tick
|
||||||
|
}
|
||||||
|
ChunkAccess chunk = this.getHandle(ChunkStatus.FULL);
|
||||||
|
|
||||||
|
java.util.List<BlockState> entities = new java.util.ArrayList<>();
|
||||||
|
|
||||||
|
for (BlockPos position : chunk.blockEntities.keySet()) {
|
||||||
|
Block block = this.worldServer.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
|
||||||
|
if (blockPredicate.test(block)) {
|
||||||
|
entities.add(block.getState(useSnapshot));
|
||||||
|
}
|
||||||
|
// Paper end
|
||||||
}
|
}
|
||||||
|
|
||||||
return entities;
|
return entities;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren