diff --git a/build.gradle b/build.gradle index 884afbc..8cef2bf 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.4-SNAPSHOT' + id 'fabric-loom' version '0.5-SNAPSHOT' id 'maven-publish' } diff --git a/gradle.properties b/gradle.properties index f0211d5..bc7a27c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,16 +2,16 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties -minecraft_version = 1.16.2 -yarn_mappings = 1.16.2+build.43 -loader_version = 0.9.2+build.206 +minecraft_version = 1.16.4 +yarn_mappings = 1.16.4+build.1 +loader_version = 0.10.6+build.214 # Mod Properties -mod_version = 0.0.2 +mod_version = 0.0.3 maven_group = dev.hephaestus archives_base_name = sax # Dependencies -fabric_version = fabric-api:0.19.0+build.398-1.16 +fabric_version = 0.25.1+build.416-1.16 fiblib_version = 0.1.5-1.16.2 mod_menu_version = 1.14.6+build.31 \ No newline at end of file diff --git a/src/main/java/dev/hephaestus/sax/server/DeObfuscator.java b/src/main/java/dev/hephaestus/sax/server/DeObfuscator.java index 77ff9a2..e3d32a8 100644 --- a/src/main/java/dev/hephaestus/sax/server/DeObfuscator.java +++ b/src/main/java/dev/hephaestus/sax/server/DeObfuscator.java @@ -20,45 +20,52 @@ public class DeObfuscator { private final ServerPlayerEntity player; private final HashSet revealed = new HashSet<>(); + private final BlockPos.Mutable mutable = new BlockPos.Mutable(); + + private Thread thread = null; public DeObfuscator(ServerPlayerEntity player) { this.player = player; } public void tick() { - Vec3d origin = this.player.getCameraPosVec(1F); + if (thread == null || !thread.isAlive()) { + thread = new Thread(() -> { + Vec3d origin = this.player.getCameraPosVec(1F); - for (Vec3i pos : this.revealed) { - if (!pos.isWithinDistance(origin, SEARCH_RADIUS)) { - this.sendBlockUpdate(new BlockPos(pos), this.player.networkHandler::sendPacket); - } - } + for (Vec3i pos : this.revealed) { + if (!pos.isWithinDistance(origin, SEARCH_RADIUS)) { + this.sendBlockUpdate(new BlockPos(pos), this.player.networkHandler::sendPacket); + } + } - this.revealed.removeIf(pos -> !pos.isWithinDistance(origin, SEARCH_RADIUS)); - BlockPos.Mutable mutable = new BlockPos.Mutable(); - - int i = 0; - for (byte x = -SEARCH_RADIUS; x <= SEARCH_RADIUS; ++x) { - for (byte y = -SEARCH_RADIUS; y <= SEARCH_RADIUS; ++y) { - for (byte z = -SEARCH_RADIUS; z <= SEARCH_RADIUS; ++z) { - if (x * x + y * y + z * z <= SEARCH_RADIUS * SEARCH_RADIUS) { - ++i; - mutable.set(origin.x, origin.y, origin.z); - mutable.move(x, y, z); - - if (Config.HIDDEN.containsKey(this.player.world.getBlockState(mutable).getBlock())) { - Vec3i pos = mutable.toImmutable(); - - if (!this.revealed.contains(pos)) { - if (this.traceForBlock(this.player, pos)) { - this.revealed.add(pos); - this.sendBlockUpdate(new BlockPos(pos), this.player.networkHandler.connection::send); + this.revealed.removeIf(pos -> !pos.isWithinDistance(origin, SEARCH_RADIUS)); + + for (byte x = -SEARCH_RADIUS; x <= SEARCH_RADIUS; ++x) { + for (byte y = -SEARCH_RADIUS; y <= SEARCH_RADIUS; ++y) { + for (byte z = -SEARCH_RADIUS; z <= SEARCH_RADIUS; ++z) { + if (x * x + y * y + z * z <= SEARCH_RADIUS * SEARCH_RADIUS) { + mutable.set(origin.x, origin.y, origin.z); + mutable.move(x, y, z); + + if (Config.HIDDEN.containsKey(this.player.world.getBlockState(mutable).getBlock())) { + Vec3i pos = mutable.toImmutable(); + + if (!this.revealed.contains(pos)) { + if (this.traceForBlock(this.player, pos)) { + this.revealed.add(pos); + this.sendBlockUpdate(new BlockPos(pos), this.player.networkHandler.connection::send); + } + } } } } } } - } + }); + + thread.setDaemon(true); + thread.start(); } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 6eed967..4ca03ec 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -21,6 +21,6 @@ "depends": { "fabricloader": ">=0.8.9+build.203", "fabric": "*", - "minecraft": "1.16.2" + "minecraft": ">=1.16.2" } }