mirror of
https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git
synced 2025-08-31 22:30:15 +00:00
SPIGOT-8045: World#getEntitiesByClass(Class<T>) only returns entities created since server start
This commit is contained in:
parent
f69c848d1e
commit
07a3b657a0
2 changed files with 29 additions and 30 deletions
|
@ -386,8 +386,8 @@
|
||||||
public void removePlayerImmediately(EntityPlayer entityplayer, Entity.RemovalReason entity_removalreason) {
|
public void removePlayerImmediately(EntityPlayer entityplayer, Entity.RemovalReason entity_removalreason) {
|
||||||
- entityplayer.remove(entity_removalreason);
|
- entityplayer.remove(entity_removalreason);
|
||||||
+ entityplayer.remove(entity_removalreason, null); // CraftBukkit - add Bukkit remove cause
|
+ entityplayer.remove(entity_removalreason, null); // CraftBukkit - add Bukkit remove cause
|
||||||
+ }
|
}
|
||||||
+
|
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ public boolean strikeLightning(Entity entitylightning) {
|
+ public boolean strikeLightning(Entity entitylightning) {
|
||||||
+ return this.strikeLightning(entitylightning, LightningStrikeEvent.Cause.UNKNOWN);
|
+ return this.strikeLightning(entitylightning, LightningStrikeEvent.Cause.UNKNOWN);
|
||||||
|
@ -401,9 +401,9 @@
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ return this.addFreshEntity(entitylightning);
|
+ return this.addFreshEntity(entitylightning);
|
||||||
}
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
+
|
||||||
@Override
|
@Override
|
||||||
public void destroyBlockProgress(int i, BlockPosition blockposition, int j) {
|
public void destroyBlockProgress(int i, BlockPosition blockposition, int j) {
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
|
@ -586,20 +586,7 @@
|
||||||
String s1 = (String) entry.getKey();
|
String s1 = (String) entry.getKey();
|
||||||
|
|
||||||
return s1 + ":" + entry.getIntValue();
|
return s1 + ":" + entry.getIntValue();
|
||||||
@@ -1716,7 +1940,11 @@
|
@@ -1754,6 +1978,7 @@
|
||||||
|
|
||||||
a() {}
|
|
||||||
|
|
||||||
- public void onCreated(Entity entity) {}
|
|
||||||
+ // CraftBukkit start - Mark entity as in world
|
|
||||||
+ public void onCreated(Entity entity) {
|
|
||||||
+ entity.inWorld = true;
|
|
||||||
+ // CraftBukkit end
|
|
||||||
+ }
|
|
||||||
|
|
||||||
public void onDestroyed(Entity entity) {
|
|
||||||
WorldServer.this.getScoreboard().entityRemoved(entity);
|
|
||||||
@@ -1754,6 +1982,7 @@
|
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
|
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
|
||||||
|
@ -607,7 +594,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTrackingEnd(Entity entity) {
|
public void onTrackingEnd(Entity entity) {
|
||||||
@@ -1780,6 +2009,14 @@
|
@@ -1780,6 +2005,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);
|
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);
|
||||||
|
|
|
@ -30,7 +30,19 @@
|
||||||
void removeSectionIfEmpty(long i, EntitySection<T> entitysection) {
|
void removeSectionIfEmpty(long i, EntitySection<T> entitysection) {
|
||||||
if (entitysection.isEmpty()) {
|
if (entitysection.isEmpty()) {
|
||||||
this.sectionStorage.remove(i);
|
this.sectionStorage.remove(i);
|
||||||
@@ -200,6 +216,12 @@
|
@@ -87,6 +103,11 @@
|
||||||
|
if (!flag) {
|
||||||
|
this.callbacks.onCreated(t0);
|
||||||
|
}
|
||||||
|
+ // CraftBukkit - Mark entity as in world
|
||||||
|
+ if (t0 instanceof Entity entity) {
|
||||||
|
+ entity.inWorld = true;
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
|
||||||
|
Visibility visibility = getEffectiveStatus(t0, entitysection.getStatus());
|
||||||
|
|
||||||
|
@@ -200,6 +221,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean storeChunkSections(long i, Consumer<T> consumer) {
|
private boolean storeChunkSections(long i, Consumer<T> consumer) {
|
||||||
|
@ -43,7 +55,7 @@
|
||||||
PersistentEntitySectionManager.b persistententitysectionmanager_b = (PersistentEntitySectionManager.b) this.chunkLoadStatuses.get(i);
|
PersistentEntitySectionManager.b persistententitysectionmanager_b = (PersistentEntitySectionManager.b) this.chunkLoadStatuses.get(i);
|
||||||
|
|
||||||
if (persistententitysectionmanager_b == PersistentEntitySectionManager.b.PENDING) {
|
if (persistententitysectionmanager_b == PersistentEntitySectionManager.b.PENDING) {
|
||||||
@@ -211,6 +233,7 @@
|
@@ -211,6 +238,7 @@
|
||||||
|
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
if (persistententitysectionmanager_b == PersistentEntitySectionManager.b.LOADED) {
|
if (persistententitysectionmanager_b == PersistentEntitySectionManager.b.LOADED) {
|
||||||
|
@ -51,7 +63,7 @@
|
||||||
this.permanentStorage.storeEntities(new ChunkEntities(new ChunkCoordIntPair(i), ImmutableList.of()));
|
this.permanentStorage.storeEntities(new ChunkEntities(new ChunkCoordIntPair(i), ImmutableList.of()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,6 +242,7 @@
|
@@ -219,6 +247,7 @@
|
||||||
this.requestChunkLoad(i);
|
this.requestChunkLoad(i);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -59,7 +71,7 @@
|
||||||
this.permanentStorage.storeEntities(new ChunkEntities(new ChunkCoordIntPair(i), list));
|
this.permanentStorage.storeEntities(new ChunkEntities(new ChunkCoordIntPair(i), list));
|
||||||
list.forEach(consumer);
|
list.forEach(consumer);
|
||||||
return true;
|
return true;
|
||||||
@@ -242,7 +266,7 @@
|
@@ -242,7 +271,7 @@
|
||||||
private boolean processChunkUnload(long i) {
|
private boolean processChunkUnload(long i) {
|
||||||
boolean flag = this.storeChunkSections(i, (entityaccess) -> {
|
boolean flag = this.storeChunkSections(i, (entityaccess) -> {
|
||||||
entityaccess.getPassengersAndSelf().forEach(this::unloadEntity);
|
entityaccess.getPassengersAndSelf().forEach(this::unloadEntity);
|
||||||
|
@ -68,7 +80,7 @@
|
||||||
|
|
||||||
if (!flag) {
|
if (!flag) {
|
||||||
return false;
|
return false;
|
||||||
@@ -253,12 +277,12 @@
|
@@ -253,12 +282,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unloadEntity(EntityAccess entityaccess) {
|
private void unloadEntity(EntityAccess entityaccess) {
|
||||||
|
@ -83,7 +95,7 @@
|
||||||
return this.chunkVisibility.get(i) != Visibility.HIDDEN ? true : this.processChunkUnload(i);
|
return this.chunkVisibility.get(i) != Visibility.HIDDEN ? true : this.processChunkUnload(i);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -271,6 +295,10 @@
|
@@ -271,6 +300,10 @@
|
||||||
this.addEntity(entityaccess, true);
|
this.addEntity(entityaccess, true);
|
||||||
});
|
});
|
||||||
this.chunkLoadStatuses.put(chunkentities.getPos().toLong(), PersistentEntitySectionManager.b.LOADED);
|
this.chunkLoadStatuses.put(chunkentities.getPos().toLong(), PersistentEntitySectionManager.b.LOADED);
|
||||||
|
@ -94,7 +106,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -296,7 +324,7 @@
|
@@ -296,7 +329,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void autoSave() {
|
public void autoSave() {
|
||||||
|
@ -103,7 +115,7 @@
|
||||||
boolean flag = this.chunkVisibility.get(i) == Visibility.HIDDEN;
|
boolean flag = this.chunkVisibility.get(i) == Visibility.HIDDEN;
|
||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
@@ -315,7 +343,7 @@
|
@@ -315,7 +348,7 @@
|
||||||
while (!longset.isEmpty()) {
|
while (!longset.isEmpty()) {
|
||||||
this.permanentStorage.flush(false);
|
this.permanentStorage.flush(false);
|
||||||
this.processPendingLoads();
|
this.processPendingLoads();
|
||||||
|
@ -112,7 +124,7 @@
|
||||||
boolean flag = this.chunkVisibility.get(i) == Visibility.HIDDEN;
|
boolean flag = this.chunkVisibility.get(i) == Visibility.HIDDEN;
|
||||||
|
|
||||||
return flag ? this.processChunkUnload(i) : this.storeChunkSections(i, (entityaccess) -> {
|
return flag ? this.processChunkUnload(i) : this.storeChunkSections(i, (entityaccess) -> {
|
||||||
@@ -327,7 +355,15 @@
|
@@ -327,7 +360,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
|
@ -129,7 +141,7 @@
|
||||||
this.permanentStorage.close();
|
this.permanentStorage.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,7 +390,7 @@
|
@@ -354,7 +395,7 @@
|
||||||
public void dumpSections(Writer writer) throws IOException {
|
public void dumpSections(Writer writer) throws IOException {
|
||||||
CSVWriter csvwriter = CSVWriter.builder().addColumn("x").addColumn("y").addColumn("z").addColumn("visibility").addColumn("load_status").addColumn("entity_count").build(writer);
|
CSVWriter csvwriter = CSVWriter.builder().addColumn("x").addColumn("y").addColumn("z").addColumn("visibility").addColumn("load_status").addColumn("entity_count").build(writer);
|
||||||
|
|
||||||
|
@ -138,7 +150,7 @@
|
||||||
PersistentEntitySectionManager.b persistententitysectionmanager_b = (PersistentEntitySectionManager.b) this.chunkLoadStatuses.get(i);
|
PersistentEntitySectionManager.b persistententitysectionmanager_b = (PersistentEntitySectionManager.b) this.chunkLoadStatuses.get(i);
|
||||||
|
|
||||||
this.sectionStorage.getExistingSectionPositionsInChunk(i).forEach((j) -> {
|
this.sectionStorage.getExistingSectionPositionsInChunk(i).forEach((j) -> {
|
||||||
@@ -398,7 +434,7 @@
|
@@ -398,7 +439,7 @@
|
||||||
private EntitySection<T> currentSection;
|
private EntitySection<T> currentSection;
|
||||||
|
|
||||||
a(final EntityAccess entityaccess, final long i, final EntitySection entitysection) {
|
a(final EntityAccess entityaccess, final long i, final EntitySection entitysection) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue