mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 12:42:26 +00:00
Finish world, chunkloading should work again?
This commit is contained in:
1 parent
c11732fc40
commit
aa24916736
5 files changed
+40
-11
No files matched your search
@@ -14,6 +14,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Iterators;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
@@ -54,6 +58,8 @@ import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Manages chunkloading for mods.
|
||||
*
|
||||
@@ -105,6 +111,25 @@ public class ForgeChunkManager
|
||||
MOD_PROP_ORDER.add("maximumChunksPerTicket");
|
||||
}
|
||||
|
||||
public static Iterator<Chunk> getPersistentChunksIterableFor(final World world, Iterator<Chunk> chunkIterator)
|
||||
{
|
||||
final ImmutableSetMultimap<ChunkCoordIntPair, Ticket> persistentChunksFor = getPersistentChunksFor(world);
|
||||
final ImmutableSet.Builder<Chunk> builder = ImmutableSet.builder();
|
||||
world.theProfiler.startSection("forcedChunkLoading");
|
||||
builder.addAll(Iterators.transform(persistentChunksFor.keys().iterator(), new Function<ChunkCoordIntPair, Chunk>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Chunk apply(@Nullable ChunkCoordIntPair input)
|
||||
{
|
||||
return world.getChunkFromChunkCoords(input.chunkXPos, input.chunkZPos);
|
||||
}
|
||||
}));
|
||||
world.theProfiler.endStartSection("regularChunkLoading");
|
||||
builder.addAll(chunkIterator);
|
||||
world.theProfiler.endSection();
|
||||
return builder.build().iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* All mods requiring chunkloading need to implement this to handle the
|
||||
* re-registration of chunk tickets at world loading time
|
||||
|
||||
Reference in new issue
Block a user