reloading chunks is not needed when resetting, fixing entities removed.
This commit is contained in:
1 parent
b8082ba5b8
commit
ca59c8f30a
6 files changed
+36
-3
No files matched your search
@@ -13,6 +13,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
import net.minecraft.world.entity.EntityLookup;
|
||||
import net.minecraft.world.explosion.Explosion;
|
||||
import net.minecraft.world.explosion.ExplosionBehavior;
|
||||
import net.minecraft.world.level.ServerWorldProperties;
|
||||
@@ -79,7 +80,14 @@ public class ServerWorld_scarpetMixin implements ServerWorldInterface
|
||||
@Final
|
||||
@Shadow
|
||||
private ServerWorldProperties worldProperties;
|
||||
@Shadow @Final private ServerEntityManager<Entity> entityManager;
|
||||
|
||||
public ServerWorldProperties getWorldPropertiesCM(){
|
||||
return worldProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityLookup<Entity> getEntityLookupCMPublic() {
|
||||
return entityManager.getLookup();
|
||||
}
|
||||
}
|
||||
+11
-1
@@ -12,6 +12,10 @@ import java.util.concurrent.Future;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import carpet.fakes.SimpleEntityLookupInterface;
|
||||
import carpet.fakes.ServerWorldInterface;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerTask;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -358,11 +362,17 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
|
||||
{
|
||||
final ChunkPos pos = chunk.getPos();
|
||||
|
||||
// remove entities
|
||||
long longPos = pos.toLong();
|
||||
if (this.loadedChunks.contains(longPos) && chunk instanceof WorldChunk)
|
||||
((SimpleEntityLookupInterface<Entity>)((ServerWorldInterface)world).getEntityLookupCMPublic()).getChunkEntities(pos).forEach(entity -> { if (!(entity instanceof PlayerEntity)) entity.discard();});
|
||||
|
||||
|
||||
if (chunk instanceof WorldChunk)
|
||||
((WorldChunk) chunk).setLoadedToWorld(false);
|
||||
|
||||
if (this.loadedChunks.remove(pos.toLong()) && chunk instanceof WorldChunk)
|
||||
this.world.unloadEntities((WorldChunk) chunk);
|
||||
this.world.unloadEntities((WorldChunk) chunk); // block entities only
|
||||
|
||||
((ServerLightingProviderInterface) this.serverLightingProvider).invokeUpdateChunkStatus(pos);
|
||||
((ServerLightingProviderInterface) this.serverLightingProvider).removeLightData(chunk);
|
||||
|
||||
Reference in new issue
Block a user