[F] Fix mutable pos toString issue
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String, BlockState> 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");
|
||||
|
||||
Reference in New Issue
Block a user