chunks that were already loaded now also generate pockets without reloading them
This commit is contained in:
parent
0c867f7d94
commit
b604e71be5
2 changed files with 12 additions and 3 deletions
|
@ -1,8 +1,8 @@
|
|||
package org.dimdev.dimdoors.pockets.virtual.reference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
@ -11,6 +11,7 @@ import net.minecraft.nbt.NbtCompound;
|
|||
import net.minecraft.nbt.NbtList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerTask;
|
||||
import net.minecraft.server.world.ChunkHolder;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
@ -134,6 +135,10 @@ public abstract class PocketGeneratorReference implements ImplementedVirtualPock
|
|||
this.applyModifiers(parameters, builder);
|
||||
|
||||
LazyPocketGenerator.currentlyGenerating = true;
|
||||
// ensure we aren't missing any chunks that were already loaded previously
|
||||
// for lazy gen
|
||||
Set<Chunk> alreadyLoadedChunks = StreamSupport.stream(parameters.getWorld().getChunkManager().threadedAnvilChunkStorage.entryIterator().spliterator(), false).map(ChunkHolder::getWorldChunk).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
|
||||
Pocket pocket = generator.prepareAndPlacePocket(parameters, builder);
|
||||
BlockPos originalOrigin = pocket.getOrigin();
|
||||
|
||||
|
@ -153,6 +158,8 @@ public abstract class PocketGeneratorReference implements ImplementedVirtualPock
|
|||
clonedGenerator.attachToPocket(lazyPocket);
|
||||
lazyPocket.init();
|
||||
|
||||
alreadyLoadedChunks.forEach(lazyPocket::chunkLoaded);
|
||||
|
||||
LazyPocketGenerator.currentlyGenerating = false;
|
||||
|
||||
while (!LazyPocketGenerator.generationQueue.isEmpty()) {
|
||||
|
@ -162,7 +169,6 @@ public abstract class PocketGeneratorReference implements ImplementedVirtualPock
|
|||
MinecraftServer server = DimensionalDoorsInitializer.getServer();
|
||||
DimensionalDoorsInitializer.getServer().send(new ServerTask(server.getTicks(), () -> (lazyPocket).chunkLoaded(chunk)));
|
||||
}
|
||||
|
||||
LazyCompatibleModifier.runLeftoverModifications(DimensionalDoorsInitializer.getWorld(lazyPocket.getWorld()));
|
||||
} else {
|
||||
LazyPocketGenerator.currentlyGenerating = false;
|
||||
|
|
|
@ -15,3 +15,6 @@ extendable class net/minecraft/block/entity/BlockEntityType$BlockEntityFac
|
|||
extendable class net/minecraft/fluid/FluidState
|
||||
accessible field net/minecraft/state/State codec Lcom/mojang/serialization/MapCodec;
|
||||
#Lnet/minecraft/state/State;codec:Lcom/mojang/serialization/MapCodec;
|
||||
|
||||
# for lazy pocket gen/ getting all currently loaded chunks
|
||||
accessible method net/minecraft/server/world/ThreadedAnvilChunkStorage entryIterator ()Ljava/lang/Iterable;
|
||||
|
|
Loading…
Reference in a new issue