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
159 changed files with 1299 additions and 1760 deletions

No files matched your search

+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.1-SNAPSHOT"
val coreVersion = "0.7.2-SNAPSHOT"
val isRelease = gradle.startParameter.taskNames.any {
it.contains("buildRelease")
@@ -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,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,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.chunks;
@@ -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.chunks;
@@ -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.chunks;
@@ -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.chunks;
@@ -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.chunks;
@@ -1,16 +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.
* 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,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.chunks.blocks;
@@ -13,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,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.chunks.blocks;
@@ -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.chunks.blocks;
@@ -13,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,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.chunks.blocks;
@@ -13,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,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.chunks.blocks;
@@ -13,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,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.chunks.blocks;
@@ -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.chunks.blocks;
@@ -13,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,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.chunks.blocks;
@@ -15,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,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,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,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,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,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,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,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,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,7 +15,7 @@ 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;
@@ -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,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,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,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,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.engine;
@@ -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.engine;
@@ -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.engine;
@@ -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,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,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;
@@ -23,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,
@@ -40,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,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,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.engine;
@@ -21,14 +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 games.cubi.utils.events.CancellableEvent;
import games.cubi.utils.events.CancellableEventRegistry;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
@@ -105,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;
@@ -121,9 +118,6 @@ public abstract class AsyncEngine implements Engine {
}
}
public static class EngineTickEvent extends CancellableEvent {}
public final CancellableEventRegistry<EngineTickEvent> engineTickEventRegistry = new CancellableEventRegistry<>();
/**
* Claims worker capacity and either runs work immediately or schedules worker batches.
*
@@ -131,11 +125,6 @@ public abstract class AsyncEngine implements Engine {
* lifecycle; false if this attempt was skipped or cleaned up during setup.
*/
private boolean dispatchTick(int scheduledTick, int startTick, long scheduledNanos) {
if (!engineTickEventRegistry.dispatch(EngineTickEvent::new)) {
Logger.debug("Skipping tick due to event being cancelled");
finishTickState();
return false;
}
int threads = config.getEngineConfig().asyncConfig().asyncProcessingThreads();
if (threads < 1) threads = 1;
@@ -181,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);
@@ -203,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++;
}
@@ -253,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 {
@@ -338,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) {
@@ -402,7 +397,7 @@ public abstract class AsyncEngine implements Engine {
}
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);
@@ -420,7 +415,7 @@ public abstract class AsyncEngine implements Engine {
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);
@@ -431,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);
@@ -447,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,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.engine;
@@ -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.engine;
@@ -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.engine;
@@ -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.engine;
@@ -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.engine;
@@ -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.engine;
@@ -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.engine;
@@ -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.engine;
@@ -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.engine;
@@ -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.engine;
@@ -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.entity;
@@ -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;
@@ -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.FloatingLocatableEquality;
import games.cubi.locatables.api.Locatable;
import games.cubi.locatables.api.MutableFloatingLocatable;
import games.cubi.locatables.api.Spatial;
import games.cubi.raycastedantiesp.core.utils.VarHandler;
import games.cubi.utils.VarHandler;
import java.lang.invoke.VarHandle;
import java.util.Objects;
@@ -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;
@@ -1,20 +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.
* 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 {
@@ -25,26 +29,30 @@ public class PlayerRegistry {
private PlayerRegistry() {}
public static PlayerRegistry getInstance() {
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) {
@@ -56,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,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.raycast;
@@ -1,281 +1,148 @@
/*
* 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.raycast;
import games.cubi.locatables.api.*;
import games.cubi.locatables.implementations.MutableChunkSection;
import games.cubi.locatables.implementations.MutableSpatialImpl;
import games.cubi.logs.Logger;
import games.cubi.locatables.api.Locatable;
import games.cubi.locatables.api.Spatial;
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, float stepSize, ParticleSpawner particleSpawner) {
//return raycastCubiNoAllocUnrolledLongBitsAccumulated(maxOccluding, alwaysShowRadius, maxRaycastRadius, debug, 1, snap, start.x(), start.y(), start.z(), end.x(), end.y(), end.z());
//return raycastUnrolledAccumulated(maxOccluding, alwaysShowRadius, maxRaycastRadius, debug, 1, snap, start, end);
return raycast(start, end, maxOccluding, alwaysShowRadius, maxRaycastRadius, debug, snap, 0f, stepSize, particleSpawner);
}
public static boolean raycast(Locatable start, Spatial end, int maxOccluding, int alwaysShowRadius, int maxRaycastRadius, boolean debug, BlockView snap, float yOffsetEnd, float stepSize, ParticleSpawner 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;
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.
float total = (float) (start.distance(clonedEnd) - stepSize); //benchmarking shows that calling distance() is faster than distanceSquared() then checking distanceSquared < stepSize*stepSize every time despite the latter replacing a square root with multiplication
if (total <= alwaysShowRadius) return true;
if (total > maxRaycastRadius) return false;
if (debug && particleSpawner == null) {
Logger.errorAndReturn(new RuntimeException("raycast called with debug enabled but no ParticleSpawner supplied"), 2, RaycastUtil.class);
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;
}
Spatial dir = clonedEnd.subtract(start).normalise().scalarMultiply(stepSize);
MutableFloatingSpatial current = new MutableSpatialImpl(start.x(),start.y(),start.z());
MutableChunkSection currentChunk = new MutableChunkSection().updateFrom(current);
ChunkOcclusionView currentOcclusionView = snap.getChunkOcclusionView(currentChunk);
for (float traveled = 0; traveled < total; traveled += stepSize) {
current.add(dir);
if (!ChunkSectionEquality.equals(currentChunk, current)) {
currentChunk.updateFrom(current);
currentOcclusionView = snap.getChunkOcclusionView(currentChunk);
}
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(current.blockX(), current.blockY(), current.blockZ())) {
maxOccluding--;
if (debug) particleSpawner.spawnParticleAt(start.world(), current, ParticleSpawner.Colour.RED);
if (maxOccluding < 1) return false;
continue;
}
if (debug) particleSpawner.spawnParticleAt(start.world(), current, ParticleSpawner.Colour.GREEN);
}
return true;
while (remainingSteps-- > 0) rayAdvancer.advance();
return rayAdvancer.occluded <= maxOccluding;
}
/*
public static boolean raycastCubiNoAllocUnrolledLongBitsAccumulated(int maxOccluding, final int alwaysShowRadius, final int maxRaycastRadius, boolean debug, final int stepSize, BlockView snap,
final double startX, final double startY, final double startZ, final double endX, final double endY, final double endZ) {
if (maxOccluding <= 0) return false;
double total = Math.sqrt(((endX - startX) * (endX - startX)) + ((endY - startY) * (endY - startY)) + ((endZ - startZ) * (endZ - startZ)));
if (total <= alwaysShowRadius) return true;
if (total > maxRaycastRadius) return false;
double finalDist = total - stepSize;
final double dirX = (endX - startX) / total * stepSize;
final double dirY = (endY - startY) / total * stepSize;
final double dirZ = (endZ - startZ) / total * stepSize;
double currentX = startX;
double currentY = startY;
double currentZ = startZ;
int chunkX = ((int) currentX) >> 4;
int chunkY = ((int) currentY) >> 4;
int chunkZ = ((int) currentZ) >> 4;
ChunkOcclusionView currentOcclusionView = snap.getChunkOcclusionView(chunkX, chunkY, chunkZ);
int occluded = 0;
double traveled = 0;
final double fourSteps = stepSize * 4.0;
while (traveled + fourSteps <= finalDist) {
currentX += dirX;
currentY += dirY;
currentZ += dirZ;
int blockX = (int) Math.floor(currentX);
int blockY = (int) Math.floor(currentY);
int blockZ = (int) Math.floor(currentZ);
if (blockX >> 4 != chunkX || blockY >> 4 != chunkY || blockZ >> 4 != chunkZ) {
chunkX = blockX >> 4;
chunkY = blockY >> 4;
chunkZ = blockZ >> 4;
currentOcclusionView = snap.getChunkOcclusionView(chunkX, chunkY, chunkZ);
}
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded ++;
currentX += dirX;
currentY += dirY;
currentZ += dirZ;
blockX = (int) Math.floor(currentX);
blockY = (int) Math.floor(currentY);
blockZ = (int) Math.floor(currentZ);
if (blockX >> 4 != chunkX || blockY >> 4 != chunkY || blockZ >> 4 != chunkZ) {
chunkX = blockX >> 4;
chunkY = blockY >> 4;
chunkZ = blockZ >> 4;
currentOcclusionView = snap.getChunkOcclusionView(chunkX, chunkY, chunkZ);
}
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded ++;
currentX += dirX;
currentY += dirY;
currentZ += dirZ;
blockX = (int) Math.floor(currentX);
blockY = (int) Math.floor(currentY);
blockZ = (int) Math.floor(currentZ);
if (blockX >> 4 != chunkX || blockY >> 4 != chunkY || blockZ >> 4 != chunkZ) {
chunkX = blockX >> 4;
chunkY = blockY >> 4;
chunkZ = blockZ >> 4;
currentOcclusionView = snap.getChunkOcclusionView(chunkX, chunkY, chunkZ);
}
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded ++;
currentX += dirX;
currentY += dirY;
currentZ += dirZ;
blockX = (int) Math.floor(currentX);
blockY = (int) Math.floor(currentY);
blockZ = (int) Math.floor(currentZ);
if (blockX >> 4 != chunkX || blockY >> 4 != chunkY || blockZ >> 4 != chunkZ) {
chunkX = blockX >> 4;
chunkY = blockY >> 4;
chunkZ = blockZ >> 4;
currentOcclusionView = snap.getChunkOcclusionView(chunkX, chunkY, chunkZ);
}
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded ++;
if (occluded >= maxOccluding) return false;
traveled += fourSteps;
}
for (; traveled < finalDist; traveled += stepSize) {
currentX += dirX;
currentY += dirY;
currentZ += dirZ;
int blockX = (int) Math.floor(currentX);
int blockY = (int) Math.floor(currentY);
int blockZ = (int) Math.floor(currentZ);
if (blockX >> 4 != chunkX || blockY >> 4 != chunkY || blockZ >> 4 != chunkZ) {
chunkX = blockX >> 4;
chunkY = blockY >> 4;
chunkZ = blockZ >> 4;
currentOcclusionView = snap.getChunkOcclusionView(chunkX, chunkY, chunkZ);
}
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded ++;
}
return occluded < maxOccluding;
}*/
/**
* The local spatial and chunk-section objects do not escape this method, so the JVM
* should be able to scalarise them while keeping the ray-stepping code easier to follow.
* A very fast, low-accuracy raycast
*/
public static boolean raycastUnrolledAccumulated(int maxOccluding, final int alwaysShowRadius, final int maxRaycastRadius, boolean debug,
final float stepSize, final BlockView snap, final Spatial start, final Spatial end) {
RayPosition current = RayPosition.from(start);
RayDirection direction = RayDirection.from(end, current);
double total = direction.getLengthAndNormalise(stepSize);
if (total <= alwaysShowRadius) return true;
if (total > maxRaycastRadius) return false;
float finalDist = (float) (total - stepSize);
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(current, direction, snap);
final RayAdvancer rayAdvancer = new RayAdvancer(startX, startY, startZ, RayDirection.ofDirection(dirX, dirY, dirZ), snap);
int remainingSteps = maxSteps;
float traveled = 0;
final float fourSteps = stepSize * 4.0f;
while (traveled + fourSteps <= finalDist) {
while (remainingSteps >= 4) {
rayAdvancer.advance();
rayAdvancer.advance();
rayAdvancer.advance();
rayAdvancer.advance();
if (rayAdvancer.occluded >= maxOccluding) return false;
traveled += fourSteps;
remainingSteps -= 4;
if (rayAdvancer.occluded > maxOccluding) return (maxSteps - remainingSteps);
}
for (; traveled < finalDist; traveled += stepSize) {
rayAdvancer.advance();
}
return rayAdvancer.occluded < maxOccluding;
return maxSteps;
}
private static final class RayAdvancer {
private final RayPosition current;
private static sealed class RayAdvancer extends RayPosition permits DebugRayAdvancer {
private final RayDirection direction;
private final RayChunkSection currentChunk;
private final BlockView blockView;
private int chunkX, chunkY, chunkZ;
private ChunkOcclusionView currentOcclusionView;
private int occluded = 0;
private RayAdvancer(RayPosition rayPosition, RayDirection rayDirection, BlockView blockView) {
current = rayPosition;
direction = rayDirection;
currentChunk = new RayChunkSection().updateFrom(current);
currentOcclusionView = blockView.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
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;
}
private void advance() {
current.advance(direction);
int blockX = current.blockX();
int blockY = current.blockY();
int blockZ = current.blockZ();
if (blockX >> 4 != currentChunk.chunkX || blockY >> 4 != currentChunk.chunkY || blockZ >> 4 != currentChunk.chunkZ) {
currentChunk.updateFrom(current);
currentOcclusionView = blockView.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
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 (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded++;
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 final class RayPosition {
private double x, y, z;
private void advance(RayDirection direction) {
x += direction.x;
y += direction.y;
z += direction.z;
}
private int blockX() {
return (int) Math.floor(x);
}
private int blockY() {
return (int) Math.floor(y);
}
private int blockZ() {
return (int) Math.floor(z);
}
private int chunkX() {
return blockX() >> 4;
}
private int chunkY() {
return blockY() >> 4;
}
private int chunkZ() {
return blockZ() >> 4;
}
private static sealed class RayPosition permits RayAdvancer {
double x, y, z;
private RayPosition(double x, double y, double z) {
this.x = x;
@@ -283,8 +150,22 @@ public class RaycastUtil {
this.z = z;
}
private static RayPosition from(Spatial spatial) {
return new RayPosition(spatial.x(), spatial.y(), spatial.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);
}
}
@@ -297,28 +178,25 @@ public class RaycastUtil {
this.z = z;
}
private static RayDirection from(Spatial end, RayPosition start) {
return new RayDirection(end.x() - start.x, end.y() - start.y, end.z() - start.z);
private 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 double getLengthAndNormalise(float stepSize) {
double len = Math.sqrt(x * x + y * y + z * z);
x = (x / len) * stepSize;
y = (y / len) * stepSize;
z = (z / len) * stepSize;
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;
}
}
private static final class RayChunkSection {
private int chunkX, chunkY, chunkZ;
private RayChunkSection updateFrom(RayPosition other) {
this.chunkX = other.chunkX();
this.chunkY = other.chunkY();
this.chunkZ = other.chunkZ();
return this;
}
}
}
@@ -1,12 +1,12 @@
/*
* 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;
package games.cubi.raycastedantiesp.core.tracked;
import games.cubi.logs.Logger;
import org.jetbrains.annotations.Nullable;
@@ -1,12 +1,12 @@
/*
* 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;
package games.cubi.raycastedantiesp.core.tracked;
import games.cubi.logs.Logger;
import org.jetbrains.annotations.Nullable;
@@ -1,19 +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.MutableFloatingSpatial;
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;
@@ -276,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());
@@ -315,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);
@@ -440,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() +
'}';
@@ -451,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,23 +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.
* 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;
@@ -32,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);
}
@@ -40,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);
}
@@ -55,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,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.tracked;
@@ -1,15 +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.
* 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;
@@ -17,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,48 +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 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,16 +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;
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,100 +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 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,19 +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.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,293 +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 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,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,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,111 +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 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,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,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,30 +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 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,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;
@@ -19,9 +19,9 @@ 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;
@@ -37,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;
/**
@@ -158,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);
}
}
@@ -168,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);
}
}
@@ -191,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,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;
@@ -15,7 +15,7 @@ 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;
@@ -55,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);
@@ -111,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,19 +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.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,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;
@@ -11,7 +11,7 @@ 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;
@@ -45,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);
@@ -86,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,20 +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.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,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.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;
@@ -28,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");
@@ -91,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;
@@ -115,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; }
@@ -136,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;
@@ -159,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,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.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;
@@ -28,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");
@@ -95,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;
@@ -112,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; }
@@ -146,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,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;
@@ -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.chunks;
@@ -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.chunks;
@@ -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.chunks;
@@ -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) {
@@ -253,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.
@@ -336,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;
}
@@ -420,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));
}
}
@@ -429,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);
@@ -445,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);
}
@@ -481,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);
@@ -630,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());
@@ -665,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);
@@ -684,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);
@@ -714,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;
}
@@ -747,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) {
@@ -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.chunks;
@@ -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.engine;
@@ -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;
@@ -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;
@@ -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.raycast;
@@ -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.tracked;
import games.cubi.raycastedantiesp.core.utils.Clearable;
import games.cubi.utils.Clearable;
import org.junit.jupiter.api.Test;
import java.time.Duration;
@@ -19,6 +19,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -87,6 +89,27 @@ class NettyEntityTrackedStateTest {
});
}
@Test
void relationshipSnapshotsRemainDefensiveWhileInternalAccessorsDoNotCopy() {
TestEntity entity = new TestEntity();
entity.setPassengerIDs(new int[]{2, 3});
entity.addLeashedEntity(4);
int[] passengerSnapshot = entity.passengerIDs();
int[] passengerInternal = entity.passengerIDsNoAlloc();
assertNotSame(passengerSnapshot, passengerInternal);
passengerSnapshot[0] = 99;
assertEquals(2, passengerInternal[0]);
assertSame(passengerInternal, entity.passengerIDsNoAlloc());
int[] leashSnapshot = entity.leashedEntityIDsOrNull();
int[] leashInternal = entity.leashedEntityIDsOrNullNoAlloc();
assertNotSame(leashSnapshot, leashInternal);
leashSnapshot[0] = 99;
assertEquals(4, leashInternal[0]);
assertSame(leashInternal, entity.leashedEntityIDsOrNullNoAlloc());
}
private static final class TestEntity extends NettyEntity<Clearable> {
private TestEntity() {
super(null, 0, 0, 0, 1, UUID.randomUUID(), false, 0, true);
@@ -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,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,13 +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.utils;
import games.cubi.utils.lists.InvasivelyLinkedSWMRList;
import org.junit.jupiter.api.Test;
import java.util.Iterator;
@@ -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;
Loaded 100 of 159 files, more files were not shown because too many files have changed in this diff. Show more