use of net.minecraft.server.v1_8_R2.ChunkRegionLoader in project TheAPI by TheDevTec.
the class v1_9_R1 method getChunk.
@Override
public Object getChunk(World world, int x, int z) {
WorldServer sworld = ((CraftWorld) world).getHandle();
net.minecraft.server.v1_9_R1.Chunk loaded = ((ChunkProviderServer) sworld.getChunkProvider()).getChunkIfLoaded(x, z);
if (loaded == null) {
// load
try {
net.minecraft.server.v1_9_R1.Chunk chunk;
chunk = ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.getChunkProvider()), chunkLoader)).a(sworld, x, z);
if (chunk != null) {
chunk.setLastSaved(sworld.getTime());
if (((ChunkProviderServer) sworld.getChunkProvider()).chunkGenerator != null) {
((ChunkProviderServer) sworld.getChunkProvider()).chunkGenerator.recreateStructures(chunk, x, z);
}
}
if (chunk != null) {
((ChunkProviderServer) sworld.getChunkProvider()).chunks.put(ChunkCoordIntPair.a(x, z), chunk);
postToMainThread(() -> {
chunk.addEntities();
});
loaded = chunk;
}
} catch (Exception e) {
}
}
if (loaded == null) {
// generate new chunk
ChunkRegionLoader loader = null;
if ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.getChunkProvider()), chunkLoader) instanceof ChunkRegionLoader) {
loader = (ChunkRegionLoader) Ref.get(((ChunkProviderServer) sworld.getChunkProvider()), chunkLoader);
}
if (loader != null && loader.chunkExists(sworld, x, z)) {
loaded = ChunkIOExecutor.syncChunkLoad(sworld, loader, (ChunkProviderServer) sworld.getChunkProvider(), x, z);
} else {
loaded = ((ChunkProviderServer) sworld.getChunkProvider()).originalGetChunkAt(x, z);
}
loaded = ((ChunkProviderServer) sworld.getChunkProvider()).chunkGenerator.getOrCreateChunk(x, z);
((ChunkProviderServer) sworld.getChunkProvider()).chunks.put(ChunkCoordIntPair.a(x, z), loaded);
}
return loaded;
}
use of net.minecraft.server.v1_8_R2.ChunkRegionLoader in project TheAPI by TheDevTec.
the class v1_12_R1 method getChunk.
@Override
public Object getChunk(World world, int x, int z) {
WorldServer sworld = ((CraftWorld) world).getHandle();
net.minecraft.server.v1_12_R1.Chunk loaded = ((ChunkProviderServer) sworld.getChunkProvider()).getChunkIfLoaded(x, z);
if (loaded == null) {
// load
try {
net.minecraft.server.v1_12_R1.Chunk chunk;
chunk = ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.getChunkProvider()), chunkLoader)).a(sworld, x, z);
if (chunk != null) {
chunk.setLastSaved(sworld.getTime());
if (((ChunkProviderServer) sworld.getChunkProvider()).chunkGenerator != null) {
((ChunkProviderServer) sworld.getChunkProvider()).chunkGenerator.recreateStructures(chunk, x, z);
}
}
if (chunk != null) {
((ChunkProviderServer) sworld.getChunkProvider()).chunks.put(ChunkCoordIntPair.a(x, z), chunk);
postToMainThread(() -> {
chunk.addEntities();
});
loaded = chunk;
}
} catch (Exception e) {
}
}
if (loaded == null) {
// generate new chunk
ChunkRegionLoader loader = null;
if ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.getChunkProvider()), chunkLoader) instanceof ChunkRegionLoader) {
loader = (ChunkRegionLoader) Ref.get(((ChunkProviderServer) sworld.getChunkProvider()), chunkLoader);
}
if (loader != null && loader.chunkExists(x, z)) {
loaded = ChunkIOExecutor.syncChunkLoad(sworld, loader, (ChunkProviderServer) sworld.getChunkProvider(), x, z);
} else {
loaded = ((ChunkProviderServer) sworld.getChunkProvider()).originalGetChunkAt(x, z);
}
loaded = ((ChunkProviderServer) sworld.getChunkProvider()).chunkGenerator.getOrCreateChunk(x, z);
((ChunkProviderServer) sworld.getChunkProvider()).chunks.put(ChunkCoordIntPair.a(x, z), loaded);
}
return loaded;
}
use of net.minecraft.server.v1_8_R2.ChunkRegionLoader in project TheAPI by TheDevTec.
the class v1_8_R2 method getChunk.
@Override
public Object getChunk(World world, int x, int z) {
WorldServer sworld = ((CraftWorld) world).getHandle();
net.minecraft.server.v1_8_R2.Chunk loaded = ((ChunkProviderServer) sworld.N()).getChunkIfLoaded(x, z);
if (loaded == null) {
// load
try {
net.minecraft.server.v1_8_R2.Chunk chunk;
chunk = ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.N()), chunkLoader)).a(sworld, x, z);
if (chunk != null) {
chunk.setLastSaved(sworld.getTime());
if (((ChunkProviderServer) sworld.N()).chunkProvider != null) {
((ChunkProviderServer) sworld.N()).chunkProvider.recreateStructures(chunk, x, z);
}
}
if (chunk != null) {
((ChunkProviderServer) sworld.N()).chunks.put(ChunkCoordIntPair.a(x, z), chunk);
postToMainThread(() -> {
chunk.addEntities();
});
loaded = chunk;
}
} catch (Exception e) {
}
}
if (loaded == null) {
// generate new chunk
ChunkRegionLoader loader = null;
if ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.N()), chunkLoader) instanceof ChunkRegionLoader) {
loader = (ChunkRegionLoader) Ref.get(((ChunkProviderServer) sworld.N()), chunkLoader);
}
if (loader != null && loader.chunkExists(sworld, x, z)) {
loaded = ChunkIOExecutor.syncChunkLoad(sworld, loader, (ChunkProviderServer) sworld.N(), x, z);
} else {
loaded = ((ChunkProviderServer) sworld.N()).originalGetChunkAt(x, z);
}
loaded = ((ChunkProviderServer) sworld.N()).chunkProvider.getOrCreateChunk(x, z);
((ChunkProviderServer) sworld.N()).chunks.put(ChunkCoordIntPair.a(x, z), loaded);
}
return loaded;
}
use of net.minecraft.server.v1_8_R2.ChunkRegionLoader in project PaperDev by Kamillaova.
the class ChunkIOProvider method callStage1.
// async stuff
public Chunk callStage1(QueuedChunk queuedChunk) throws RuntimeException {
try (Timing ignored = queuedChunk.provider.world.timings.chunkIOStage1.startTimingIfSync()) {
// Paper
ChunkRegionLoader loader = queuedChunk.loader;
Object[] data = loader.loadChunk(queuedChunk.world, queuedChunk.x, queuedChunk.z);
if (data != null) {
queuedChunk.compound = (NBTTagCompound) data[1];
return (Chunk) data[0];
}
return null;
} catch (IOException ex) {
throw new RuntimeException(ex);
// Paper - Mirror vanilla by catching everything (else) rather than immediately crashing the server
// stage2 will receive a null chunk and then load it synchronously, where vanilla MC will properly log and recover
// stage2 will _not_ however return that instance, only load it
} catch (Exception ex) {
return null;
}
}
Aggregations