Files
Paper/src/main/java/org/bukkit/craftbukkit/chunkio/QueuedChunk.java
T
Travis Watkins d7d81fa68f Load all already generated chunks via async chunk system
Currently we use the async chunk loading system only when players trigger
chunk loading. If a chunk is loaded for any other reason it goes through
a separate codepath. This means if a player has trigged a chunk load and
before the chunk loads something else wants the same chunk we will load it
twice and throw away the second result. With this change we instead use
the sync processing feature of the AsynchronousExecutor to load the chunk
which will pull it out of the queue if it was already queued to load. This
means we only ever load a chunk once. Because chunk generation is not
thread safe we still fallback to the vanilla chunk loading system if the
chunk does not currently exist.
2014-02-01 22:03:04 -06:00

39 lines
1019 B
Java

package org.bukkit.craftbukkit.chunkio;
import net.minecraft.server.ChunkProviderServer;
import net.minecraft.server.ChunkRegionLoader;
import net.minecraft.server.NBTTagCompound;
import net.minecraft.server.World;
class QueuedChunk {
final int x;
final int z;
final ChunkRegionLoader loader;
final World world;
final ChunkProviderServer provider;
NBTTagCompound compound;
public QueuedChunk(int x, int z, ChunkRegionLoader loader, World world, ChunkProviderServer provider) {
this.x = x;
this.z = z;
this.loader = loader;
this.world = world;
this.provider = provider;
}
@Override
public int hashCode() {
return (x * 31 + z * 29) ^ world.hashCode();
}
@Override
public boolean equals(Object object) {
if (object instanceof QueuedChunk) {
QueuedChunk other = (QueuedChunk) object;
return x == other.x && z == other.z && world == other.world;
}
return false;
}
}