69 lines
1.9 KiB
Java
69 lines
1.9 KiB
Java
package baritone.api.utils;
|
|
import intent.zeroday.util.BlockPosApiUtil;
|
|
import intent.zeroday.util.IBlockStateEntry;
|
|
import intent.zeroday.util.WouldHelper;
|
|
|
|
|
|
import baritone.pathing.CachedWorld;
|
|
import baritone.pathing.BaritoneCore;
|
|
import java.io.IOException;
|
|
import java.nio.file.Path;
|
|
|
|
public final class BaritoneWorldData implements ICachedWorldData {
|
|
public transient int count;
|
|
public transient CachedWorld cachedWorld;
|
|
private transient ContainerMemoryStore containerMemoryStore;
|
|
private transient WouldHelper waypointsWouldHelper;
|
|
public transient Path path;
|
|
|
|
private void syncStorage() {
|
|
System.out.println("Started saving saved containers in a new thread");
|
|
|
|
try {
|
|
this.containerMemoryStore.syncStorage();
|
|
} catch (IOException ioException) {
|
|
ioException.printStackTrace();
|
|
System.out.println("Failed to save saved containers");
|
|
}
|
|
}
|
|
|
|
public BaritoneWorldData(Path path2, int count) {
|
|
|
|
|
|
|
|
|
|
this.path = path2;
|
|
this.cachedWorld = new CachedWorld(path2.resolve("cache"), count);
|
|
this.waypointsWouldHelper = new WouldHelper(path2.resolve("waypoints"));
|
|
this.containerMemoryStore = new ContainerMemoryStore(path2.resolve("containers"));
|
|
this.count = count;
|
|
}
|
|
|
|
public void updateState() {
|
|
BaritoneCore.getBaritoneThreadPoolExecutor().execute(this::syncStorage2);
|
|
BaritoneCore.getBaritoneThreadPoolExecutor().execute(this::syncStorage);
|
|
}
|
|
|
|
@Override
|
|
public IContainerMemory getContainersBaritoneHelper2() {
|
|
return this.containerMemoryStore;
|
|
}
|
|
|
|
private void syncStorage2() {
|
|
|
|
|
|
System.out.println("Started saving the world in a new thread");
|
|
this.cachedWorld.syncStorage();
|
|
}
|
|
|
|
@Override
|
|
public IBlockStateEntry getCacheBaritoneComponent022() {
|
|
return this.cachedWorld;
|
|
}
|
|
|
|
@Override
|
|
public BlockPosApiUtil getWaypointsWouldHelper() {
|
|
return this.waypointsWouldHelper;
|
|
}
|
|
}
|