mirror of
https://github.com/Cubicake/RaycastedAntiESP.git
synced 2026-11-17 06:26:04 -05:00
Compare commits
49
Commits
v2/optimise
...
citizens
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9951b5d7a1 | ||
|
|
e99c3b9de2 | ||
|
|
0500f4bd5f | ||
|
|
9a841308ff | ||
|
|
c4bf1cbf0b | ||
|
|
db22c675db | ||
|
|
5a42fd74ad | ||
|
|
85b788742c | ||
|
|
20f660b8a3 | ||
|
|
4d17483a5a | ||
|
|
274b081c78 | ||
|
|
45e14637e0 | ||
|
|
b007735636 | ||
|
|
bb7275a618 | ||
|
|
853fa1531a | ||
|
|
396382bcc2 | ||
|
|
aae6bdb53c | ||
|
|
2f8f698069 | ||
|
|
fc3badb90a | ||
|
|
7aab3b60e8 | ||
|
|
2ab157bd4a | ||
|
|
3227c63e2e | ||
|
|
1dc77b3e6f | ||
|
|
cb044f789d | ||
|
|
c110aab634 | ||
|
|
5d407afbdf | ||
|
|
a8f12c9a24 | ||
|
|
0e4c251c6c | ||
|
|
e2b598a361 | ||
|
|
8c140cf8b6 | ||
|
|
4fe9ab02ef | ||
|
|
a21102d04f | ||
|
|
22488e9e71 | ||
|
|
bc40438cb3 | ||
|
|
3f633710e7 | ||
|
|
8de5d53198 | ||
|
|
53650f9b63 | ||
|
|
ba812bce3a | ||
|
|
42932abaa5 | ||
|
|
290749dde8 | ||
|
|
e19808fb4b | ||
|
|
691d429652 | ||
|
|
1575091d12 | ||
|
|
4919383c73 | ||
|
|
5293db6c86 | ||
|
|
c5f17a7b12 | ||
|
|
ddafbd0c25 | ||
|
|
8d9a354154 | ||
|
|
33ab1cd234 |
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
## Contributions
|
||||
Contributions via pull requests are welcome. Please join our [discord](https://discord.cubi.games) or make an `issue` to discuss any contributions beforehand to make sure they will not conflict with or hinder existing plans.
|
||||
|
||||
A good place to start with contributions is to look for `issue`s flagged with the label `help wanted`.
|
||||
A good place to start with contributions is to look for `issue`s flagged with the label `Outside Help Welcome`. These have been deemed as uninvasive changes, typically not requiring a complete understanding of the project. You are welcome to send a PR resolving these issues without first discussing changes with a maintainer.
|
||||
|
||||
You must hold the rights to any code you contribute, and must agree to licence it under the same licence as the rest of the project in perpetuity, explicitly including any and all changes to the project's licence by project maintainers in the future. The project's licence can always be found at [LICENSE](LICENSE).
|
||||
|
||||
|
||||
@@ -11,12 +11,20 @@ The supported minecraft versions are 1.21.4+. Only Paper and derivative software
|
||||
## Use cases:
|
||||
|
||||
- Prevent cheating (anti-esp hacks)
|
||||
- Block usage of pie-ray to locate underground bases or farms
|
||||
- Prevent mods such as mini-maps or cheat clients from displaying the locations of hidden entities
|
||||
- This is the plugin's primary purpose.
|
||||
- Block usage of pie-ray to locate underground bases or farms.
|
||||
- Prevent mods such as mini-maps or cheat clients from displaying the locations of hidden entities.
|
||||
- Increase client-side performance for low-end devices
|
||||
- Massive megabases containing hundreds of armour stands, item frames, banners etc can cause performance issues on low-end devices unable to process so many entities. Raycasted AntiESP will cull those entities for the client, reducing the number of entities to process.
|
||||
- Reduce network load by limiting packets
|
||||
- With `keep-client-entity-when-hidden` set to true, running RaycastedAntiESP will significantly reduce the number of entity packets sent to the client.
|
||||
- While entity packets are only a small portion of network bandwidth, this will still have a measurable impact and may be useful on extremely bandwidth-limited servers.
|
||||
- Unless you are extremely limited by bandwidth, this will probably be unnoticeable.
|
||||
- Hide nametags behind walls
|
||||
- Yes, this plugin is overkill for doing that, yes you can do it anyways.
|
||||
|
||||
## Configuration
|
||||
RaycastedAntiESP has many configuration options. A full list with explanations can be found at https://raycastedantiesp.cubi.games/config/.
|
||||
|
||||
## Dependencies:
|
||||
- Packetevents
|
||||
|
||||
@@ -38,7 +38,7 @@ dependencies {
|
||||
testImplementation("it.unimi.dsi:fastutil:8.5.18")
|
||||
}
|
||||
|
||||
val coreVersion = "0.7.0-SNAPSHOT"
|
||||
val coreVersion = "0.7.1-SNAPSHOT"
|
||||
|
||||
val isRelease = gradle.startParameter.taskNames.any {
|
||||
it.contains("buildRelease")
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core;
|
||||
|
||||
import games.cubi.logs.PlatformLogger;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.chunks;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.chunks.blocks.BlockChunkDataBuilder;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.chunks;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.chunks;
|
||||
|
||||
public final class ChunkData {
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.chunks;
|
||||
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
import static games.cubi.raycastedantiesp.core.chunks.ChunkData.LOCAL_MASK;
|
||||
|
||||
public interface ChunkOcclusionView {
|
||||
/**
|
||||
* The parameters here are local coordinates within the chunk section, so they must be in the range [0, 15].
|
||||
@@ -9,4 +19,12 @@ public interface ChunkOcclusionView {
|
||||
* @return true if the block at the given local coordinates is occluding, false otherwise.
|
||||
*/
|
||||
boolean isOccludingLocal(@Range(from = 0, to = 15) int x, @Range(from = 0, to = 15) int y, @Range(from = 0, to = 15) int z);
|
||||
|
||||
default boolean isOccludingGlobal(int x, int y, int z) {
|
||||
return isOccludingLocal(x & LOCAL_MASK, y & LOCAL_MASK, z & LOCAL_MASK);
|
||||
}
|
||||
|
||||
default boolean isSolid() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.chunks;
|
||||
|
||||
import org.jetbrains.annotations.Range;
|
||||
@@ -45,5 +53,10 @@ public sealed interface OccludingChunkData extends ChunkOcclusionView permits Oc
|
||||
public OccludingChunkData setOccluding(int x, int y, int z, boolean occluding) {
|
||||
return filled().setOccluding(x, y, z, occluding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSolid() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.chunks;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.chunks.blocks;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.chunks.BlockChunkData;
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.chunks.blocks;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.chunks.BlockChunkData;
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.chunks.blocks;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.chunks.BlockChunkData;
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.chunks.blocks;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.chunks.BlockChunkData;
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.chunks.blocks;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.chunks.BlockChunkData;
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.chunks.blocks;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.chunks.BlockChunkData;
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.chunks.blocks;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.chunks.BlockChunkData;
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.chunks.blocks;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.chunks.BlockChunkData;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.config;
|
||||
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.config;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.config;
|
||||
|
||||
public interface Config {
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.config;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.config;
|
||||
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.config;
|
||||
|
||||
public class ConfigLoadException extends RuntimeException {
|
||||
|
||||
@@ -306,11 +306,28 @@ public class ConfigManager {
|
||||
Files.createFile(configPath);
|
||||
}
|
||||
}
|
||||
prependConfigDocumentationHeaderIfMissing();
|
||||
} catch (IOException e) {
|
||||
throw new ConfigLoadException("Failed to create config.yml", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void prependConfigDocumentationHeaderIfMissing() {
|
||||
try {
|
||||
String content = Files.readString(configPath);
|
||||
|
||||
if (content.startsWith("#")) {
|
||||
Logger.debug("Config starts with comment");
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.debug("no starting comment");
|
||||
Files.writeString(configPath, "# An explanation of this configuration file and what all the options do can be found at https://raycastedantiesp.cubi.games/config/" + System.lineSeparator() + content);
|
||||
} catch (Exception e) {
|
||||
Logger.warning(e,3, ConfigManager.class);
|
||||
}
|
||||
}
|
||||
|
||||
private ConfigurationNode loadConfigNode() {
|
||||
try {
|
||||
return loader.load();
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.config;
|
||||
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.config;
|
||||
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.config;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.config.engine.EngineConfig;
|
||||
|
||||
@@ -18,7 +18,7 @@ public record UpdateConfig(boolean checkRelease, boolean checkBeta, boolean chec
|
||||
ConfigReader.bool(ConfigReader.node(node, "check-release"), "updates.check-release"),
|
||||
ConfigReader.bool(ConfigReader.node(node, "check-beta"), "updates.check-beta"),
|
||||
ConfigReader.bool(ConfigReader.node(node, "check-alpha"), "updates.check-alpha"),
|
||||
ConfigReader.bool(ConfigReader.node(node, "notify-ingame"), "updates.notify-ingame")
|
||||
ConfigReader.bool(ConfigReader.node(node, "notify-in-game"), "updates.notify-in-game")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.config.engine;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.config.Config;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.config.engine;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.config.Config;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.config.engine;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.config.ConfigEnum;
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.config.raycast;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.config.Config;
|
||||
|
||||
+21
-2
@@ -1,15 +1,34 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.config.raycast;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.config.ConfigReader;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
public class PlayerConfig extends RaycastConfig {
|
||||
private PlayerConfig(RaycastConfig config) {
|
||||
private final boolean onlyCheckSneaking;
|
||||
|
||||
private PlayerConfig(RaycastConfig config, boolean onlyCheckSneaking) {
|
||||
super(config.enabled(), config.hideSoundsWhenHidden(), config.getMaxOccludingCount(), config.getAlwaysShowRadius(),
|
||||
config.getRaycastRadius(), config.hideOnSpawnDistance(), config.getVisibleRecheckIntervalTicks(),
|
||||
config.keepClientEntityWhenHidden());
|
||||
this.onlyCheckSneaking = onlyCheckSneaking;
|
||||
}
|
||||
|
||||
public static PlayerConfig load(ConfigurationNode node, String path) {
|
||||
return new PlayerConfig(RaycastConfig.load(node, path, true, true));
|
||||
return new PlayerConfig(
|
||||
RaycastConfig.load(node, path, true, true),
|
||||
ConfigReader.bool(ConfigReader.node(node, "only-check-sneaking"), path + ".only-check-sneaking")
|
||||
);
|
||||
}
|
||||
|
||||
public boolean onlyCheckSneaking() {
|
||||
return onlyCheckSneaking;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.config.raycast;
|
||||
|
||||
import games.cubi.logs.Logger;
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.config.raycast;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.config.Config;
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.config.raycast;
|
||||
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
@@ -384,7 +384,10 @@ public abstract class AsyncEngine implements Engine {
|
||||
EntityView<?> entityView = player.entityView();
|
||||
|
||||
int checked = entityView.forEachNeedingRecheckEntity(entityConfig.getVisibleRecheckIntervalTicks(), currentTick, !(timings instanceof TickTimingBatchNoOp), worldEpoch, entity -> {
|
||||
boolean wasVisible = entity.visible();
|
||||
if (entity.glowing()) {
|
||||
entityView.setVisibility(entity, true, currentTick, worldEpoch);
|
||||
return;
|
||||
}
|
||||
if (attachedToAlwaysVisibleEntityOrSelf(player, entityView, entity, currentTick, worldEpoch)) {
|
||||
return;
|
||||
}
|
||||
@@ -400,7 +403,10 @@ public abstract class AsyncEngine implements Engine {
|
||||
EntityView<?> playerView = player.playerView();
|
||||
|
||||
int checked = playerView.forEachNeedingRecheckEntity(playerConfig.getVisibleRecheckIntervalTicks(), currentTick, !(timings instanceof TickTimingBatchNoOp), worldEpoch, otherPlayer -> {
|
||||
boolean wasVisible = otherPlayer.visible();
|
||||
if (otherPlayer.glowing() || (playerConfig.onlyCheckSneaking() && !otherPlayer.sneaking())) {
|
||||
playerView.setVisibility(otherPlayer, true, currentTick, worldEpoch);
|
||||
return;
|
||||
}
|
||||
if (attachedToAlwaysVisibleEntityOrSelf(player, playerView, otherPlayer, currentTick, worldEpoch)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.engine;
|
||||
|
||||
public interface AsyncRunner {
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.engine;
|
||||
|
||||
public interface Engine {
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.engine;
|
||||
|
||||
public class TickTimingBatch {
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.engine;
|
||||
|
||||
public class TickTimingBatchNoOp extends TickTimingBatch {
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.engine;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.engine;
|
||||
|
||||
record TickTimingSnapshot(
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.engine;
|
||||
|
||||
final class TickTimings {
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.engine;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.LongArrayList;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.engine;
|
||||
|
||||
public class TimingStatsNoOp extends TimingStats {
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.engine;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
|
||||
package games.cubi.raycastedantiesp.core.entity;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.utils.CopyOnWriteMTIntSet;
|
||||
import games.cubi.utils.sets.CopyOnWriteMTIntSet;
|
||||
|
||||
/**
|
||||
* Global registry of entity IDs which RaycastedAntiESP must ignore.
|
||||
|
||||
@@ -0,0 +1,355 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.players;
|
||||
|
||||
import games.cubi.locatables.api.FloatingLocatableEquality;
|
||||
import games.cubi.locatables.api.Locatable;
|
||||
import games.cubi.locatables.api.MutableFloatingLocatable;
|
||||
import games.cubi.locatables.api.Spatial;
|
||||
import games.cubi.raycastedantiesp.core.utils.VarHandler;
|
||||
|
||||
import java.lang.invoke.VarHandle;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A mutable, thread-safe location and view state for a player.
|
||||
*
|
||||
* <p>Mutations are serialized because platform and packet lifecycle callbacks
|
||||
* may write from different threads. World and scalar reads use relaxed
|
||||
* per-field access: a read may combine values from adjacent updates.</p>
|
||||
* <p></p>
|
||||
* Reads of several fields are not coherently published. This is acceptable
|
||||
* since players typically move in small increments, so an old x and new z
|
||||
* still closely approximate the player's actual position. In less-frequent
|
||||
* cases such as teleports or dimension switches, raycasts may use the incorrect
|
||||
* position briefly. This does not matter, as incorrect state will be fixed by next tick's raycast.
|
||||
*/
|
||||
public final class PlayerLocatable implements MutableFloatingLocatable, FloatingLocatableEquality {
|
||||
private final Object writerMonitor = new Object();
|
||||
|
||||
private volatile UUID world; private static final VarHandle WORLD = VarHandler.get(PlayerLocatable.class, "world", UUID.class);
|
||||
private volatile double x; private static final VarHandle X = VarHandler.get(PlayerLocatable.class, "x", double.class);
|
||||
private volatile double y; private static final VarHandle Y = VarHandler.get(PlayerLocatable.class, "y", double.class);
|
||||
private volatile double z; private static final VarHandle Z = VarHandler.get(PlayerLocatable.class, "z", double.class);
|
||||
private volatile float yaw; private static final VarHandle YAW = VarHandler.get(PlayerLocatable.class, "yaw", float.class);
|
||||
private volatile float pitch; private static final VarHandle PITCH = VarHandler.get(PlayerLocatable.class, "pitch", float.class);
|
||||
private volatile PlayerPose pose; private static final VarHandle POSE = VarHandler.get(PlayerLocatable.class, "pose", PlayerPose.class);
|
||||
|
||||
public PlayerLocatable() {
|
||||
}
|
||||
|
||||
/** Initialises or replaces the complete valid player state. */
|
||||
public void initialise(UUID world, double footX, double footY, double footZ, float yaw, float pitch, PlayerPose pose) {
|
||||
validateFullState(world, footX, footY, footZ, yaw, pitch, pose);
|
||||
synchronized (writerMonitor) {
|
||||
writeFullState(world, footX, footY, footZ, yaw, pitch, pose);
|
||||
}
|
||||
}
|
||||
|
||||
/** Updates the complete state for a world change. */
|
||||
public void worldChange(UUID world, double footX, double footY, double footZ, float yaw, float pitch, PlayerPose pose) {
|
||||
validateFullState(world, footX, footY, footZ, yaw, pitch, pose);
|
||||
synchronized (writerMonitor) {
|
||||
writeFullState(world, footX, footY, footZ, yaw, pitch, pose);
|
||||
}
|
||||
}
|
||||
|
||||
/** Updates the player's foot position while retaining rotation and pose. */
|
||||
public void updateFoot(double footX, double footY, double footZ) {
|
||||
validateFinite(footX, footY, footZ);
|
||||
synchronized (writerMonitor) {
|
||||
X.setOpaque(this, footX);
|
||||
Y.setOpaque(this, footY);
|
||||
Z.setOpaque(this, footZ);
|
||||
}
|
||||
}
|
||||
|
||||
/** Updates the player's rotation while retaining position and pose. */
|
||||
public void updateRotation(float yaw, float pitch) {
|
||||
validateRotation(yaw, pitch);
|
||||
synchronized (writerMonitor) {
|
||||
YAW.setOpaque(this, yaw);
|
||||
PITCH.setOpaque(this, pitch);
|
||||
}
|
||||
}
|
||||
|
||||
/** Updates the player's pose while retaining position and rotation. */
|
||||
public void updatePose(PlayerPose pose) {
|
||||
Objects.requireNonNull(pose, "pose");
|
||||
synchronized (writerMonitor) {
|
||||
POSE.setOpaque(this, pose);
|
||||
}
|
||||
}
|
||||
|
||||
/** Updates position and rotation in one logical operation. */
|
||||
public void updateFootAndRotation(double footX, double footY, double footZ, float yaw, float pitch) {
|
||||
validateFinite(footX, footY, footZ);
|
||||
validateRotation(yaw, pitch);
|
||||
synchronized (writerMonitor) {
|
||||
X.setOpaque(this, footX);
|
||||
Y.setOpaque(this, footY);
|
||||
Z.setOpaque(this, footZ);
|
||||
YAW.setOpaque(this, yaw);
|
||||
PITCH.setOpaque(this, pitch);
|
||||
}
|
||||
}
|
||||
|
||||
/** Invalidates and clears the complete player state. */
|
||||
public void invalidate() {
|
||||
synchronized (writerMonitor) {
|
||||
WORLD.setOpaque(this, null);
|
||||
X.setOpaque(this, 0.0);
|
||||
Y.setOpaque(this, 0.0);
|
||||
Z.setOpaque(this, 0.0);
|
||||
YAW.setOpaque(this, 0.0f);
|
||||
PITCH.setOpaque(this, 0.0f);
|
||||
POSE.setOpaque(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID world() {
|
||||
return (UUID) WORLD.getOpaque(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double x() {
|
||||
return (double) X.getOpaque(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double y() {
|
||||
return (double) Y.getOpaque(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double z() {
|
||||
return (double) Z.getOpaque(this);
|
||||
}
|
||||
|
||||
public float yaw() {
|
||||
return (float) YAW.getOpaque(this);
|
||||
}
|
||||
|
||||
public float pitch() {
|
||||
return (float) PITCH.getOpaque(this);
|
||||
}
|
||||
|
||||
public PlayerPose pose() {
|
||||
return (PlayerPose) POSE.getOpaque(this);
|
||||
}
|
||||
|
||||
public float cameraYOffset() {
|
||||
PlayerPose currentPose = (PlayerPose) POSE.getOpaque(this);
|
||||
return currentPose == null ? 0.0f : currentPose.cameraYOffset();
|
||||
}
|
||||
|
||||
public double cameraX() {
|
||||
return (double) X.getOpaque(this);
|
||||
}
|
||||
|
||||
public double cameraY() {
|
||||
double currentY = (double) Y.getOpaque(this);
|
||||
PlayerPose currentPose = (PlayerPose) POSE.getOpaque(this);
|
||||
return currentY + (currentPose == null ? 0.0 : (double) currentPose.cameraYOffset());
|
||||
}
|
||||
|
||||
public double cameraZ() {
|
||||
return (double) Z.getOpaque(this);
|
||||
}
|
||||
|
||||
public double cameraDistanceSquared(Spatial spatial) {
|
||||
Objects.requireNonNull(spatial, "spatial");
|
||||
double targetX = spatial.x();
|
||||
double targetY = spatial.y();
|
||||
double targetZ = spatial.z();
|
||||
double currentX = (double) X.getOpaque(this);
|
||||
double currentY = (double) Y.getOpaque(this);
|
||||
double currentZ = (double) Z.getOpaque(this);
|
||||
PlayerPose currentPose = (PlayerPose) POSE.getOpaque(this);
|
||||
double dx = currentX - targetX;
|
||||
double dy = currentY + (currentPose == null ? 0.0 : (double) currentPose.cameraYOffset()) - targetY;
|
||||
double dz = currentZ - targetZ;
|
||||
return dx * dx + dy * dy + dz * dz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerLocatable setX(double x) {
|
||||
validateFinite(x);
|
||||
synchronized (writerMonitor) {
|
||||
X.setOpaque(this, x);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerLocatable setY(double y) {
|
||||
validateFinite(y);
|
||||
synchronized (writerMonitor) {
|
||||
Y.setOpaque(this, y);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerLocatable setZ(double z) {
|
||||
validateFinite(z);
|
||||
synchronized (writerMonitor) {
|
||||
Z.setOpaque(this, z);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerLocatable setPosition(double x, double y, double z) {
|
||||
validateFinite(x, y, z);
|
||||
synchronized (writerMonitor) {
|
||||
X.setOpaque(this, x);
|
||||
Y.setOpaque(this, y);
|
||||
Z.setOpaque(this, z);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerLocatable setPosition(Spatial spatial) {
|
||||
Objects.requireNonNull(spatial, "spatial");
|
||||
return setPosition(spatial.x(), spatial.y(), spatial.z());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerLocatable setWorld(UUID world) {
|
||||
if (world == null) {
|
||||
invalidate();
|
||||
return this;
|
||||
}
|
||||
synchronized (writerMonitor) {
|
||||
WORLD.setOpaque(this, world);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerLocatable setLocation(Locatable locatable) {
|
||||
Objects.requireNonNull(locatable, "locatable");
|
||||
return setLocation(locatable.world(), locatable.x(), locatable.y(), locatable.z());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerLocatable setLocation(UUID world, double x, double y, double z) {
|
||||
validateFinite(x, y, z);
|
||||
if (world == null) {
|
||||
invalidate();
|
||||
return this;
|
||||
}
|
||||
synchronized (writerMonitor) {
|
||||
X.setOpaque(this, x);
|
||||
Y.setOpaque(this, y);
|
||||
Z.setOpaque(this, z);
|
||||
WORLD.setOpaque(this, world);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerLocatable set(Locatable locatable) {
|
||||
return setLocation(locatable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerLocatable set(double x, double y, double z) {
|
||||
return setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerLocatable set(int x, int y, int z) {
|
||||
return setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerLocatable set(double x, double y, double z, UUID world) {
|
||||
return setLocation(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocatableType getType() {
|
||||
return LocatableType.ThreadSafe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return isEqualTo(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return makeHash();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean strictlyEquals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof PlayerLocatable that)) {
|
||||
return false;
|
||||
}
|
||||
UUID thisWorld = world();
|
||||
double thisX = x();
|
||||
double thisY = y();
|
||||
double thisZ = z();
|
||||
return Objects.equals(thisWorld, that.world())
|
||||
&& Double.doubleToLongBits(thisX) == Double.doubleToLongBits(that.x())
|
||||
&& Double.doubleToLongBits(thisY) == Double.doubleToLongBits(that.y())
|
||||
&& Double.doubleToLongBits(thisZ) == Double.doubleToLongBits(that.z());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringForm();
|
||||
}
|
||||
|
||||
/** This method must only be called while holding {@link #writerMonitor}. */
|
||||
private void writeFullState(UUID world, double footX, double footY, double footZ, float yaw, float pitch, PlayerPose pose) {
|
||||
WORLD.setOpaque(this, null);
|
||||
X.setOpaque(this, footX);
|
||||
Y.setOpaque(this, footY);
|
||||
Z.setOpaque(this, footZ);
|
||||
YAW.setOpaque(this, yaw);
|
||||
PITCH.setOpaque(this, pitch);
|
||||
POSE.setOpaque(this, pose);
|
||||
WORLD.setOpaque(this, world);
|
||||
}
|
||||
|
||||
private static void validateFullState(UUID world, double footX, double footY, double footZ, float yaw, float pitch, PlayerPose pose) {
|
||||
Objects.requireNonNull(world, "world");
|
||||
Objects.requireNonNull(pose, "pose");
|
||||
validateFinite(footX, footY, footZ);
|
||||
validateRotation(yaw, pitch);
|
||||
}
|
||||
|
||||
private static void validateFinite(double x, double y, double z) {
|
||||
if (!Double.isFinite(x) || !Double.isFinite(y) || !Double.isFinite(z)) {
|
||||
throw new IllegalArgumentException("Coordinates must be finite");
|
||||
}
|
||||
}
|
||||
|
||||
private static void validateFinite(double value) {
|
||||
if (!Double.isFinite(value)) {
|
||||
throw new IllegalArgumentException("Coordinate must be finite");
|
||||
}
|
||||
}
|
||||
|
||||
private static void validateRotation(float yaw, float pitch) {
|
||||
if (!Float.isFinite(yaw) || !Float.isFinite(pitch) || pitch < -90.0f || pitch > 90.0f) {
|
||||
throw new IllegalArgumentException("Rotation must be finite and pitch must be between -90 and 90 degrees");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.players;
|
||||
|
||||
/** Player body poses and the corresponding camera height above the feet. */
|
||||
public enum PlayerPose {
|
||||
UNKNOWN(1.62f),
|
||||
STANDING(1.62f),
|
||||
SNEAKING(1.27f),
|
||||
SWIMMING(0.40f),
|
||||
FALL_FLYING(0.40f),
|
||||
SPIN_ATTACK(0.40f),
|
||||
SLEEPING(0.20f),
|
||||
DYING(0.20f);
|
||||
|
||||
private final float cameraYOffset;
|
||||
|
||||
PlayerPose(float cameraYOffset) {
|
||||
this.cameraYOffset = cameraYOffset;
|
||||
}
|
||||
|
||||
public float cameraYOffset() {
|
||||
return cameraYOffset;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.players;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.tracked.NettyEntity;
|
||||
@@ -13,14 +21,11 @@ public class PlayerRegistry {
|
||||
NettyEntity<?> createSelfEntity(PlayerData playerData, int selfEntityID, UUID playerUUID);
|
||||
}
|
||||
|
||||
private static PlayerRegistry instance;
|
||||
private static final PlayerRegistry instance = new PlayerRegistry();
|
||||
|
||||
private PlayerRegistry() {}
|
||||
|
||||
public static PlayerRegistry getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new PlayerRegistry();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.raycast;
|
||||
|
||||
import games.cubi.locatables.api.Locatable;
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.raycast;
|
||||
|
||||
import games.cubi.locatables.api.BlockSpatial;
|
||||
import games.cubi.locatables.api.Locatable;
|
||||
import games.cubi.locatables.api.MutableFloatingSpatial;
|
||||
import games.cubi.locatables.api.Spatial;
|
||||
import games.cubi.locatables.api.*;
|
||||
import games.cubi.locatables.implementations.MutableChunkSection;
|
||||
import games.cubi.locatables.implementations.MutableSpatialImpl;
|
||||
import games.cubi.logs.Logger;
|
||||
import games.cubi.raycastedantiesp.core.chunks.ChunkOcclusionView;
|
||||
import games.cubi.raycastedantiesp.core.view.BlockView;
|
||||
|
||||
public class RaycastUtil {
|
||||
@@ -14,15 +21,18 @@ public class RaycastUtil {
|
||||
//This is deliberately a ray-stepping algorithm rather than DDA as it is much faster (2x in benchmarking)
|
||||
//Missing blocks is acceptable, as it will be assumed the player can see past those corners.
|
||||
//While this uses objects, JHM and in-game profiling have both shown that all objects used here are consistently scalarised by the JVM.
|
||||
public static boolean raycast(Locatable start, Spatial end, int maxOccluding, int alwaysShowRadius, int maxRaycastRadius, boolean debug, BlockView snap, int stepSize, ParticleSpawner particleSpawner) {
|
||||
public static boolean raycast(Locatable start, Spatial end, int maxOccluding, int alwaysShowRadius, int maxRaycastRadius, boolean debug, BlockView snap, float stepSize, ParticleSpawner particleSpawner) {
|
||||
//return raycastCubiNoAllocUnrolledLongBitsAccumulated(maxOccluding, alwaysShowRadius, maxRaycastRadius, debug, 1, snap, start.x(), start.y(), start.z(), end.x(), end.y(), end.z());
|
||||
|
||||
//return raycastUnrolledAccumulated(maxOccluding, alwaysShowRadius, maxRaycastRadius, debug, 1, snap, start, end);
|
||||
return raycast(start, end, maxOccluding, alwaysShowRadius, maxRaycastRadius, debug, snap, 0f, stepSize, particleSpawner);
|
||||
}
|
||||
|
||||
public static boolean raycast(Locatable start, Spatial end, int maxOccluding, int alwaysShowRadius, int maxRaycastRadius, boolean debug, BlockView snap, float yOffsetEnd, int stepSize, ParticleSpawner particleSpawner) {
|
||||
public static boolean raycast(Locatable start, Spatial end, int maxOccluding, int alwaysShowRadius, int maxRaycastRadius, boolean debug, BlockView snap, float yOffsetEnd, float stepSize, ParticleSpawner particleSpawner) {
|
||||
double endOffset = end instanceof BlockSpatial ? 0.5 : 0.0;
|
||||
MutableFloatingSpatial clonedEnd = new MutableSpatialImpl(end.x() + endOffset, end.y() + endOffset + yOffsetEnd, end.z() + endOffset);
|
||||
//Equivalent to end.cloneAndIfBlockThenCentre(); but not used since the JVM was not reliably scalarising that method (probably due to the polymorphic overriding?). This causes 0 object allocations.
|
||||
double total = start.distance(clonedEnd) - stepSize; //benchmarking shows that calling distance() is faster than distanceSquared() then checking distanceSquared < stepSize*stepSize every time despite the latter replacing a square root with multiplication
|
||||
float total = (float) (start.distance(clonedEnd) - stepSize); //benchmarking shows that calling distance() is faster than distanceSquared() then checking distanceSquared < stepSize*stepSize every time despite the latter replacing a square root with multiplication
|
||||
if (total <= alwaysShowRadius) return true;
|
||||
if (total > maxRaycastRadius) return false;
|
||||
if (debug && particleSpawner == null) {
|
||||
@@ -32,11 +42,17 @@ public class RaycastUtil {
|
||||
Spatial dir = clonedEnd.subtract(start).normalise().scalarMultiply(stepSize);
|
||||
|
||||
MutableFloatingSpatial current = new MutableSpatialImpl(start.x(),start.y(),start.z());
|
||||
MutableChunkSection currentChunk = new MutableChunkSection().updateFrom(current);
|
||||
ChunkOcclusionView currentOcclusionView = snap.getChunkOcclusionView(currentChunk);
|
||||
|
||||
for (double traveled = 0; traveled < total; traveled += stepSize) { //benchmarking shows that for loop is marginally faster than while loop initially (after running for a while they are equal
|
||||
for (float traveled = 0; traveled < total; traveled += stepSize) {
|
||||
current.add(dir);
|
||||
if (!ChunkSectionEquality.equals(currentChunk, current)) {
|
||||
currentChunk.updateFrom(current);
|
||||
currentOcclusionView = snap.getChunkOcclusionView(currentChunk);
|
||||
}
|
||||
|
||||
if (snap.isBlockOccluding(current.blockX(), current.blockY(), current.blockZ())) {
|
||||
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(current.blockX(), current.blockY(), current.blockZ())) {
|
||||
maxOccluding--;
|
||||
if (debug) particleSpawner.spawnParticleAt(start.world(), current, ParticleSpawner.Colour.RED);
|
||||
if (maxOccluding < 1) return false;
|
||||
@@ -47,4 +63,275 @@ public class RaycastUtil {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
public static boolean raycastCubiNoAllocUnrolledLongBitsAccumulated(int maxOccluding, final int alwaysShowRadius, final int maxRaycastRadius, boolean debug, final int stepSize, BlockView snap,
|
||||
final double startX, final double startY, final double startZ, final double endX, final double endY, final double endZ) {
|
||||
if (maxOccluding <= 0) return false;
|
||||
|
||||
double total = Math.sqrt(((endX - startX) * (endX - startX)) + ((endY - startY) * (endY - startY)) + ((endZ - startZ) * (endZ - startZ)));
|
||||
if (total <= alwaysShowRadius) return true;
|
||||
if (total > maxRaycastRadius) return false;
|
||||
double finalDist = total - stepSize;
|
||||
|
||||
final double dirX = (endX - startX) / total * stepSize;
|
||||
final double dirY = (endY - startY) / total * stepSize;
|
||||
final double dirZ = (endZ - startZ) / total * stepSize;
|
||||
|
||||
double currentX = startX;
|
||||
double currentY = startY;
|
||||
double currentZ = startZ;
|
||||
|
||||
int chunkX = ((int) currentX) >> 4;
|
||||
int chunkY = ((int) currentY) >> 4;
|
||||
int chunkZ = ((int) currentZ) >> 4;
|
||||
ChunkOcclusionView currentOcclusionView = snap.getChunkOcclusionView(chunkX, chunkY, chunkZ);
|
||||
|
||||
int occluded = 0;
|
||||
|
||||
double traveled = 0;
|
||||
final double fourSteps = stepSize * 4.0;
|
||||
while (traveled + fourSteps <= finalDist) {
|
||||
currentX += dirX;
|
||||
currentY += dirY;
|
||||
currentZ += dirZ;
|
||||
|
||||
int blockX = (int) Math.floor(currentX);
|
||||
int blockY = (int) Math.floor(currentY);
|
||||
int blockZ = (int) Math.floor(currentZ);
|
||||
if (blockX >> 4 != chunkX || blockY >> 4 != chunkY || blockZ >> 4 != chunkZ) {
|
||||
chunkX = blockX >> 4;
|
||||
chunkY = blockY >> 4;
|
||||
chunkZ = blockZ >> 4;
|
||||
currentOcclusionView = snap.getChunkOcclusionView(chunkX, chunkY, chunkZ);
|
||||
}
|
||||
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded ++;
|
||||
|
||||
currentX += dirX;
|
||||
currentY += dirY;
|
||||
currentZ += dirZ;
|
||||
|
||||
blockX = (int) Math.floor(currentX);
|
||||
blockY = (int) Math.floor(currentY);
|
||||
blockZ = (int) Math.floor(currentZ);
|
||||
if (blockX >> 4 != chunkX || blockY >> 4 != chunkY || blockZ >> 4 != chunkZ) {
|
||||
chunkX = blockX >> 4;
|
||||
chunkY = blockY >> 4;
|
||||
chunkZ = blockZ >> 4;
|
||||
currentOcclusionView = snap.getChunkOcclusionView(chunkX, chunkY, chunkZ);
|
||||
}
|
||||
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded ++;
|
||||
|
||||
currentX += dirX;
|
||||
currentY += dirY;
|
||||
currentZ += dirZ;
|
||||
|
||||
blockX = (int) Math.floor(currentX);
|
||||
blockY = (int) Math.floor(currentY);
|
||||
blockZ = (int) Math.floor(currentZ);
|
||||
if (blockX >> 4 != chunkX || blockY >> 4 != chunkY || blockZ >> 4 != chunkZ) {
|
||||
chunkX = blockX >> 4;
|
||||
chunkY = blockY >> 4;
|
||||
chunkZ = blockZ >> 4;
|
||||
currentOcclusionView = snap.getChunkOcclusionView(chunkX, chunkY, chunkZ);
|
||||
}
|
||||
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded ++;
|
||||
|
||||
currentX += dirX;
|
||||
currentY += dirY;
|
||||
currentZ += dirZ;
|
||||
|
||||
blockX = (int) Math.floor(currentX);
|
||||
blockY = (int) Math.floor(currentY);
|
||||
blockZ = (int) Math.floor(currentZ);
|
||||
if (blockX >> 4 != chunkX || blockY >> 4 != chunkY || blockZ >> 4 != chunkZ) {
|
||||
chunkX = blockX >> 4;
|
||||
chunkY = blockY >> 4;
|
||||
chunkZ = blockZ >> 4;
|
||||
currentOcclusionView = snap.getChunkOcclusionView(chunkX, chunkY, chunkZ);
|
||||
}
|
||||
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded ++;
|
||||
|
||||
if (occluded >= maxOccluding) return false;
|
||||
|
||||
traveled += fourSteps;
|
||||
}
|
||||
|
||||
for (; traveled < finalDist; traveled += stepSize) {
|
||||
currentX += dirX;
|
||||
currentY += dirY;
|
||||
currentZ += dirZ;
|
||||
|
||||
int blockX = (int) Math.floor(currentX);
|
||||
int blockY = (int) Math.floor(currentY);
|
||||
int blockZ = (int) Math.floor(currentZ);
|
||||
if (blockX >> 4 != chunkX || blockY >> 4 != chunkY || blockZ >> 4 != chunkZ) {
|
||||
chunkX = blockX >> 4;
|
||||
chunkY = blockY >> 4;
|
||||
chunkZ = blockZ >> 4;
|
||||
currentOcclusionView = snap.getChunkOcclusionView(chunkX, chunkY, chunkZ);
|
||||
}
|
||||
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded ++;
|
||||
}
|
||||
|
||||
return occluded < maxOccluding;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* The local spatial and chunk-section objects do not escape this method, so the JVM
|
||||
* should be able to scalarise them while keeping the ray-stepping code easier to follow.
|
||||
*/
|
||||
public static boolean raycastUnrolledAccumulated(int maxOccluding, final int alwaysShowRadius, final int maxRaycastRadius, boolean debug,
|
||||
final float stepSize, final BlockView snap, final Spatial start, final Spatial end) {
|
||||
RayPosition current = RayPosition.from(start);
|
||||
RayDirection direction = RayDirection.from(end, current);
|
||||
double total = direction.getLengthAndNormalise(stepSize);
|
||||
if (total <= alwaysShowRadius) return true;
|
||||
if (total > maxRaycastRadius) return false;
|
||||
float finalDist = (float) (total - stepSize);
|
||||
|
||||
RayChunkSection currentChunk = new RayChunkSection().updateFrom(current);
|
||||
ChunkOcclusionView currentOcclusionView = snap.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
|
||||
|
||||
int occluded = 0;
|
||||
|
||||
float traveled = 0;
|
||||
final float fourSteps = stepSize * 4.0f;
|
||||
while (traveled + fourSteps <= finalDist) {
|
||||
current.advance(direction);
|
||||
int blockX = current.blockX();
|
||||
int blockY = current.blockY();
|
||||
int blockZ = current.blockZ();
|
||||
if (blockX >> 4 != currentChunk.chunkX || blockY >> 4 != currentChunk.chunkY || blockZ >> 4 != currentChunk.chunkZ) {
|
||||
currentChunk.updateFrom(current);
|
||||
currentOcclusionView = snap.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
|
||||
}
|
||||
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded++;
|
||||
|
||||
current.advance(direction);
|
||||
blockX = current.blockX();
|
||||
blockY = current.blockY();
|
||||
blockZ = current.blockZ();
|
||||
if (blockX >> 4 != currentChunk.chunkX || blockY >> 4 != currentChunk.chunkY || blockZ >> 4 != currentChunk.chunkZ) {
|
||||
currentChunk.updateFrom(current);
|
||||
currentOcclusionView = snap.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
|
||||
}
|
||||
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded++;
|
||||
|
||||
current.advance(direction);
|
||||
blockX = current.blockX();
|
||||
blockY = current.blockY();
|
||||
blockZ = current.blockZ();
|
||||
if (blockX >> 4 != currentChunk.chunkX || blockY >> 4 != currentChunk.chunkY || blockZ >> 4 != currentChunk.chunkZ) {
|
||||
currentChunk.updateFrom(current);
|
||||
currentOcclusionView = snap.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
|
||||
}
|
||||
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded++;
|
||||
|
||||
current.advance(direction);
|
||||
blockX = current.blockX();
|
||||
blockY = current.blockY();
|
||||
blockZ = current.blockZ();
|
||||
if (blockX >> 4 != currentChunk.chunkX || blockY >> 4 != currentChunk.chunkY || blockZ >> 4 != currentChunk.chunkZ) {
|
||||
currentChunk.updateFrom(current);
|
||||
currentOcclusionView = snap.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
|
||||
}
|
||||
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded++;
|
||||
|
||||
if (occluded >= maxOccluding) return false;
|
||||
|
||||
traveled += fourSteps;
|
||||
}
|
||||
|
||||
for (; traveled < finalDist; traveled += stepSize) {
|
||||
current.advance(direction);
|
||||
int blockX = current.blockX();
|
||||
int blockY = current.blockY();
|
||||
int blockZ = current.blockZ();
|
||||
if (blockX >> 4 != currentChunk.chunkX || blockY >> 4 != currentChunk.chunkY || blockZ >> 4 != currentChunk.chunkZ) {
|
||||
currentChunk.updateFrom(current);
|
||||
currentOcclusionView = snap.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
|
||||
}
|
||||
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded++;
|
||||
}
|
||||
|
||||
return occluded < maxOccluding;
|
||||
}
|
||||
|
||||
private static final class RayPosition {
|
||||
private double x, y, z;
|
||||
|
||||
private void advance(RayDirection direction) {
|
||||
x += direction.x;
|
||||
y += direction.y;
|
||||
z += direction.z;
|
||||
}
|
||||
|
||||
private int blockX() {
|
||||
return (int) Math.floor(x);
|
||||
}
|
||||
|
||||
private int blockY() {
|
||||
return (int) Math.floor(y);
|
||||
}
|
||||
|
||||
private int blockZ() {
|
||||
return (int) Math.floor(z);
|
||||
}
|
||||
|
||||
private int chunkX() {
|
||||
return blockX() >> 4;
|
||||
}
|
||||
|
||||
private int chunkY() {
|
||||
return blockY() >> 4;
|
||||
}
|
||||
|
||||
private int chunkZ() {
|
||||
return blockZ() >> 4;
|
||||
}
|
||||
|
||||
private RayPosition(double x, double y, double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
private static RayPosition from(Spatial spatial) {
|
||||
return new RayPosition(spatial.x(), spatial.y(), spatial.z());
|
||||
}
|
||||
}
|
||||
|
||||
private static final class RayDirection {
|
||||
private double x, y, z;
|
||||
|
||||
private RayDirection(double x, double y, double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
private static RayDirection from(Spatial end, RayPosition start) {
|
||||
return new RayDirection(end.x() - start.x, end.y() - start.y, end.z() - start.z);
|
||||
}
|
||||
|
||||
private double getLengthAndNormalise(float stepSize) {
|
||||
double len = Math.sqrt(x * x + y * y + z * z);
|
||||
x = (x / len) * stepSize;
|
||||
y = (y / len) * stepSize;
|
||||
z = (z / len) * stepSize;
|
||||
return len;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class RayChunkSection {
|
||||
private int chunkX, chunkY, chunkZ;
|
||||
|
||||
private RayChunkSection updateFrom(RayPosition other) {
|
||||
this.chunkX = other.chunkX();
|
||||
this.chunkY = other.chunkY();
|
||||
this.chunkZ = other.chunkZ();
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,7 @@
|
||||
|
||||
package games.cubi.raycastedantiesp.core.tracked;
|
||||
|
||||
import games.cubi.locatables.api.ImmutableSpatial;
|
||||
import games.cubi.locatables.api.MutableFloatingSpatial;
|
||||
import games.cubi.locatables.implementations.ImmutableSpatialImpl;
|
||||
import games.cubi.raycastedantiesp.core.players.PlayerData;
|
||||
import games.cubi.raycastedantiesp.core.utils.Clearable;
|
||||
import games.cubi.raycastedantiesp.core.utils.PrimitiveIntArrayList;
|
||||
@@ -38,6 +36,11 @@ public abstract class NettyEntity<PacketReplayData extends Clearable> implements
|
||||
private volatile double y; private static final VarHandle Y = VarHandler.get(NettyEntity.class, "y", double.class);
|
||||
private volatile double z; private static final VarHandle Z = VarHandler.get(NettyEntity.class, "z", double.class);
|
||||
|
||||
// Packet-derived state shared with the engine.
|
||||
private static final byte FLAG_SNEAKING = 1;
|
||||
private static final byte FLAG_GLOWING = 1 << 1;
|
||||
private volatile byte trackedFlags; private static final VarHandle TRACKED_FLAGS = VarHandler.get(NettyEntity.class, "trackedFlags", byte.class);
|
||||
|
||||
// Packet-thread-only replay and client state.
|
||||
private float yaw;
|
||||
private float pitch;
|
||||
@@ -65,7 +68,7 @@ public abstract class NettyEntity<PacketReplayData extends Clearable> implements
|
||||
private volatile boolean visible;
|
||||
|
||||
// Constants
|
||||
|
||||
public static final int NEVER_CHECKED = Integer.MIN_VALUE;
|
||||
public static final int NO_VEHICLE = -1;
|
||||
public static final int NO_LEASHER = -2;
|
||||
public static final int SELF_ENTITY_TYPE = -29;
|
||||
@@ -117,11 +120,43 @@ public abstract class NettyEntity<PacketReplayData extends Clearable> implements
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean glowing() {
|
||||
return (((byte) TRACKED_FLAGS.getOpaque(this)) & FLAG_GLOWING) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sneaking() {
|
||||
return (((byte) TRACKED_FLAGS.getOpaque(this)) & FLAG_SNEAKING) != 0;
|
||||
}
|
||||
|
||||
public boolean setGlowing(boolean glowing) {
|
||||
return setTrackedFlag(FLAG_GLOWING, glowing);
|
||||
}
|
||||
|
||||
public boolean setSneaking(boolean sneaking) {
|
||||
return setTrackedFlag(FLAG_SNEAKING, sneaking);
|
||||
}
|
||||
|
||||
private boolean setTrackedFlag(byte mask, boolean enabled) {
|
||||
byte previous = enabled
|
||||
? (byte) TRACKED_FLAGS.getAndBitwiseOrRelease(this, mask)
|
||||
: (byte) TRACKED_FLAGS.getAndBitwiseAndRelease(this, (byte) ~mask);
|
||||
boolean changed = (previous & mask) != (enabled ? mask : 0);
|
||||
if (changed) {
|
||||
// A concurrent engine check may overwrite this marker. Hidden entities retry next tick; visible entities
|
||||
// may wait for their configured recheck or remain visible if rechecks are disabled.
|
||||
// This is acceptable and not considered an issue.
|
||||
LAST_CHECKED.setOpaque(this, NEVER_CHECKED);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lastChecked() {
|
||||
return (int) LAST_CHECKED.getOpaque(this);
|
||||
}
|
||||
// todo it may be that this is only ever set by the engine thread? If so, just volatile annotation may be safe enough, as no two engine threads should update a single player at the same time (add guard lock for this)
|
||||
|
||||
@Override
|
||||
public TrackedEntity<?> setLastChecked(int lastChecked) {
|
||||
LAST_CHECKED.setOpaque(this, lastChecked);
|
||||
@@ -381,6 +416,7 @@ public abstract class NettyEntity<PacketReplayData extends Clearable> implements
|
||||
if (packetReplayData != null) packetReplayData.clear();
|
||||
packetReplayData = null;
|
||||
|
||||
TRACKED_FLAGS.setOpaque(this, (byte) 0);
|
||||
VEHICLE_ID.setOpaque(this, NO_VEHICLE);
|
||||
PASSENGER_IDS.setRelease(this, null);
|
||||
leashedIDs = null;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.tracked;
|
||||
|
||||
import games.cubi.locatables.api.BlockSpatial;
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.tracked;
|
||||
|
||||
import games.cubi.locatables.api.ImmutableSpatial;
|
||||
import games.cubi.locatables.api.MutableFloatingSpatial;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -18,6 +25,10 @@ public interface TrackedEntity<PacketReplayData> extends MutableFloatingSpatial
|
||||
boolean visible();
|
||||
TrackedEntity<?> setVisible(boolean visible);
|
||||
|
||||
boolean glowing();
|
||||
|
||||
boolean sneaking();
|
||||
|
||||
int lastChecked();
|
||||
TrackedEntity<?> setLastChecked(int lastChecked);
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.tracked;
|
||||
|
||||
import games.cubi.locatables.api.ImmutableBlockSpatial;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
import games.cubi.logs.Logger;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
public interface Clearable {
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
/**
|
||||
* Thread-safe int sets. Hashcode and equals are not implemented.
|
||||
*/
|
||||
public interface CopyOnWriteMTIntSet {
|
||||
boolean contains(int value);
|
||||
|
||||
void add(int value);
|
||||
|
||||
/**
|
||||
* @return whether the value was removed
|
||||
*/
|
||||
boolean remove(int value);
|
||||
|
||||
// testing both impls by changing this factory method
|
||||
static CopyOnWriteMTIntSet get() {
|
||||
return new SortedMTIntSet();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
import games.cubi.logs.Logger;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
import java.lang.annotation.*; /**
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
import it.unimi.dsi.fastutil.Hash;
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
|
||||
import java.lang.invoke.VarHandle;
|
||||
|
||||
/**
|
||||
* A thread-safe copy-on-write int set backed by an open-addressing int hash set from fastutil.
|
||||
* Designed for highly concurrent reads and rare writes.
|
||||
*/
|
||||
public class MTWrappedFastIntSet implements CopyOnWriteMTIntSet {
|
||||
private volatile IntOpenHashSet backingSet; private static final VarHandle BACKING_SET = VarHandler.get(MTWrappedFastIntSet.class, "backingSet", IntOpenHashSet.class);
|
||||
|
||||
public MTWrappedFastIntSet() {
|
||||
backingSet = new IntOpenHashSet();
|
||||
}
|
||||
|
||||
public boolean contains(int value) {
|
||||
return ((IntOpenHashSet) BACKING_SET.getAcquire(this)).contains(value);
|
||||
}
|
||||
|
||||
public void add(int value) {
|
||||
while (true) {
|
||||
IntOpenHashSet oldSet = (IntOpenHashSet) BACKING_SET.getAcquire(this);
|
||||
if (oldSet.contains(value)) return;
|
||||
|
||||
IntOpenHashSet newSet = oldSet.clone();
|
||||
newSet.add(value);
|
||||
boolean success = BACKING_SET.weakCompareAndSetRelease(this, oldSet, newSet);
|
||||
if (success) return;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean remove(int value) {
|
||||
while (true) {
|
||||
IntOpenHashSet oldSet = (IntOpenHashSet) BACKING_SET.getAcquire(this);
|
||||
if (!oldSet.contains(value)) return false;
|
||||
|
||||
IntOpenHashSet newSet = oldSet.clone();
|
||||
boolean setSuccess = newSet.remove(value);
|
||||
boolean casSuccess = BACKING_SET.weakCompareAndSetRelease(this, oldSet, newSet);
|
||||
if (!setSuccess) throw new IllegalStateException("Backing set was mutated after publication");
|
||||
if (casSuccess) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
import games.cubi.logs.Logger;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
import java.lang.invoke.VarHandle;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* A thread-safe copy-on-write int set where values are stored in ascending order.
|
||||
* Designed for highly concurrent reads and rare writes.
|
||||
*/
|
||||
public class SortedMTIntSet implements CopyOnWriteMTIntSet {
|
||||
private volatile int[] values = new int[0]; private static final VarHandle VALUES = VarHandler.get(SortedMTIntSet.class, "values", int[].class);
|
||||
|
||||
public boolean contains(int value) {
|
||||
int[] valueSnapshot = (int[]) VALUES.getAcquire(this);
|
||||
return Arrays.binarySearch(valueSnapshot, value) >= 0;
|
||||
}
|
||||
|
||||
public void add(int value) {
|
||||
while (true) {
|
||||
int[] oldValues = (int[]) VALUES.getAcquire(this);
|
||||
int result = Arrays.binarySearch(oldValues, value);
|
||||
|
||||
if (result >= 0) return; //already in array
|
||||
int[] newValues = new int[oldValues.length + 1];
|
||||
int insertionPoint = -result - 1;
|
||||
|
||||
System.arraycopy(oldValues, 0, newValues, 0, insertionPoint);
|
||||
newValues[insertionPoint] = value;
|
||||
// If the new value is larger than the old values, this will do nothing
|
||||
System.arraycopy(oldValues, insertionPoint, newValues, insertionPoint + 1, oldValues.length - insertionPoint);
|
||||
|
||||
boolean success = VALUES.weakCompareAndSetRelease(this, oldValues, newValues);
|
||||
if (success) return;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean remove(int value) {
|
||||
while (true) {
|
||||
int[] oldValues = (int[]) VALUES.getAcquire(this);
|
||||
int result = Arrays.binarySearch(oldValues, value);
|
||||
|
||||
if (result < 0) return false; //not in array
|
||||
int[] newValues = new int[oldValues.length - 1];
|
||||
|
||||
System.arraycopy(oldValues, 0, newValues, 0, result);
|
||||
System.arraycopy(oldValues, result + 1, newValues, result, oldValues.length - result - 1);
|
||||
|
||||
boolean success = VALUES.weakCompareAndSetRelease(this, oldValues, newValues);
|
||||
if (success) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
public class ThreadGuard {
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
import ca.spottedleaf.concurrentutil.util.ConcurrentUtil;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.view;
|
||||
|
||||
import ca.spottedleaf.concurrentutil.map.SWMRInt2ObjectHashTable;
|
||||
@@ -6,6 +14,7 @@ import games.cubi.locatables.api.BlockSpatial;
|
||||
import games.cubi.logs.Logger;
|
||||
import games.cubi.raycastedantiesp.core.chunks.BlockInfoResolver;
|
||||
import games.cubi.raycastedantiesp.core.chunks.BlockChunkData;
|
||||
import games.cubi.raycastedantiesp.core.chunks.ChunkOcclusionView;
|
||||
import games.cubi.raycastedantiesp.core.chunks.OccludingChunkData;
|
||||
import games.cubi.raycastedantiesp.core.tracked.TrackedTileEntity;
|
||||
import games.cubi.raycastedantiesp.core.tracked.NettyTileEntity;
|
||||
@@ -58,6 +67,10 @@ public abstract class AbstractBlockView<R extends Clearable, T extends NettyTile
|
||||
|
||||
protected abstract T createTrackedTileEntity(BlockSpatial position, char blockID, boolean visible);
|
||||
|
||||
@Override
|
||||
public ChunkOcclusionView getChunkOcclusionView(int chunkX, int chunkY, int chunkZ) {
|
||||
return chunks.getSection(chunkX, chunkY, chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockOccluding(int x, int y, int z) {
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.view;
|
||||
|
||||
import games.cubi.locatables.api.BlockLocatable;
|
||||
import games.cubi.locatables.api.BlockSpatial;
|
||||
import games.cubi.locatables.api.SpatialChunkSection;
|
||||
import games.cubi.raycastedantiesp.core.chunks.ChunkOcclusionView;
|
||||
import games.cubi.raycastedantiesp.core.tracked.TrackedTileEntity;
|
||||
import games.cubi.raycastedantiesp.core.chunks.BlockChunkData;
|
||||
import games.cubi.raycastedantiesp.core.chunks.OccludingChunkData;
|
||||
@@ -19,6 +29,15 @@ import java.util.function.IntSupplier;
|
||||
* decisions; visibility fields and the transition queue are safe for that Netty/engine overlap.</p>
|
||||
*/
|
||||
public interface BlockView extends Clearable {
|
||||
/**
|
||||
* Parameters are chunk coordinates
|
||||
*/
|
||||
ChunkOcclusionView getChunkOcclusionView(int chunkX, int chunkY, int chunkZ);
|
||||
|
||||
default ChunkOcclusionView getChunkOcclusionView(SpatialChunkSection chunkSection) {
|
||||
return getChunkOcclusionView(chunkSection.chunkX(), chunkSection.chunkY(), chunkSection.chunkZ());
|
||||
}
|
||||
|
||||
boolean isBlockOccluding(BlockLocatable location);
|
||||
|
||||
boolean isBlockOccluding(int x, int y, int z);
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.view;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.tracked.TrackedTileEntity;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.view;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.tracked.TrackedEntity;
|
||||
@@ -62,14 +70,14 @@ public interface EntityView<T extends TrackedEntity<?>> extends Clearable {
|
||||
*
|
||||
* @return number of entities passed to {@code action}.
|
||||
*/
|
||||
int forEachNeedingRecheck(int recheckTicks, int currentTick, Consumer<UUID> action);
|
||||
int forEachNeedingRecheck(int visibleRecheckTicks, int currentTick, Consumer<UUID> action);
|
||||
|
||||
/**
|
||||
* Iterates currently tracked entities that should be visibility-checked.
|
||||
*
|
||||
* @return number of entities passed to {@code action}, or 0 if {@code countingActuallyNeeded} is false.
|
||||
*/
|
||||
int forEachNeedingRecheckEntity(int recheckTicks, int currentTick, boolean countingActuallyNeeded, int expectedWorldEpoch, Consumer<NettyEntity<?>> action);
|
||||
int forEachNeedingRecheckEntity(int visibleRecheckTicks, int currentTick, boolean countingActuallyNeeded, int expectedWorldEpoch, Consumer<NettyEntity<?>> action);
|
||||
|
||||
boolean hasPendingTransitions();
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.view;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.tracked.TrackedEntity;
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.view;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.utils.Clearable;
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.view;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.utils.Clearable;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.view;
|
||||
|
||||
import games.cubi.logs.Logger;
|
||||
|
||||
+15
@@ -1,9 +1,18 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.view.chunks;
|
||||
|
||||
import ca.spottedleaf.concurrentutil.map.SWMRLong2ObjectHashTable;
|
||||
import games.cubi.raycastedantiesp.core.chunks.BlockChunkData;
|
||||
import games.cubi.raycastedantiesp.core.chunks.BlockInfoResolver;
|
||||
import games.cubi.raycastedantiesp.core.chunks.ChunkData;
|
||||
import games.cubi.raycastedantiesp.core.chunks.ChunkOcclusionView;
|
||||
import games.cubi.raycastedantiesp.core.chunks.blocks.TwoBlockChunkData;
|
||||
|
||||
import static games.cubi.raycastedantiesp.core.view.chunks.ChunkSectionStore.packChunkCoords;
|
||||
@@ -16,6 +25,12 @@ public final class BlockChunkSectionStore extends SWMRLong2ObjectHashTable<Block
|
||||
this.blockInfoResolver = blockInfoResolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkOcclusionView getSection(int chunkX, int chunkY, int chunkZ) {
|
||||
long key = packChunkCoords(chunkX, chunkY, chunkZ);
|
||||
return get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOccluding(int x, int y, int z) {
|
||||
long key = packGlobalCoords(x, y, z);
|
||||
|
||||
+14
@@ -1,9 +1,23 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.view.chunks;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.chunks.BlockChunkData;
|
||||
import games.cubi.raycastedantiesp.core.chunks.ChunkOcclusionView;
|
||||
import games.cubi.raycastedantiesp.core.chunks.OccludingChunkData;
|
||||
|
||||
public interface ChunkSectionStore {
|
||||
/**
|
||||
* Coordinates are chunk coordinates
|
||||
*/
|
||||
ChunkOcclusionView getSection(int chunkX, int chunkY, int chunkZ);
|
||||
|
||||
boolean isOccluding(int x, int y, int z);
|
||||
|
||||
void setBlockID(int x, int y, int z, int blockID);
|
||||
|
||||
+15
-4
@@ -1,10 +1,15 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.view.chunks;
|
||||
|
||||
import ca.spottedleaf.concurrentutil.map.SWMRLong2ObjectHashTable;
|
||||
import games.cubi.raycastedantiesp.core.chunks.BlockChunkData;
|
||||
import games.cubi.raycastedantiesp.core.chunks.BlockInfoResolver;
|
||||
import games.cubi.raycastedantiesp.core.chunks.ChunkData;
|
||||
import games.cubi.raycastedantiesp.core.chunks.OccludingChunkData;
|
||||
import games.cubi.raycastedantiesp.core.chunks.*;
|
||||
|
||||
import static games.cubi.raycastedantiesp.core.view.chunks.ChunkSectionStore.packChunkCoords;
|
||||
import static games.cubi.raycastedantiesp.core.view.chunks.ChunkSectionStore.packGlobalCoords;
|
||||
@@ -16,6 +21,12 @@ public final class OccludingChunkSectionStore extends SWMRLong2ObjectHashTable<O
|
||||
this.blockInfoResolver = blockInfoResolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkOcclusionView getSection(int chunkX, int chunkY, int chunkZ) {
|
||||
long key = packChunkCoords(chunkX, chunkY, chunkZ);
|
||||
return get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOccluding(int x, int y, int z) {
|
||||
long key = packGlobalCoords(x, y, z);
|
||||
|
||||
+6
@@ -209,6 +209,10 @@ public abstract class PacketEntityViewController<P> {
|
||||
* @return Whether or not to cancel the packet event. <code>true</code> to cancel, <code>false</code> to do nothing.
|
||||
*/
|
||||
protected boolean handleEntityMetadata(P packet, int entityID, PlayerData playerData, int currentTick) {
|
||||
NettyEntity<?> entity = playerData.entityFromID(entityID);
|
||||
if (entity != null) {
|
||||
processTrackedMetadata(packet, entity);
|
||||
}
|
||||
cachePacket(packet, entityID, playerData, currentTick);
|
||||
return cancelIfEnabledAndHidden(entityID, playerData);
|
||||
}
|
||||
@@ -787,6 +791,8 @@ public abstract class PacketEntityViewController<P> {
|
||||
/** @return The entity ID of the entity */
|
||||
protected abstract int processPositionSyncPacket(P packet, PlayerData playerData, int currentTick);
|
||||
|
||||
protected abstract void processTrackedMetadata(P packet, NettyEntity<?> entity);
|
||||
|
||||
protected abstract void cachePacket(P packet, int entityID, PlayerData playerData, int currentTick);
|
||||
/** @return The entity ID of the entity */
|
||||
protected abstract int processRotationPacket(P packet, PlayerData playerData, int currentTick);
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.chunks;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.chunks.blocks.ByteArrayBlockChunkData;
|
||||
|
||||
+20
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.config.raycast;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -15,9 +23,20 @@ class RaycastConfigTest {
|
||||
EntityConfig entityConfig = EntityConfig.load(entityNode(false), "checks.entity");
|
||||
|
||||
assertTrue(playerConfig.keepClientEntityWhenHidden());
|
||||
assertFalse(playerConfig.onlyCheckSneaking());
|
||||
assertFalse(entityConfig.keepClientEntityWhenHidden());
|
||||
}
|
||||
|
||||
@Test
|
||||
void playerSneakingOnlySettingLoadsIndependently() throws SerializationException {
|
||||
ConfigurationNode node = entityNode(true);
|
||||
node.node("only-check-sneaking").set(true);
|
||||
|
||||
PlayerConfig playerConfig = PlayerConfig.load(node, "checks.player");
|
||||
|
||||
assertTrue(playerConfig.onlyCheckSneaking());
|
||||
}
|
||||
|
||||
@Test
|
||||
void tileEntityConfigDoesNotRequireOrEnableClientRetention() throws SerializationException {
|
||||
TileEntityConfig config = TileEntityConfig.load(baseNode(), "checks.tile-entity");
|
||||
@@ -38,6 +57,7 @@ class RaycastConfigTest {
|
||||
ConfigurationNode node = baseNode();
|
||||
node.node("hide-sounds-when-hidden").set(true);
|
||||
node.node("keep-client-entity-when-hidden").set(keepClientEntityWhenHidden);
|
||||
node.node("only-check-sneaking").set(false);
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.engine;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.players;
|
||||
|
||||
import games.cubi.locatables.implementations.ImmutableLocatableImpl;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class PlayerLocatableConcurrencyTest {
|
||||
private static final UUID WORLD = UUID.fromString("00000000-0000-0000-0000-000000000001");
|
||||
private static final UUID OTHER_WORLD = UUID.fromString("00000000-0000-0000-0000-000000000002");
|
||||
|
||||
@Test
|
||||
void concurrentReadersAndWritersObserveFiniteSamples() throws Exception {
|
||||
PlayerLocatable location = new PlayerLocatable();
|
||||
location.initialise(WORLD, 0.0, 1.0, 2.0, 0.0f, 0.0f, PlayerPose.STANDING);
|
||||
ImmutableLocatableImpl target = new ImmutableLocatableImpl(WORLD, 10.0, 11.0, 12.0);
|
||||
|
||||
AtomicBoolean running = new AtomicBoolean(true);
|
||||
AtomicReference<Throwable> failure = new AtomicReference<>();
|
||||
CountDownLatch readersStarted = new CountDownLatch(4);
|
||||
ExecutorService executor = Executors.newFixedThreadPool(6);
|
||||
List<Future<?>> readers = new ArrayList<>();
|
||||
|
||||
try {
|
||||
Future<?> lifecycleWriter = executor.submit(() -> runLifecycleWriter(location));
|
||||
Future<?> partialWriter = executor.submit(() -> runPartialWriter(location));
|
||||
for (int i = 0; i < 4; i++) {
|
||||
readers.add(executor.submit(() -> runReader(location, target, running, readersStarted, failure)));
|
||||
}
|
||||
|
||||
assertTrue(readersStarted.await(5, TimeUnit.SECONDS));
|
||||
lifecycleWriter.get(10, TimeUnit.SECONDS);
|
||||
partialWriter.get(10, TimeUnit.SECONDS);
|
||||
running.set(false);
|
||||
for (Future<?> reader : readers) {
|
||||
reader.get(10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
assertNull(failure.get(), () -> "Concurrent reader failed: " + failure.get());
|
||||
} finally {
|
||||
running.set(false);
|
||||
executor.shutdownNow();
|
||||
assertTrue(executor.awaitTermination(10, TimeUnit.SECONDS));
|
||||
}
|
||||
}
|
||||
|
||||
private static void runLifecycleWriter(PlayerLocatable location) {
|
||||
for (int i = 0; i < 20_000; i++) {
|
||||
UUID world = (i & 1) == 0 ? WORLD : OTHER_WORLD;
|
||||
location.worldChange(world, i, i + 1.0, i + 2.0, i % 360.0f, (i % 180.0f) - 90.0f, poseFor(i));
|
||||
if ((i & 255) == 0) {
|
||||
location.invalidate();
|
||||
location.initialise(world, i, i + 1.0, i + 2.0, 0.0f, 0.0f, PlayerPose.UNKNOWN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void runPartialWriter(PlayerLocatable location) {
|
||||
for (int i = 0; i < 20_000; i++) {
|
||||
try {
|
||||
location.updateFoot(i + 0.25, i + 1.25, i + 2.25);
|
||||
location.updateRotation(i % 360.0f, (i % 180.0f) - 90.0f);
|
||||
location.updatePose(poseFor(i + 1));
|
||||
} catch (IllegalStateException ignored) {
|
||||
// The lifecycle writer is allowed to invalidate between partial updates.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void runReader(PlayerLocatable location, ImmutableLocatableImpl target, AtomicBoolean running,
|
||||
CountDownLatch readersStarted, AtomicReference<Throwable> failure) {
|
||||
readersStarted.countDown();
|
||||
try {
|
||||
while (running.get()) {
|
||||
location.world();
|
||||
double x = location.x();
|
||||
double y = location.y();
|
||||
double z = location.z();
|
||||
float yaw = location.yaw();
|
||||
float pitch = location.pitch();
|
||||
location.pose();
|
||||
float cameraYOffset = location.cameraYOffset();
|
||||
double cameraX = location.cameraX();
|
||||
double cameraY = location.cameraY();
|
||||
double cameraZ = location.cameraZ();
|
||||
double distanceSquared = location.cameraDistanceSquared(target);
|
||||
|
||||
if (!Double.isFinite(x) || !Double.isFinite(y) || !Double.isFinite(z)
|
||||
|| !Float.isFinite(yaw) || !Float.isFinite(pitch)
|
||||
|| !Float.isFinite(cameraYOffset)
|
||||
|| !Double.isFinite(cameraX) || !Double.isFinite(cameraY) || !Double.isFinite(cameraZ)
|
||||
|| !Double.isFinite(distanceSquared)) {
|
||||
throw new AssertionError("Observed a non-finite player sample");
|
||||
}
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
failure.compareAndSet(null, throwable);
|
||||
}
|
||||
}
|
||||
|
||||
private static PlayerPose poseFor(int value) {
|
||||
return switch (Math.floorMod(value, 4)) {
|
||||
case 0 -> PlayerPose.STANDING;
|
||||
case 1 -> PlayerPose.SNEAKING;
|
||||
case 2 -> PlayerPose.SWIMMING;
|
||||
default -> PlayerPose.SLEEPING;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.players;
|
||||
|
||||
import games.cubi.locatables.implementations.ImmutableLocatableImpl;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class PlayerLocatableTest {
|
||||
private static final UUID WORLD = UUID.fromString("00000000-0000-0000-0000-000000000001");
|
||||
private static final UUID OTHER_WORLD = UUID.fromString("00000000-0000-0000-0000-000000000002");
|
||||
|
||||
@Test
|
||||
void poseCameraOffsetsAreExposed() {
|
||||
assertEquals(1.62f, PlayerPose.UNKNOWN.cameraYOffset());
|
||||
assertEquals(1.62f, PlayerPose.STANDING.cameraYOffset());
|
||||
assertEquals(1.27f, PlayerPose.SNEAKING.cameraYOffset());
|
||||
assertEquals(0.40f, PlayerPose.SWIMMING.cameraYOffset());
|
||||
assertEquals(0.40f, PlayerPose.FALL_FLYING.cameraYOffset());
|
||||
assertEquals(0.40f, PlayerPose.SPIN_ATTACK.cameraYOffset());
|
||||
assertEquals(0.20f, PlayerPose.SLEEPING.cameraYOffset());
|
||||
assertEquals(0.20f, PlayerPose.DYING.cameraYOffset());
|
||||
}
|
||||
|
||||
@Test
|
||||
void startsInvalidAndInitializesCompleteCameraState() {
|
||||
PlayerLocatable location = new PlayerLocatable();
|
||||
|
||||
assertNull(location.world());
|
||||
assertNull(location.pose());
|
||||
assertEquals(0.0f, location.cameraYOffset());
|
||||
|
||||
location.initialise(WORLD, 10.0, 20.0, 30.0, 90.0f, -25.0f, PlayerPose.SNEAKING);
|
||||
|
||||
assertEquals(WORLD, location.world());
|
||||
assertEquals(10.0, location.x());
|
||||
assertEquals(20.0, location.y());
|
||||
assertEquals(30.0, location.z());
|
||||
assertEquals(90.0f, location.yaw());
|
||||
assertEquals(-25.0f, location.pitch());
|
||||
assertEquals(PlayerPose.SNEAKING, location.pose());
|
||||
assertEquals(1.27f, location.cameraYOffset());
|
||||
assertEquals(10.0, location.cameraX());
|
||||
assertEquals(21.27, location.cameraY(), 1.0e-6);
|
||||
assertEquals(30.0, location.cameraZ());
|
||||
assertEquals(1.27 * 1.27, location.cameraDistanceSquared(new ImmutableLocatableImpl(WORLD, 10.0, 20.0, 30.0)), 1.0e-6);
|
||||
}
|
||||
|
||||
@Test
|
||||
void partialUpdatesPreserveOmittedStateAndRequireInitialization() {
|
||||
PlayerLocatable location = new PlayerLocatable();
|
||||
assertThrows(IllegalStateException.class, () -> location.updateFoot(1.0, 2.0, 3.0));
|
||||
assertThrows(IllegalStateException.class, () -> location.updateRotation(1.0f, 2.0f));
|
||||
assertThrows(IllegalStateException.class, () -> location.updatePose(PlayerPose.STANDING));
|
||||
|
||||
location.initialise(WORLD, 1.0, 2.0, 3.0, 4.0f, 5.0f, PlayerPose.STANDING);
|
||||
location.updateFoot(6.0, 7.0, 8.0);
|
||||
location.updateRotation(9.0f, 10.0f);
|
||||
location.updatePose(PlayerPose.SNEAKING);
|
||||
|
||||
assertEquals(6.0, location.x());
|
||||
assertEquals(7.0, location.y());
|
||||
assertEquals(8.0, location.z());
|
||||
assertEquals(9.0f, location.yaw());
|
||||
assertEquals(10.0f, location.pitch());
|
||||
assertEquals(PlayerPose.SNEAKING, location.pose());
|
||||
}
|
||||
|
||||
@Test
|
||||
void locatableMutationsPreserveViewStateAndSetWorldNullInvalidates() {
|
||||
PlayerLocatable location = new PlayerLocatable();
|
||||
location.initialise(WORLD, 1.0, 2.0, 3.0, 4.0f, 5.0f, PlayerPose.SLEEPING);
|
||||
|
||||
assertSame(location, location.setPosition(6.0, 7.0, 8.0));
|
||||
assertSame(location, location.setLocation(OTHER_WORLD, 9.0, 10.0, 11.0));
|
||||
assertEquals(4.0f, location.yaw());
|
||||
assertEquals(5.0f, location.pitch());
|
||||
assertEquals(PlayerPose.SLEEPING, location.pose());
|
||||
assertEquals(OTHER_WORLD, location.world());
|
||||
assertEquals(9.0, location.x());
|
||||
assertEquals(10.0, location.y());
|
||||
assertEquals(11.0, location.z());
|
||||
|
||||
location.setWorld(null);
|
||||
|
||||
assertNull(location.world());
|
||||
assertNull(location.pose());
|
||||
assertEquals(0.0, location.x());
|
||||
assertEquals(0.0, location.y());
|
||||
assertEquals(0.0, location.z());
|
||||
assertThrows(IllegalStateException.class, () -> location.setWorld(WORLD));
|
||||
}
|
||||
|
||||
@Test
|
||||
void equalityUsesWorldAndFootCoordinatesOnly() {
|
||||
PlayerLocatable first = new PlayerLocatable();
|
||||
PlayerLocatable second = new PlayerLocatable();
|
||||
first.initialise(WORLD, 1.0, 2.0, 3.0, 4.0f, 5.0f, PlayerPose.STANDING);
|
||||
second.initialise(WORLD, 1.0, 2.0, 3.0, 90.0f, -5.0f, PlayerPose.SLEEPING);
|
||||
|
||||
assertEquals(first, second);
|
||||
assertEquals(first.hashCode(), second.hashCode());
|
||||
assertTrue(first.strictlyEquals(second));
|
||||
}
|
||||
|
||||
@Test
|
||||
void fullStateRejectsInvalidValues() {
|
||||
PlayerLocatable location = new PlayerLocatable();
|
||||
|
||||
assertThrows(NullPointerException.class, () -> location.initialise(null, 0.0, 0.0, 0.0, 0.0f, 0.0f, PlayerPose.STANDING));
|
||||
assertThrows(NullPointerException.class, () -> location.initialise(WORLD, 0.0, 0.0, 0.0, 0.0f, 0.0f, null));
|
||||
assertThrows(IllegalArgumentException.class, () -> location.initialise(WORLD, Double.NaN, 0.0, 0.0, 0.0f, 0.0f, PlayerPose.STANDING));
|
||||
assertThrows(IllegalArgumentException.class, () -> location.initialise(WORLD, 0.0, 0.0, 0.0, Float.NaN, 0.0f, PlayerPose.STANDING));
|
||||
assertThrows(IllegalArgumentException.class, () -> location.initialise(WORLD, 0.0, 0.0, 0.0, 0.0f, 91.0f, PlayerPose.STANDING));
|
||||
assertNull(location.world());
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.raycast;
|
||||
|
||||
import games.cubi.locatables.api.Locatable;
|
||||
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.tracked;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.utils.Clearable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Phaser;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class NettyEntityTrackedStateTest {
|
||||
@Test
|
||||
void trackedFlagsUpdateIndependentlyAndReportChanges() {
|
||||
TestEntity entity = new TestEntity();
|
||||
|
||||
assertTrue(entity.setSneaking(true));
|
||||
assertTrue(entity.sneaking());
|
||||
assertFalse(entity.glowing());
|
||||
assertEquals(NettyEntity.NEVER_CHECKED, entity.lastChecked());
|
||||
|
||||
entity.setLastChecked(10);
|
||||
assertFalse(entity.setSneaking(true));
|
||||
assertEquals(10, entity.lastChecked());
|
||||
|
||||
assertTrue(entity.setGlowing(true));
|
||||
assertTrue(entity.sneaking());
|
||||
assertTrue(entity.glowing());
|
||||
assertEquals(NettyEntity.NEVER_CHECKED, entity.lastChecked());
|
||||
|
||||
entity.clear();
|
||||
|
||||
assertFalse(entity.sneaking());
|
||||
assertFalse(entity.glowing());
|
||||
}
|
||||
|
||||
@Test
|
||||
void concurrentUpdatesToDifferentFlagsDoNotOverwriteEachOther() {
|
||||
assertTimeoutPreemptively(Duration.ofSeconds(10), () -> {
|
||||
TestEntity entity = new TestEntity();
|
||||
int iterations = 2_000;
|
||||
Phaser phases = new Phaser(3);
|
||||
AtomicBoolean lostUpdate = new AtomicBoolean();
|
||||
|
||||
try (var executor = Executors.newFixedThreadPool(2)) {
|
||||
var sneakingTask = executor.submit(() -> {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
phases.arriveAndAwaitAdvance();
|
||||
entity.setSneaking(true);
|
||||
phases.arriveAndAwaitAdvance();
|
||||
}
|
||||
});
|
||||
var glowingTask = executor.submit(() -> {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
phases.arriveAndAwaitAdvance();
|
||||
entity.setGlowing(true);
|
||||
phases.arriveAndAwaitAdvance();
|
||||
}
|
||||
});
|
||||
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
entity.clear();
|
||||
phases.arriveAndAwaitAdvance();
|
||||
phases.arriveAndAwaitAdvance();
|
||||
if (!entity.sneaking() || !entity.glowing()) {
|
||||
lostUpdate.set(true);
|
||||
}
|
||||
}
|
||||
sneakingTask.get();
|
||||
glowingTask.get();
|
||||
}
|
||||
|
||||
assertFalse(lostUpdate.get());
|
||||
});
|
||||
}
|
||||
|
||||
private static final class TestEntity extends NettyEntity<Clearable> {
|
||||
private TestEntity() {
|
||||
super(null, 0, 0, 0, 1, UUID.randomUUID(), false, 0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
+87
-22
@@ -8,12 +8,16 @@
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
import games.cubi.utils.sets.CopyOnWriteMTIntSet;
|
||||
import games.cubi.utils.sets.SortedStripedMTIntSet;
|
||||
import org.junit.jupiter.api.DynamicContainer;
|
||||
import org.junit.jupiter.api.TestFactory;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -22,6 +26,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
@@ -30,8 +35,7 @@ import static org.junit.jupiter.api.DynamicTest.dynamicTest;
|
||||
|
||||
class CopyOnWriteMTIntSetTest {
|
||||
private static final List<Implementation> IMPLEMENTATIONS = List.of(
|
||||
new Implementation("sorted array", SortedMTIntSet::new),
|
||||
new Implementation("fastutil wrapper", MTWrappedFastIntSet::new)
|
||||
new Implementation("sorted stripes", SortedStripedMTIntSet::new)
|
||||
);
|
||||
|
||||
@TestFactory
|
||||
@@ -41,6 +45,7 @@ class CopyOnWriteMTIntSetTest {
|
||||
Stream.of(
|
||||
dynamicTest("adds, finds, and removes all int values", () -> basicOperations(implementation.create())),
|
||||
dynamicTest("removes beginning, middle, and end values", () -> removalPositions(implementation.create())),
|
||||
dynamicTest("traverses one coherent snapshot", () -> snapshotTraversal(implementation.create())),
|
||||
dynamicTest("supports concurrent readers and writers", () -> concurrentReadersAndWriters(implementation.create()))
|
||||
)
|
||||
));
|
||||
@@ -77,41 +82,80 @@ class CopyOnWriteMTIntSetTest {
|
||||
assertFalse(set.contains(5));
|
||||
}
|
||||
|
||||
private static void snapshotTraversal(CopyOnWriteMTIntSet set) {
|
||||
set.add(1);
|
||||
set.add(2);
|
||||
set.add(3);
|
||||
|
||||
Set<Integer> observed = new HashSet<>();
|
||||
set.forEach(value -> {
|
||||
assertTrue(observed.add(value));
|
||||
if (value == 1) {
|
||||
assertTrue(set.remove(2));
|
||||
set.add(4);
|
||||
}
|
||||
});
|
||||
|
||||
assertTrue(observed.containsAll(Set.of(1, 2, 3)));
|
||||
assertTrue(observed.size() == 3);
|
||||
assertFalse(set.contains(2));
|
||||
assertTrue(set.contains(4));
|
||||
|
||||
set.remove(1);
|
||||
set.remove(3);
|
||||
set.remove(4);
|
||||
set.forEach(value -> assertTrue(false, "An empty set must not be traversed: " + value));
|
||||
}
|
||||
|
||||
private static void concurrentReadersAndWriters(CopyOnWriteMTIntSet set) {
|
||||
assertTimeoutPreemptively(Duration.ofSeconds(10), () -> {
|
||||
int valueCount = 512;
|
||||
int addedBase = 10_000;
|
||||
for (int value = 0; value < valueCount; value++) {
|
||||
set.add(value);
|
||||
assertTimeoutPreemptively(Duration.ofSeconds(20), () -> {
|
||||
int transientCount = 512;
|
||||
int transientBase = 100_000;
|
||||
for (int value = 0; value < transientCount; value++) {
|
||||
set.add(transientBase + value);
|
||||
}
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(6);
|
||||
int valueCount = 2_048;
|
||||
ExecutorService executor = Executors.newFixedThreadPool(8);
|
||||
CountDownLatch start = new CountDownLatch(1);
|
||||
List<Future<?>> futures = new ArrayList<>();
|
||||
try {
|
||||
for (int worker = 0; worker < 2; worker++) {
|
||||
int from = worker * valueCount / 2;
|
||||
int to = (worker + 1) * valueCount / 2;
|
||||
int workerIndex = worker;
|
||||
futures.add(executor.submit(() -> {
|
||||
await(start);
|
||||
for (int value = from; value < to; value++) {
|
||||
assertTrue(set.remove(value));
|
||||
}
|
||||
}));
|
||||
futures.add(executor.submit(() -> {
|
||||
await(start);
|
||||
for (int value = from; value < to; value++) {
|
||||
set.add(addedBase + value);
|
||||
if (workerIndex == 0) {
|
||||
for (int value = 0; value < valueCount; value++) {
|
||||
addFinalValues(set, value);
|
||||
}
|
||||
} else {
|
||||
for (int value = valueCount - 1; value >= 0; value--) {
|
||||
addFinalValues(set, value);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
for (int reader = 0; reader < 2; reader++) {
|
||||
for (int remover = 0; remover < 2; remover++) {
|
||||
futures.add(executor.submit(() -> {
|
||||
await(start);
|
||||
for (int value = 0; value < transientCount; value++) {
|
||||
set.remove(transientBase + value);
|
||||
}
|
||||
}));
|
||||
}
|
||||
for (int reader = 0; reader < 3; reader++) {
|
||||
futures.add(executor.submit(() -> {
|
||||
await(start);
|
||||
for (int iteration = 0; iteration < 10_000; iteration++) {
|
||||
int value = iteration % valueCount;
|
||||
set.contains(value);
|
||||
set.contains(addedBase + value);
|
||||
set.contains(-value - 1);
|
||||
set.contains(Integer.MIN_VALUE);
|
||||
set.contains(Integer.MAX_VALUE);
|
||||
if (iteration % 100 == 0) {
|
||||
Set<Integer> snapshot = new HashSet<>();
|
||||
set.forEach(snapshotValue -> assertTrue(snapshot.add(snapshotValue), "Duplicate value in traversal snapshot: " + snapshotValue));
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
@@ -125,13 +169,34 @@ class CopyOnWriteMTIntSetTest {
|
||||
executor.awaitTermination(5, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
Set<Integer> expected = new HashSet<>();
|
||||
for (int value = 0; value < valueCount; value++) {
|
||||
assertFalse(set.contains(value));
|
||||
assertTrue(set.contains(addedBase + value));
|
||||
expected.add(value);
|
||||
expected.add(-value - 1);
|
||||
}
|
||||
expected.add(Integer.MIN_VALUE);
|
||||
expected.add(Integer.MAX_VALUE);
|
||||
|
||||
Set<Integer> actual = new HashSet<>();
|
||||
set.forEach(value -> assertTrue(actual.add(value), "Duplicate value in final snapshot: " + value));
|
||||
assertEquals(expected, actual);
|
||||
for (int value = 0; value < transientCount; value++) {
|
||||
assertFalse(set.contains(transientBase + value));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void addFinalValues(CopyOnWriteMTIntSet set, int value) {
|
||||
set.add(value);
|
||||
set.add(-value - 1);
|
||||
set.add(value);
|
||||
set.add(-value - 1);
|
||||
if (value == 0) {
|
||||
set.add(Integer.MIN_VALUE);
|
||||
set.add(Integer.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
private static void await(CountDownLatch latch) {
|
||||
try {
|
||||
latch.await();
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -0,0 +1,301 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
import games.cubi.utils.sets.SortedStripedMTIntSet;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class SortedMTIntSetTest {
|
||||
private static final Field STATE_FIELD = declaredField(SortedStripedMTIntSet.class, "state");
|
||||
private static final Field STRIPES_FIELD = declaredField(STATE_FIELD.getType(), "stripes");
|
||||
private static final Field MASK_FIELD = declaredField(STATE_FIELD.getType(), "mask");
|
||||
|
||||
@Test
|
||||
void validatesStripeCounts() {
|
||||
for (int stripeCount : List.of(1, 2, 4, 8, 16, 1024)) {
|
||||
StateSnapshot snapshot = snapshot(new SortedStripedMTIntSet(stripeCount));
|
||||
assertEquals(stripeCount, snapshot.stripes.length);
|
||||
assertEquals(stripeCount - 1, snapshot.mask);
|
||||
}
|
||||
|
||||
for (int invalidStripeCount : List.of(0, -1, -2, 3, 5, 6, 12)) {
|
||||
assertThrows(IllegalArgumentException.class, () -> new SortedStripedMTIntSet(invalidStripeCount));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void routesValuesWithTheStripeMask() {
|
||||
int[] values = {
|
||||
Integer.MIN_VALUE, -8, -4, -3, -2, -1,
|
||||
0, 1, 2, 3, 4, 5, 8, Integer.MAX_VALUE
|
||||
};
|
||||
SortedStripedMTIntSet set = new SortedStripedMTIntSet(4);
|
||||
for (int value : values) {
|
||||
set.add(value);
|
||||
}
|
||||
|
||||
StateSnapshot snapshot = snapshot(set);
|
||||
for (int stripeIndex = 0; stripeIndex < snapshot.stripes.length; stripeIndex++) {
|
||||
int expectedStripe = stripeIndex;
|
||||
int[] expected = Arrays.stream(values)
|
||||
.filter(value -> (value & 3) == expectedStripe)
|
||||
.sorted()
|
||||
.toArray();
|
||||
assertArrayEquals(expected, snapshot.stripes[stripeIndex]);
|
||||
}
|
||||
assertValid(set, new HashSet<>(Arrays.stream(values).boxed().toList()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void keepsEveryStripeSortedAcrossInsertionOrdersAndRemovals() {
|
||||
int[] values = new Random(12345L).ints(241, -120, 121).distinct().toArray();
|
||||
List<int[]> insertionOrders = List.of(
|
||||
Arrays.stream(values).sorted().toArray(),
|
||||
Arrays.stream(values).boxed().sorted((left, right) -> Integer.compare(right, left)).mapToInt(Integer::intValue).toArray(),
|
||||
shuffled(values)
|
||||
);
|
||||
|
||||
for (int[] insertionOrder : insertionOrders) {
|
||||
SortedStripedMTIntSet set = new SortedStripedMTIntSet();
|
||||
Set<Integer> expected = new HashSet<>();
|
||||
for (int value : insertionOrder) {
|
||||
set.add(value);
|
||||
expected.add(value);
|
||||
}
|
||||
assertValid(set, expected);
|
||||
|
||||
for (int value : insertionOrder) {
|
||||
if ((value & 3) == 0) {
|
||||
assertTrue(set.remove(value));
|
||||
expected.remove(value);
|
||||
}
|
||||
}
|
||||
assertValid(set, expected);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void growsOnlyAtTheRequiredLiveCountThresholds() {
|
||||
SortedStripedMTIntSet set = new SortedStripedMTIntSet();
|
||||
|
||||
for (int value = 0; value < 50; value++) {
|
||||
set.add(value);
|
||||
}
|
||||
assertEquals(1, stripeCount(set));
|
||||
set.add(0);
|
||||
assertEquals(1, stripeCount(set));
|
||||
|
||||
set.add(50);
|
||||
assertEquals(2, stripeCount(set));
|
||||
for (int value = 51; value < 100; value++) {
|
||||
set.add(value);
|
||||
}
|
||||
assertEquals(2, stripeCount(set));
|
||||
set.add(0);
|
||||
assertEquals(2, stripeCount(set));
|
||||
|
||||
set.add(100);
|
||||
assertEquals(4, stripeCount(set));
|
||||
for (int value = 101; value < 200; value++) {
|
||||
set.add(value);
|
||||
}
|
||||
assertEquals(4, stripeCount(set));
|
||||
set.add(0);
|
||||
assertEquals(4, stripeCount(set));
|
||||
|
||||
set.add(200);
|
||||
assertEquals(8, stripeCount(set));
|
||||
Set<Integer> expected = new HashSet<>();
|
||||
for (int value = 0; value <= 200; value++) {
|
||||
expected.add(value);
|
||||
}
|
||||
assertValid(set, expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
void preservesMembershipAndRoutingDuringGrowth() {
|
||||
SortedStripedMTIntSet set = new SortedStripedMTIntSet();
|
||||
Set<Integer> expected = new HashSet<>();
|
||||
for (int count = 1; count <= 401; count++) {
|
||||
int value = (count & 1) == 0 ? -count : count;
|
||||
set.add(value);
|
||||
expected.add(value);
|
||||
if (count == 50 || count == 51 || count == 100 || count == 101 || count == 200 || count == 201 || count == 401) {
|
||||
assertValid(set, expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void preservesSortedOrderWhenGrowthSplitsAnOldStripe() {
|
||||
SortedStripedMTIntSet set = new SortedStripedMTIntSet(2);
|
||||
Set<Integer> expected = new HashSet<>();
|
||||
for (int value = 200; value >= 0; value -= 2) {
|
||||
set.add(value);
|
||||
expected.add(value);
|
||||
}
|
||||
|
||||
assertEquals(4, stripeCount(set));
|
||||
assertValid(set, expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
void neverShrinksAfterRemovals() {
|
||||
SortedStripedMTIntSet set = new SortedStripedMTIntSet();
|
||||
for (int value = 0; value < 201; value++) {
|
||||
set.add(value);
|
||||
}
|
||||
assertEquals(8, stripeCount(set));
|
||||
|
||||
for (int value = 0; value < 201; value++) {
|
||||
assertTrue(set.remove(value));
|
||||
}
|
||||
assertEquals(8, stripeCount(set));
|
||||
assertValid(set, Set.of());
|
||||
set.add(Integer.MIN_VALUE);
|
||||
assertEquals(8, stripeCount(set));
|
||||
}
|
||||
|
||||
@Test
|
||||
void ordinaryMutationsReplaceOnlyTheSelectedStripe() {
|
||||
SortedStripedMTIntSet set = new SortedStripedMTIntSet(4);
|
||||
for (int value = 0; value < 4; value++) {
|
||||
set.add(value);
|
||||
}
|
||||
|
||||
StateSnapshot beforeAdd = snapshot(set);
|
||||
set.add(4);
|
||||
StateSnapshot afterAdd = snapshot(set);
|
||||
assertNotSame(beforeAdd.state, afterAdd.state);
|
||||
assertNotSame(beforeAdd.stripes[0], afterAdd.stripes[0]);
|
||||
for (int stripeIndex = 1; stripeIndex < 4; stripeIndex++) {
|
||||
assertSame(beforeAdd.stripes[stripeIndex], afterAdd.stripes[stripeIndex]);
|
||||
}
|
||||
|
||||
StateSnapshot beforeDuplicate = snapshot(set);
|
||||
set.add(4);
|
||||
assertSame(beforeDuplicate.state, snapshot(set).state);
|
||||
assertFalse(set.remove(100));
|
||||
assertSame(beforeDuplicate.state, snapshot(set).state);
|
||||
|
||||
StateSnapshot beforeRemove = snapshot(set);
|
||||
assertTrue(set.remove(4));
|
||||
StateSnapshot afterRemove = snapshot(set);
|
||||
assertNotSame(beforeRemove.state, afterRemove.state);
|
||||
assertNotSame(beforeRemove.stripes[0], afterRemove.stripes[0]);
|
||||
for (int stripeIndex = 1; stripeIndex < 4; stripeIndex++) {
|
||||
assertSame(beforeRemove.stripes[stripeIndex], afterRemove.stripes[stripeIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void traversesOneImmutableSnapshotAcrossStripes() {
|
||||
SortedStripedMTIntSet set = new SortedStripedMTIntSet(4);
|
||||
Set<Integer> expected = new HashSet<>(Set.of(-4, 0, 1, 2, 3, 4, 5, 8));
|
||||
expected.forEach(set::add);
|
||||
|
||||
Set<Integer> observed = new HashSet<>();
|
||||
boolean[] mutated = {false};
|
||||
set.forEach(value -> {
|
||||
assertTrue(observed.add(value));
|
||||
if (!mutated[0]) {
|
||||
mutated[0] = true;
|
||||
assertTrue(set.remove(5));
|
||||
set.add(99);
|
||||
}
|
||||
});
|
||||
|
||||
assertEquals(expected, observed);
|
||||
expected.remove(5);
|
||||
expected.add(99);
|
||||
assertValid(set, expected);
|
||||
|
||||
SortedStripedMTIntSet empty = new SortedStripedMTIntSet(2);
|
||||
empty.forEach(value -> assertTrue(false, "An empty set must not be traversed: " + value));
|
||||
}
|
||||
|
||||
private static int[] shuffled(int[] values) {
|
||||
int[] shuffled = values.clone();
|
||||
Random random = new Random(9876L);
|
||||
for (int index = shuffled.length - 1; index > 0; index--) {
|
||||
int swapIndex = random.nextInt(index + 1);
|
||||
int value = shuffled[index];
|
||||
shuffled[index] = shuffled[swapIndex];
|
||||
shuffled[swapIndex] = value;
|
||||
}
|
||||
return shuffled;
|
||||
}
|
||||
|
||||
private static void assertValid(SortedStripedMTIntSet set, Set<Integer> expected) {
|
||||
StateSnapshot snapshot = snapshot(set);
|
||||
assertEquals(snapshot.stripes.length - 1, snapshot.mask);
|
||||
|
||||
Set<Integer> actual = new HashSet<>();
|
||||
for (int stripeIndex = 0; stripeIndex < snapshot.stripes.length; stripeIndex++) {
|
||||
int[] stripe = snapshot.stripes[stripeIndex];
|
||||
for (int valueIndex = 1; valueIndex < stripe.length; valueIndex++) {
|
||||
assertTrue(stripe[valueIndex - 1] < stripe[valueIndex]);
|
||||
}
|
||||
for (int value : stripe) {
|
||||
assertEquals(stripeIndex, value & snapshot.mask);
|
||||
assertTrue(actual.add(value), "Duplicate value in published stripes: " + value);
|
||||
}
|
||||
}
|
||||
assertEquals(expected, actual);
|
||||
|
||||
for (int value : expected) {
|
||||
assertTrue(set.contains(value));
|
||||
}
|
||||
}
|
||||
|
||||
private static int stripeCount(SortedStripedMTIntSet set) {
|
||||
return snapshot(set).stripes.length;
|
||||
}
|
||||
|
||||
private static StateSnapshot snapshot(SortedStripedMTIntSet set) {
|
||||
try {
|
||||
Object state = STATE_FIELD.get(set);
|
||||
return new StateSnapshot(
|
||||
state,
|
||||
(int[][]) STRIPES_FIELD.get(state),
|
||||
MASK_FIELD.getInt(state)
|
||||
);
|
||||
} catch (ReflectiveOperationException exception) {
|
||||
throw new AssertionError("Unable to inspect published set state", exception);
|
||||
}
|
||||
}
|
||||
|
||||
private static Field declaredField(Class<?> type, String name) {
|
||||
try {
|
||||
Field field = type.getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
} catch (ReflectiveOperationException exception) {
|
||||
throw new ExceptionInInitializerError(exception);
|
||||
}
|
||||
}
|
||||
|
||||
private record StateSnapshot(Object state, int[][] stripes, int mask) {
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.utils;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.view;
|
||||
|
||||
import games.cubi.raycastedantiesp.core.tracked.TrackedEntity;
|
||||
|
||||
+8
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.core.view.chunks;
|
||||
|
||||
import games.cubi.locatables.api.BlockLocatable;
|
||||
|
||||
Loaded 100 of 146 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user