Some comments
This commit is contained in:
parent
fad5a6deac
commit
51243f0981
30
src/main/java/baritone/cache/WorldProvider.java
vendored
30
src/main/java/baritone/cache/WorldProvider.java
vendored
@ -22,7 +22,6 @@ import baritone.api.cache.IWorldProvider;
|
|||||||
import baritone.utils.Helper;
|
import baritone.utils.Helper;
|
||||||
import baritone.utils.accessor.IAnvilChunkLoader;
|
import baritone.utils.accessor.IAnvilChunkLoader;
|
||||||
import baritone.utils.accessor.IChunkProviderServer;
|
import baritone.utils.accessor.IChunkProviderServer;
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
|
||||||
import net.minecraft.server.integrated.IntegratedServer;
|
import net.minecraft.server.integrated.IntegratedServer;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
|
|
||||||
@ -50,13 +49,20 @@ public class WorldProvider implements IWorldProvider, Helper {
|
|||||||
return this.currentWorld;
|
return this.currentWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void initWorld(WorldClient world) {
|
/**
|
||||||
int dimensionID = world.provider.getDimensionType().getId();
|
* Called when a new world is initialized to discover the
|
||||||
File directory;
|
*
|
||||||
File readme;
|
* @param dimension The ID of the world's dimension
|
||||||
|
*/
|
||||||
|
public final void initWorld(int dimension) {
|
||||||
|
// Fight me @leijurv
|
||||||
|
File directory, readme;
|
||||||
|
|
||||||
IntegratedServer integratedServer = mc.getIntegratedServer();
|
IntegratedServer integratedServer = mc.getIntegratedServer();
|
||||||
|
|
||||||
|
// If there is an integrated server running (Aka Singleplayer) then do magic to find the world save file
|
||||||
if (integratedServer != null) {
|
if (integratedServer != null) {
|
||||||
WorldServer localServerWorld = integratedServer.getWorld(dimensionID);
|
WorldServer localServerWorld = integratedServer.getWorld(dimension);
|
||||||
IChunkProviderServer provider = (IChunkProviderServer) localServerWorld.getChunkProvider();
|
IChunkProviderServer provider = (IChunkProviderServer) localServerWorld.getChunkProvider();
|
||||||
IAnvilChunkLoader loader = (IAnvilChunkLoader) provider.getChunkLoader();
|
IAnvilChunkLoader loader = (IAnvilChunkLoader) provider.getChunkLoader();
|
||||||
directory = loader.getChunkSaveLocation();
|
directory = loader.getChunkSaveLocation();
|
||||||
@ -69,27 +75,27 @@ public class WorldProvider implements IWorldProvider, Helper {
|
|||||||
|
|
||||||
directory = new File(directory, "baritone");
|
directory = new File(directory, "baritone");
|
||||||
readme = directory;
|
readme = directory;
|
||||||
|
} else { // Otherwise, the server must be remote...
|
||||||
} else {
|
|
||||||
//remote
|
|
||||||
directory = new File(Baritone.getDir(), mc.getCurrentServerData().serverIP);
|
directory = new File(Baritone.getDir(), mc.getCurrentServerData().serverIP);
|
||||||
readme = Baritone.getDir();
|
readme = Baritone.getDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
// lol wtf is this baritone folder in my minecraft save?
|
// lol wtf is this baritone folder in my minecraft save?
|
||||||
try (FileOutputStream out = new FileOutputStream(new File(readme, "readme.txt"))) {
|
try (FileOutputStream out = new FileOutputStream(new File(readme, "readme.txt"))) {
|
||||||
// good thing we have a readme
|
// good thing we have a readme
|
||||||
out.write("https://github.com/cabaletta/baritone\n".getBytes());
|
out.write("https://github.com/cabaletta/baritone\n".getBytes());
|
||||||
} catch (IOException ignored) {}
|
} catch (IOException ignored) {}
|
||||||
|
|
||||||
directory = new File(directory, "DIM" + dimensionID);
|
// We will actually store the world data in a subfolder: "DIM<id>"
|
||||||
Path dir = directory.toPath();
|
Path dir = new File(directory, "DIM" + dimension).toPath();
|
||||||
if (!Files.exists(dir)) {
|
if (!Files.exists(dir)) {
|
||||||
try {
|
try {
|
||||||
Files.createDirectories(dir);
|
Files.createDirectories(dir);
|
||||||
} catch (IOException ignored) {}
|
} catch (IOException ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Baritone world data dir: " + dir);
|
System.out.println("Baritone world data dir: " + dir);
|
||||||
this.currentWorld = worldCache.computeIfAbsent(dir, d -> new WorldData(d, dimensionID));
|
this.currentWorld = worldCache.computeIfAbsent(dir, d -> new WorldData(d, dimension));
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void closeWorld() {
|
public final void closeWorld() {
|
||||||
|
@ -103,7 +103,7 @@ public final class GameEventHandler implements IGameEventListener, Helper {
|
|||||||
if (event.getState() == EventState.POST) {
|
if (event.getState() == EventState.POST) {
|
||||||
cache.closeWorld();
|
cache.closeWorld();
|
||||||
if (event.getWorld() != null) {
|
if (event.getWorld() != null) {
|
||||||
cache.initWorld(event.getWorld());
|
cache.initWorld(event.getWorld().provider.getDimensionType().getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,9 +17,13 @@
|
|||||||
|
|
||||||
package baritone.utils.accessor;
|
package baritone.utils.accessor;
|
||||||
|
|
||||||
|
import baritone.cache.WorldProvider;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @see WorldProvider
|
||||||
|
*
|
||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 8/4/2018 11:36 AM
|
* @since 8/4/2018 11:36 AM
|
||||||
*/
|
*/
|
||||||
|
@ -17,9 +17,12 @@
|
|||||||
|
|
||||||
package baritone.utils.accessor;
|
package baritone.utils.accessor;
|
||||||
|
|
||||||
|
import net.minecraft.world.WorldProvider;
|
||||||
import net.minecraft.world.chunk.storage.IChunkLoader;
|
import net.minecraft.world.chunk.storage.IChunkLoader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @see WorldProvider
|
||||||
|
*
|
||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 8/4/2018 11:33 AM
|
* @since 8/4/2018 11:33 AM
|
||||||
*/
|
*/
|
||||||
|
@ -17,10 +17,14 @@
|
|||||||
|
|
||||||
package baritone.utils.pathing;
|
package baritone.utils.pathing;
|
||||||
|
|
||||||
import baritone.utils.Helper;
|
|
||||||
import net.minecraft.world.border.WorldBorder;
|
import net.minecraft.world.border.WorldBorder;
|
||||||
|
|
||||||
public class BetterWorldBorder implements Helper {
|
/**
|
||||||
|
* Essentially, a "rule" for the path finder, prevents proposed movements from attempting to venture
|
||||||
|
* into the world border, and prevents actual movements from placing blocks in the world border.
|
||||||
|
*/
|
||||||
|
public class BetterWorldBorder {
|
||||||
|
|
||||||
private final double minX;
|
private final double minX;
|
||||||
private final double maxX;
|
private final double maxX;
|
||||||
private final double minZ;
|
private final double minZ;
|
||||||
|
Loading…
Reference in New Issue
Block a user