Skip to content

Commit 1a4b8e5

Browse files
committed
Moves stuff off thread. Adds support for 1.16.2+
1 parent 4382669 commit 1a4b8e5

File tree

4 files changed

+40
-33
lines changed

4 files changed

+40
-33
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'fabric-loom' version '0.4-SNAPSHOT'
2+
id 'fabric-loom' version '0.5-SNAPSHOT'
33
id 'maven-publish'
44
}
55

gradle.properties

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
org.gradle.jvmargs=-Xmx1G
33

44
# Fabric Properties
5-
minecraft_version = 1.16.2
6-
yarn_mappings = 1.16.2+build.43
7-
loader_version = 0.9.2+build.206
5+
minecraft_version = 1.16.4
6+
yarn_mappings = 1.16.4+build.1
7+
loader_version = 0.10.6+build.214
88

99
# Mod Properties
10-
mod_version = 0.0.2
10+
mod_version = 0.0.3
1111
maven_group = dev.hephaestus
1212
archives_base_name = sax
1313

1414
# Dependencies
15-
fabric_version = fabric-api:0.19.0+build.398-1.16
15+
fabric_version = 0.25.1+build.416-1.16
1616
fiblib_version = 0.1.5-1.16.2
1717
mod_menu_version = 1.14.6+build.31

src/main/java/dev/hephaestus/sax/server/DeObfuscator.java

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,52 @@ public class DeObfuscator {
2020

2121
private final ServerPlayerEntity player;
2222
private final HashSet<Vec3i> revealed = new HashSet<>();
23+
private final BlockPos.Mutable mutable = new BlockPos.Mutable();
24+
25+
private Thread thread = null;
2326

2427
public DeObfuscator(ServerPlayerEntity player) {
2528
this.player = player;
2629
}
2730

2831
public void tick() {
29-
Vec3d origin = this.player.getCameraPosVec(1F);
32+
if (thread == null || !thread.isAlive()) {
33+
thread = new Thread(() -> {
34+
Vec3d origin = this.player.getCameraPosVec(1F);
3035

31-
for (Vec3i pos : this.revealed) {
32-
if (!pos.isWithinDistance(origin, SEARCH_RADIUS)) {
33-
this.sendBlockUpdate(new BlockPos(pos), this.player.networkHandler::sendPacket);
34-
}
35-
}
36+
for (Vec3i pos : this.revealed) {
37+
if (!pos.isWithinDistance(origin, SEARCH_RADIUS)) {
38+
this.sendBlockUpdate(new BlockPos(pos), this.player.networkHandler::sendPacket);
39+
}
40+
}
3641

37-
this.revealed.removeIf(pos -> !pos.isWithinDistance(origin, SEARCH_RADIUS));
38-
BlockPos.Mutable mutable = new BlockPos.Mutable();
39-
40-
int i = 0;
41-
for (byte x = -SEARCH_RADIUS; x <= SEARCH_RADIUS; ++x) {
42-
for (byte y = -SEARCH_RADIUS; y <= SEARCH_RADIUS; ++y) {
43-
for (byte z = -SEARCH_RADIUS; z <= SEARCH_RADIUS; ++z) {
44-
if (x * x + y * y + z * z <= SEARCH_RADIUS * SEARCH_RADIUS) {
45-
++i;
46-
mutable.set(origin.x, origin.y, origin.z);
47-
mutable.move(x, y, z);
48-
49-
if (Config.HIDDEN.containsKey(this.player.world.getBlockState(mutable).getBlock())) {
50-
Vec3i pos = mutable.toImmutable();
51-
52-
if (!this.revealed.contains(pos)) {
53-
if (this.traceForBlock(this.player, pos)) {
54-
this.revealed.add(pos);
55-
this.sendBlockUpdate(new BlockPos(pos), this.player.networkHandler.connection::send);
42+
this.revealed.removeIf(pos -> !pos.isWithinDistance(origin, SEARCH_RADIUS));
43+
44+
for (byte x = -SEARCH_RADIUS; x <= SEARCH_RADIUS; ++x) {
45+
for (byte y = -SEARCH_RADIUS; y <= SEARCH_RADIUS; ++y) {
46+
for (byte z = -SEARCH_RADIUS; z <= SEARCH_RADIUS; ++z) {
47+
if (x * x + y * y + z * z <= SEARCH_RADIUS * SEARCH_RADIUS) {
48+
mutable.set(origin.x, origin.y, origin.z);
49+
mutable.move(x, y, z);
50+
51+
if (Config.HIDDEN.containsKey(this.player.world.getBlockState(mutable).getBlock())) {
52+
Vec3i pos = mutable.toImmutable();
53+
54+
if (!this.revealed.contains(pos)) {
55+
if (this.traceForBlock(this.player, pos)) {
56+
this.revealed.add(pos);
57+
this.sendBlockUpdate(new BlockPos(pos), this.player.networkHandler.connection::send);
58+
}
59+
}
5660
}
5761
}
5862
}
5963
}
6064
}
61-
}
65+
});
66+
67+
thread.setDaemon(true);
68+
thread.start();
6269
}
6370
}
6471

src/main/resources/fabric.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
"depends": {
2222
"fabricloader": ">=0.8.9+build.203",
2323
"fabric": "*",
24-
"minecraft": "1.16.2"
24+
"minecraft": ">=1.16.2"
2525
}
2626
}

0 commit comments

Comments
 (0)