forked from cybertiger/Bukkit-LibNBT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InstanceChunkLoader.java
79 lines (66 loc) · 2.57 KB
/
InstanceChunkLoader.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.cyberiantiger.minecraft.unsafe.v1_13_R2;
import java.io.IOException;
import java.util.function.Consumer;
import net.minecraft.server.v1_13_R2.Chunk;
import net.minecraft.server.v1_13_R2.ChunkRegionLoader;
import net.minecraft.server.v1_13_R2.ExceptionWorldConflict;
import net.minecraft.server.v1_13_R2.GeneratorAccess;
import net.minecraft.server.v1_13_R2.IAsyncChunkSaver;
import net.minecraft.server.v1_13_R2.IChunkAccess;
import net.minecraft.server.v1_13_R2.IChunkLoader;
import net.minecraft.server.v1_13_R2.ProtoChunk;
// Safe not to extend ChunkRegionLoader - CB does not cast to ChunkRegionLoader anywhere.
public final class InstanceChunkLoader implements IChunkLoader, IAsyncChunkSaver {
private final ChunkRegionLoader loadLoader;
private final ChunkRegionLoader saveLoader;
public InstanceChunkLoader(ChunkRegionLoader loadLoader, ChunkRegionLoader saveLoader) {
this.loadLoader = loadLoader;
this.saveLoader = saveLoader;
}
@Override
public Chunk a(GeneratorAccess arg0, int i, int j, Consumer<Chunk> arg3) throws IOException {
// if (saveLoader.chunkExists(i, j)) {
// return saveLoader.a(arg0, i, j, arg3);
// }
return loadLoader.a(arg0, i, j, arg3);
}
@Override
public ProtoChunk b(GeneratorAccess arg0, int i, int j, Consumer<IChunkAccess> arg3) throws IOException {
// if (saveLoader.chunkExists(i, j)) {
// return saveLoader.b(arg0, i, j, arg3);
// }
return loadLoader.b(arg0, i, j, arg3);
}
@Override
public void saveChunk(net.minecraft.server.v1_13_R2.World world, IChunkAccess chunk) throws IOException, ExceptionWorldConflict {
saveLoader.saveChunk(world, chunk);
}
// @Override
// public void a(net.minecraft.server.v1_13_R2.IBlockAccess world, Chunk chunk) throws IOException {
// // Assume this is supposed to be some sort of save operation.
// // Can't tell from NMS - empty method.
// saveLoader.a(world, chunk);
// }
// @Override
// public void c() {
// // XXX: Can't guess if this is a save or load operation.
// }
@Override
public void b() {
// XXX: Can't guess if this is a save or load operation.
}
@Override
public boolean a() {
// Looks like a flush() / sync() method.
return saveLoader.a();
}
// @Override
// public boolean chunkExists(int arg0, int arg1) {
// // maybe
// return loadLoader.chunkExists(arg0, arg1);
// }
}