Reorganize the forced chunks a bit- offload the cost of immutable map building to the mods, rather than the chunk tick
This commit is contained in:
parent
b89467d101
commit
8d5b8a81fe
1 changed files with 13 additions and 10 deletions
|
@ -81,7 +81,7 @@ public class ForgeChunkManager
|
||||||
|
|
||||||
private static Map<String, LoadingCallback> callbacks = Maps.newHashMap();
|
private static Map<String, LoadingCallback> callbacks = Maps.newHashMap();
|
||||||
|
|
||||||
private static Map<World, SetMultimap<ChunkCoordIntPair,Ticket>> forcedChunks = new MapMaker().weakKeys().makeMap();
|
private static Map<World, ImmutableSetMultimap<ChunkCoordIntPair,Ticket>> forcedChunks = new MapMaker().weakKeys().makeMap();
|
||||||
private static BiMap<UUID,Ticket> pendingEntities = HashBiMap.create();
|
private static BiMap<UUID,Ticket> pendingEntities = HashBiMap.create();
|
||||||
|
|
||||||
private static Map<World,Cache<Long, Chunk>> dormantChunkCache = new MapMaker().weakKeys().makeMap();
|
private static Map<World,Cache<Long, Chunk>> dormantChunkCache = new MapMaker().weakKeys().makeMap();
|
||||||
|
@ -209,17 +209,17 @@ public class ForgeChunkManager
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current max depth for this ticket.
|
* Gets the current max depth for this ticket.
|
||||||
* Should be the same as getMaxChunkListDepth()
|
* Should be the same as getMaxChunkListDepth()
|
||||||
* unless setChunkListDepth has been called.
|
* unless setChunkListDepth has been called.
|
||||||
*
|
*
|
||||||
* @return Current max depth
|
* @return Current max depth
|
||||||
*/
|
*/
|
||||||
public int getChunkListDepth()
|
public int getChunkListDepth()
|
||||||
{
|
{
|
||||||
return maxDepth;
|
return maxDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the maximum chunk depth size
|
* Get the maximum chunk depth size
|
||||||
*
|
*
|
||||||
|
@ -316,8 +316,7 @@ public class ForgeChunkManager
|
||||||
ArrayListMultimap<String, Ticket> newTickets = ArrayListMultimap.<String, Ticket>create();
|
ArrayListMultimap<String, Ticket> newTickets = ArrayListMultimap.<String, Ticket>create();
|
||||||
tickets.put(world, newTickets);
|
tickets.put(world, newTickets);
|
||||||
|
|
||||||
SetMultimap<ChunkCoordIntPair,Ticket> forcedChunkMap = LinkedHashMultimap.create();
|
forcedChunks.put(world, ImmutableSetMultimap.<ChunkCoordIntPair,Ticket>of());
|
||||||
forcedChunks.put(world, forcedChunkMap);
|
|
||||||
|
|
||||||
if (!(world instanceof WorldServer))
|
if (!(world instanceof WorldServer))
|
||||||
{
|
{
|
||||||
|
@ -612,7 +611,8 @@ public class ForgeChunkManager
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ticket.requestedChunks.add(chunk);
|
ticket.requestedChunks.add(chunk);
|
||||||
forcedChunks.get(ticket.world).put(chunk, ticket);
|
ImmutableSetMultimap<ChunkCoordIntPair, Ticket> newMap = ImmutableSetMultimap.<ChunkCoordIntPair,Ticket>builder().putAll(forcedChunks.get(ticket.world)).put(chunk, ticket).build();
|
||||||
|
forcedChunks.put(ticket.world, newMap);
|
||||||
if (ticket.maxDepth > 0 && ticket.requestedChunks.size() > ticket.maxDepth)
|
if (ticket.maxDepth > 0 && ticket.requestedChunks.size() > ticket.maxDepth)
|
||||||
{
|
{
|
||||||
ChunkCoordIntPair removed = ticket.requestedChunks.iterator().next();
|
ChunkCoordIntPair removed = ticket.requestedChunks.iterator().next();
|
||||||
|
@ -650,7 +650,10 @@ public class ForgeChunkManager
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ticket.requestedChunks.remove(chunk);
|
ticket.requestedChunks.remove(chunk);
|
||||||
forcedChunks.get(ticket.world).remove(chunk, ticket);
|
LinkedHashMultimap<ChunkCoordIntPair, Ticket> copy = LinkedHashMultimap.create(forcedChunks.get(ticket.world));
|
||||||
|
copy.remove(chunk, ticket);
|
||||||
|
ImmutableSetMultimap<ChunkCoordIntPair, Ticket> newMap = ImmutableSetMultimap.copyOf(copy);
|
||||||
|
forcedChunks.put(ticket.world,newMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loadConfiguration()
|
static void loadConfiguration()
|
||||||
|
@ -676,7 +679,7 @@ public class ForgeChunkManager
|
||||||
*/
|
*/
|
||||||
public static SetMultimap<ChunkCoordIntPair, Ticket> getPersistentChunksFor(World world)
|
public static SetMultimap<ChunkCoordIntPair, Ticket> getPersistentChunksFor(World world)
|
||||||
{
|
{
|
||||||
return forcedChunks.containsKey(world) ? ImmutableSetMultimap.copyOf(forcedChunks.get(world)) : ImmutableSetMultimap.<ChunkCoordIntPair,Ticket>of();
|
return forcedChunks.containsKey(world) ? forcedChunks.get(world) : ImmutableSetMultimap.<ChunkCoordIntPair,Ticket>of();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void saveWorld(World world)
|
static void saveWorld(World world)
|
||||||
|
|
Loading…
Reference in a new issue