toxic cloud to get around two references to mc.player.dimension

This commit is contained in:
Leijurv 2018-11-09 19:24:02 -08:00
parent 3ddf6b2335
commit b054e9dbe8
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
6 changed files with 21 additions and 15 deletions

View File

@ -17,7 +17,6 @@
package baritone.cache; package baritone.cache;
import baritone.api.cache.IBlockTypeAccess;
import baritone.utils.Helper; import baritone.utils.Helper;
import baritone.utils.pathing.PathingBlockType; import baritone.utils.pathing.PathingBlockType;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -31,7 +30,7 @@ import java.util.*;
* @author Brady * @author Brady
* @since 8/3/2018 1:04 AM * @since 8/3/2018 1:04 AM
*/ */
public final class CachedChunk implements IBlockTypeAccess, Helper { public final class CachedChunk implements Helper {
public static final Set<Block> BLOCKS_TO_KEEP_TRACK_OF; public static final Set<Block> BLOCKS_TO_KEEP_TRACK_OF;
@ -143,8 +142,7 @@ public final class CachedChunk implements IBlockTypeAccess, Helper {
calculateHeightMap(); calculateHeightMap();
} }
@Override public final IBlockState getBlock(int x, int y, int z, int dimension) {
public final IBlockState getBlock(int x, int y, int z) {
int internalPos = z << 4 | x; int internalPos = z << 4 | x;
if (heightMap[internalPos] == y) { if (heightMap[internalPos] == y) {
// we have this exact block, it's a surface block // we have this exact block, it's a surface block
@ -155,10 +153,10 @@ public final class CachedChunk implements IBlockTypeAccess, Helper {
return overview[internalPos]; return overview[internalPos];
} }
PathingBlockType type = getType(x, y, z); PathingBlockType type = getType(x, y, z);
if (type == PathingBlockType.SOLID && y == 127 && mc.player.dimension == -1) { if (type == PathingBlockType.SOLID && y == 127 && dimension == -1) {
return Blocks.BEDROCK.getDefaultState(); return Blocks.BEDROCK.getDefaultState();
} }
return ChunkPacker.pathingTypeToBlock(type); return ChunkPacker.pathingTypeToBlock(type, dimension);
} }
private PathingBlockType getType(int x, int y, int z) { private PathingBlockType getType(int x, int y, int z) {

View File

@ -59,22 +59,25 @@ public final class CachedRegion implements ICachedRegion {
*/ */
private final int z; private final int z;
private final int dimension;
/** /**
* Has this region been modified since its most recent load or save * Has this region been modified since its most recent load or save
*/ */
private boolean hasUnsavedChanges; private boolean hasUnsavedChanges;
CachedRegion(int x, int z) { CachedRegion(int x, int z, int dimension) {
this.x = x; this.x = x;
this.z = z; this.z = z;
this.hasUnsavedChanges = false; this.hasUnsavedChanges = false;
this.dimension = dimension;
} }
@Override @Override
public final IBlockState getBlock(int x, int y, int z) { public final IBlockState getBlock(int x, int y, int z) {
CachedChunk chunk = chunks[x >> 4][z >> 4]; CachedChunk chunk = chunks[x >> 4][z >> 4];
if (chunk != null) { if (chunk != null) {
return chunk.getBlock(x & 15, y, z & 15); return chunk.getBlock(x & 15, y, z & 15, dimension);
} }
return null; return null;
} }

View File

@ -56,7 +56,9 @@ public final class CachedWorld implements ICachedWorld, Helper {
private final LinkedBlockingQueue<Chunk> toPack = new LinkedBlockingQueue<>(); private final LinkedBlockingQueue<Chunk> toPack = new LinkedBlockingQueue<>();
CachedWorld(Path directory) { private final int dimension;
CachedWorld(Path directory, int dimension) {
if (!Files.exists(directory)) { if (!Files.exists(directory)) {
try { try {
Files.createDirectories(directory); Files.createDirectories(directory);
@ -64,6 +66,7 @@ public final class CachedWorld implements ICachedWorld, Helper {
} }
} }
this.directory = directory.toString(); this.directory = directory.toString();
this.dimension = dimension;
System.out.println("Cached world directory: " + directory); System.out.println("Cached world directory: " + directory);
// Insert an invalid region element // Insert an invalid region element
cachedRegions.put(0, null); cachedRegions.put(0, null);
@ -241,7 +244,7 @@ public final class CachedWorld implements ICachedWorld, Helper {
*/ */
private synchronized CachedRegion getOrCreateRegion(int regionX, int regionZ) { private synchronized CachedRegion getOrCreateRegion(int regionX, int regionZ) {
return cachedRegions.computeIfAbsent(getRegionID(regionX, regionZ), id -> { return cachedRegions.computeIfAbsent(getRegionID(regionX, regionZ), id -> {
CachedRegion newRegion = new CachedRegion(regionX, regionZ); CachedRegion newRegion = new CachedRegion(regionX, regionZ, dimension);
newRegion.load(this.directory); newRegion.load(this.directory);
return newRegion; return newRegion;
}); });

View File

@ -144,7 +144,7 @@ public final class ChunkPacker implements Helper {
return PathingBlockType.SOLID; return PathingBlockType.SOLID;
} }
public static IBlockState pathingTypeToBlock(PathingBlockType type) { public static IBlockState pathingTypeToBlock(PathingBlockType type, int dimension) {
switch (type) { switch (type) {
case AIR: case AIR:
return Blocks.AIR.getDefaultState(); return Blocks.AIR.getDefaultState();
@ -154,7 +154,7 @@ public final class ChunkPacker implements Helper {
return Blocks.LAVA.getDefaultState(); return Blocks.LAVA.getDefaultState();
case SOLID: case SOLID:
// Dimension solid types // Dimension solid types
switch (mc.player.dimension) { switch (dimension) {
case -1: case -1:
return Blocks.NETHERRACK.getDefaultState(); return Blocks.NETHERRACK.getDefaultState();
case 0: case 0:

View File

@ -35,11 +35,13 @@ public class WorldData implements IWorldData {
private final Waypoints waypoints; private final Waypoints waypoints;
//public final MapData map; //public final MapData map;
public final Path directory; public final Path directory;
public final int dimension;
WorldData(Path directory) { WorldData(Path directory, int dimension) {
this.directory = directory; this.directory = directory;
this.cache = new CachedWorld(directory.resolve("cache")); this.cache = new CachedWorld(directory.resolve("cache"), dimension);
this.waypoints = new Waypoints(directory.resolve("waypoints")); this.waypoints = new Waypoints(directory.resolve("waypoints"));
this.dimension = dimension;
} }
public void onClose() { public void onClose() {

View File

@ -91,7 +91,7 @@ public enum WorldProvider implements IWorldProvider, Helper {
} catch (IOException ignored) {} } catch (IOException ignored) {}
} }
System.out.println("Baritone world data dir: " + dir); System.out.println("Baritone world data dir: " + dir);
this.currentWorld = this.worldCache.computeIfAbsent(dir, WorldData::new); this.currentWorld = this.worldCache.computeIfAbsent(dir, d -> new WorldData(d, dimensionID));
} }
public final void closeWorld() { public final void closeWorld() {