Commits

DerFrZocker authored and md_5 committed 09b99daf309
SPIGOT-6722: Close entity manager when unloading world
No tags

nms-patches/net/minecraft/world/level/entity/PersistentEntitySectionManager.patch

Added
1 +--- a/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
2 ++++ b/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
3 +@@ -82,7 +82,7 @@
4 + long i = SectionPosition.c(t0.getChunkCoordinates());
5 + EntitySection<T> entitysection = this.sectionStorage.c(i);
6 +
7 +- entitysection.a((Object) t0);
8 ++ entitysection.a(t0); // CraftBukkit - decompile error
9 + t0.a(new PersistentEntitySectionManager.a(t0, i, entitysection));
10 + if (!flag) {
11 + this.callbacks.f(t0);
12 +@@ -254,13 +254,13 @@
13 + }
14 +
15 + private void f() {
16 +- this.chunksToUnload.removeIf((i) -> {
17 ++ this.chunksToUnload.removeIf((java.util.function.LongPredicate) (i) -> { // CraftBukkit - decompile error
18 + return this.chunkVisibility.get(i) != Visibility.HIDDEN ? true : this.d(i);
19 + });
20 + }
21 +
22 + private void g() {
23 +- ChunkEntities chunkentities;
24 ++ ChunkEntities<T> chunkentities; // CraftBukkit - decompile error
25 +
26 + while ((chunkentities = (ChunkEntities) this.loadingInbox.poll()) != null) {
27 + chunkentities.b().forEach((entityaccess) -> {
28 +@@ -292,7 +292,7 @@
29 + }
30 +
31 + public void b() {
32 +- this.h().forEach((i) -> {
33 ++ this.h().forEach((java.util.function.LongConsumer) (i) -> { // CraftBukkit - decompile error
34 + boolean flag = this.chunkVisibility.get(i) == Visibility.HIDDEN;
35 +
36 + if (flag) {
37 +@@ -311,7 +311,7 @@
38 + while (!longset.isEmpty()) {
39 + this.permanentStorage.a(false);
40 + this.g();
41 +- longset.removeIf((i) -> {
42 ++ longset.removeIf((java.util.function.LongPredicate) (i) -> { // CraftBukkit - decompile error
43 + boolean flag = this.chunkVisibility.get(i) == Visibility.HIDDEN;
44 +
45 + return flag ? this.d(i) : this.a(i, (entityaccess) -> {
46 +@@ -323,7 +323,15 @@
47 + }
48 +
49 + public void close() throws IOException {
50 +- this.c();
51 ++ // CraftBukkit start - add save boolean
52 ++ close(true);
53 ++ }
54 ++
55 ++ public void close(boolean save) throws IOException {
56 ++ if (save) {
57 ++ this.c(); // PAIL rename saveAll
58 ++ }
59 ++ // CraftBukkit end
60 + this.permanentStorage.close();
61 + }
62 +
63 +@@ -350,7 +358,7 @@
64 + public void a(Writer writer) throws IOException {
65 + CSVWriter csvwriter = CSVWriter.a().a("x").a("y").a("z").a("visibility").a("load_status").a("entity_count").a(writer);
66 +
67 +- this.sectionStorage.a().forEach((i) -> {
68 ++ this.sectionStorage.a().forEach((java.util.function.LongConsumer) (i) -> { // CraftBukkit - decompile error
69 + PersistentEntitySectionManager.b persistententitysectionmanager_b = (PersistentEntitySectionManager.b) this.chunkLoadStatuses.get(i);
70 +
71 + this.sectionStorage.a(i).forEach((j) -> {
72 +@@ -389,7 +397,7 @@
73 + private EntitySection<T> currentSection;
74 +
75 + a(EntityAccess entityaccess, long i, EntitySection entitysection) {
76 +- this.entity = entityaccess;
77 ++ this.entity = (T) entityaccess; // CraftBukkit - decompile error
78 + this.currentSectionKey = i;
79 + this.currentSection = entitysection;
80 + }
81 +@@ -409,7 +417,7 @@
82 + PersistentEntitySectionManager.this.a(this.currentSectionKey, this.currentSection);
83 + EntitySection<T> entitysection = PersistentEntitySectionManager.this.sectionStorage.c(i);
84 +
85 +- entitysection.a((Object) this.entity);
86 ++ entitysection.a(this.entity); // CraftBukkit - decompile error
87 + this.currentSection = entitysection;
88 + this.currentSectionKey = i;
89 + this.a(visibility, entitysection.c());

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut