diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index 666c3259..b7a6a750 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -35,6 +35,8 @@ import net.minecraft.world.chunk.ChunkSection; import net.minecraft.world.chunk.ChunkStatus; import org.hydev.hyritone.Hyritone; +import static org.hydev.hyritone.MiscUtils.posId; + /** * Wraps get for chuck caching capability * @@ -102,7 +104,7 @@ public class BlockStateInterface { // Hyritone: Replace the block with seed block if (Baritone.settings().mineWithSeed.value) { - String key = new BlockPos(x, y, z).toString(); + String key = posId(new BlockPos(x, y, z)); if (Hyritone.seedServerCache.blocksMap.containsKey(key)) { return Hyritone.seedServerCache.blocksMap.get(key); diff --git a/src/main/java/org/hydev/hyritone/MiscUtils.java b/src/main/java/org/hydev/hyritone/MiscUtils.java index 04630b40..5901abbe 100644 --- a/src/main/java/org/hydev/hyritone/MiscUtils.java +++ b/src/main/java/org/hydev/hyritone/MiscUtils.java @@ -17,6 +17,7 @@ package org.hydev.hyritone; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.StringTextComponent; import static baritone.api.utils.Helper.mc; @@ -45,4 +46,15 @@ public class MiscUtils { print("§8[§7Debug§8]§7 " + text); } + + /** + * Get an identifier for a block pos that's unique for each xyz + * + * @param pos Block position + * @return Stringify + */ + public static String posId(BlockPos pos) + { + return String.format("[%s,%s,%s]", pos.getX(), pos.getY(), pos.getZ()); + } } diff --git a/src/main/java/org/hydev/hyritone/SeedServerCache.java b/src/main/java/org/hydev/hyritone/SeedServerCache.java index 546aa892..a44dcc03 100644 --- a/src/main/java/org/hydev/hyritone/SeedServerCache.java +++ b/src/main/java/org/hydev/hyritone/SeedServerCache.java @@ -47,6 +47,7 @@ import static baritone.api.utils.Helper.mc; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.stream.Collectors.toList; import static org.hydev.hyritone.MiscUtils.debug; +import static org.hydev.hyritone.MiscUtils.posId; /** * TODO: Write a description for this class! @@ -141,7 +142,7 @@ public class SeedServerCache extends Behavior // Update blocks map Map map = new HashMap<>(); - cacheBlocks.forEach(b -> map.put(b.toString(), Blocks.DIAMOND_ORE.getDefaultState())); + cacheBlocks.forEach(b -> map.put(posId(b), Blocks.DIAMOND_ORE.getDefaultState())); blocksMap = map; debug("Found " + cacheBlocks.size() + " valid ores."); @@ -170,7 +171,7 @@ public class SeedServerCache extends Behavior if (!cacheBlocks.removeIf(b -> b.equals(pos))) return; // Remove block from map - blocksMap.remove(pos.toString()); + blocksMap.remove(posId(pos)); // Remove block from server HttpGet get = new HttpGet("http://localhost:12255/api/remove-block");