performance improvement and no allocation promise
This commit is contained in:
parent
2133ab39b7
commit
826f3788d0
24
src/main/java/baritone/cache/CachedChunk.java
vendored
24
src/main/java/baritone/cache/CachedChunk.java
vendored
@ -18,6 +18,7 @@
|
|||||||
package baritone.cache;
|
package baritone.cache;
|
||||||
|
|
||||||
import baritone.utils.pathing.PathingBlockType;
|
import baritone.utils.pathing.PathingBlockType;
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
@ -119,7 +120,7 @@ public final class CachedChunk {
|
|||||||
*/
|
*/
|
||||||
private final BitSet data;
|
private final BitSet data;
|
||||||
|
|
||||||
private final BitSet special;
|
private final Int2ObjectOpenHashMap<String> special;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The block names of each surface level block for generating an overview
|
* The block names of each surface level block for generating an overview
|
||||||
@ -142,16 +143,15 @@ public final class CachedChunk {
|
|||||||
this.heightMap = new int[256];
|
this.heightMap = new int[256];
|
||||||
this.specialBlockLocations = specialBlockLocations;
|
this.specialBlockLocations = specialBlockLocations;
|
||||||
this.cacheTimestamp = cacheTimestamp;
|
this.cacheTimestamp = cacheTimestamp;
|
||||||
this.special = new BitSet();
|
this.special = new Int2ObjectOpenHashMap<>();
|
||||||
calculateHeightMap();
|
calculateHeightMap();
|
||||||
setSpecial();
|
setSpecial();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void setSpecial() {
|
private final void setSpecial() {
|
||||||
for (List<BlockPos> list : specialBlockLocations.values()) {
|
for (Map.Entry<String, List<BlockPos>> entry : specialBlockLocations.entrySet()) {
|
||||||
for (BlockPos pos : list) {
|
for (BlockPos pos : entry.getValue()) {
|
||||||
System.out.println("Turning on bit");
|
special.put(getPositionIndex(pos.getX(), pos.getY(), pos.getZ()), entry.getKey());
|
||||||
special.set(getPositionIndex(pos.getX(), pos.getY(), pos.getZ()) >> 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,15 +170,9 @@ public final class CachedChunk {
|
|||||||
}*/
|
}*/
|
||||||
return overview[internalPos];
|
return overview[internalPos];
|
||||||
}
|
}
|
||||||
if (special.get(index >> 1)) {
|
String str = special.get(index);
|
||||||
// this block is special
|
if (str != null) {
|
||||||
for (Map.Entry<String, List<BlockPos>> entry : specialBlockLocations.entrySet()) {
|
return ChunkPacker.stringToBlock(str).getDefaultState();
|
||||||
for (BlockPos pos : entry.getValue()) {
|
|
||||||
if (pos.getX() == x && pos.getY() == y && pos.getZ() == z) {
|
|
||||||
return ChunkPacker.stringToBlock(entry.getKey()).getDefaultState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == PathingBlockType.SOLID && y == 127 && dimension == -1) {
|
if (type == PathingBlockType.SOLID && y == 127 && dimension == -1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user