Compare commits

...
Author SHA1 Message Date
Cubicake 2d07b595d7 direction raycaster 2026-09-10 19:57:15 +09:30
Cubicake 37c905eb8c Remove unnecessary allocs 2026-09-07 18:05:45 +09:30
Cubicake 516b5df1d3 PrimitiveIntArrayList.remove does not mutate the provided array 2026-09-07 17:51:31 +09:30
Cubicake 914779f3e0 Remove utterly pointless overload 2026-09-07 17:49:22 +09:30
Cubicake 7c16afccb3 Remove unused EntityViewTransition and BlockViewTransition 2026-09-07 15:21:53 +09:30
Cubicake a49213e054 Remove unused constants 2026-09-07 15:04:29 +09:30
Cubicake 6877911210 Make it more compact 2026-09-07 14:59:53 +09:30
Cubicake 006ac0ba7a Update imports and move entity spawn tasks 2026-09-07 14:54:04 +09:30
Cubicake f92de7631b Move more util classes to games.cubi.util 2026-09-07 14:53:24 +09:30
Cubicake a6903ebffd Move more util classes to games.cubi.util 2026-09-07 11:52:14 +09:30
Cubicake d01e202401 Move util classes to games.cubi.util 2026-09-07 11:43:20 +09:30
Cubicake 71406b5803 Avoid allocating pointless arrays 2026-09-07 11:37:04 +09:30
Cubicake 30a9a73e25 PrimitiveIntArrayList.toString() is already null-guarded 2026-09-07 11:20:01 +09:30
Cubicake e982cb4550 probably pointless but why not make this private 2026-09-06 19:53:55 +09:30
Cubicake 37514fa879 Remove unused and misleading method 2026-09-06 17:48:54 +09:30
Cubicake 6eee4351ab ImplementationRegistry 2026-09-06 17:02:23 +09:30
Cubicake 1f0cb15714 Disable block chunk parsers since they currently use more memory and cpu for no gain. 2026-09-06 16:53:44 +09:30
Cubicake 367976e51f StrokkCommands 2.3.0: Nicer benchmark command syntax 2026-09-02 21:52:38 +09:30
Cubicake c4c3c498c2 Bump StrokkCommands 2026-09-01 22:54:54 +09:30
Cubicake c29667aae0 Make copyright headers more readable 2026-08-31 19:19:46 +09:30
Cubicake 558e773085 Make copyright headers more readable 2026-08-31 19:11:50 +09:30
Cubicake 30b123ba3c Cache a player data array 2026-08-30 16:31:25 +09:30
Cubicake 87fd94baf4 Rename getInstance to get 2026-08-30 13:44:18 +09:30
Cubicake 1e5a4eb95b Merge remote-tracking branch 'origin/main' 2026-08-28 21:43:36 +09:30
Cubicake 981b375d6d This way even if you leave a trailing "." it resolves correctly (resolves #90) 2026-08-28 21:43:11 +09:30
Cubicake 6de11030b0 Bump version 2026-08-26 21:04:42 +09:30
Cubicake d445aa58ba Resolve #88 for blocks too 2026-08-25 20:08:32 +09:30
Cubicake 49311be791 Properly precompute hideOnSpawnDistanceSquared 2026-08-25 19:53:19 +09:30
Cubicake 0b4df5124b Do not send unrelated packets in a bundle (#88) 2026-08-25 19:52:45 +09:30
Cubicake 4435058373 Do not send unrelated packets in a bundle (#88) 2026-08-25 19:46:20 +09:30
Cubicake 4dfed55d48 Add clientVisible tracking 2026-08-23 14:56:47 +09:30
Cubicake c2b6941922 Add clientVisible tracking 2026-08-23 14:51:49 +09:30
Cubicake feb80bf678 Update submodules 2026-08-23 11:41:25 +09:30
Cubicake c4fd919a08 Update submodules 2026-08-22 12:18:26 +09:30
Cubicake 40f91482d4 Don't step into the final block 2026-08-22 12:13:49 +09:30
Cubicake 3f82330433 Match the other change 2026-08-21 19:24:16 +09:30
Cubicake 8cfe2b0a2e Mark barrier as non-occluding 2026-08-21 19:05:04 +09:30
Cubicake f2c1d01051 Don't count the block it first hits as solid 2026-08-21 17:59:50 +09:30
Cubicake e1d0db9d5f oops 2026-08-21 17:51:46 +09:30
Cubicake a86a9bc4c0 Merge remote-tracking branch 'origin/main' 2026-08-21 17:46:06 +09:30
Cubicake 377c12a00a Final cleanup 2026-08-21 17:45:45 +09:30
Cubicake 9bc14b2097 Slightly faster; less arithmetic 2026-08-21 17:37:41 +09:30
Cubicake 02f9df6643 Simplify and seal code 2026-08-21 17:29:00 +09:30
Cubicake e2af9f65c1 Remove unused param 2026-08-21 17:21:58 +09:30
Cubicake 0eb1766a4a Switch to faster method for everything 2026-08-21 17:21:29 +09:30
Cubicake 4a3f25045f Add AsyncEngine class to log
#86
2026-08-21 14:27:48 +09:30
Cubicake 0c80348416 Do not log every npc/hologram spawn
#86
2026-08-21 14:21:10 +09:30
Cubicake 4295d2fe8a Better benchmarking 2026-08-20 22:20:39 +09:30
Cubicake 3f8ccff505 It gets even faster somehow 2026-08-20 22:20:21 +09:30
Cubicake bc440490f9 Reduce division ops 2026-08-20 17:11:02 +09:30
Cubicake 5527e38ea4 Actually no-alloc now (faster too) 2026-08-17 23:00:27 +09:30
Cubicake 244fde97c0 Merge remote-tracking branch 'origin/main' 2026-08-16 20:49:37 +09:30
Cubicake 8b3a62f1f5 So so much easier to read, same perf (well 2ns slower in testing but probably run-to-run variance) 2026-08-16 20:48:09 +09:30
Cubicake 45d0e0581c Update README.md 2026-08-15 17:37:06 +09:30
Cubicake aa7934f258 Rewrite existing configs to set it to false 2026-08-13 17:26:56 +09:30
Cubicake cfdb255b56 Set sound-effect check to false by default 2026-08-13 16:54:42 +09:30
Cubicake 14e6aaaae6 Might as well keep this debugging code in case future issues occur (Added to diagnose RoseStacker issue) 2026-08-13 16:54:11 +09:30
Cubicake d7cc7abd8c Cover all run types 2026-08-13 16:51:28 +09:30
Cubicake 73e58e191e oops 2026-08-13 16:48:38 +09:30
Cubicake e5a591af1a Add worldless particle spawn 2026-08-11 17:27:31 +09:30
Cubicake 9951b5d7a1 Add licence header to every class 2026-08-10 16:57:09 +09:30
Cubicake e99c3b9de2 Change default only-check-sneaking to minimise noticeability of running this plugin 2026-08-09 21:18:27 +09:30
Cubicake 0500f4bd5f So it turns out that using the connection with initialised timeouts is the smart thing to do 2026-08-09 20:17:45 +09:30
Cubicake 9a841308ff Bump ver 2026-08-09 16:21:08 +09:30
Cubicake c4bf1cbf0b Citizens compat 2026-08-09 13:24:24 +09:30
Cubicake db22c675db Restore usual raycasting for now 2026-08-09 13:23:09 +09:30
Cubicake 5a42fd74ad optimise 2026-08-08 22:05:02 +09:30
Cubicake 85b788742c Update CONTRIBUTING.md 2026-08-07 19:03:29 +09:30
Cubicake 20f660b8a3 Splitting was inefficient 2026-08-06 10:20:51 +09:30
Cubicake 4d17483a5a Use floats 2026-08-06 09:32:12 +09:30
Cubicake 274b081c78 Add solid check 2026-08-05 22:34:10 +09:30
Cubicake 45e14637e0 Separate debug path 2026-08-05 22:17:22 +09:30
Cubicake b007735636 About 18% faster raycasting 2026-08-05 22:04:16 +09:30
Cubicake bb7275a618 Add chunk section stuff 2026-08-05 22:04:04 +09:30
Cubicake 853fa1531a Tests 2026-08-05 17:09:12 +09:30
Cubicake 396382bcc2 Add pose enum 2026-08-05 17:09:06 +09:30
Cubicake aae6bdb53c Add playerlocatable 2026-08-05 17:07:36 +09:30
Cubicake 2f8f698069 Merge remote-tracking branch 'origin/main' 2026-08-04 17:44:08 +09:30
Cubicake fc3badb90a Make PlayerRegistry final 2026-08-04 17:43:30 +09:30
Cubicake 7aab3b60e8 Consider not overwriting configs 2026-08-04 16:31:33 +09:30
Cubicake 2ab157bd4a Merge remote-tracking branch 'origin/main' 2026-08-02 22:19:06 +09:30
Cubicake 3227c63e2e Remove unused imports 2026-08-02 22:18:46 +09:30
Cubicake 1dc77b3e6f Prepend comment to top of file 2026-08-02 21:25:23 +09:30
Cubicake cb044f789d Add link to config doc 2026-08-02 19:28:13 +09:30
Cubicake c110aab634 Update usecases 2026-08-02 17:37:34 +09:30
Cubicake 5d407afbdf Add retrying 2026-08-02 15:40:20 +09:30
Cubicake a8f12c9a24 Change defaults 2026-08-02 15:01:57 +09:30
Cubicake 0e4c251c6c Fix typo 2026-08-02 14:55:05 +09:30
Cubicake e2b598a361 Don't flush 2026-08-02 14:50:19 +09:30
Cubicake 8c140cf8b6 Update leafpile 2026-08-02 14:40:30 +09:30
Cubicake 4fe9ab02ef Reduce allocations when sending block changes 2026-08-02 14:40:06 +09:30
Cubicake a21102d04f Use striped sets and place in utils 2026-08-02 14:18:39 +09:30
Cubicake 22488e9e71 Fix fancycompat logs 2026-08-02 14:18:17 +09:30
Cubicake bc40438cb3 Remove unused set 2026-08-02 13:50:23 +09:30
Cubicake 3f633710e7 Merge pull request #77 from Cubicake/v2/glowing-sneaking
Exempt all glowing entities and add a config to only check sneaking players
2026-08-01 23:02:58 +09:30
Cubicake 8de5d53198 idk 2026-08-01 23:02:40 +09:30
Cubicake 53650f9b63 Remove stupid test 2026-08-01 22:59:52 +09:30
Cubicake ba812bce3a Default to true to minimise intrusion on vanilla 2026-08-01 22:49:17 +09:30
Cubicake 42932abaa5 Prioritise skipping visible recheck -1, and tidy up 2026-08-01 22:22:02 +09:30
Cubicake 290749dde8 Exempt glowing entities and non-sneaking players when configured to exempt non-sneaking players 2026-08-01 22:22:01 +09:30
Cubicake e19808fb4b Remove stupid test 2026-08-01 22:22:01 +09:30
Cubicake 691d429652 Document visible-recheck-interval-ticks 2026-08-01 22:22:01 +09:30
Cubicake 1575091d12 Implement metadata packet scanning 2026-08-01 22:22:01 +09:30
Cubicake 4919383c73 Tests 2026-08-01 22:22:01 +09:30
Cubicake 5293db6c86 Add only-check-sneaking player config option 2026-08-01 22:22:01 +09:30
Cubicake c5f17a7b12 Add glowing and sneaking state storage 2026-08-01 22:22:01 +09:30
Cubicake ddafbd0c25 Old todo: no longer relevant 2026-08-01 22:22:01 +09:30
Cubicake 8d9a354154 Merge pull request #76 from Cubicake/v2/optimise
More optimisations
2026-08-01 22:21:14 +09:30
Cubicake 33ab1cd234 Add timeouts 2026-08-01 21:24:48 +09:30
168 changed files with 3652 additions and 1420 deletions

No files matched your search

+1 -3
View File
@@ -118,9 +118,7 @@ gradle-app.setting
**/build/
# Common working directory
run/
runs/
run-1-21-11/
run*/
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
+1 -1
View File
@@ -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).
+10 -2
View File
@@ -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 entities which would not be visible to vanilla players.
- 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
+4 -4
View File
@@ -1,9 +1,9 @@
/*
* 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.
* 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.
*/
import java.time.Instant
@@ -38,7 +38,7 @@ dependencies {
testImplementation("it.unimi.dsi:fastutil:8.5.18")
}
val coreVersion = "0.7.0-SNAPSHOT"
val coreVersion = "0.7.2-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,9 +1,9 @@
/*
* 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.
* 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;
@@ -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,8 +1,16 @@
/*
* 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;
import static games.cubi.raycastedantiesp.core.utils.VarHandler.LONG_ARRAY_HANDLE;
import static games.cubi.utils.VarHandler.LONG_ARRAY_HANDLE;
/**
* A 4096-bit bitset, where 1 indicates occluding and 0 indicates not occluding.
@@ -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;
@@ -5,8 +13,8 @@ import games.cubi.raycastedantiesp.core.chunks.BlockInfoResolver;
import games.cubi.raycastedantiesp.core.chunks.ChunkData;
import java.util.Arrays;
import static games.cubi.raycastedantiesp.core.utils.VarHandler.CHAR_ARRAY_HANDLE;
import static games.cubi.raycastedantiesp.core.utils.VarHandler.LONG_ARRAY_HANDLE;
import static games.cubi.utils.VarHandler.CHAR_ARRAY_HANDLE;
import static games.cubi.utils.VarHandler.LONG_ARRAY_HANDLE;
abstract class AbstractPalettedBlockChunkData implements BlockChunkData {
// Each concrete palette store allocates its maximum palette size up front. Adding a block only fills another slot in this array.
@@ -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.chunks.blocks;
import games.cubi.raycastedantiesp.core.chunks.BlockChunkData;
@@ -5,7 +13,7 @@ import games.cubi.raycastedantiesp.core.chunks.BlockInfoResolver;
import games.cubi.raycastedantiesp.core.chunks.ChunkData;
import java.util.function.IntUnaryOperator;
import static games.cubi.raycastedantiesp.core.utils.VarHandler.BYTE_ARRAY_HANDLE;
import static games.cubi.utils.VarHandler.BYTE_ARRAY_HANDLE;
public class ByteArrayBlockChunkData extends AbstractPalettedBlockChunkData {
private final byte[] blockData = new byte[ChunkData.BLOCK_COUNT];
@@ -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;
@@ -5,8 +13,8 @@ import games.cubi.raycastedantiesp.core.chunks.BlockInfoResolver;
import games.cubi.raycastedantiesp.core.chunks.ChunkData;
import java.util.Arrays;
import static games.cubi.raycastedantiesp.core.utils.VarHandler.CHAR_ARRAY_HANDLE;
import static games.cubi.raycastedantiesp.core.utils.VarHandler.LONG_ARRAY_HANDLE;
import static games.cubi.utils.VarHandler.CHAR_ARRAY_HANDLE;
import static games.cubi.utils.VarHandler.LONG_ARRAY_HANDLE;
public class CharArrayBlockChunkData implements BlockChunkData {
private final char[] blockData;
@@ -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;
@@ -5,7 +13,7 @@ import games.cubi.raycastedantiesp.core.chunks.BlockInfoResolver;
import games.cubi.raycastedantiesp.core.chunks.ChunkData;
import java.util.function.IntUnaryOperator;
import static games.cubi.raycastedantiesp.core.utils.VarHandler.BYTE_ARRAY_HANDLE;
import static games.cubi.utils.VarHandler.BYTE_ARRAY_HANDLE;
public class FourBlockChunkData extends AbstractPalettedBlockChunkData {
private static final int ENTRIES_PER_BYTE = 4;
@@ -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.chunks.blocks;
import games.cubi.raycastedantiesp.core.chunks.BlockChunkData;
@@ -5,7 +13,7 @@ import games.cubi.raycastedantiesp.core.chunks.BlockInfoResolver;
import games.cubi.raycastedantiesp.core.chunks.ChunkData;
import java.util.function.IntUnaryOperator;
import static games.cubi.raycastedantiesp.core.utils.VarHandler.BYTE_ARRAY_HANDLE;
import static games.cubi.utils.VarHandler.BYTE_ARRAY_HANDLE;
public class SixteenBlockChunkData extends AbstractPalettedBlockChunkData {
private static final int ENTRIES_PER_BYTE = 2;
@@ -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;
@@ -7,7 +15,7 @@ import java.util.Arrays;
import static games.cubi.raycastedantiesp.core.chunks.ChunkData.packLocalChecked;
import static games.cubi.raycastedantiesp.core.chunks.ChunkData.packUncheckedGuarded;
import static games.cubi.raycastedantiesp.core.utils.VarHandler.LONG_ARRAY_HANDLE;
import static games.cubi.utils.VarHandler.LONG_ARRAY_HANDLE;
//functionally a bitset
public class TwoBlockChunkData implements 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,9 +1,9 @@
/*
* 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.
* 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;
@@ -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 {
@@ -1,9 +1,9 @@
/*
* 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.
* 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;
@@ -15,22 +15,26 @@ import games.cubi.raycastedantiesp.core.config.raycast.EntityConfig;
import games.cubi.raycastedantiesp.core.config.raycast.PlayerConfig;
import games.cubi.raycastedantiesp.core.config.raycast.SoundEffectsConfig;
import games.cubi.raycastedantiesp.core.config.raycast.TileEntityConfig;
import games.cubi.raycastedantiesp.core.utils.VarHandler;
import games.cubi.utils.VarHandler;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.yaml.NodeStyle;
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
import java.lang.invoke.VarHandle;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.annotation.Documented;
import java.lang.invoke.VarHandle;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.function.Supplier;
public class ConfigManager {
@@ -306,6 +310,8 @@ public class ConfigManager {
Files.createFile(configPath);
}
}
ConfigMigrations.prependConfigDocumentationHeaderIfMissing(configPath);
ConfigMigrations.migrateSoundEffectsEnabled(configPath);
} catch (IOException e) {
throw new ConfigLoadException("Failed to create config.yml", e);
}
@@ -357,6 +363,108 @@ public class ConfigManager {
}
}
/**
* Temporary text-level config mutations. Remove this class when these migrations are no longer needed.
*/
private static final class ConfigMigrations {
private static final Pattern YAML_KEY = Pattern.compile("^([ \\t]*)([^:#\\s][^:]*):.*$");
private static final Pattern SOUND_EFFECTS_ENABLED_TRUE = Pattern.compile("^([ \\t]*enabled[ \\t]*:[ \\t]*)true([ \\t]*(?:#.*)?)$", Pattern.CASE_INSENSITIVE);
private ConfigMigrations() {
}
private static void prependConfigDocumentationHeaderIfMissing(Path configPath) {
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);
}
}
@Temporary(forRemovalIn = "0.8.0")
private static void migrateSoundEffectsEnabled(Path configPath) {
try {
String content = Files.readString(configPath, StandardCharsets.UTF_8);
String migrated = replaceSoundEffectsEnabled(content);
if (!content.equals(migrated)) {
Files.writeString(configPath, migrated, StandardCharsets.UTF_8);
}
} catch (IOException e) {
throw new ConfigLoadException("Failed to migrate sound-effects.enabled in config.yml", e);
}
}
private static String replaceSoundEffectsEnabled(String content) {
StringBuilder migrated = new StringBuilder(content.length());
int lineStart = 0;
int checksIndent = -1;
int soundEffectsIndent = -1;
boolean changed = false;
while (lineStart < content.length()) {
int lineEnd = content.indexOf('\n', lineStart);
boolean hasLineEnding = lineEnd >= 0;
int contentEnd = hasLineEnding ? lineEnd : content.length();
int lineContentEnd = contentEnd > lineStart && content.charAt(contentEnd - 1) == '\r'
? contentEnd - 1 : contentEnd;
String line = content.substring(lineStart, lineContentEnd);
String lineEnding = content.substring(lineContentEnd, contentEnd) + (hasLineEnding ? "\n" : "");
Matcher key = YAML_KEY.matcher(line);
if (key.matches()) {
int indent = key.group(1).length();
String name = key.group(2).trim();
if (checksIndent < 0) {
if (name.equals("checks")) {
checksIndent = indent;
}
} else if (indent <= checksIndent) {
checksIndent = name.equals("checks") ? indent : -1;
soundEffectsIndent = -1;
} else if (soundEffectsIndent < 0) {
if (name.equals("sound-effects")) {
soundEffectsIndent = indent;
}
} else if (indent <= soundEffectsIndent) {
soundEffectsIndent = name.equals("sound-effects") ? indent : -1;
}
}
if (soundEffectsIndent >= 0 && key.matches()
&& key.group(2).trim().equals("enabled")
&& key.group(1).length() > soundEffectsIndent) {
Matcher enabled = SOUND_EFFECTS_ENABLED_TRUE.matcher(line);
if (enabled.matches()) {
line = enabled.group(1) + "false" + enabled.group(2);
changed = true;
}
}
migrated.append(line).append(lineEnding);
if (!hasLineEnding) {
break;
}
lineStart = contentEnd + 1;
}
return changed ? migrated.toString() : content;
}
@Documented
private @interface Temporary {
String forRemovalIn();
}
}
private ConfigurationNode node(ConfigurationNode root, String path) {
String[] parts = path.split("\\.");
return ConfigReader.node(root, parts);
@@ -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;
@@ -1,9 +1,9 @@
/*
* 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.
* 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;
@@ -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")
);
}
@@ -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;
@@ -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;
@@ -1,9 +1,9 @@
/*
* 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.
* 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;
@@ -1,9 +1,9 @@
/*
* 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.
* 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;
@@ -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;
@@ -15,6 +23,10 @@ public class RaycastConfig implements Config {
private final short visibleRecheckIntervalTicks;
private final boolean keepClientEntityWhenHidden;
public final int alwaysShowRadiusSquared;
public final int raycastRadiusSquared;
public final int hideOnSpawnDistanceSquared;
public RaycastConfig(boolean enabled, boolean hideSoundsWhenHidden, int maxOccludingCount, int alwaysShowRadius,
int raycastRadius, int hideOnSpawnDistance, int visibleRecheckIntervalTicks) {
this(enabled, hideSoundsWhenHidden, maxOccludingCount, alwaysShowRadius, raycastRadius, hideOnSpawnDistance,
@@ -32,6 +44,10 @@ public class RaycastConfig implements Config {
this.hideOnSpawnDistance = (short) hideOnSpawnDistance;
this.visibleRecheckIntervalTicks = (short) visibleRecheckIntervalTicks;
this.keepClientEntityWhenHidden = keepClientEntityWhenHidden;
alwaysShowRadiusSquared = alwaysShowRadius * alwaysShowRadius;
raycastRadiusSquared = raycastRadius * raycastRadius;
hideOnSpawnDistanceSquared = hideOnSpawnDistance * hideOnSpawnDistance;
}
protected static RaycastConfig load(ConfigurationNode node, String path, boolean hasHideSoundsWhenHidden) {
@@ -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;
@@ -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;
@@ -1,14 +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.
* 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 games.cubi.locatables.api.ImmutableSpatial;
import games.cubi.locatables.api.Locatable;
import games.cubi.logs.Logger;
import games.cubi.raycastedantiesp.core.config.ConfigManager;
@@ -22,12 +21,11 @@ import games.cubi.raycastedantiesp.core.players.PlayerData;
import games.cubi.raycastedantiesp.core.players.PlayerRegistry;
import games.cubi.raycastedantiesp.core.raycast.ParticleSpawner;
import games.cubi.raycastedantiesp.core.raycast.RaycastUtil;
import games.cubi.raycastedantiesp.core.utils.PrimitiveIntArrayList;
import games.cubi.utils.lists.PrimitiveIntArrayList;
import games.cubi.raycastedantiesp.core.view.BlockView;
import games.cubi.raycastedantiesp.core.view.EntityView;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
@@ -104,7 +102,7 @@ public abstract class AsyncEngine implements Engine {
int latestTick = currentTickSupplier.getAsInt();
if (latestTick > startTick) {
// If running behind, don't yield the thread, just run the next tick immediately
Logger.warning("Tick thread completed tick #" + startTick + " after tick #" + latestTick + " had already begun. Starting next tick immediately instead of yielding thread to scheduler. This is probably safe to ignore but may suggest that your server is overloaded.", 5);
Logger.warning("Tick thread completed tick #" + startTick + " after tick #" + latestTick + " had already begun. Starting next tick immediately instead of yielding thread to scheduler. This is probably safe to ignore but may suggest that your server is overloaded.", 5, AsyncEngine.class);
startTick = latestTick;
scheduledNanos = System.nanoTime();
scheduledTick = latestTick;
@@ -172,13 +170,13 @@ public abstract class AsyncEngine implements Engine {
final int currentTick = startTick;
runningTick.set(currentTick);
claimedRunningTick = true;
Collection<PlayerData> allPlayers = PlayerRegistry.getInstance().getAllPlayerData();
PlayerData[] allPlayers = PlayerRegistry.get().getPlayerDataArray();
EntityConfig entityConfig = config.getEntityConfig();
PlayerConfig playerConfig = config.getPlayerConfig();
TileEntityConfig tileEntityConfig = config.getTileEntityConfig();
if (recordTimings) {
timings = new TickTimings(scheduledTick, scheduledNanos, currentTick, startNanos, threads, allPlayers.size());
timings = new TickTimings(scheduledTick, scheduledNanos, currentTick, startNanos, threads, allPlayers.length);
}
/*
Logger.debug("Tick #" + currentTick);
@@ -194,24 +192,30 @@ public abstract class AsyncEngine implements Engine {
// If only one thread is configured, just use the current async thread to avoid the overhead of scheduling tasks and context switching.
if (threads == 1) {
handedOffToSubTick = true;
subTick(new ArrayList<>(allPlayers), entityConfig, playerConfig, tileEntityConfig, debugConfig, currentTick, timings, tickTimingStats);
subTick(allPlayers, entityConfig, playerConfig, tileEntityConfig, debugConfig, currentTick, timings, tickTimingStats);
return true;
}
List<List<PlayerData>> batches = new ArrayList<>(threads);
List<PlayerData[]> batches = new ArrayList<>(threads);
int playerCount = allPlayers.length;
for (int i = 0; i < threads; i++) {
batches.add(new ArrayList<>());
int batchSize = (playerCount + threads - 1 - i) / threads;
batches.add(new PlayerData[batchSize]);
}
int index = 0;
for (PlayerData playerData : allPlayers) {
batches.get(index++ % threads).add(playerData);
int batchIndex = index % threads;
int position = index / threads;
batches.get(batchIndex)[position] = playerData;
index++;
}
TickTimings tickTimings = timings; // needs to be effectively-final for lambda
int scheduledBatches = 0;
try {
for (List<PlayerData> batch : batches) {
for (PlayerData[] batch : batches) {
asyncRunner.runNow(() -> subTick(batch, entityConfig, playerConfig, tileEntityConfig, debugConfig, currentTick, tickTimings, tickTimingStats));
scheduledBatches++;
}
@@ -244,7 +248,7 @@ public abstract class AsyncEngine implements Engine {
* @param timingStats the timing sink selected when this tick started, so config changes during
* worker execution do not split one tick across sinks.
*/
private void subTick(List<PlayerData> batch, EntityConfig entityConfig, PlayerConfig playerConfig, TileEntityConfig tileEntityConfig, DebugConfig debugConfig, int currentTick, TickTimings timings, TimingStats timingStats) {
private void subTick(PlayerData[] batch, EntityConfig entityConfig, PlayerConfig playerConfig, TileEntityConfig tileEntityConfig, DebugConfig debugConfig, int currentTick, TickTimings timings, TimingStats timingStats) {
TickTimingBatch batchTimings = timings == null ? TickTimingBatchNoOp.INSTANCE : new TickTimingBatch();
long batchStartNanos = batchTimings.startBatch();
try {
@@ -329,7 +333,7 @@ public abstract class AsyncEngine implements Engine {
}
}
private void processTickForPlayers(List<PlayerData> playerDataList, EntityConfig entityConfig, PlayerConfig playerConfig, TileEntityConfig tileEntityConfig,
private void processTickForPlayers(PlayerData[] playerDataList, EntityConfig entityConfig, PlayerConfig playerConfig, TileEntityConfig tileEntityConfig,
boolean debugParticles, int currentTick, TickTimingBatch timings) {
for (PlayerData playerData : playerDataList) {
@@ -384,13 +388,16 @@ 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;
}
timings.incrementEntityRaycasts();
boolean canSee = RaycastUtil.raycast(playerLocation, entity, entityConfig.getMaxOccludingCount(), entityConfig.getAlwaysShowRadius(), entityConfig.getRaycastRadius(), debugParticles, blockView, entity.getYOffset(), 1, particleSpawner);
boolean canSee = RaycastUtil.raycastUnrolledAccumulated(entityConfig.getMaxOccludingCount(), entityConfig.alwaysShowRadiusSquared, entityConfig.raycastRadiusSquared, debugParticles, entity.getYOffset(), blockView, playerLocation, entity, particleSpawner);
entityView.setVisibility(entity, canSee, currentTick, worldEpoch);
});
timings.addEntityChecked(checked);
@@ -400,12 +407,15 @@ 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;
}
timings.incrementPlayerRaycasts();
boolean canSee = RaycastUtil.raycast(playerLocation, otherPlayer, playerConfig.getMaxOccludingCount(), playerConfig.getAlwaysShowRadius(), playerConfig.getRaycastRadius(), debugParticles, blockView, 1.5f, 1, particleSpawner);
boolean canSee = RaycastUtil.raycastUnrolledAccumulated(playerConfig.getMaxOccludingCount(), playerConfig.alwaysShowRadiusSquared, playerConfig.raycastRadiusSquared, debugParticles, 1.5f, blockView, playerLocation, otherPlayer, particleSpawner);
playerView.setVisibility(otherPlayer, canSee, currentTick, worldEpoch);
});
timings.addPlayerChecked(checked);
@@ -416,7 +426,7 @@ public abstract class AsyncEngine implements Engine {
if (!player.nettyData().isSelfEntityID(entity.leashingEntity())
&& !player.nettyData().isSelfEntityID(entity.vehicleID())
&& !EntityBypassRegistry.isBypassed(entity.vehicleID())
&& !PrimitiveIntArrayList.contains(entity.passengerIDs(), selfEntityID)) {
&& !PrimitiveIntArrayList.contains(entity.passengerIDsNoAlloc(), selfEntityID)) {
return false;
}
view.setVisibility(entity, true, currentTick, worldEpoch);
@@ -432,7 +442,7 @@ public abstract class AsyncEngine implements Engine {
return BlockView.VisibilityResolver.HIDE;
}
timings.incrementTileRaycasts();
boolean canSee = RaycastUtil.raycast(playerLocation, tileEntityLocation, tileEntityConfig.getMaxOccludingCount() + 1, tileEntityConfig.getAlwaysShowRadius(), tileEntityConfig.getRaycastRadius(), debugParticles, blockView, 1, particleSpawner);
boolean canSee = RaycastUtil.raycastUnrolledAccumulated(tileEntityConfig.getMaxOccludingCount(), tileEntityConfig.alwaysShowRadiusSquared, tileEntityConfig.raycastRadiusSquared, debugParticles, 0, blockView, playerLocation, tileEntityLocation, particleSpawner);
return canSee ? BlockView.VisibilityResolver.SHOW : BlockView.VisibilityResolver.HIDE;
});
timings.addTileChecked(checked);
@@ -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,14 +1,14 @@
/*
* 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.
* 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.entity;
import games.cubi.raycastedantiesp.core.utils.CopyOnWriteMTIntSet;
import games.cubi.utils.sets.CopyOnWriteMTIntSet;
/**
* Global registry of entity IDs which RaycastedAntiESP must ignore.
@@ -1,17 +1,21 @@
/*
* 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.
* 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.logs.Logger;
import games.cubi.raycastedantiesp.core.tracked.EntitySpawnTask;
import games.cubi.raycastedantiesp.core.tracked.NettyEntity;
import games.cubi.raycastedantiesp.core.utils.*;
import games.cubi.raycastedantiesp.core.utils.Packet.Packets;
import games.cubi.utils.Clearable;
import games.cubi.utils.VarHandler;
import games.cubi.utils.lists.IntArrayListMarker;
import games.cubi.utils.lists.PrimitiveIntArrayList;
import it.unimi.dsi.fastutil.ints.Int2IntArrayMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
@@ -28,6 +32,9 @@ import static games.cubi.raycastedantiesp.core.tracked.NettyEntity.NO_VEHICLE;
* Per-player mutable state intended for Netty-side packet tracking and deferred reconciliation.
*/
public class NettyData implements Clearable {
//
public boolean packetsAreWithinBundle = false;
//
private static final int DEFAULT_MAP_SIZE = 16;
//
// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -66,6 +73,14 @@ public class NettyData implements Clearable {
return PrimitiveIntArrayList.getCopyOrNull(unresolvedLeashedEntityIDsByHolderID.get(holderEntityID));
}
/**
* Returns internal Netty-thread reconciliation state without copying it.
* Callers must not mutate the returned array.
*/
public int[] getUnresolvedLeashesNoAlloc(int holderEntityID) {
return unresolvedLeashedEntityIDsByHolderID.get(holderEntityID);
}
public int[] consumeUnresolvedLeashes(int holderEntityID) {
int[] existing = unresolvedLeashedEntityIDsByHolderID.remove(holderEntityID);
if (PrimitiveIntArrayList.isEmpty(existing)) {
@@ -126,6 +141,14 @@ public class NettyData implements Clearable {
return PrimitiveIntArrayList.getCopyOrNull(unresolvedPassengerIDsByVehicleID.get(vehicleEntityID));
}
/**
* Returns internal Netty-thread reconciliation state without copying it.
* Callers must not mutate the returned array.
*/
public int[] getUnresolvedPassengersNoAlloc(int vehicleEntityID) {
return unresolvedPassengerIDsByVehicleID.get(vehicleEntityID);
}
/**
* Replaces any previous unresolved passenger state for this vehicle.
* The passenger packet is authoritative, so the latest packet wins.
@@ -1,9 +1,9 @@
/*
* 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.
* 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;
@@ -12,7 +12,7 @@ import games.cubi.locatables.api.Locatable;
import games.cubi.locatables.implementations.ThreadSafeLocatable;
import games.cubi.logs.Logger;
import games.cubi.raycastedantiesp.core.tracked.NettyEntity;
import games.cubi.raycastedantiesp.core.utils.VarHandler;
import games.cubi.utils.VarHandler;
import games.cubi.raycastedantiesp.core.view.BlockView;
import games.cubi.raycastedantiesp.core.view.EntityView;
import games.cubi.raycastedantiesp.core.view.ViewRegistry;
@@ -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.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,45 +1,58 @@
/*
* 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;
import games.cubi.utils.VarHandler;
import java.lang.invoke.VarHandle;
import java.util.Collection;
import java.util.Collections;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
public class PlayerRegistry {
public final class PlayerRegistry {
@FunctionalInterface
public interface SelfEntityCreator {
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();
}
public static PlayerRegistry get() {
return instance;
}
private final ConcurrentHashMap<UUID, PlayerData> playerDataMap = new ConcurrentHashMap<>();
private final Collection<PlayerData> unmodifiablePlayerData = Collections.unmodifiableCollection(playerDataMap.values());
private volatile PlayerData[] playerDataArray = new PlayerData[0]; private static final VarHandle PLAYER_DATA_ARRAY = VarHandler.get(PlayerRegistry.class, "playerDataArray", PlayerData[].class);
/** Forcefully registers a player and returns the new PlayerData, even if they were already registered.**/
public PlayerData registerAndGetPlayer(UUID playerUUID, int joinTick, int selfEntityID, SelfEntityCreator selfEntityCreator) {
public synchronized PlayerData registerAndGetPlayer(UUID playerUUID, int joinTick, int selfEntityID, SelfEntityCreator selfEntityCreator) {
PlayerData newData = new PlayerData(playerUUID, false, joinTick, selfEntityID, selfEntityCreator);
PlayerData old = playerDataMap.put(playerUUID, newData);
if (old != null) old.markDisconnected();
updatePlayerDataArray();
return newData;
}
public void unregisterPlayer(UUID playerUUID) {
public synchronized void unregisterPlayer(UUID playerUUID) {
PlayerData unregisteredPlayer = playerDataMap.remove(playerUUID);
if (unregisteredPlayer == null) {
return;
}
unregisteredPlayer.markDisconnected();
updatePlayerDataArray();
}
public PlayerData getPlayerData(UUID playerUUID) {
@@ -51,9 +64,34 @@ public class PlayerRegistry {
}
/**
* @return Live, mutable collection of all PlayerData instances.
* @return Live, unmodifiable view of all PlayerData instances.
* **/
public Collection<PlayerData> getAllPlayerData() {
return playerDataMap.values();
return unmodifiablePlayerData;
}
private void updatePlayerDataArray() {
PLAYER_DATA_ARRAY.setRelease(this, playerDataMap.values().toArray(PlayerData[]::new));
}
/**
* Do not mutate this array, all changes must go through {@link #registerAndGetPlayer(UUID, int, int, SelfEntityCreator)} /
* {@link #unregisterPlayer(UUID)}.
* <p></p>
* Changes to this array will be lost on next player join/leave, and will not apply everywhere.
*/
public PlayerData[] getPlayerDataArray() {
return (PlayerData[]) PLAYER_DATA_ARRAY.getAcquire(this);
}
public void forEachPlayer(Consumer<PlayerData> consumer) {
PlayerData[] data = getPlayerDataArray();
for (PlayerData player : data) {
consumer.accept(player);
}
}
public int getPlayerCount() {
return playerDataMap.size();
}
}
@@ -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;
@@ -14,4 +22,6 @@ public interface ParticleSpawner {
void spawnParticleAt(Locatable locatable, Colour colour);
void spawnParticleAt(UUID world, Spatial spatial, Colour colour);
void spawnParticleAt(UUID world, double x, double y, double z, Colour colour);
}
@@ -1,50 +1,202 @@
/*
* 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.implementations.MutableSpatialImpl;
import games.cubi.logs.Logger;
import games.cubi.locatables.api.BlockSpatial;
import games.cubi.raycastedantiesp.core.chunks.ChunkOcclusionView;
import games.cubi.raycastedantiesp.core.view.BlockView;
import java.util.UUID;
public class RaycastUtil {
//True: Has line-of-sight
//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) {
return raycast(start, end, maxOccluding, alwaysShowRadius, maxRaycastRadius, debug, snap, 0f, stepSize, particleSpawner);
/**
* Mutable position and chunk-section state is flattened into the advancer so C2 only
* needs to scalarise one state holder while retaining a readable ray-stepping method.
*/
public static boolean raycastUnrolledAccumulated(int maxOccluding, final int alwaysShowRadiusSquared, final int maxRaycastRadiusSquared, boolean debug,
float yOffsetEnd, final BlockView snap, final Locatable start, final Spatial end, ParticleSpawner spawner) {
double startX = start.x();
double startY = start.y();
double startZ = start.z();
double endOffset = end instanceof BlockSpatial ? 0.5 : 0.0;
RayDirection direction = RayDirection.from(end.x() + endOffset, end.y() + endOffset + yOffsetEnd, end.z() + endOffset, startX, startY, startZ);
double lengthSquared = direction.getLengthSquared();
if (lengthSquared <= alwaysShowRadiusSquared) return true;
if (lengthSquared > maxRaycastRadiusSquared) return false;
double total = direction.normaliseAndGetLength(lengthSquared);
float finalDist = (float) (total - 1);
final RayAdvancer rayAdvancer = debug ? new DebugRayAdvancer(startX, startY, startZ, direction, snap, start.world(), spawner) : new RayAdvancer(startX, startY, startZ, direction, snap);
int remainingSteps = (int) Math.floor(finalDist);
while (remainingSteps >= 4) {
rayAdvancer.advance();
rayAdvancer.advance();
rayAdvancer.advance();
rayAdvancer.advance();
if (rayAdvancer.occluded > maxOccluding) return false;
remainingSteps -= 4;
}
while (remainingSteps-- > 0) rayAdvancer.advance();
return rayAdvancer.occluded <= maxOccluding;
}
public static boolean raycast(Locatable start, Spatial end, int maxOccluding, int alwaysShowRadius, int maxRaycastRadius, boolean debug, BlockView snap, float yOffsetEnd, int 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
if (total <= alwaysShowRadius) return true;
if (total > maxRaycastRadius) return false;
if (debug && particleSpawner == null) {
Logger.errorAndReturn(new RuntimeException("raycast called with debug enabled but no ParticleSpawner supplied"), 2, RaycastUtil.class);
/**
* A very fast, low-accuracy raycast
*/
public static int fastRaycastDirection(int maxOccluding, final BlockView snap, final Spatial start,
final double dirX, final double dirY, final double dirZ, final int maxSteps) {
double startX = start.x();
double startY = start.y();
double startZ = start.z();
final RayAdvancer rayAdvancer = new RayAdvancer(startX, startY, startZ, RayDirection.ofDirection(dirX, dirY, dirZ), snap);
int remainingSteps = maxSteps;
while (remainingSteps >= 4) {
rayAdvancer.advance();
rayAdvancer.advance();
rayAdvancer.advance();
rayAdvancer.advance();
remainingSteps -= 4;
if (rayAdvancer.occluded > maxOccluding) return (maxSteps - remainingSteps);
}
return maxSteps;
}
private static sealed class RayAdvancer extends RayPosition permits DebugRayAdvancer {
private final RayDirection direction;
private final BlockView blockView;
private int chunkX, chunkY, chunkZ;
private ChunkOcclusionView currentOcclusionView;
private int occluded = 0;
private RayAdvancer(double startX, double startY, double startZ, RayDirection direction, BlockView blockView) {
super(startX, startY, startZ);
this.direction = direction;
chunkX = blockX() >> 4;
chunkY = blockY() >> 4;
chunkZ = blockZ() >> 4;
currentOcclusionView = blockView.getChunkOcclusionView(chunkX, chunkY, chunkZ);
this.blockView = blockView;
}
Spatial dir = clonedEnd.subtract(start).normalise().scalarMultiply(stepSize);
MutableFloatingSpatial current = new MutableSpatialImpl(start.x(),start.y(),start.z());
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
current.add(dir);
if (snap.isBlockOccluding(current.blockX(), current.blockY(), current.blockZ())) {
maxOccluding--;
if (debug) particleSpawner.spawnParticleAt(start.world(), current, ParticleSpawner.Colour.RED);
if (maxOccluding < 1) return false;
continue;
private void advance() {
add(direction);
int blockX = blockX();
int blockY = blockY();
int blockZ = blockZ();
if (!isCurrentChunk(blockX, blockY, blockZ)) {
moveToChunk(blockX, blockY, blockZ);
currentOcclusionView = blockView.getChunkOcclusionView(chunkX, chunkY, chunkZ);
}
if (debug) particleSpawner.spawnParticleAt(start.world(), current, ParticleSpawner.Colour.GREEN);
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) {
occluded++;
particleRed();
} else particleGreen();
}
private boolean isCurrentChunk(int blockX, int blockY, int blockZ) {
return blockX >> 4 == chunkX && blockY >> 4 == chunkY && blockZ >> 4 == chunkZ;
// ((nextChunkX ^ chunkX) | (nextChunkY ^ chunkY) | (nextChunkZ ^ chunkZ)) != 0 is slower than this
}
private void moveToChunk(int blockX, int blockY, int blockZ) {
chunkX = blockX >> 4;
chunkY = blockY >> 4;
chunkZ = blockZ >> 4;
}
void particleGreen() {}
void particleRed() {}
}
private static final class DebugRayAdvancer extends RayAdvancer {
private final UUID world;
private final ParticleSpawner particleSpawner;
private DebugRayAdvancer(double startX, double startY, double startZ, RayDirection direction, BlockView blockView, UUID world, ParticleSpawner particleSpawner) {
super(startX, startY, startZ, direction, blockView);
this.world = world;
this.particleSpawner = particleSpawner;
}
void particleGreen() {
particleSpawner.spawnParticleAt(world, x, y, z, ParticleSpawner.Colour.GREEN);
}
void particleRed() {
particleSpawner.spawnParticleAt(world, x, y, z, ParticleSpawner.Colour.RED);
}
}
private static sealed class RayPosition permits RayAdvancer {
double x, y, z;
private RayPosition(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
final void add(RayDirection direction) {
x += direction.x;
y += direction.y;
z += direction.z;
}
final int blockX() {
return (int) Math.floor(x);
}
final int blockY() {
return (int) Math.floor(y);
}
final int blockZ() {
return (int) Math.floor(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(double endX, double endY, double endZ, double startX, double startY, double startZ) {
return new RayDirection(endX - startX, endY - startY, endZ - startZ);
}
private static RayDirection ofDirection(double x, double y, double z) {
return new RayDirection(x, y, z);
}
private double getLengthSquared() {
return x * x + y * y + z * z;
}
private double normaliseAndGetLength(double lengthSquared) {
double len = Math.sqrt(lengthSquared);
double scale = 1 / len;
x *= scale;
y *= scale;
z *= scale;
return len;
}
return true;
}
}
@@ -1,4 +1,12 @@
package games.cubi.raycastedantiesp.core.utils;
/*
* 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.logs.Logger;
import org.jetbrains.annotations.Nullable;
@@ -1,4 +1,12 @@
package games.cubi.raycastedantiesp.core.utils;
/*
* 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.logs.Logger;
import org.jetbrains.annotations.Nullable;
@@ -1,21 +1,19 @@
/*
* 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.
* 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 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;
import games.cubi.raycastedantiesp.core.utils.IntArrayListMarker;
import games.cubi.raycastedantiesp.core.utils.VarHandler;
import games.cubi.utils.Clearable;
import games.cubi.utils.lists.PrimitiveIntArrayList;
import games.cubi.utils.lists.IntArrayListMarker;
import games.cubi.utils.VarHandler;
import org.jetbrains.annotations.Nullable;
import java.lang.invoke.VarHandle;
@@ -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);
@@ -241,12 +276,27 @@ public abstract class NettyEntity<PacketReplayData extends Clearable> implements
return this;
}
/**
* @return a clone of the passenger ID array, which may be null
*/
@Override
public int[] passengerIDs() {
int[] current = passengerIDsAcquire();
return current == null ? null : current.clone();
}
/**
* Do not mutate this.
* <p></p>
* This method is not considered public api.
* <p>
* Returned array may be null
* </p>
*/
public int[] passengerIDsNoAlloc() {
return passengerIDsAcquire();
}
@Override
public TrackedEntity<?> setPassengerIDs(int[] passengerIDs) {
PASSENGER_IDS.setRelease(this, passengerIDs == null ? new int[0] : passengerIDs.clone());
@@ -280,6 +330,17 @@ public abstract class NettyEntity<PacketReplayData extends Clearable> implements
return PrimitiveIntArrayList.getCopyOrNull(leashedIDs);
}
/**
* Returns internal Netty-thread leash state without copying it.
* Callers must not mutate the returned array.
* <p>
* This is not considered public API.
* </p>
*/
public int@Nullable[] leashedEntityIDsOrNullNoAlloc() {
return leashedIDs;
}
@Override
public int leashingEntity() {
return (int) LEASHER_ID.getOpaque(this);
@@ -381,6 +442,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;
@@ -404,9 +466,9 @@ public abstract class NettyEntity<PacketReplayData extends Clearable> implements
", velocityY=" + velocityY() +
", velocityZ=" + velocityZ() +
", onGround=" + onGround() +
", leashedIDs=" + nullableArrayToString(leashedIDs) +
", leashedIDs=" + PrimitiveIntArrayList.toString(leashedIDs) +
", leasherID=" + leashingEntity() +
", passengerIDs=" + nullableArrayToString(passengerIDsAcquire()) +
", passengerIDs=" + PrimitiveIntArrayList.toString(passengerIDsAcquire()) +
", vehicleID=" + vehicleID() +
", entityData=" + entityData() +
'}';
@@ -415,9 +477,4 @@ public abstract class NettyEntity<PacketReplayData extends Clearable> implements
private int[] passengerIDsAcquire() {
return (int[]) PASSENGER_IDS.getAcquire(this);
}
private static String nullableArrayToString(int[] values) {
return values == null ? null : PrimitiveIntArrayList.toString(values);
}
}
@@ -1,15 +1,24 @@
/*
* 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;
import games.cubi.raycastedantiesp.core.utils.Clearable;
import games.cubi.raycastedantiesp.core.utils.InvasivelyLinkedSWMRList;
import games.cubi.raycastedantiesp.core.utils.VarHandler;
import games.cubi.utils.Clearable;
import games.cubi.utils.lists.InvasivelyLinkedSWMRList;
import games.cubi.utils.VarHandler;
import java.lang.invoke.VarHandle;
/** Tile visibility and lifecycle are shared with the engine; block and replay data are packet-thread-only. */
/** Tile desired visibility and lifecycle are shared with the engine; client, block, and replay data are packet-thread-only. */
public abstract class NettyTileEntity<PacketReplayData extends Clearable> extends InvasivelyLinkedSWMRList<NettyTileEntity<PacketReplayData>> implements TrackedTileEntity<PacketReplayData> {
private volatile boolean visible;
private boolean clientVisible;
private volatile int lastChecked; private static final VarHandle LAST_CHECKED = VarHandler.get(NettyTileEntity.class, "lastChecked", int.class);
private char blockID;
private PacketReplayData extraData;
@@ -24,6 +33,7 @@ public abstract class NettyTileEntity<PacketReplayData extends Clearable> extend
this.blockID = blockID;
this.visible = visible;
this.clientVisible = visible;
LAST_CHECKED.set(this, lastChecked);
}
@@ -32,6 +42,7 @@ public abstract class NettyTileEntity<PacketReplayData extends Clearable> extend
this.y = y;
this.z = z;
this.visible = visible;
this.clientVisible = visible;
this.blockID = blockID;
LAST_CHECKED.set(this, NEVER_CHECKED);
}
@@ -47,6 +58,17 @@ public abstract class NettyTileEntity<PacketReplayData extends Clearable> extend
return this;
}
@Override
public boolean clientVisible() {
return clientVisible;
}
@Override
public TrackedTileEntity<PacketReplayData> setClientVisible(boolean clientVisible) {
this.clientVisible = clientVisible;
return this;
}
@Override
public int lastChecked() {
return (int) LAST_CHECKED.getAcquire(this);
@@ -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,7 +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.tracked;
import games.cubi.locatables.api.ImmutableBlockSpatial;
import games.cubi.raycastedantiesp.core.utils.Clearable;
import games.cubi.utils.Clearable;
public interface TrackedTileEntity<T> extends ImmutableBlockSpatial, Clearable {
int NEVER_CHECKED = Integer.MIN_VALUE;
@@ -9,6 +17,10 @@ public interface TrackedTileEntity<T> extends ImmutableBlockSpatial, Clearable {
boolean visible();
TrackedTileEntity<T> setVisible(boolean visible);
/** Packet-thread-only client state. */
boolean clientVisible();
TrackedTileEntity<T> setClientVisible(boolean clientVisible);
int lastChecked();
TrackedTileEntity<T> setLastChecked(int lastChecked);
@@ -1,9 +1,9 @@
/*
* 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.
* 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,40 +0,0 @@
package games.cubi.raycastedantiesp.core.utils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;
/**
* A Set-like data structure that stores canonical instances of key values.
* Any compatible key type with {@code equals} and {@code hashcode} implemented identically to the value type may be used for lookup,
* but only canonical values of type {@code V} may be stored.
*
* @param <K> key type used for lookup
* @param <V> stored canonical value type
*/
public interface CanonicalSet<K, V extends K> {
int size();
boolean isEmpty();
boolean contains(K keyValue);
@Nullable V get(K keyValue);
@Nullable V add(V keyValue);
void addAll(Set<? extends V> keyValues);
@Nullable V computeIfAbsent(K keyValue, @NotNull Function<? super K, ? extends V> mappingFunction);
@Nullable V remove(K keyValue);
void clear();
@NotNull Set<V> keySet();
@NotNull Collection<V> values();
}
@@ -1,8 +0,0 @@
package games.cubi.raycastedantiesp.core.utils;
public interface Clearable {
/**
* Dereferences all internal references to other objects, allowing them to be garbage collected. In theory this isn't needed but idk what's causing the memory leak so we're covering all bases.
*/
void clear();
}
@@ -1,92 +0,0 @@
package games.cubi.raycastedantiesp.core.utils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
public class ConcurrentSelfMap<K, V extends K> implements CanonicalSet<K, V> {
private final ConcurrentHashMap<V, V> backingMap = new ConcurrentHashMap<>();
public ConcurrentSelfMap() {}
@Override
public int size() {
return backingMap.size();
}
@Override
public boolean isEmpty() {
return backingMap.isEmpty();
}
@Override
public boolean contains(K keyValue) {
return backingMap.containsKey(keyValue);
}
@Override
public @Nullable V get(K keyValue) {
return backingMap.get(keyValue);
}
@Override
public @Nullable V add(V keyValue) {
return backingMap.put(keyValue, keyValue);
}
@Override
public void addAll(Set<? extends V> keyValues) {
for (V keyValue : keyValues) {
backingMap.put(keyValue, keyValue);
}
}
@Override
public @Nullable V computeIfAbsent(
K keyValue,
@NotNull Function<? super K, ? extends V> mappingFunction
) {
V existing = backingMap.get(keyValue);
if (existing != null) {
return existing;
}
V canonicalValue = mappingFunction.apply(keyValue);
if (canonicalValue == null) {
return null;
}
if (!canonicalValue.equals(keyValue)) {
throw new IllegalArgumentException(
"Computed canonical value must be equal to the key value."
);
}
V racedValue = backingMap.putIfAbsent(canonicalValue, canonicalValue);
return racedValue != null ? racedValue : canonicalValue;
}
@Override
public @Nullable V remove(K keyValue) {
return backingMap.remove(keyValue);
}
@Override
public void clear() {
backingMap.clear();
}
@Override
public @NotNull Set<V> keySet() {
return backingMap.keySet();
}
@Override
public @NotNull Collection<V> values() {
return backingMap.values();
}
}
@@ -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,11 +0,0 @@
package games.cubi.raycastedantiesp.core.utils;
import java.lang.annotation.*; /**
* {@code int[]} fields annotated with this are backing arrays for {@code IntArrayLists}. {@code IntArrayLists} are not objects directly, instead just an {@code int[]} array, with static operations provided by {@link PrimitiveIntArrayList}.
* <p>
* This is used to avoid the overhead of an actual object for each {@link PrimitiveIntArrayList}. To further reduce overhead, the field may not be initialised, {@link PrimitiveIntArrayList} is null safe.
*
* <p> Do not use this array directly, all calls should go through {@link PrimitiveIntArrayList}.
*/
@Documented @Retention(RetentionPolicy.SOURCE) @Target({ElementType.TYPE_USE, ElementType.FIELD, ElementType.PARAMETER})
public @interface IntArrayListMarker {}
@@ -1,285 +0,0 @@
package games.cubi.raycastedantiesp.core.utils;
import org.jetbrains.annotations.NotNull;
import java.lang.invoke.VarHandle;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Objects;
/**
* An intrusive doubly linked node designed for a single-writer,
* multiple-reader access pattern.
*
* <h2>Concurrency model</h2>
* <ul>
* <li>Exactly one writer may modify a list.</li>
* <li>Readers may traverse forward concurrently.</li>
* <li>Readers must not inspect {@code previousWriterOnly()}.</li>
* <li>The writer must not reuse a removed node until all readers that
* could still hold that node have quiesced.</li>
* </ul>
*
* <p>Forward links are published with release semantics and read with
* acquire semantics. The backward link is plain because only the writer
* may access it.</p>
*
* <p>A common layout uses a permanent sentinel node. Data nodes are placed
* after the sentinel, and the sentinel itself is never unlinked.</p>
*
* @param <T> the concrete node type
*/
public abstract class InvasivelyLinkedSWMRList<T extends InvasivelyLinkedSWMRList<T>> implements Iterable<T> {
private T next; private static final VarHandle NEXT = VarHandler.get(InvasivelyLinkedSWMRList.class, "next", InvasivelyLinkedSWMRList.class);
private T previous;
/**
* Returns this object with its concrete node type.
*
* <p>An implementation must return {@code this}:</p>
*
* <pre>{@code
* @Override
* protected MyNode self() {
* return this;
* }
* }</pre>
*/
@SuppressWarnings("unchecked")
protected final T self() {
return (T) this;
}
/**
* Provides access to private fields {@code next} and {@code previous}. They are only accessible from within this class, not subclasses.
*/
private static <N extends InvasivelyLinkedSWMRList<N>> InvasivelyLinkedSWMRList<N> linksOf(N node) {
return node;
}
/**
* Returns the next node using acquire semantics.
*
* <p>This is the forward-link operation intended for concurrent
* readers.</p>
*/
@SuppressWarnings("unchecked")
public final T nextAcquire() {
return (T) NEXT.getAcquire(this);
}
/**
* Returns the next node without memory ordering.
*
* <p>Only the single writer may call this method.</p>
*/
private T nextWriterOnly() {
return next;
}
private void setNextRelease(T value) {
NEXT.setRelease(this, value);
}
/**
* Returns the preceding node.
*
* <p>Only the single writer may call this method. Concurrent readers
* must not use the backward link.</p>
*/
public final T previousWriterOnly() {
return previous;
}
/**
* Reports whether this node has a predecessor.
*
* <p>Only the single writer may call this method. A permanent sentinel
* normally has no predecessor and therefore returns {@code false}.</p>
*/
public final boolean isLinkedWriterOnly() {
return previous != null;
}
/**
* Reports whether both intrusive links are clear.
*
* <p>This does not prove that no reader still holds the node. Node
* lifetime and reader quiescence must be managed separately.</p>
*/
public final boolean isDetachedWriterOnly() {
return previous == null && nextWriterOnly() == null;
}
/**
* Inserts {@code node} directly after this node.
*
* <p>Only the single writer may call this method.</p>
*
* <p>The inserted node must:</p>
* <ul>
* <li>not be this node;</li>
* <li>have both intrusive links clear;</li>
* <li>not be visible to any reader;</li>
* <li>not belong to another list.</li>
* </ul>
*
* <p>The release store to this node's forward link is the insertion
* linearisation point. A reader that observes the inserted node through
* {@link #nextAcquire()} also observes writes made to the node before
* insertion.</p>
*
* @param node detached node to insert
* @throws NullPointerException if {@code node} is null
* @throws IllegalArgumentException if asked to insert this node
* @throws IllegalStateException if {@code node} appears linked
*/
public final void linkAfter(T node) {
Objects.requireNonNull(node, "node");
T self = self();
if (node == self) {
throw new IllegalArgumentException("A node cannot be linked after itself");
}
InvasivelyLinkedSWMRList<T> nodeLinks = linksOf(node);
if (nodeLinks.previous != null || nodeLinks.nextWriterOnly() != null) {
throw new IllegalStateException("The node is already linked or is not detached");
}
T oldNext = nextWriterOnly();
if (node == oldNext) {
throw new IllegalStateException("The node is already the current successor");
}
/*
* Fully initialise the inserted node before publishing it.
*/
nodeLinks.previous = self;
nodeLinks.next = oldNext;
if (oldNext != null) {
InvasivelyLinkedSWMRList<T> oldNextLinks = linksOf(oldNext);
oldNextLinks.previous = node;
}
/*
* Publication and insertion linearisation point.
*/
setNextRelease(node);
}
/**
* Removes this node from its current list.
*
* <p>Only the single writer may call this method.</p>
*
* <p>The node must have a predecessor. This rule prevents accidental
* removal of a permanent sentinel and avoids the need to update an
* external head reference.</p>
*
* <p>A concurrent reader may still:</p>
* <ul>
* <li>return this node after it has been removed;</li>
* <li>continue from this node to its former successor;</li>
* <li>observe the cleared forward link and stop early.</li>
* </ul>
*
* <p>The removed node must not be modified, reused, or inserted again
* until every reader that could hold it has quiesced.</p>
*
* @return the node that followed this node, or {@code null}
* @throws IllegalStateException if this node has no predecessor
*/
public final T unlink() {
T oldPrevious = previous;
if (oldPrevious == null) {
throw new IllegalStateException(
"Cannot unlink a detached node or sentinel node"
);
}
T oldNext = nextWriterOnly();
/*
* Update the writer-only backward link first. The following release
* store also publishes this change, though readers must not depend
* on it.
*/
if (oldNext != null) {
InvasivelyLinkedSWMRList<T> oldNextLinks = linksOf(oldNext);
oldNextLinks.previous = oldPrevious;
}
/*
* Bypass this node. This is the removal linearisation point.
*/
InvasivelyLinkedSWMRList<T> previousLinks = linksOf(oldPrevious);
previousLinks.setNextRelease(oldNext);
/*
* Clear this node after it has been bypassed. Release semantics are
* stronger than strictly required here, but they keep the ordering
* rules simple and explicit.
*/
previous = null;
setNextRelease(null);
return oldNext;
}
/**
* Detaches a list head after its owner has published a replacement head.
*
* <p>Only the single writer may call this method. Concurrent readers that already hold the old head may either
* continue to the former successor or stop at the cleared link, matching the weakly-consistent iterator contract.</p>
*/
public final T detachHeadWriterOnly() {
if (previous != null) {
throw new IllegalStateException("Only a list head may be detached with this method");
}
T oldNext = nextWriterOnly();
if (oldNext != null) {
linksOf(oldNext).previous = null;
}
setNextRelease(null);
return oldNext;
}
/**
* Returns a weakly consistent forward iterator beginning with this node.
*
* <p>The iterator does not create a snapshot. During concurrent writes
* it may miss inserted nodes, return removed nodes, or stop early after
* reaching a removed node. It does not throw
* {@link java.util.ConcurrentModificationException}.</p>
*/
@Override
public final @NotNull Iterator<T> iterator() {
return new Iterator<>() {
private T next = self();
@Override
public boolean hasNext() {
return next != null;
}
@Override
public T next() {
T result = next;
if (result == null) {
throw new NoSuchElementException();
}
next = result.nextAcquire();
return result;
}
};
}
}
@@ -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,103 +0,0 @@
package games.cubi.raycastedantiesp.core.utils;
import games.cubi.logs.Logger;
/**
* Static utility class for operations on int arrays annotated with {@link IntArrayListMarker}, which are intended to be used as lists of integers without the overhead of autoboxing.
* <p>
* {@link IntArrayListMarker} fields may be null or non-initialised to save memory, {@code IntArrayList} methods will treat null or non-initialised arrays as empty lists.
* <p>
* Arrays expand and contract as needed such that the length of the backing array is always equal to the number of elements in the list, so there is no extra capacity. This means that adding or removing elements from the list will involve creating a new array and copying the existing elements, which can be inefficient for large lists. However, this design choice was made to save memory and avoid the overhead of maintaining a separate size field and capacity management logic.
*/
public class PrimitiveIntArrayList {
private PrimitiveIntArrayList() {}
public static int size(int@IntArrayListMarker[] array) {
return array == null ? 0 : array.length;
}
public static boolean isEmpty(int@IntArrayListMarker[] array) {
return array == null || array.length == 0;
}
public static boolean contains(int@IntArrayListMarker[] array, int value) {
if (array == null) return false;
for (int i : array) {
if (i == value) return true;
}
return false;
}
/**
* Caller of this method <b>must</b> reassign the returned array to the original array reference, as the original array will not be modified and a new array with the added element will be returned.
*/
public static int@IntArrayListMarker[] add(int@IntArrayListMarker[] array, int value) {
if (array == null) {
return new int[]{value};
} else {
int[] newArray = new int[array.length + 1];
System.arraycopy(array, 0, newArray, 0, array.length);
newArray[array.length] = value;
return newArray;
}
}
/**
* Caller of this method <b>must</b> reassign the returned array to the original array reference, as the original array will not be modified and a new array with the added element will be returned.
*/
public static int@IntArrayListMarker[] remove(int@IntArrayListMarker[] array, int value) {
if (array == null) return null;
int index = -1;
for (int i = 0; i < array.length; i++) {
if (array[i] == value) {
index = i;
break;
}
}
if (index == -1) return array; // value not found, return original array
int[] newArray = new int[array.length - 1];
System.arraycopy(array, 0, newArray, 0, index);
System.arraycopy(array, index + 1, newArray, index, array.length - index - 1);
return newArray;
}
/**
* Caller of this method <b>must</b> reassign the returned array to the original array reference, as the original array will not be modified and a new array with the added element will be returned.
*/
public static int@IntArrayListMarker[] clear(int@IntArrayListMarker[] array) {
return null;
}
public static int get(int@IntArrayListMarker[] array, int index) {
if (array == null) Logger.errorAndReturn(new IndexOutOfBoundsException("Attempted to find value at index: " + index + ", for IntArrayList with size: 0"), 3, PrimitiveIntArrayList.class);
if (index < 0 || index >= array.length) Logger.errorAndReturn(new IndexOutOfBoundsException("Attempted to find value at index: " + index + ", for IntArrayList with size: " + size(array)), 3, PrimitiveIntArrayList.class);
return array[index];
}
public static int@IntArrayListMarker[] set(int@IntArrayListMarker[] array, int index, int value) {
array[index] = value;
return array;
}
public static int[] getCopyOrNull(int@IntArrayListMarker[] array) {
if (size(array) == 0) return null;
int[] copy = new int[array.length];
System.arraycopy(array, 0, copy, 0, array.length);
return copy;
}
public static String toString(int@IntArrayListMarker[] array) {
if (array == null) return "[]";
StringBuilder sb = new StringBuilder();
sb.append("[");
for (int i = 0; i < array.length; i++) {
sb.append(array[i]);
if (i < array.length - 1) {
sb.append(", ");
}
}
sb.append("]");
return sb.toString();
}
}
@@ -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,22 +0,0 @@
package games.cubi.raycastedantiesp.core.utils;
import ca.spottedleaf.concurrentutil.util.ConcurrentUtil;
import java.lang.invoke.VarHandle;
/** Just a shorter alias of useful methods from ConcurrentUtil**/
public final class VarHandler {
public static final VarHandle BYTE_ARRAY_HANDLE = ConcurrentUtil.getArrayHandle(byte[].class);
public static final VarHandle CHAR_ARRAY_HANDLE = ConcurrentUtil.getArrayHandle(char[].class);
public static final VarHandle LONG_ARRAY_HANDLE = ConcurrentUtil.getArrayHandle(long[].class);
private VarHandler() {}
public static VarHandle get(Class<?> classOf, String fieldName, Class<?> fieldClass) {
return ConcurrentUtil.getVarHandle(classOf, fieldName, fieldClass);
}
public static VarHandle $tatic(Class<?> classOf, String fieldName, Class<?> fieldClass) {
return ConcurrentUtil.getStaticVarHandle(classOf, fieldName, fieldClass);
}
}
@@ -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,13 +14,14 @@ 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;
import games.cubi.raycastedantiesp.core.players.PlayerData;
import games.cubi.raycastedantiesp.core.utils.Clearable;
import games.cubi.raycastedantiesp.core.utils.InvasivelyLinkedSWMRList;
import games.cubi.raycastedantiesp.core.utils.VarHandler;
import games.cubi.utils.Clearable;
import games.cubi.utils.lists.InvasivelyLinkedSWMRList;
import games.cubi.utils.VarHandler;
import games.cubi.raycastedantiesp.core.view.chunks.BlockChunkSectionStore;
import games.cubi.raycastedantiesp.core.view.chunks.ChunkSectionStore;
import games.cubi.raycastedantiesp.core.view.chunks.OccludingChunkSectionStore;
@@ -28,9 +37,6 @@ import java.util.function.IntSupplier;
import static games.cubi.raycastedantiesp.core.chunks.ChunkData.packUncheckedGuarded;
public abstract class AbstractBlockView<R extends Clearable, T extends NettyTileEntity<R>> implements BlockView {
public static final int CHUNK_SIZE = 16;
public static final int LOCAL_MASK = CHUNK_SIZE - 1;
private final ChunkSectionStore chunks;
private final boolean trackAllBlocks;
/**
@@ -58,6 +64,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) {
@@ -145,7 +155,7 @@ public abstract class AbstractBlockView<R extends Clearable, T extends NettyTile
tileEntity.setVisible(shouldBeVisible);
tileEntity.setLastChecked(currentTick);
if (visibilityChanged) {
BlockViewTransition.Type type = shouldBeVisible ? BlockViewTransition.Type.SHOW : BlockViewTransition.Type.HIDE;
TransitionType.Tile type = shouldBeVisible ? TransitionType.Tile.SHOW : TransitionType.Tile.HIDE;
transitions.add(type, tileEntity, modeToken, expectedWorldEpoch);
}
}
@@ -155,6 +165,7 @@ public abstract class AbstractBlockView<R extends Clearable, T extends NettyTile
public void recordOutboundTileEntityVisibility(TrackedTileEntity<?> tileEntity, boolean visible) {
if (tileEntity != null) {
tileEntity.setVisible(visible);
tileEntity.setClientVisible(visible);
tileEntity.setLastChecked(TrackedTileEntity.NEVER_CHECKED);
}
}
@@ -178,6 +189,8 @@ public abstract class AbstractBlockView<R extends Clearable, T extends NettyTile
if (!tileEntity.visible()) {
tileEntity.setVisible(true);
tileEntity.setLastChecked(currentTick);
}
if (!tileEntity.clientVisible()) {
visibilityRepairConsumer.accept(tileEntity);
}
});
@@ -1,11 +1,21 @@
/*
* 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;
import games.cubi.raycastedantiesp.core.utils.Clearable;
import games.cubi.utils.Clearable;
import java.util.Collection;
import java.util.UUID;
import java.util.function.Consumer;
@@ -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);
@@ -36,21 +55,23 @@ public interface BlockView extends Clearable {
TrackedTileEntity<?> getTrackedTileEntity(UUID world, BlockSpatial position);
/** Returns the engine's desired visibility, not the state currently applied to the client. */
boolean isVisible(UUID world, BlockSpatial position, int currentTick);
/**
* Records visibility established by the current outbound packet without queuing another packet. This also resets
* the check timestamp because the transmitted state supersedes the result of any previous visibility check. The
* tile entity must be the current state returned by this view's structural-writer operations.
* Records visibility established by the current outbound packet without queuing another packet. This synchronizes
* both desired and client visibility and resets the check timestamp because the transmitted state supersedes the
* result of any previous visibility check. The tile entity must be the current state returned by this view's
* structural-writer operations.
*/
void recordOutboundTileEntityVisibility(TrackedTileEntity<?> tileEntity, boolean visible);
/**
* Applies a mode change from the structural writer.
*
* Invokes {@code visibilityRepairConsumer} for each tile entity made visible when checks are disabled. The
* structural writer must send their current state directly rather than publishing them to the engine transition
* queue.
* Sets every desired state visible when checks are disabled and invokes {@code visibilityRepairConsumer} for each
* tile entity still hidden from the client. The structural writer must send their current state directly rather
* than publishing them to the engine transition queue.
*/
void applyTileEntityCheckMode(boolean enabled, int currentTick, Consumer<TrackedTileEntity<?>> visibilityRepairConsumer);
@@ -92,7 +113,7 @@ public interface BlockView extends Clearable {
@FunctionalInterface
interface TransitionConsumer {
void accept(BlockViewTransition.Type type, TrackedTileEntity<?> tileEntity, long modeToken, int worldEpoch);
void accept(TransitionType.Tile type, TrackedTileEntity<?> tileEntity, long modeToken, int worldEpoch);
}
void drainTransitions(TransitionConsumer consumer);
@@ -1,11 +0,0 @@
package games.cubi.raycastedantiesp.core.view;
import games.cubi.raycastedantiesp.core.tracked.TrackedTileEntity;
// Retains the originating object identity so a delayed transition cannot target a replacement at the same coordinates.
public record BlockViewTransition(Type type, TrackedTileEntity<?> tileEntity, long modeToken, int worldEpoch) {
public enum Type {
SHOW,
HIDE,
}
}
@@ -1,9 +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.raycastedantiesp.core.tracked.TrackedEntity;
import games.cubi.locatables.api.Spatial;
import games.cubi.raycastedantiesp.core.tracked.NettyEntity;
import games.cubi.raycastedantiesp.core.utils.Clearable;
import games.cubi.utils.Clearable;
import java.util.Collection;
import java.util.UUID;
@@ -37,9 +45,6 @@ public interface EntityView<T extends TrackedEntity<?>> extends Clearable {
*/
int size();
@Deprecated
boolean isVisible(UUID entityUUID, int currentTick);
boolean isVisible(UUID entityUUID);
boolean isVisible(int entityID);
@@ -62,14 +67,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();
@@ -78,7 +83,7 @@ public interface EntityView<T extends TrackedEntity<?>> extends Clearable {
@FunctionalInterface
interface TransitionConsumer {
void accept(EntityViewTransition.Type type, TrackedEntity<?> entity, int worldEpoch);
void accept(TransitionType.Entity type, TrackedEntity<?> entity, int worldEpoch);
}
void drainTransitions(TransitionConsumer consumer);
@@ -1,12 +0,0 @@
package games.cubi.raycastedantiesp.core.view;
import games.cubi.raycastedantiesp.core.tracked.TrackedEntity;
// Used to cache visibility changes until the player's netty thread next processes
public record EntityViewTransition(Type type, TrackedEntity<?> entity, int worldEpoch) {
public enum Type {
SHOW,
HIDE,
FORGET,
}
}
@@ -1,6 +1,14 @@
/*
* 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;
import games.cubi.utils.Clearable;
import games.cubi.utils.IntrusiveSPSCQueue;
import games.cubi.raycastedantiesp.core.tracked.TrackedTileEntity;
@@ -20,7 +28,7 @@ public final class PackedBlockTransitionQueue {
private final IntrusiveSPSCQueue<QueueEntry> publishedEntries = new IntrusiveSPSCQueue<>();
private final PendingBatch pending = new PendingBatch();
public void add(BlockViewTransition.Type type, TrackedTileEntity<?> tileEntity, long modeToken, int worldEpoch) {
public void add(TransitionType.Tile type, TrackedTileEntity<?> tileEntity, long modeToken, int worldEpoch) {
Objects.requireNonNull(type, "type");
Objects.requireNonNull(tileEntity, "tileEntity");
@@ -83,17 +91,17 @@ public final class PackedBlockTransitionQueue {
pending.clear();
}
private abstract static class QueueEntry extends IntrusiveSPSCQueue.Node {
private abstract static sealed class QueueEntry extends IntrusiveSPSCQueue.Node {
abstract void drain(BlockView.TransitionConsumer consumer);
}
private static final class SingleEntry extends QueueEntry {
private final BlockViewTransition.Type type;
private final TransitionType.Tile type;
private final TrackedTileEntity<?> tileEntity;
private final long modeToken;
private final int worldEpoch;
private SingleEntry(BlockViewTransition.Type type, TrackedTileEntity<?> tileEntity, long modeToken, int worldEpoch) {
private SingleEntry(TransitionType.Tile type, TrackedTileEntity<?> tileEntity, long modeToken, int worldEpoch) {
this.type = type;
this.tileEntity = tileEntity;
this.modeToken = modeToken;
@@ -107,13 +115,13 @@ public final class PackedBlockTransitionQueue {
}
private static final class PendingBatch implements Clearable {
private BlockViewTransition.Type t1, t2, t3, t4, t5, t6, t7, t8;
private TransitionType.Tile t1, t2, t3, t4, t5, t6, t7, t8;
private TrackedTileEntity<?> e1, e2, e3, e4, e5, e6, e7, e8;
private long modeToken;
private int worldEpoch;
private int count;
private void add(BlockViewTransition.Type type, TrackedTileEntity<?> tileEntity) {
private void add(TransitionType.Tile type, TrackedTileEntity<?> tileEntity) {
switch (++count) {
case 1 -> { t1 = type; e1 = tileEntity; }
case 2 -> { t2 = type; e2 = tileEntity; }
@@ -128,22 +136,12 @@ public final class PackedBlockTransitionQueue {
}
public void clear() {
t1 = null;
t2 = null;
t3 = null;
t4 = null;
t5 = null;
t6 = null;
t7 = null;
t8 = null;
e1 = null;
e2 = null;
e3 = null;
e4 = null;
e5 = null;
e6 = null;
e7 = null;
e8 = null;
t1 = null; t2 = null; t3 = null; t4 = null;
t5 = null; t6 = null; t7 = null; t8 = null;
e1 = null; e2 = null; e3 = null; e4 = null;
e5 = null; e6 = null; e7 = null; e8 = null;
modeToken = 0L;
worldEpoch = 0;
count = 0;
@@ -151,29 +149,22 @@ public final class PackedBlockTransitionQueue {
}
private static final class BatchEntry extends QueueEntry {
private final BlockViewTransition.Type t1, t2, t3, t4, t5, t6, t7, t8;
private final TransitionType.Tile t1, t2, t3, t4, t5, t6, t7, t8;
private final TrackedTileEntity<?> e1, e2, e3, e4, e5, e6, e7, e8;
private final long modeToken;
private final int worldEpoch;
private final int count;
private BatchEntry(PendingBatch pending) {
t1 = pending.t1;
t2 = pending.t2;
t3 = pending.t3;
t4 = pending.t4;
t5 = pending.t5;
t6 = pending.t6;
t7 = pending.t7;
t8 = pending.t8;
e1 = pending.e1;
e2 = pending.e2;
e3 = pending.e3;
e4 = pending.e4;
e5 = pending.e5;
e6 = pending.e6;
e7 = pending.e7;
e8 = pending.e8;
t1 = pending.t1; t2 = pending.t2;
t3 = pending.t3; t4 = pending.t4;
t5 = pending.t5; t6 = pending.t6;
t7 = pending.t7; t8 = pending.t8;
e1 = pending.e1; e2 = pending.e2;
e3 = pending.e3; e4 = pending.e4;
e5 = pending.e5; e6 = pending.e6;
e7 = pending.e7; e8 = pending.e8;
modeToken = pending.modeToken;
worldEpoch = pending.worldEpoch;
count = pending.count;
@@ -1,6 +1,14 @@
/*
* 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;
import games.cubi.utils.Clearable;
import games.cubi.utils.IntrusiveSPSCQueue;
import games.cubi.raycastedantiesp.core.tracked.TrackedEntity;
@@ -20,7 +28,7 @@ public final class PackedEntityTransitionQueue { //todo: potentially merge this
private final IntrusiveSPSCQueue<QueueEntry> publishedEntries = new IntrusiveSPSCQueue<>();
private final PendingBatch pending = new PendingBatch();
public void add(EntityViewTransition.Type type, TrackedEntity<?> entity, int worldEpoch) {
public void add(TransitionType.Entity type, TrackedEntity<?> entity, int worldEpoch) {
Objects.requireNonNull(type, "type");
Objects.requireNonNull(entity, "entity");
@@ -87,11 +95,11 @@ public final class PackedEntityTransitionQueue { //todo: potentially merge this
}
private static final class SingleEntry extends QueueEntry {
private final EntityViewTransition.Type type;
private final TransitionType.Entity type;
private final TrackedEntity<?> entity;
private final int worldEpoch;
private SingleEntry(EntityViewTransition.Type type, TrackedEntity<?> entity, int worldEpoch) {
private SingleEntry(TransitionType.Entity type, TrackedEntity<?> entity, int worldEpoch) {
this.type = type;
this.entity = entity;
this.worldEpoch = worldEpoch;
@@ -104,26 +112,12 @@ public final class PackedEntityTransitionQueue { //todo: potentially merge this
}
private static final class PendingBatch implements Clearable {
private EntityViewTransition.Type t1;
private EntityViewTransition.Type t2;
private EntityViewTransition.Type t3;
private EntityViewTransition.Type t4;
private EntityViewTransition.Type t5;
private EntityViewTransition.Type t6;
private EntityViewTransition.Type t7;
private EntityViewTransition.Type t8;
private TrackedEntity<?> e1;
private TrackedEntity<?> e2;
private TrackedEntity<?> e3;
private TrackedEntity<?> e4;
private TrackedEntity<?> e5;
private TrackedEntity<?> e6;
private TrackedEntity<?> e7;
private TrackedEntity<?> e8;
private TransitionType.Entity t1, t2, t3, t4, t5, t6, t7, t8;
private TrackedEntity<?> e1, e2, e3, e4, e5, e6, e7, e8;
private int worldEpoch;
private int count;
private void add(EntityViewTransition.Type type, TrackedEntity<?> entity) {
private void add(TransitionType.Entity type, TrackedEntity<?> entity) {
switch (++count) {
case 1 -> { t1 = type; e1 = entity; }
case 2 -> { t2 = type; e2 = entity; }
@@ -138,64 +132,33 @@ public final class PackedEntityTransitionQueue { //todo: potentially merge this
}
public void clear() {
t1 = null;
t2 = null;
t3 = null;
t4 = null;
t5 = null;
t6 = null;
t7 = null;
t8 = null;
e1 = null;
e2 = null;
e3 = null;
e4 = null;
e5 = null;
e6 = null;
e7 = null;
e8 = null;
t1 = null; t2 = null; t3 = null; t4 = null;
t5 = null; t6 = null; t7 = null; t8 = null;
e1 = null; e2 = null; e3 = null; e4 = null;
e5 = null; e6 = null; e7 = null; e8 = null;
worldEpoch = 0;
count = 0;
}
}
private static final class BatchEntry extends QueueEntry {
private final EntityViewTransition.Type t1;
private final EntityViewTransition.Type t2;
private final EntityViewTransition.Type t3;
private final EntityViewTransition.Type t4;
private final EntityViewTransition.Type t5;
private final EntityViewTransition.Type t6;
private final EntityViewTransition.Type t7;
private final EntityViewTransition.Type t8;
private final TrackedEntity<?> e1;
private final TrackedEntity<?> e2;
private final TrackedEntity<?> e3;
private final TrackedEntity<?> e4;
private final TrackedEntity<?> e5;
private final TrackedEntity<?> e6;
private final TrackedEntity<?> e7;
private final TrackedEntity<?> e8;
private final TransitionType.Entity t1, t2, t3, t4, t5, t6, t7, t8;
private final TrackedEntity<?> e1, e2, e3, e4, e5, e6, e7, e8;
private final int worldEpoch;
private final int count;
private BatchEntry(PendingBatch pending) {
t1 = pending.t1;
t2 = pending.t2;
t3 = pending.t3;
t4 = pending.t4;
t5 = pending.t5;
t6 = pending.t6;
t7 = pending.t7;
t8 = pending.t8;
e1 = pending.e1;
e2 = pending.e2;
e3 = pending.e3;
e4 = pending.e4;
e5 = pending.e5;
e6 = pending.e6;
e7 = pending.e7;
e8 = pending.e8;
t1 = pending.t1; t2 = pending.t2;
t3 = pending.t3; t4 = pending.t4;
t5 = pending.t5; t6 = pending.t6;
t7 = pending.t7; t8 = pending.t8;
e1 = pending.e1; e2 = pending.e2;
e3 = pending.e3; e4 = pending.e4;
e5 = pending.e5; e6 = pending.e6;
e7 = pending.e7; e8 = pending.e8;
worldEpoch = pending.worldEpoch;
count = pending.count;
}
@@ -0,0 +1,21 @@
/*
* 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;
public interface TransitionType {
enum Entity {
SHOW,
HIDE,
FORGET,
}
enum Tile {
SHOW,
HIDE,
}
}
@@ -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;
@@ -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);
@@ -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);
@@ -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);
@@ -1,9 +1,9 @@
/*
* 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.
* 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.controller;
@@ -18,7 +18,7 @@ import games.cubi.raycastedantiesp.core.tracked.NettyEntity;
import games.cubi.raycastedantiesp.core.players.NettyData;
import games.cubi.raycastedantiesp.core.players.PlayerData;
import games.cubi.raycastedantiesp.core.players.PlayerRegistry;
import games.cubi.raycastedantiesp.core.utils.PrimitiveIntArrayList;
import games.cubi.utils.lists.PrimitiveIntArrayList;
import games.cubi.raycastedantiesp.core.utils.Packet;
import games.cubi.raycastedantiesp.core.view.EntityView;
import it.unimi.dsi.fastutil.ints.IntArrayList;
@@ -50,11 +50,9 @@ public abstract class PacketEntityViewController<P> {
protected EntityConfig entityConfig = null;
protected PlayerConfig playerConfig = null;
protected double hideOnSpawnEntityDistanceSquared = 0;
protected double hideOnSpawnPlayerDistanceSquared = 0;
protected void handleWorldStatePacket(UUID player, String world, UUID worldUUID, int minWorldHeight, int currentTick) {
PlayerData playerData = PlayerRegistry.getInstance().getPlayerData(player);
PlayerData playerData = PlayerRegistry.get().getPlayerData(player);
if (playerData == null) {
Logger.error("Received world state packet for unknown player, uuid=" + player, 2, PacketEntityViewController.class);
return;
@@ -91,7 +89,7 @@ public abstract class PacketEntityViewController<P> {
}
protected PlayerData handlePlayPhaseLoginPacket(int entityID, UUID playerUUID, int currentTick) {
return PlayerRegistry.getInstance().registerAndGetPlayer(playerUUID, currentTick, entityID, this::createSelfEntity);
return PlayerRegistry.get().registerAndGetPlayer(playerUUID, currentTick, entityID, this::createSelfEntity);
}
protected abstract NettyEntity<?> createSelfEntity(PlayerData ownData, int entityID, UUID playerUUID);
@@ -103,7 +101,7 @@ public abstract class PacketEntityViewController<P> {
if (player == null) {
return;
}
PlayerRegistry.getInstance().unregisterPlayer(player);
PlayerRegistry.get().unregisterPlayer(player);
}
/**
* @return Whether or not to cancel the packet event. <code>true</code> to cancel, <code>false</code> to do nothing.
@@ -123,11 +121,13 @@ public abstract class PacketEntityViewController<P> {
NettyEntity<?> entity = Logger.requireNonNull(processEntitySpawn(playerData, packet, world, currentTick), "processEntitySpawn returned null", 3, PacketEntityViewController.class);
if ((!isPlayer && entityConfig.enabled()) || isPlayer && playerConfig.enabled()) {
RaycastConfig config = (isPlayer) ? playerConfig : entityConfig;
if (config.enabled()) {
Locatable ownLocation = playerData.ownLocation();
boolean staleOwnLocation = ownLocation == null || ownLocation.world() == null || !ownLocation.world().equals(world);
double distanceSquared = staleOwnLocation ? Double.POSITIVE_INFINITY : ownLocation.distanceSquared(entity);
if (distanceSquared > (isPlayer ? hideOnSpawnPlayerDistanceSquared : hideOnSpawnEntityDistanceSquared)) {
if (distanceSquared > config.hideOnSpawnDistanceSquared) {
entity.setVisible(false);
entity.setClientVisible(false);
if (isPlayer) {
@@ -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);
}
@@ -249,7 +253,7 @@ public abstract class PacketEntityViewController<P> {
protected boolean handleEntityPassengers(int entityID, int[] passengers, PlayerData playerData, int currentTick) {
boolean bypassedVehicle = EntityBypassRegistry.isBypassed(entityID);
NettyEntity<?> vehicle = bypassedVehicle ? null : playerData.entityFromID(entityID);
int[] previousPassengers = getPreviousPassengerState(entityID, vehicle, playerData);
final int[] previousPassengers = getPreviousPassengerState(entityID, vehicle, playerData);
playerData.nettyData().consumeUnresolvedPassengers(entityID); // throw away any unresolved passengers as this new packet will have the correct passenger list
// "Stale" passengers are passengers that the previous authoritative state said were mounted,
// but the new full replacement passenger list no longer contains.
@@ -332,19 +336,19 @@ public abstract class PacketEntityViewController<P> {
private int[] getPreviousPassengerState(int vehicleID, NettyEntity<?> vehicle, PlayerData playerData) {
if (vehicle != null) {
int[] previousPassengerIDs = vehicle.passengerIDs();
final int[] previousPassengerIDs = vehicle.passengerIDsNoAlloc();
if (!PrimitiveIntArrayList.isEmpty(previousPassengerIDs)) {
return previousPassengerIDs;
}
}
return playerData.nettyData().getUnresolvedPassengers(vehicleID);
return playerData.nettyData().getUnresolvedPassengersNoAlloc(vehicleID);
}
/**
* Clears reverse vehicle links for passengers that were part of the previous vehicle state,
* but are absent from the new authoritative replacement list.
*/
private void clearStalePassengerReferences(int vehicleID, int[] previousPassengers, int[] newPassengers, PlayerData playerData) {
private void clearStalePassengerReferences(int vehicleID, final int[] previousPassengers, int[] newPassengers, PlayerData playerData) {
if (PrimitiveIntArrayList.isEmpty(previousPassengers)) {
return;
}
@@ -416,7 +420,7 @@ public abstract class PacketEntityViewController<P> {
NettyEntity<?> unresolvedVehicle = playerData.entityFromID(unresolvedVehicleID);
if (unresolvedVehicle != null) {
// this can occur if the vehicle existed at the time of the passenger packet but not the passenger, and somehow the passenger never got resolved to the vehicle (missing spawn packets etc). In reality this should never happen.
unresolvedVehicle.setPassengerIDs(PrimitiveIntArrayList.remove(unresolvedVehicle.passengerIDs(), entityID));
unresolvedVehicle.setPassengerIDs(PrimitiveIntArrayList.remove(unresolvedVehicle.passengerIDsNoAlloc(), entityID));
}
}
@@ -425,7 +429,7 @@ public abstract class PacketEntityViewController<P> {
return;
}
int[] currentPassengerIDs = entity.passengerIDs();
int[] currentPassengerIDs = entity.passengerIDsNoAlloc();
if (!PrimitiveIntArrayList.isEmpty(currentPassengerIDs)) {
for (int passengerID : currentPassengerIDs) {
NettyEntity<?> passenger = playerData.entityFromID(passengerID);
@@ -441,7 +445,7 @@ public abstract class PacketEntityViewController<P> {
}
NettyEntity<?> vehicle = playerData.entityFromID(vehicleID);
if (vehicle != null) {
vehicle.setPassengerIDs(PrimitiveIntArrayList.remove(vehicle.passengerIDs(), entityID));
vehicle.setPassengerIDs(PrimitiveIntArrayList.remove(vehicle.passengerIDsNoAlloc(), entityID));
}
entity.setVehicleID(NO_VEHICLE);
}
@@ -477,7 +481,7 @@ public abstract class PacketEntityViewController<P> {
}
// A tracked entity owns the same two relationship directions in its resolved state.
int[] currentLeashedEntityIDs = entity.leashedEntityIDsOrNull();
final int[] currentLeashedEntityIDs = entity.leashedEntityIDsOrNullNoAlloc();
if (!PrimitiveIntArrayList.isEmpty(currentLeashedEntityIDs)) {
for (int leashedEntityID : currentLeashedEntityIDs) {
NettyEntity<?> leashedEntity = playerData.entityFromID(leashedEntityID);
@@ -626,7 +630,7 @@ public abstract class PacketEntityViewController<P> {
* 2. this entity is the passenger and the vehicle was already known.
*/
protected void reconcileUnresolvedPassengers(NettyEntity<?> insertedEntity, PlayerData playerData) {
int[] pendingPassengers = playerData.nettyData().getUnresolvedPassengers(insertedEntity.entityID());
int[] pendingPassengers = playerData.nettyData().getUnresolvedPassengersNoAlloc(insertedEntity.entityID());
if (!PrimitiveIntArrayList.isEmpty(pendingPassengers)) {
playerData.nettyData().consumeUnresolvedPassengers(insertedEntity.entityID());
handleEntityPassengersNow(insertedEntity, pendingPassengers, playerData, insertedEntity.lastChecked());
@@ -661,7 +665,7 @@ public abstract class PacketEntityViewController<P> {
// Vanilla may send entity state before its spawn packet, and those packets were already
// forwarded to the client. Discard deferred tracking work rather than replaying duplicates.
playerData.nettyData().clearPendingPostSpawnTasksForEntity(entityID);
int[] pendingPassengers = playerData.nettyData().getUnresolvedPassengers(entityID);
int[] pendingPassengers = playerData.nettyData().getUnresolvedPassengersNoAlloc(entityID);
if (!PrimitiveIntArrayList.isEmpty(pendingPassengers)) {
for (int passengerID : pendingPassengers) {
NettyEntity<?> passenger = playerData.entityFromID(passengerID);
@@ -680,7 +684,7 @@ public abstract class PacketEntityViewController<P> {
holder.addLeashedEntity(entityID);
}
}
int[] pendingLeashedEntityIDs = playerData.nettyData().getUnresolvedLeashes(entityID);
int[] pendingLeashedEntityIDs = playerData.nettyData().getUnresolvedLeashesNoAlloc(entityID);
if (!PrimitiveIntArrayList.isEmpty(pendingLeashedEntityIDs)) {
for (int leashedEntityID : pendingLeashedEntityIDs) {
NettyEntity<?> leashedEntity = playerData.entityFromID(leashedEntityID);
@@ -710,7 +714,7 @@ public abstract class PacketEntityViewController<P> {
}
}
int[] pendingLeashedEntityIDs = playerData.nettyData().getUnresolvedLeashes(entityID);
int[] pendingLeashedEntityIDs = playerData.nettyData().getUnresolvedLeashesNoAlloc(entityID);
if (PrimitiveIntArrayList.isEmpty(pendingLeashedEntityIDs)) {
return;
}
@@ -743,15 +747,15 @@ public abstract class PacketEntityViewController<P> {
if (!vehicle.clientVisible() || (keepingClientEntityWhenHidden(vehicle, playerData) && !vehicle.visible())) {
return;
}
sendEntityPassengerPacket(vehicle.entityID(), collectClientVisiblePassengers(vehicle.passengerIDs(), playerData), playerData);
sendEntityPassengerPacket(vehicle.entityID(), collectClientVisiblePassengers(vehicle.passengerIDsNoAlloc(), playerData), playerData);
}
protected IntArrayList collectClientVisiblePassengers(int[] passengerIDs, PlayerData playerData) {
protected IntArrayList collectClientVisiblePassengers(final int[] passengerIDs, PlayerData playerData) {
// HackyEntityIDGuard reserves -1, so it cannot accidentally match an entity being shown.
return collectClientVisiblePassengers(passengerIDs, playerData, -1);
}
protected IntArrayList collectClientVisiblePassengers(int[] passengerIDs, PlayerData playerData, int entityBeingShownID) {
protected IntArrayList collectClientVisiblePassengers(final int[] passengerIDs, PlayerData playerData, int entityBeingShownID) {
int size = passengerIDs == null ? 0 : passengerIDs.length;
IntArrayList visiblePassengers = new IntArrayList(size);
if (passengerIDs == null) {
@@ -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;
@@ -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;
}
@@ -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;
@@ -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());
}
}
Loaded 100 of 168 files, more files were not shown because too many files have changed in this diff. Show more