Skip to content

Commit a8f34c8

Browse files
committed
revert BlockESP
1 parent 467b234 commit a8f34c8

File tree

1 file changed

+31
-29
lines changed
  • src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp

1 file changed

+31
-29
lines changed

src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/BlockESP.java

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,22 @@
1717
import meteordevelopment.meteorclient.systems.modules.Categories;
1818
import meteordevelopment.meteorclient.systems.modules.Module;
1919
import meteordevelopment.meteorclient.utils.Utils;
20+
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
2021
import meteordevelopment.meteorclient.utils.render.color.RainbowColors;
2122
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
23+
import meteordevelopment.meteorclient.utils.world.Dimension;
2224
import meteordevelopment.orbit.EventHandler;
2325
import net.minecraft.block.Block;
24-
import net.minecraft.util.Util;
2526
import net.minecraft.util.math.BlockPos;
2627
import net.minecraft.util.math.ChunkPos;
2728
import net.minecraft.world.chunk.Chunk;
28-
import net.minecraft.world.dimension.DimensionType;
2929

3030
import java.util.Iterator;
3131
import java.util.List;
3232
import java.util.Map;
3333
import java.util.Set;
34-
import java.util.concurrent.Executor;
34+
import java.util.concurrent.ExecutorService;
35+
import java.util.concurrent.Executors;
3536

3637
public class BlockESP extends Module {
3738
private final SettingGroup sgGeneral = settings.getDefaultGroup();
@@ -80,9 +81,9 @@ public class BlockESP extends Module {
8081

8182
private final Long2ObjectMap<ESPChunk> chunks = new Long2ObjectOpenHashMap<>();
8283
private final Set<ESPGroup> groups = new ReferenceOpenHashSet<>();
83-
private final Executor workerThread = Util.getMainWorkerExecutor().named("BlockESP");
84+
private final ExecutorService workerThread = Executors.newSingleThreadExecutor();
8485

85-
private DimensionType lastDimension;
86+
private Dimension lastDimension;
8687

8788
public BlockESP() {
8889
super(Categories.Render, "block-esp", "Renders specified blocks through walls.", "search");
@@ -101,7 +102,7 @@ public void onActivate() {
101102
searchChunk(chunk);
102103
}
103104

104-
lastDimension = mc.world.getDimension();
105+
lastDimension = PlayerUtils.getDimension();
105106
}
106107

107108
@Override
@@ -159,7 +160,7 @@ private void onChunkData(ChunkDataEvent event) {
159160
}
160161

161162
private void searchChunk(Chunk chunk) {
162-
workerThread.execute(() -> {
163+
workerThread.submit(() -> {
163164
if (!isActive()) return;
164165
ESPChunk schunk = ESPChunk.searchChunk(chunk, blocks.get());
165166

@@ -192,43 +193,44 @@ private void onBlockUpdate(BlockUpdateEvent event) {
192193
boolean added = blocks.get().contains(event.newState.getBlock()) && !blocks.get().contains(event.oldState.getBlock());
193194
boolean removed = !added && !blocks.get().contains(event.newState.getBlock()) && blocks.get().contains(event.oldState.getBlock());
194195

195-
if (!added && !removed) return;
196-
197-
workerThread.execute(() -> {
198-
synchronized (chunks) {
199-
ESPChunk chunk = chunks.get(key);
196+
if (added || removed) {
197+
workerThread.submit(() -> {
198+
synchronized (chunks) {
199+
ESPChunk chunk = chunks.get(key);
200200

201-
if (chunk == null) {
202-
chunk = new ESPChunk(chunkX, chunkZ);
203-
if (chunk.shouldBeDeleted()) return;
201+
if (chunk == null) {
202+
chunk = new ESPChunk(chunkX, chunkZ);
203+
if (chunk.shouldBeDeleted()) return;
204204

205-
chunks.put(key, chunk);
206-
}
205+
chunks.put(key, chunk);
206+
}
207207

208-
blockPos.set(bx, by, bz);
208+
blockPos.set(bx, by, bz);
209209

210-
if (added) chunk.add(blockPos);
211-
else chunk.remove(blockPos);
210+
if (added) chunk.add(blockPos);
211+
else chunk.remove(blockPos);
212212

213-
// Update neighbour blocks
214-
for (int x = -1; x < 2; x++) {
215-
for (int z = -1; z < 2; z++) {
216-
for (int y = -1; y < 2; y++) {
217-
if (x == 0 && y == 0 && z == 0) continue;
213+
// Update neighbour blocks
214+
for (int x = -1; x < 2; x++) {
215+
for (int z = -1; z < 2; z++) {
216+
for (int y = -1; y < 2; y++) {
217+
if (x == 0 && y == 0 && z == 0) continue;
218218

219-
updateBlock(bx + x, by + y, bz + z);
219+
updateBlock(bx + x, by + y, bz + z);
220+
}
220221
}
221222
}
222223
}
223-
}
224-
});
224+
});
225+
}
225226
}
226227

227228
@EventHandler
228229
private void onPostTick(TickEvent.Post event) {
229-
DimensionType dimension = mc.world.getDimension();
230+
Dimension dimension = PlayerUtils.getDimension();
230231

231232
if (lastDimension != dimension) onActivate();
233+
232234
lastDimension = dimension;
233235
}
234236

0 commit comments

Comments
 (0)