Compare commits

..
78 Commits
Author SHA1 Message Date
Cubicake 5b207a9ecd Update FUNDING.yml 2026-10-22 14:12:11 +10:30
Cubicake d90ac06a63 Merge remote-tracking branch 'origin/main' 2026-10-05 21:35:26 +10:30
Cubicake 77237fde49 Fix #94 2026-10-05 21:35:17 +10:30
Cubicake 40ae58b7ee Fix test 2026-10-05 21:32:14 +10:30
Cubicake 02c24527ef Don't hide sounds by default (not like this does anything rn) 2026-10-05 18:15:27 +10:30
Cubicake c9f374e074 Don't hide sounds by default (not like this does anything rn) 2026-10-05 18:05:14 +10:30
Cubicake 2cb0a46917 Merge pull request #95 from Cubicake/v2/more-config-reworking
Rework config
2026-10-05 18:01:26 +10:30
Cubicake d6818e579d fix submodules 2026-10-05 17:57:04 +10:30
Cubicake 807477712d Update pointers 2026-10-05 17:26:59 +10:30
Cubicake 6073e634c4 Finish config migration 2026-10-05 17:26:52 +10:30
Cubicake ad707b7158 Rebase 2026-10-05 17:26:42 +10:30
Cubicake 3ebb4a9138 Doc update 2026-10-05 17:25:33 +10:30
Cubicake ca8bb02010 Remove unused 2026-10-05 17:25:33 +10:30
Cubicake c393d502bd Match config entries to block data 2026-10-05 17:25:33 +10:30
Cubicake f032a12a66 Match config entries to block data 2026-10-05 17:25:33 +10:30
Cubicake fd343fc9b3 More transferring to idiomatic Configurate 2026-10-05 17:25:33 +10:30
Cubicake 21653da4f9 More transferring to idiomatic Configurate 2026-10-05 17:25:32 +10:30
Cubicake c42f008fa0 Begin transferring to idiomatic Configurate 2026-10-05 17:25:32 +10:30
Cubicake 1fcec23a57 Allow searching bukkit from console 2026-09-16 16:30:22 +09:30
Cubicake 37c905eb8c Remove unnecessary allocs 2026-09-07 18:05:45 +09:30
Cubicake 516b5df1d3 PrimitiveIntArrayList.remove does not mutate the provided array 2026-09-07 17:51:31 +09:30
Cubicake 914779f3e0 Remove utterly pointless overload 2026-09-07 17:49:22 +09:30
Cubicake 7c16afccb3 Remove unused EntityViewTransition and BlockViewTransition 2026-09-07 15:21:53 +09:30
Cubicake a49213e054 Remove unused constants 2026-09-07 15:04:29 +09:30
Cubicake 6877911210 Make it more compact 2026-09-07 14:59:53 +09:30
Cubicake 006ac0ba7a Update imports and move entity spawn tasks 2026-09-07 14:54:04 +09:30
Cubicake f92de7631b Move more util classes to games.cubi.util 2026-09-07 14:53:24 +09:30
Cubicake a6903ebffd Move more util classes to games.cubi.util 2026-09-07 11:52:14 +09:30
Cubicake d01e202401 Move util classes to games.cubi.util 2026-09-07 11:43:20 +09:30
Cubicake 71406b5803 Avoid allocating pointless arrays 2026-09-07 11:37:04 +09:30
Cubicake 30a9a73e25 PrimitiveIntArrayList.toString() is already null-guarded 2026-09-07 11:20:01 +09:30
Cubicake e982cb4550 probably pointless but why not make this private 2026-09-06 19:53:55 +09:30
Cubicake 37514fa879 Remove unused and misleading method 2026-09-06 17:48:54 +09:30
Cubicake 6eee4351ab ImplementationRegistry 2026-09-06 17:02:23 +09:30
Cubicake 1f0cb15714 Disable block chunk parsers since they currently use more memory and cpu for no gain. 2026-09-06 16:53:44 +09:30
Cubicake 367976e51f StrokkCommands 2.3.0: Nicer benchmark command syntax 2026-09-02 21:52:38 +09:30
Cubicake c4c3c498c2 Bump StrokkCommands 2026-09-01 22:54:54 +09:30
Cubicake c29667aae0 Make copyright headers more readable 2026-08-31 19:19:46 +09:30
Cubicake 558e773085 Make copyright headers more readable 2026-08-31 19:11:50 +09:30
Cubicake 30b123ba3c Cache a player data array 2026-08-30 16:31:25 +09:30
Cubicake 87fd94baf4 Rename getInstance to get 2026-08-30 13:44:18 +09:30
Cubicake 1e5a4eb95b Merge remote-tracking branch 'origin/main' 2026-08-28 21:43:36 +09:30
Cubicake 981b375d6d This way even if you leave a trailing "." it resolves correctly (resolves #90) 2026-08-28 21:43:11 +09:30
Cubicake 6de11030b0 Bump version 2026-08-26 21:04:42 +09:30
Cubicake d445aa58ba Resolve #88 for blocks too 2026-08-25 20:08:32 +09:30
Cubicake 49311be791 Properly precompute hideOnSpawnDistanceSquared 2026-08-25 19:53:19 +09:30
Cubicake 0b4df5124b Do not send unrelated packets in a bundle (#88) 2026-08-25 19:52:45 +09:30
Cubicake 4435058373 Do not send unrelated packets in a bundle (#88) 2026-08-25 19:46:20 +09:30
Cubicake 4dfed55d48 Add clientVisible tracking 2026-08-23 14:56:47 +09:30
Cubicake c2b6941922 Add clientVisible tracking 2026-08-23 14:51:49 +09:30
Cubicake feb80bf678 Update submodules 2026-08-23 11:41:25 +09:30
Cubicake c4fd919a08 Update submodules 2026-08-22 12:18:26 +09:30
Cubicake 40f91482d4 Don't step into the final block 2026-08-22 12:13:49 +09:30
Cubicake 3f82330433 Match the other change 2026-08-21 19:24:16 +09:30
Cubicake 8cfe2b0a2e Mark barrier as non-occluding 2026-08-21 19:05:04 +09:30
Cubicake f2c1d01051 Don't count the block it first hits as solid 2026-08-21 17:59:50 +09:30
Cubicake e1d0db9d5f oops 2026-08-21 17:51:46 +09:30
Cubicake a86a9bc4c0 Merge remote-tracking branch 'origin/main' 2026-08-21 17:46:06 +09:30
Cubicake 377c12a00a Final cleanup 2026-08-21 17:45:45 +09:30
Cubicake 9bc14b2097 Slightly faster; less arithmetic 2026-08-21 17:37:41 +09:30
Cubicake 02f9df6643 Simplify and seal code 2026-08-21 17:29:00 +09:30
Cubicake e2af9f65c1 Remove unused param 2026-08-21 17:21:58 +09:30
Cubicake 0eb1766a4a Switch to faster method for everything 2026-08-21 17:21:29 +09:30
Cubicake 4a3f25045f Add AsyncEngine class to log
#86
2026-08-21 14:27:48 +09:30
Cubicake 0c80348416 Do not log every npc/hologram spawn
#86
2026-08-21 14:21:10 +09:30
Cubicake 4295d2fe8a Better benchmarking 2026-08-20 22:20:39 +09:30
Cubicake 3f8ccff505 It gets even faster somehow 2026-08-20 22:20:21 +09:30
Cubicake bc440490f9 Reduce division ops 2026-08-20 17:11:02 +09:30
Cubicake 5527e38ea4 Actually no-alloc now (faster too) 2026-08-17 23:00:27 +09:30
Cubicake 244fde97c0 Merge remote-tracking branch 'origin/main' 2026-08-16 20:49:37 +09:30
Cubicake 8b3a62f1f5 So so much easier to read, same perf (well 2ns slower in testing but probably run-to-run variance) 2026-08-16 20:48:09 +09:30
Cubicake 45d0e0581c Update README.md 2026-08-15 17:37:06 +09:30
Cubicake aa7934f258 Rewrite existing configs to set it to false 2026-08-13 17:26:56 +09:30
Cubicake cfdb255b56 Set sound-effect check to false by default 2026-08-13 16:54:42 +09:30
Cubicake 14e6aaaae6 Might as well keep this debugging code in case future issues occur (Added to diagnose RoseStacker issue) 2026-08-13 16:54:11 +09:30
Cubicake d7cc7abd8c Cover all run types 2026-08-13 16:51:28 +09:30
Cubicake 73e58e191e oops 2026-08-13 16:48:38 +09:30
Cubicake e5a591af1a Add worldless particle spawn 2026-08-11 17:27:31 +09:30
182 changed files with 3440 additions and 2724 deletions

No files matched your search

+2 -2
View File
@@ -3,7 +3,7 @@
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: cubicake
ko_fi: #cubicake
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
@@ -12,4 +12,4 @@ lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cl
polar: # Replace with a single Polar username
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
thanks_dev: # Replace with a single thanks.dev username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
custom: ['https://cubi.games/donate/variable']# Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
+3 -3
View File
@@ -118,9 +118,9 @@ gradle-app.setting
**/build/
# Common working directory
run/
runs/
run-1-21-11/
run*/
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
# Libraries are supposed to be committed
!libraries/*/*
+1 -1
View File
@@ -13,7 +13,7 @@ The supported minecraft versions are 1.21.4+. Only Paper and derivative software
- Prevent cheating (anti-esp hacks)
- This is the plugin's primary purpose.
- Block usage of pie-ray to locate underground bases or farms.
- Prevent mods such as mini-maps or cheat clients from displaying the locations of hidden entities.
- Prevent mods such as mini-maps or cheat clients from displaying the locations of entities which would not be visible to vanilla players.
- Increase client-side performance for low-end devices
- Massive megabases containing hundreds of armour stands, item frames, banners etc can cause performance issues on low-end devices unable to process so many entities. Raycasted AntiESP will cull those entities for the client, reducing the number of entities to process.
- Reduce network load by limiting packets
+1
View File
@@ -0,0 +1 @@
extra["patchedConfigurateYaml"] = files("libraries/configurate-yaml/yaml-4.3.0-SNAPSHOT-cubi.jar")
+9 -5
View File
@@ -1,17 +1,20 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright © 2026 Cubicake.
* This file is part of RaycastedAntiESP.
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 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
import org.gradle.api.file.FileCollection
plugins {
id("java-library")
}
val patchedConfigurateYaml = rootProject.extra["patchedConfigurateYaml"] as FileCollection
repositories {
mavenCentral()
maven { url = uri("https://repo.codemc.io/repository/maven-releases/") }
@@ -20,7 +23,7 @@ repositories {
dependencies {
compileOnly("org.spongepowered:configurate-core:4.2.0")
compileOnly("org.spongepowered:configurate-yaml:4.2.0")
compileOnly(patchedConfigurateYaml)
compileOnly("it.unimi.dsi:fastutil:8.5.18")
implementation(project(":locatables"))
@@ -33,12 +36,13 @@ dependencies {
testImplementation(project(":leafpile"))
testImplementation(project(":logging"))
testImplementation("org.spongepowered:configurate-core:4.2.0")
testImplementation(patchedConfigurateYaml)
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
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,26 +1,22 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright © 2026 Cubicake.
* This file is part of RaycastedAntiESP.
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 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;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;
public record BlockProcessorConfig(BlockProcessorMode mode, boolean trackAllBlocks) implements Config {
public static BlockProcessorConfig load(ConfigurationNode root) {
ConfigurationNode node = ConfigReader.node(root, "block-processor");
String modeName = ConfigReader.string(ConfigReader.node(node, "mode"), "block-processor.mode");
BlockProcessorMode mode = BlockProcessorMode.fromString(modeName);
if (mode == null) {
throw new ConfigLoadException("block-processor.mode has unsupported value '" + modeName + "'");
}
return new BlockProcessorConfig(
mode,
ConfigReader.bool(ConfigReader.node(node, "track-all-blocks"), "block-processor.track-all-blocks")
);
}
@ConfigSerializable
public record BlockProcessorConfig(
@Comment("Block processor implementation used by the plugin.")
BlockProcessorMode mode,
@Comment("Track every block rather than only tile entities.")
boolean trackAllBlocks
) implements Config {
public static final BlockProcessorConfig DEFAULT = new BlockProcessorConfig(BlockProcessorMode.PACKETEVENTS, false);
}
@@ -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;
@@ -13,19 +13,24 @@ 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 org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Setting;
public record ChecksConfig(PlayerConfig playerConfig, EntityConfig entityConfig, TileEntityConfig tileEntityConfig, SoundEffectsConfig soundEffectsConfig, ChunkSectionConfig chunkSectionConfig) implements Config {
public static ChecksConfig load(ConfigurationNode root) {
ConfigurationNode checks = ConfigReader.node(root, "checks");
return new ChecksConfig(
PlayerConfig.load(ConfigReader.node(checks, "player"), "checks.player"),
EntityConfig.load(ConfigReader.node(checks, "entity"), "checks.entity"),
TileEntityConfig.load(ConfigReader.node(checks, "tile-entity"), "checks.tile-entity"),
SoundEffectsConfig.load(ConfigReader.node(checks, "sound-effects"), "checks.sound-effects"),
ChunkSectionConfig.load(ConfigReader.node(checks, "chunk-section"), "checks.chunk-section")
);
}
@ConfigSerializable
public record ChecksConfig(
@Setting("player") PlayerConfig playerConfig,
@Setting("entity") EntityConfig entityConfig,
@Setting("tile-entity") TileEntityConfig tileEntityConfig,
@Setting("sound-effects") SoundEffectsConfig soundEffectsConfig,
@Setting("chunk-section") ChunkSectionConfig chunkSectionConfig
) implements Config {
public static final ChecksConfig DEFAULT = new ChecksConfig(
PlayerConfig.DEFAULT,
EntityConfig.DEFAULT,
TileEntityConfig.DEFAULT,
SoundEffectsConfig.DEFAULT,
ChunkSectionConfig.DEFAULT
);
public boolean hasEnabledStatusChanges(ChecksConfig startup) {
return playerConfig.enabled() != startup.playerConfig.enabled()
@@ -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;
@@ -0,0 +1,327 @@
package games.cubi.raycastedantiesp.core.config;
import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.NodePath;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* A mutable configuration under preparation, separate from the active runtime snapshot.
* Used only during a load or edit; ConfigManager owns synchronization, persistence, and publication.
*/
final class ConfigCandidate {
private final CommentedConfigurationNode node;
private final CommentedConfigurationNode defaults;
private final List<Repair> repairs = new ArrayList<>();
private boolean dirty;
ConfigCandidate(CommentedConfigurationNode node, CommentedConfigurationNode defaults) {
this.node = node;
this.defaults = defaults;
dirty |= ConfigMigration.migrate(node);
dirty |= ConfigMapping.removeDuplicateHeader(node);
mergeDefaults();
}
CommentedConfigurationNode node() {
return node;
}
List<Repair> repairs() {
return repairs;
}
boolean isDirty() {
return dirty;
}
void markDirty() {
dirty = true;
}
boolean hasDefault(NodePath path) {
return !defaults.node(path.array()).virtual();
}
void mergeDefaults() {
dirty |= mergeMissing(defaults, node);
}
LoggingConfig parseLoggingConfig() {
return deserializeWithRepairs(NodePath.path("logging"), LoggingConfig.class);
}
RootConfig parseReadyConfig() {
// Hiding sounds from hidden entities is currently unsupported; persist the false defaults.
for (String section : List.of("player", "entity")) {
repair(NodePath.path("checks", section, "hide-sounds-when-hidden"), "hiding sounds from hidden entities is currently unsupported");
}
int attemptsRemaining = Math.max(2, countLeaves(defaults) + 1);
while (attemptsRemaining-- > 0) {
RootConfig root = deserializeWithRepairs(NodePath.path(), RootConfig.class);
if (!RootConfig.CURRENT_VERSION.equals(root.configVersion())) {
throw ConfigMigration.unsupportedVersion(root.configVersion());
}
List<AbsoluteViolation> violations = validate(root);
if (violations.isEmpty()) {
canonicalizeEnums(root);
return root;
}
boolean repaired = false;
for (AbsoluteViolation violation : violations) {
repaired |= repair(violation.path, violation.message);
}
if (!repaired) {
throw new ConfigLoadException("Configuration validation failed without a repairable default");
}
}
throw new ConfigLoadException("Configuration could not be repaired after exhausting the available defaults");
}
private void canonicalizeEnums(RootConfig root) {
canonicalizeValue(NodePath.path("engine", "mode"), root.engineConfig().mode().getName());
canonicalizeValue(NodePath.path("block-processor", "mode"), root.blockProcessorConfig().mode().getName());
}
private void canonicalizeValue(NodePath path, String value) {
ConfigurationNode target = node.node(path.array());
if (!Objects.equals(target.raw(), value)) {
target.raw(value);
dirty = true;
}
}
private <T> T deserializeWithRepairs(NodePath mappingPath, Class<T> type) {
int attemptsRemaining = Math.max(1, countLeaves(defaults.node(mappingPath.array())) + 1);
while (attemptsRemaining-- > 0) {
try {
T value = node.node(mappingPath.array()).get(type);
if (value == null) {
throw new ConfigLoadException("Configuration mapper returned null for " + pathToString(mappingPath));
}
return value;
} catch (SerializationException exception) {
boolean repaired = false;
for (SerializationException failure : leafFailures(exception)) {
NodePath failurePath = normalizePath(failure.path(), mappingPath);
repaired |= repair(failurePath, failure.rawMessage());
}
if (!repaired) {
throw new ConfigLoadException("Invalid configuration at " + pathToString(mappingPath), exception);
}
}
}
throw new ConfigLoadException("Configuration at " + pathToString(mappingPath) + " could not be repaired");
}
private List<AbsoluteViolation> validate(RootConfig root) {
List<AbsoluteViolation> violations = new ArrayList<>();
if (!root.blockProcessorConfig().trackAllBlocks() && root.checksConfig().chunkSectionConfig().enabled()) {
violations.add(new AbsoluteViolation(
NodePath.path("checks", "chunk-section", "enabled"),
"must be false when block-processor.track-all-blocks is false"
));
}
return violations;
}
boolean repair(NodePath failedPath, String reason) {
NodePath repairPath = findRepairPath(failedPath);
if (repairPath == null) {
return false;
}
ConfigurationNode target = node.node(repairPath.array());
ConfigurationNode replacement = defaults.node(repairPath.array());
if (Objects.equals(target.raw(), replacement.raw())) {
return false;
}
String existingComment = target instanceof CommentedConfigurationNode commented ? commented.comment() : null;
target.from(replacement);
copyComments(replacement, target);
if (existingComment != null && target instanceof CommentedConfigurationNode commented) {
commented.comment(existingComment);
}
dirty = true;
repairs.add(new Repair(repairPath, reason, replacement.raw()));
return true;
}
private NodePath findRepairPath(NodePath failedPath) {
Object[] parts = failedPath.array();
for (int index = 0; index < parts.length; index++) {
if (parts[index] instanceof Number) {
parts = Arrays.copyOf(parts, index);
break;
}
}
for (int length = parts.length; length >= 0; length--) {
NodePath candidate = NodePath.path(Arrays.copyOf(parts, length));
if (!defaults.node(candidate.array()).virtual()) {
return candidate;
}
}
return null;
}
private List<SerializationException> leafFailures(SerializationException root) {
List<SerializationException> failures = new ArrayList<>();
ArrayDeque<SerializationException> pending = new ArrayDeque<>();
pending.add(root);
while (!pending.isEmpty()) {
SerializationException current = pending.removeFirst();
boolean hasNested = false;
for (Throwable suppressed : current.getSuppressed()) {
if (suppressed instanceof SerializationException nested) {
pending.addLast(nested);
hasNested = true;
}
}
if (!hasNested) {
failures.add(current);
}
}
return failures;
}
private NodePath normalizePath(NodePath failurePath, NodePath mappingPath) {
if (failurePath == null || failurePath.size() == 0) {
return mappingPath;
}
if (startsWith(failurePath, mappingPath)) {
return failurePath;
}
return mappingPath.plus(failurePath);
}
private boolean startsWith(NodePath path, NodePath prefix) {
if (prefix.size() > path.size()) {
return false;
}
for (int index = 0; index < prefix.size(); index++) {
if (!Objects.equals(path.get(index), prefix.get(index))) {
return false;
}
}
return true;
}
private boolean mergeMissing(ConfigurationNode defaults, ConfigurationNode target) {
if (target.virtual() || target.raw() == null && target.childrenMap().isEmpty() && target.childrenList().isEmpty()) {
target.from(defaults);
copyComments(defaults, target);
return true;
}
boolean changed = mergeComment(defaults, target);
if (!defaults.childrenMap().isEmpty()) {
Object raw = target.raw();
if (target.childrenMap().isEmpty() && !(raw instanceof Map<?, ?>)) {
return repair(target.path(), "expected a mapping");
}
for (Map.Entry<Object, ? extends ConfigurationNode> entry : defaults.childrenMap().entrySet()) {
changed |= mergeMissing(entry.getValue(), target.node(entry.getKey()));
}
} else if (!defaults.childrenList().isEmpty() && target.isList()) {
// Entries can be reordered or removed, so default comments must follow values rather than indices.
Map<String, ConfigurationNode> commentedDefaults = new LinkedHashMap<>();
for (ConfigurationNode child : defaults.childrenList()) {
if (child.rawScalar() instanceof String value && child instanceof CommentedConfigurationNode commented && commented.comment() != null) {
commentedDefaults.put(value, child);
}
}
for (ConfigurationNode child : target.childrenList()) {
if (child.rawScalar() instanceof String value) {
ConfigurationNode defaultChild = commentedDefaults.get(value);
if (defaultChild != null) {
changed |= mergeComment(defaultChild, child);
}
}
}
}
return changed;
}
private boolean mergeComment(ConfigurationNode defaults, ConfigurationNode target) {
if (!(defaults instanceof CommentedConfigurationNode defaultCommented) || !(target instanceof CommentedConfigurationNode targetCommented)) {
return false;
}
if (targetCommented.comment() == null && defaultCommented.comment() != null) {
targetCommented.comment(defaultCommented.comment());
return true;
}
return false;
}
private void copyComments(ConfigurationNode source, ConfigurationNode target) {
if (source instanceof CommentedConfigurationNode sourceCommented
&& target instanceof CommentedConfigurationNode targetCommented
&& sourceCommented.comment() != null) {
targetCommented.commentIfAbsent(sourceCommented.comment());
}
for (Map.Entry<Object, ? extends ConfigurationNode> entry : source.childrenMap().entrySet()) {
copyComments(entry.getValue(), target.node(entry.getKey()));
}
List<? extends ConfigurationNode> sourceChildren = source.childrenList();
List<? extends ConfigurationNode> targetChildren = target.childrenList();
for (int index = 0; index < Math.min(sourceChildren.size(), targetChildren.size()); index++) {
copyComments(sourceChildren.get(index), targetChildren.get(index));
}
}
private int countLeaves(ConfigurationNode node) {
if (node.childrenMap().isEmpty() && node.childrenList().isEmpty()) {
return 1;
}
int count = 0;
for (ConfigurationNode child : node.childrenMap().values()) {
count += countLeaves(child);
}
for (ConfigurationNode child : node.childrenList()) {
count += countLeaves(child);
}
return Math.max(1, count);
}
private static String pathToString(NodePath path) {
if (path.size() == 0) {
return "<root>";
}
StringBuilder result = new StringBuilder();
for (Object part : path) {
if (part instanceof Number) {
result.append('[').append(part).append(']');
} else {
if (!result.isEmpty()) {
result.append('.');
}
result.append(part);
}
}
return result.toString();
}
record Repair(NodePath path, String reason, Object defaultValue) {
Repair {
path = path.copy();
}
String pathString() {
return pathToString(path);
}
}
private record AbsoluteViolation(NodePath path, String message) {
}
}
@@ -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,21 +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.config;
import org.spongepowered.configurate.ConfigurationNode;
public interface ConfigExtension<T extends Config> {
Class<T> type();
T load(ConfigurationNode config, BlockProcessorConfig blockProcessorConfig);
default boolean requiresRestart(T startupConfig, T nextConfig) {
return !startupConfig.equals(nextConfig);
}
}
@@ -0,0 +1,78 @@
package games.cubi.raycastedantiesp.core.config;
import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.loader.HeaderMode;
import org.spongepowered.configurate.serialize.SerializationException;
import org.spongepowered.configurate.yaml.NodeStyle;
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
import java.io.IOException;
import java.nio.file.AtomicMoveNotSupportedException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Objects;
/** Owns YAML loading, default-node creation, and replacement of config.yml through a temporary file. */
final class ConfigFile {
private final Path dataFolder;
private final Path configPath;
private final YamlConfigurationLoader loader;
ConfigFile(Path dataFolder) {
this.dataFolder = Objects.requireNonNull(dataFolder, "dataFolder");
configPath = dataFolder.resolve("config.yml");
loader = createLoader(configPath);
}
private YamlConfigurationLoader createLoader(Path path) {
return YamlConfigurationLoader.builder()
.path(path)
.nodeStyle(NodeStyle.BLOCK)
.headerMode(HeaderMode.PRESERVE)
.defaultOptions(ConfigMapping.options())
.build();
}
CommentedConfigurationNode createDefaultNode() {
CommentedConfigurationNode defaults = loader.createNode();
try {
defaults.set(RootConfig.class, RootConfig.DEFAULT);
} catch (SerializationException e) {
throw new ConfigLoadException("Code-defined configuration defaults could not be serialized", e);
}
return defaults;
}
CommentedConfigurationNode load() {
try {
Files.createDirectories(dataFolder);
return Files.exists(configPath) ? loader.load() : loader.createNode();
} catch (IOException e) {
throw new ConfigLoadException("Failed to load config.yml", e);
}
}
void save(CommentedConfigurationNode node) {
Path temporaryPath = null;
try {
temporaryPath = Files.createTempFile(dataFolder, "config-", ".yml.tmp");
createLoader(temporaryPath).save(node);
try {
Files.move(temporaryPath, configPath, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
} catch (AtomicMoveNotSupportedException exception) {
Files.move(temporaryPath, configPath, StandardCopyOption.REPLACE_EXISTING);
}
temporaryPath = null;
} catch (IOException e) {
throw new ConfigLoadException("Failed to save config.yml", e);
} finally {
if (temporaryPath != null) {
try {
Files.deleteIfExists(temporaryPath);
} catch (IOException ignored) {
}
}
}
}
}
@@ -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,103 +15,136 @@ 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.CommentedConfigurationNode;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.yaml.NodeStyle;
import org.spongepowered.configurate.ConfigurateException;
import org.spongepowered.configurate.NodePath;
import org.spongepowered.configurate.serialize.SerializationException;
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
import java.lang.invoke.VarHandle;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
import java.util.Set;
/**
* Coordinates startup, runtime edits, and publication of configuration snapshots.
* ConfigCandidate prepares values and repairs; ConfigFile handles persistence.
*/
public class ConfigManager {
private static final String REQUIRED_CONFIG_VERSION = "2.0";
private static ConfigManager instance;
private static volatile ConfigManager instance;
private static final VarHandle INSTANCE = VarHandler.$tatic(ConfigManager.class, "instance", ConfigManager.class);
private final Supplier<InputStream> resourceSupplier;
private final Path dataFolder;
private final Path configPath;
private final YamlConfigurationLoader loader;
private final List<ConfigExtension<? extends Config>> extensions;
private final ConfigFile configFile;
private ConfigurationNode config;
private volatile ActiveState activeState = new ActiveState(LoggingConfig.DEFAULT, null);
private static final VarHandle ACTIVE_STATE = VarHandler.get(ConfigManager.class, "activeState", ActiveState.class);
private RootConfig startupConfig;
private volatile RootConfig activeConfig; private static final VarHandle ACTIVE_CONFIG = VarHandler.get(ConfigManager.class, "activeConfig", RootConfig.class);
private CommentedConfigurationNode configNode;
private ConfigManager(Supplier<InputStream> resourceSupplier, Path dataFolder, List<ConfigExtension<? extends Config>> extensions) {
this.resourceSupplier = resourceSupplier;
this.dataFolder = dataFolder;
this.extensions = List.copyOf(extensions);
this.configPath = dataFolder.resolve("config.yml");
this.loader = YamlConfigurationLoader.builder()
.path(configPath)
.nodeStyle(NodeStyle.BLOCK)
.build();
load();
ConfigManager(Path dataFolder) {
configFile = new ConfigFile(dataFolder);
}
public static ConfigManager initialiseConfigManager(Supplier<InputStream> resourceSupplier, Path dataFolder, List<ConfigExtension<? extends Config>> extensions) {
if (instance == null) {
instance = new ConfigManager(resourceSupplier, dataFolder, extensions);
public static synchronized ConfigManager initialiseConfigManager(Path dataFolder) {
ConfigManager current = (ConfigManager) INSTANCE.getAcquire();
if (current == null) {
ConfigManager manager = new ConfigManager(dataFolder);
INSTANCE.setRelease(manager);
try {
manager.loadLoggingConfig();
} catch (RuntimeException exception) {
INSTANCE.setRelease(null);
throw exception;
}
current = manager;
}
return instance;
return current;
}
public static ConfigManager get() {
if (instance == null) {
ConfigManager current = (ConfigManager) INSTANCE.getAcquire();
if (current == null) {
Logger.errorAndReturn(new RuntimeException("ConfigManager accessed before being initiated. Please report this."), 2, ConfigManager.class);
}
return instance;
return current;
}
public void load() {
ensureConfigFileExists();
ConfigurationNode loaded = loadConfigNode();
ConfigurationNode defaults = loadBundledDefaults();
if (defaults != null && mergeMissing(defaults, loaded)) {
saveConfigNode(loaded);
}
RootConfig parsed = parse(loaded);
validateReload(parsed);
config = loaded;
if (startupConfig == null) {
startupConfig = parsed;
}
ACTIVE_CONFIG.setOpaque(this, parsed);
public static LoggingConfig getLoggingConfigOrDefault() {
ConfigManager current = (ConfigManager) INSTANCE.getAcquire();
return current == null ? LoggingConfig.DEFAULT : current.getLoggingConfig();
}
public SetConfigResult setConfigValue(String path, String rawValue) {
ConfigurationNode candidate = loadConfigNode();
ConfigurationNode target = node(candidate, path);
public synchronized void completeInitialLoad() {
if (startupConfig != null) {
throw new IllegalStateException("Configuration loading has already been completed");
}
ConfigCandidate candidate = prepare();
RootConfig ready = candidate.parseReadyConfig();
saveIfChanged(candidate);
startupConfig = ready;
configNode = candidate.node();
ACTIVE_STATE.setRelease(this, new ActiveState(ready.loggingConfig(), ready));
logRepairs(candidate.repairs());
}
/**
* Reloads the complete configuration. The active snapshot is replaced only after parsing and validation succeed.
*/
public synchronized void load() {
requireReady();
ConfigCandidate candidate = prepare();
RootConfig ready = candidate.parseReadyConfig();
saveIfChanged(candidate);
configNode = candidate.node();
logRepairs(candidate.repairs());
validateReload(ready);
ACTIVE_STATE.setRelease(this, new ActiveState(ready.loggingConfig(), ready));
}
public synchronized SetConfigResult setConfigValue(String path, String rawValue) {
requireReady();
ConfigCandidate candidate = prepare();
ConfigurationNode target = node(candidate.node(), path);
if (target.virtual()) {
return SetConfigResult.invalid("Unknown config path: " + path);
}
ConfigReader.setRaw(target, ConfigReader.parseRawValue(rawValue));
try {
Object parsedValue = parseRawValue(rawValue);
target.set(parsedValue);
candidate.markDirty();
NodePath targetPath = NodePath.path((Object[]) path.split("\\."));
if (parsedValue == null && candidate.hasDefault(targetPath)) {
candidate.repair(targetPath, "value cannot be null");
}
} catch (ConfigurateException e) {
return SetConfigResult.invalid("Invalid YAML value: " + rawValue);
}
return applyCandidate(candidate, false);
}
public SetConfigResult addConfigListValue(String path, String rawValue) {
public synchronized SetConfigResult addConfigListValue(String path, String rawValue) {
requireReady();
return mutateConfigListValue(path, rawValue, ListMutation.ADD);
}
public SetConfigResult removeConfigListValue(String path, String rawValue) {
public synchronized SetConfigResult removeConfigListValue(String path, String rawValue) {
requireReady();
return mutateConfigListValue(path, rawValue, ListMutation.REMOVE);
}
private SetConfigResult mutateConfigListValue(String path, String rawValue, ListMutation mutation) {
ConfigurationNode candidate = loadConfigNode();
ConfigurationNode target = node(candidate, path);
ConfigCandidate candidate = prepare();
ConfigurationNode target = node(candidate.node(), path);
if (target.virtual()) {
return SetConfigResult.invalid("Unknown config path: " + path);
}
@@ -124,7 +157,13 @@ public class ConfigManager {
return SetConfigResult.invalid(path + " is not a list path");
}
Object parsedValue = ConfigReader.parseRawValue(rawValue);
Object parsedValue;
try {
parsedValue = parseRawValue(rawValue);
} catch (ConfigurateException e) {
return SetConfigResult.invalid("Invalid YAML value: " + rawValue);
}
boolean changed = switch (mutation) {
case ADD -> {
if (values.contains(parsedValue)) {
@@ -135,113 +174,115 @@ public class ConfigManager {
}
case REMOVE -> values.remove(parsedValue);
};
if (!changed) {
return SetConfigResult.invalid("No change made for " + path);
}
ConfigReader.setRaw(target, values);
try {
target.set(values);
candidate.markDirty();
} catch (SerializationException e) {
return SetConfigResult.invalid("Failed to update " + path);
}
return applyCandidate(candidate, true);
}
private SetConfigResult applyCandidate(ConfigurationNode candidate, boolean allowRestartRequired) {
RootConfig parsed;
private SetConfigResult applyCandidate(ConfigCandidate candidate, boolean allowRestartRequired) {
candidate.mergeDefaults();
RootConfig ready;
try {
parsed = parse(candidate);
validateReload(parsed);
ready = candidate.parseReadyConfig();
validateReload(ready);
} catch (RestartRequiredException e) {
if (!allowRestartRequired) {
return SetConfigResult.invalid(e.getMessage());
}
config = candidate;
saveConfigNode(candidate);
return SetConfigResult.restartRequired(e.getMessage());
saveIfChanged(candidate);
configNode = candidate.node();
logRepairs(candidate.repairs());
return SetConfigResult.restartRequired(e.getMessage(), candidate.repairs());
} catch (ConfigLoadException e) {
return SetConfigResult.invalid(e.getMessage());
}
config = candidate;
ACTIVE_CONFIG.setOpaque(this, parsed);
saveConfigNode(candidate);
return SetConfigResult.ok();
saveIfChanged(candidate);
configNode = candidate.node();
ACTIVE_STATE.setRelease(this, new ActiveState(ready.loggingConfig(), ready));
logRepairs(candidate.repairs());
return SetConfigResult.ok(candidate.repairs());
}
public LoggingConfig getLoggingConfig() {
return ((ActiveState) ACTIVE_STATE.getAcquire(this)).loggingConfig;
}
public PlayerConfig getPlayerConfig() {
return activeConfig().checksConfig().playerConfig();
return requireReady().checksConfig().playerConfig();
}
public EntityConfig getEntityConfig() {
return activeConfig().checksConfig().entityConfig();
return requireReady().checksConfig().entityConfig();
}
public TileEntityConfig getTileEntityConfig() {
return activeConfig().checksConfig().tileEntityConfig();
return requireReady().checksConfig().tileEntityConfig();
}
public SoundEffectsConfig getSoundEffectsConfig() {
return activeConfig().checksConfig().soundEffectsConfig();
return requireReady().checksConfig().soundEffectsConfig();
}
public ChunkSectionConfig getChunkSectionConfig() {
return activeConfig().checksConfig().chunkSectionConfig();
return requireReady().checksConfig().chunkSectionConfig();
}
public DebugConfig getDebugConfig() {
RootConfig current = activeConfig();
return current == null ? null : current.debugConfig();
return requireReady().debugConfig();
}
public UpdateConfig getUpdateConfig() {
return activeConfig().updateConfig();
return requireReady().updateConfig();
}
public EngineConfig getEngineConfig() {
return activeConfig().engineConfig();
return requireReady().engineConfig();
}
public BlockProcessorConfig getBlockProcessorConfig() {
return activeConfig().blockProcessorConfig();
return requireReady().blockProcessorConfig();
}
public <T extends Config> T getExtensionConfig(Class<T> type) {
return activeConfig().extensionConfig(type);
}
private RootConfig activeConfig() {
return (RootConfig) ACTIVE_CONFIG.getOpaque(this);
}
public ConfigurationNode getConfigFile() {
return config;
}
public Map<String, Object> getConfigValues() {
public synchronized Map<String, Object> getConfigValues() {
requireReady();
Map<String, Object> values = new LinkedHashMap<>();
collectConfigValues(config, "", values);
return values;
collectConfigValues(configNode, "", values);
return Collections.unmodifiableMap(values);
}
private RootConfig parse(ConfigurationNode loaded) {
String version = ConfigReader.string(ConfigReader.node(loaded, "config-version"), "config-version");
if (!REQUIRED_CONFIG_VERSION.equals(version)) {
throw new ConfigLoadException("Unsupported config-version '" + version + "'. RaycastedAntiESP requires config-version '2.0'.");
}
void loadLoggingConfig() {
ConfigCandidate candidate = prepare();
LoggingConfig logging = candidate.parseLoggingConfig();
saveIfChanged(candidate);
configNode = candidate.node();
ACTIVE_STATE.setRelease(this, new ActiveState(logging, null));
logRepairs(candidate.repairs());
}
ChecksConfig checksConfig = ChecksConfig.load(loaded);
EngineConfig engineConfig = EngineConfig.load(loaded);
BlockProcessorConfig blockProcessorConfig = BlockProcessorConfig.load(loaded);
DebugConfig debugConfig = DebugConfig.load(loaded);
UpdateConfig updateConfig = UpdateConfig.load(loaded);
Map<Class<? extends Config>, Config> extensionConfigs = new LinkedHashMap<>();
for (ConfigExtension<? extends Config> extension : extensions) {
extensionConfigs.put(extension.type(), extension.load(loaded, blockProcessorConfig));
}
private ConfigCandidate prepare() {
return new ConfigCandidate(configFile.load(), configFile.createDefaultNode());
}
if (!blockProcessorConfig.trackAllBlocks() && checksConfig.chunkSectionConfig().enabled()) {
throw new ConfigLoadException("checks.chunk-section.enabled must be false when block-processor.track-all-blocks is false");
private void saveIfChanged(ConfigCandidate candidate) {
if (candidate.isDirty()) {
configFile.save(candidate.node());
}
}
return new RootConfig(version, checksConfig, engineConfig, blockProcessorConfig, debugConfig, updateConfig, Map.copyOf(extensionConfigs));
private Object parseRawValue(String rawValue) throws ConfigurateException {
ConfigurationNode parsed = YamlConfigurationLoader.builder()
.defaultOptions(ConfigMapping.options())
.buildAndLoadString("value: " + rawValue);
return parsed.node("value").raw();
}
private void validateReload(RootConfig next) {
@@ -257,20 +298,34 @@ public class ConfigManager {
if (!next.checksConfig().entityConfig().excludedTypes().equals(startupConfig.checksConfig().entityConfig().excludedTypes())) {
throw new RestartRequiredException("excluded entity types cannot be changed without a restart.");
}
if (!next.checksConfig().tileEntityConfig().excludedBlocks().equals(startupConfig.checksConfig().tileEntityConfig().excludedBlocks())) {
throw new RestartRequiredException("excluded tile-entity blocks cannot be changed without a restart.");
}
if (next.checksConfig().hasEnabledStatusChanges(startupConfig.checksConfig())) {
throw new RestartRequiredException("player and entity checks cannot be enabled or disabled without a restart.");
}
for (ConfigExtension<? extends Config> extension : extensions) {
validateExtensionReload(extension, next);
}
private RootConfig requireReady() {
RootConfig ready = ((ActiveState) ACTIVE_STATE.getAcquire(this)).readyConfig;
if (ready == null) {
throw new IllegalStateException("Configuration is not available until completeInitialLoad has finished");
}
return ready;
}
private void logRepairs(List<ConfigCandidate.Repair> repairs) {
for (ConfigCandidate.Repair repair : repairs) {
String reason = repair.reason() == null || repair.reason().isBlank() ? "invalid value" : repair.reason();
String message = "Invalid config value at " + repair.pathString() + ": " + reason
+ ". Replaced it with the default " + displayValue(repair.defaultValue()) + ".";
Logger.warning(message, 4, ConfigManager.class);
}
}
private <T extends Config> void validateExtensionReload(ConfigExtension<T> extension, RootConfig next) {
T startupExtensionConfig = startupConfig.extensionConfig(extension.type());
T nextExtensionConfig = next.extensionConfig(extension.type());
if (extension.requiresRestart(startupExtensionConfig, nextExtensionConfig)) {
throw new RestartRequiredException("block-processor." + extension.type().getSimpleName() + " cannot be changed without a restart");
}
private String displayValue(Object value) {
String displayed = String.valueOf(value);
return displayed.length() <= 160 ? displayed : displayed.substring(0, 157) + "...";
}
private void collectConfigValues(ConfigurationNode node, String path, Map<String, Object> values) {
@@ -280,103 +335,18 @@ public class ConfigManager {
}
return;
}
if (!node.childrenList().isEmpty()) {
values.put(path, node.childrenList().stream().map(ConfigurationNode::raw).toList());
return;
}
for (Map.Entry<Object, ? extends ConfigurationNode> entry : node.childrenMap().entrySet()) {
String key = String.valueOf(entry.getKey());
String nextPath = path.isEmpty() ? key : path + "." + key;
collectConfigValues(entry.getValue(), nextPath, values);
}
}
private void ensureConfigFileExists() {
try {
Files.createDirectories(dataFolder);
if (!Files.exists(configPath)) {
InputStream resource = resourceSupplier.get();
if (resource != null) {
try (resource) {
Files.copy(resource, configPath);
}
} else {
Files.createFile(configPath);
}
}
prependConfigDocumentationHeaderIfMissing();
} catch (IOException e) {
throw new ConfigLoadException("Failed to create config.yml", e);
}
}
private void prependConfigDocumentationHeaderIfMissing() {
try {
String content = Files.readString(configPath);
if (content.startsWith("#")) {
Logger.debug("Config starts with comment");
return;
}
Logger.debug("no starting comment");
Files.writeString(configPath, "# An explanation of this configuration file and what all the options do can be found at https://raycastedantiesp.cubi.games/config/" + System.lineSeparator() + content);
} catch (Exception e) {
Logger.warning(e,3, ConfigManager.class);
}
}
private ConfigurationNode loadConfigNode() {
try {
return loader.load();
} catch (IOException e) {
throw new ConfigLoadException("Failed to load config.yml", e);
}
}
private ConfigurationNode loadBundledDefaults() {
InputStream resource = resourceSupplier.get();
if (resource == null) {
return null;
}
try (resource) {
return YamlConfigurationLoader.builder()
.source(() -> new BufferedReader(new InputStreamReader(resource)))
.build()
.load();
} catch (IOException e) {
throw new ConfigLoadException("Failed to load bundled config defaults", e);
}
}
private boolean mergeMissing(ConfigurationNode defaults, ConfigurationNode target) {
if (target.virtual()) {
target.from(defaults);
return true;
}
boolean changed = false;
if (!defaults.childrenMap().isEmpty()) {
for (Map.Entry<Object, ? extends ConfigurationNode> entry : defaults.childrenMap().entrySet()) {
changed |= mergeMissing(entry.getValue(), target.node(entry.getKey()));
}
}
return changed;
}
private void saveConfigNode(ConfigurationNode node) {
try {
loader.save(node);
} catch (IOException e) {
throw new ConfigLoadException("Failed to save config.yml", e);
collectConfigValues(entry.getValue(), path.isEmpty() ? key : path + "." + key, values);
}
}
private ConfigurationNode node(ConfigurationNode root, String path) {
String[] parts = path.split("\\.");
return ConfigReader.node(root, parts);
return root.node((Object[]) path.split("\\."));
}
private enum ListMutation {
@@ -384,23 +354,38 @@ public class ConfigManager {
REMOVE
}
private record ActiveState(LoggingConfig loggingConfig, RootConfig readyConfig) {
}
private static final class RestartRequiredException extends ConfigLoadException {
private RestartRequiredException(String message) {
super(message);
}
}
public record SetConfigResult(boolean success, boolean restartRequired, String message) {
public static SetConfigResult ok() {
return new SetConfigResult(true, false, "Config value updated.");
public record SetConfigResult(boolean success, boolean restartRequired, boolean repaired, String message) {
private static SetConfigResult ok(List<ConfigCandidate.Repair> repairs) {
if (repairs.isEmpty()) {
return new SetConfigResult(true, false, false, "Config value updated.");
}
return new SetConfigResult(true, false, true, repairMessage(repairs));
}
public static SetConfigResult restartRequired(String message) {
return new SetConfigResult(true, true, message);
private static SetConfigResult restartRequired(String message, List<ConfigCandidate.Repair> repairs) {
String result = repairs.isEmpty() ? message : message + " " + repairMessage(repairs);
return new SetConfigResult(true, true, !repairs.isEmpty(), result);
}
public static SetConfigResult invalid(String message) {
return new SetConfigResult(false, false, message);
return new SetConfigResult(false, false, false, message);
}
private static String repairMessage(List<ConfigCandidate.Repair> repairs) {
Set<String> paths = new LinkedHashSet<>();
for (ConfigCandidate.Repair repair : repairs) {
paths.add(repair.pathString());
}
return "Invalid values at " + String.join(", ", paths) + " were replaced with defaults.";
}
}
}
@@ -0,0 +1,234 @@
package games.cubi.raycastedantiesp.core.config;
import games.cubi.raycastedantiesp.core.config.engine.EngineMode;
import games.cubi.raycastedantiesp.core.config.raycast.BlockSelector;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.ConfigurationOptions;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.objectmapping.ObjectMapper;
import org.spongepowered.configurate.serialize.SerializationException;
import org.spongepowered.configurate.serialize.TypeSerializer;
import org.spongepowered.configurate.serialize.TypeSerializerCollection;
import org.spongepowered.configurate.util.NamingSchemes;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.function.LongFunction;
final class ConfigMapping {
private static final String HEADER = "An explanation of this configuration file and what all the options do can be found at https://raycastedantiesp.cubi.games/config/";
private static final String LEGACY_HEADER = "An explanation of this configuration file and what the options do can be found at https://raycastedantiesp.cubi.games/config/";
private static final ConfigurationOptions OPTIONS = createOptions();
private ConfigMapping() {
}
static ConfigurationOptions options() {
return OPTIONS;
}
static boolean removeDuplicateHeader(CommentedConfigurationNode node) {
// Without a blank line, the legacy YAML header is loaded as a comment on config-version.
CommentedConfigurationNode version = node.node("config-version");
String comment = version.comment();
if (comment == null) {
return false;
}
var lines = comment.lines().toList();
var remaining = lines.stream().filter(line -> {
String normalized = line.strip().replace("https\\://", "https://");
return !LEGACY_HEADER.equals(normalized) && !HEADER.equals(normalized);
}).toList();
if (remaining.size() == lines.size()) {
return false;
}
String retainedComment = String.join("\n", remaining);
version.comment(retainedComment.isBlank() ? null : retainedComment);
return true;
}
private static ConfigurationOptions createOptions() {
ObjectMapper.Factory mapper = ObjectMapper.factoryBuilder()
.defaultNamingScheme(NamingSchemes.LOWER_CASE_DASHED)
.addProcessor(ListEntryComments.class, (annotation, type) -> {
Map<String, String> comments = new HashMap<>();
for (ListEntryComments.Entry entry : annotation.value()) {
comments.put(entry.value(), entry.comment());
}
return (value, node) -> {
for (ConfigurationNode child : node.childrenList()) {
if (child.rawScalar() instanceof String entry && child instanceof CommentedConfigurationNode commented) {
String comment = comments.get(entry);
if (comment != null) {
commented.commentIfAbsent(comment);
}
}
}
};
})
.addConstraint(ConfigRange.class, (annotation, type) -> value -> {
if (!(value instanceof Number number)) {
throw new SerializationException(type, "Expected a numeric value");
}
long numericValue = number.longValue();
if (numericValue < annotation.min() || numericValue > annotation.max()) {
throw new SerializationException(type, "Value must be between " + annotation.min() + " and " + annotation.max());
}
})
.build();
TypeSerializer<String> stringSerializer = strictScalarSerializer(
String.class,
"a string",
String.class::cast,
value -> value
);
TypeSerializer<Boolean> booleanSerializer = strictScalarSerializer(
Boolean.class,
"a boolean",
Boolean.class::cast,
value -> value
);
TypeSerializer<Byte> byteSerializer = strictIntegerSerializer("a byte", Byte.MIN_VALUE, Byte.MAX_VALUE, value -> (byte) value);
TypeSerializer<Short> shortSerializer = strictIntegerSerializer("a short", Short.MIN_VALUE, Short.MAX_VALUE, value -> (short) value);
TypeSerializer<Integer> integerSerializer = strictIntegerSerializer("an integer", Integer.MIN_VALUE, Integer.MAX_VALUE, value -> (int) value);
TypeSerializerCollection serializers = TypeSerializerCollection.defaults().childBuilder()
.registerExact(String.class, stringSerializer)
.registerExact(boolean.class, booleanSerializer)
.registerExact(Boolean.class, booleanSerializer)
.registerExact(byte.class, byteSerializer)
.registerExact(Byte.class, byteSerializer)
.registerExact(short.class, shortSerializer)
.registerExact(Short.class, shortSerializer)
.registerExact(int.class, integerSerializer)
.registerExact(Integer.class, integerSerializer)
.registerExact(BlockSelector.class, blockSelectorSerializer())
.registerExact(EngineMode.class, enumSerializer(EngineMode::fromString, EngineMode::getName))
.registerExact(BlockProcessorMode.class, enumSerializer(BlockProcessorMode::fromString, BlockProcessorMode::getName))
.registerAnnotatedObjects(mapper)
.build();
return ConfigurationOptions.defaults()
.header(HEADER)
.serializers(serializers)
.shouldCopyDefaults(true);
}
private static <T> TypeSerializer<T> strictScalarSerializer(
Class<T> type,
String expected,
Function<Object, T> reader,
Function<T, Object> writer
) {
return new TypeSerializer<>() {
@Override
public T deserialize(@NotNull Type expectedType, @NotNull ConfigurationNode node) throws SerializationException {
Object raw = node.rawScalar();
if (!type.isInstance(raw)) {
throw new SerializationException(expectedType, "Expected " + expected);
}
return reader.apply(raw);
}
@Override
public void serialize(@NotNull Type expectedType, T value, @NotNull ConfigurationNode node) {
node.raw(value == null ? null : writer.apply(value));
}
};
}
private static <T extends Number> TypeSerializer<T> strictIntegerSerializer(String expected, long minimum, long maximum, LongFunction<T> converter) {
return new TypeSerializer<>() {
@Override
public T deserialize(@NotNull Type expectedType, @NotNull ConfigurationNode node) throws SerializationException {
Object raw = node.rawScalar();
if (!(raw instanceof Number number)) {
throw new SerializationException(expectedType, "Expected " + expected);
}
long value = exactLong(expectedType, number);
if (value < minimum || value > maximum) {
throw new SerializationException(expectedType, "Value is outside the supported range for " + expected);
}
return converter.apply(value);
}
@Override
public void serialize(@NotNull Type expectedType, T value, @NotNull ConfigurationNode node) {
node.raw(value == null ? null : value.intValue());
}
};
}
private static long exactLong(Type expectedType, Number number) throws SerializationException {
try {
return switch (number) {
case Byte ignored -> number.longValue();
case Short ignored -> number.longValue();
case Integer ignored -> number.longValue();
case Long ignored -> number.longValue();
case BigInteger value -> value.longValueExact();
case BigDecimal value -> value.longValueExact();
default -> exactLongFromFloatingPoint(expectedType, number.doubleValue());
};
} catch (ArithmeticException exception) {
throw new SerializationException(expectedType, "Expected an integer", exception);
}
}
private static long exactLongFromFloatingPoint(Type expectedType, double value) throws SerializationException {
if (!Double.isFinite(value) || Math.rint(value) != value || value < Long.MIN_VALUE || value > Long.MAX_VALUE) {
throw new SerializationException(expectedType, "Expected an integer");
}
return (long) value;
}
private static <T> TypeSerializer<T> enumSerializer(Function<String, T> parser, Function<T, String> writer) {
return new TypeSerializer<>() {
@Override
public T deserialize(@NotNull Type expectedType, @NotNull ConfigurationNode node) throws SerializationException {
Object raw = node.rawScalar();
if (!(raw instanceof String string)) {
throw new SerializationException(expectedType, "Expected a string");
}
T parsed = parser.apply(string);
if (parsed == null) {
throw new SerializationException(expectedType, "Unsupported value '" + string + "'");
}
return parsed;
}
@Override
public void serialize(@NotNull Type expectedType, T value, @NotNull ConfigurationNode node) {
node.raw(value == null ? null : writer.apply(value));
}
};
}
private static TypeSerializer<BlockSelector> blockSelectorSerializer() {
return new TypeSerializer<>() {
@Override
public BlockSelector deserialize(@NotNull Type expectedType, @NotNull ConfigurationNode node) throws SerializationException {
Object raw = node.rawScalar();
if (!(raw instanceof String value)) {
throw new SerializationException(expectedType, "Expected a namespaced block selector");
}
try {
return BlockSelector.parse(value);
} catch (IllegalArgumentException exception) {
throw new SerializationException(expectedType, exception.getMessage(), exception);
}
}
@Override
public void serialize(@NotNull Type expectedType, BlockSelector value, @NotNull ConfigurationNode node) {
node.raw(value == null ? null : value.toString());
}
};
}
}
@@ -0,0 +1,69 @@
package games.cubi.raycastedantiesp.core.config;
import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.ConfigurateException;
import org.spongepowered.configurate.NodePath;
import org.spongepowered.configurate.transformation.ConfigurationTransformation;
import org.spongepowered.configurate.transformation.MoveStrategy;
/** Upgrades supported on-disk schemas before defaults are merged or objects are mapped. */
final class ConfigMigration {
private static final String PREVIOUS_CONFIG_VERSION = "2.0";
private static final ConfigurationTransformation VERSION_2_1_TRANSFORMATION = createVersion21Transformation();
private ConfigMigration() {
}
static boolean migrate(CommentedConfigurationNode node) {
ConfigurationNode versionNode = node.node("config-version");
Object rawVersion = versionNode.raw();
if (rawVersion == null) {
versionNode.raw(RootConfig.CURRENT_VERSION);
return true;
}
if (!(rawVersion instanceof String version)) {
throw new ConfigLoadException("config-version must be a string");
}
if (RootConfig.CURRENT_VERSION.equals(version)) {
return false;
}
if (!PREVIOUS_CONFIG_VERSION.equals(version)) {
throw unsupportedVersion(version);
}
try {
VERSION_2_1_TRANSFORMATION.apply(node);
} catch (ConfigurateException e) {
throw new ConfigLoadException("Failed to migrate config-version '" + PREVIOUS_CONFIG_VERSION + "' to '" + RootConfig.CURRENT_VERSION + "'", e);
}
versionNode.raw(RootConfig.CURRENT_VERSION);
return true;
}
static ConfigLoadException unsupportedVersion(String version) {
return new ConfigLoadException(
"Unsupported config-version '" + version + "'. RaycastedAntiESP requires config-version '"
+ RootConfig.CURRENT_VERSION + "'."
);
}
private static ConfigurationTransformation createVersion21Transformation() {
ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder().moveStrategy(MoveStrategy.MERGE);
addMove(builder, "info-level", "info", "level");
addMove(builder, "info-exempted-classes", "info", "exempted-classes");
addMove(builder, "warn-level", "warn", "level");
addMove(builder, "warn-exempted-classes", "warn", "exempted-classes");
addMove(builder, "error-level", "error", "level");
addMove(builder, "error-exempted-classes", "error", "exempted-classes");
builder.addAction(NodePath.path("block-processor", "packetevents"), (path, value) -> {
value.raw(null);
return null;
});
return builder.build();
}
private static void addMove(ConfigurationTransformation.Builder builder, String oldKey, String severity, String newKey) {
builder.addAction(NodePath.path("debug", oldKey), (path, value) -> new Object[] {"logging", severity, newKey});
}
}
@@ -0,0 +1,16 @@
package games.cubi.raycastedantiesp.core.config;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.RECORD_COMPONENT})
public @interface ConfigRange {
long min();
long max();
}
@@ -1,154 +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.config;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
public final class ConfigReader {
private ConfigReader() {}
public static ConfigurationNode node(ConfigurationNode parent, String... path) {
return parent.node((Object[]) path);
}
public static String string(ConfigurationNode node, String path) {
Object raw = node.raw();
if (raw instanceof String value) {
return value;
}
throw invalid(path, "string", raw);
}
public static int integer(ConfigurationNode node, String path) {
Object raw = node.raw();
if (raw instanceof Number value) {
return exactInteger(value, path, "integer");
}
throw invalid(path, "integer", raw);
}
public static boolean bool(ConfigurationNode node, String path) {
Object raw = node.raw();
if (raw instanceof Boolean value) {
return value;
}
throw invalid(path, "boolean", raw);
}
public static List<String> stringList(ConfigurationNode node, String path) {
if (node.virtual() || node.raw() == null) {
return List.of();
}
if (node.childrenList().isEmpty()) {
Object raw = node.raw();
if (raw instanceof List<?> list && list.isEmpty()) {
return List.of();
}
throw invalid(path, "list of strings", raw);
}
List<String> values = new ArrayList<>();
for (ConfigurationNode child : node.childrenList()) {
Object raw = child.raw();
if (!(raw instanceof String value)) {
throw invalid(path, "list of strings", raw);
}
values.add(value);
}
return List.copyOf(values);
}
public static List<Integer> integerList(ConfigurationNode node, String path) {
if (node.virtual() || node.raw() == null) {
return List.of();
}
if (node.childrenList().isEmpty()) {
Object raw = node.raw();
if (raw instanceof List<?> list && list.isEmpty()) {
return List.of();
}
throw invalid(path, "list of integers", raw);
}
List<Integer> values = new ArrayList<>();
for (ConfigurationNode child : node.childrenList()) {
Object raw = child.raw();
if (!(raw instanceof Number value)) {
throw invalid(path, "list of integers", raw);
}
int id = exactInteger(value, path, "list of integers");
if (id < 0) {
throw new ConfigLoadException(path + " cannot contain negative block state IDs: " + id);
}
values.add(id);
}
return List.copyOf(values);
}
public static Object parseRawValue(String rawValue) {
try {
ConfigurationNode parsed = org.spongepowered.configurate.yaml.YamlConfigurationLoader.builder()
.source(() -> new java.io.BufferedReader(new java.io.StringReader("value: " + rawValue)))
.build()
.load();
return parsed.node("value").raw();
} catch (java.io.IOException e) {
throw new ConfigLoadException("Invalid YAML value: " + rawValue, e);
}
}
public static void setRaw(ConfigurationNode node, Object value) {
try {
node.set(value);
} catch (SerializationException e) {
throw new ConfigLoadException("Failed to set config value", e);
}
}
private static ConfigLoadException invalid(String path, String expected, Object raw) {
String actual = raw == null ? "null" : raw.getClass().getSimpleName();
return new ConfigLoadException(path + " must be a " + expected + " but was " + actual);
}
private static int exactInteger(Number value, String path, String expected) {
try {
return switch (value) {
case Byte ignored -> value.intValue();
case Short ignored -> value.intValue();
case Integer ignored -> value.intValue();
case Long longValue -> {
if (longValue < Integer.MIN_VALUE || longValue > Integer.MAX_VALUE) {
throw invalid(path, expected, value);
}
yield longValue.intValue();
}
case BigInteger bigInteger -> bigInteger.intValueExact();
case BigDecimal bigDecimal -> bigDecimal.intValueExact();
default -> exactIntegerFromFloatingPoint(value, path, expected);
};
} catch (ArithmeticException e) {
throw invalid(path, expected, value);
}
}
private static int exactIntegerFromFloatingPoint(Number value, String path, String expected) {
double doubleValue = value.doubleValue();
if (!Double.isFinite(doubleValue)
|| Math.rint(doubleValue) != doubleValue
|| doubleValue < Integer.MIN_VALUE
|| doubleValue > Integer.MAX_VALUE) {
throw invalid(path, expected, value);
}
return (int) doubleValue;
}
}
@@ -1,85 +1,30 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright © 2026 Cubicake.
* This file is part of RaycastedAntiESP.
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 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;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;
import java.util.List;
public record DebugConfig(byte infoLevel, List<String> infoExemptedClasses, byte warnLevel, List<String> warnExemptedClasses,
byte errorLevel, List<String> errorExemptedClasses, boolean debugParticles, boolean timings) implements Config {
public static DebugConfig load(ConfigurationNode root) {
ConfigurationNode node = ConfigReader.node(root, "debug");
return new DebugConfig(
level(ConfigReader.node(node, "info-level"), "debug.info-level"),
ConfigReader.stringList(ConfigReader.node(node, "info-exempted-classes"), "debug.info-exempted-classes"),
level(ConfigReader.node(node, "warn-level"), "debug.warn-level"),
ConfigReader.stringList(ConfigReader.node(node, "warn-exempted-classes"), "debug.warn-exempted-classes"),
level(ConfigReader.node(node, "error-level"), "debug.error-level"),
ConfigReader.stringList(ConfigReader.node(node, "error-exempted-classes"), "debug.error-exempted-classes"),
ConfigReader.bool(ConfigReader.node(node, "particles"), "debug.particles"),
ConfigReader.bool(ConfigReader.node(node, "timings"), "debug.timings")
);
}
public byte getInfoLevel() {
return infoLevel;
}
public byte getWarnLevel() {
return warnLevel;
}
public byte getErrorLevel() {
return errorLevel;
}
@ConfigSerializable
public record DebugConfig(
@Comment("Show raycast debug particles.")
boolean particles,
@Comment("Record and report engine timing information.")
boolean timings
) implements Config {
public static final DebugConfig DEFAULT = new DebugConfig(false, false);
public boolean showDebugParticles() {
return debugParticles;
return particles;
}
public boolean recordTimings() {
return timings;
}
public boolean isExempted(Severity severity, Class<?>... sources) {
List<String> exempted = switch (severity) {
case INFO -> infoExemptedClasses;
case WARN -> warnExemptedClasses;
case ERROR -> errorExemptedClasses;
};
if (sources == null || exempted.isEmpty()) {
return false;
}
for (Class<?> source : sources) {
if (source == null) {
continue;
}
if (exempted.contains(source.getSimpleName()) || exempted.contains(source.getName())) {
return true;
}
}
return false;
}
private static byte level(ConfigurationNode node, String path) {
int level = ConfigReader.integer(node, path);
if (level < 0 || level > 10) {
throw new ConfigLoadException(path + " must be between 0 and 10");
}
return (byte) level;
}
public enum Severity {
INFO,
WARN,
ERROR
}
}
@@ -0,0 +1,23 @@
package games.cubi.raycastedantiesp.core.config;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/** Adds comments to collection entries matched by their serialized string values, without replacing existing comments. */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.RECORD_COMPONENT})
public @interface ListEntryComments {
Entry[] value();
@Retention(RetentionPolicy.RUNTIME)
@Target({})
@interface Entry {
String value();
String comment();
}
}
@@ -0,0 +1,33 @@
package games.cubi.raycastedantiesp.core.config;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;
import java.util.List;
@ConfigSerializable
public record LogLevelConfig(
@Comment("Messages above this level are suppressed. Set to 0 to suppress this severity.")
@ConfigRange(min = 0, max = 10)
byte level,
@Comment("Simple or fully qualified class names whose messages should be suppressed.")
List<String> exemptedClasses
) implements Config {
public static final LogLevelConfig DEFAULT = new LogLevelConfig((byte) 5, List.of());
public LogLevelConfig {
exemptedClasses = List.copyOf(exemptedClasses);
}
public boolean isExempted(Class<?>... sources) {
if (sources == null || exemptedClasses.isEmpty()) {
return false;
}
for (Class<?> source : sources) {
if (source != null && (exemptedClasses.contains(source.getSimpleName()) || exemptedClasses.contains(source.getName()))) {
return true;
}
}
return false;
}
}
@@ -0,0 +1,22 @@
package games.cubi.raycastedantiesp.core.config;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
@ConfigSerializable
public record LoggingConfig(LogLevelConfig info, LogLevelConfig warn, LogLevelConfig error) implements Config {
public static final LoggingConfig DEFAULT = new LoggingConfig(LogLevelConfig.DEFAULT, LogLevelConfig.DEFAULT, LogLevelConfig.DEFAULT);
public LogLevelConfig forSeverity(Severity severity) {
return switch (severity) {
case INFO -> info;
case WARN -> warn;
case ERROR -> error;
};
}
public enum Severity {
INFO,
WARN,
ERROR
}
}
@@ -1,20 +1,35 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright © 2026 Cubicake.
* This file is part of RaycastedAntiESP.
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 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;
import games.cubi.raycastedantiesp.core.config.engine.EngineConfig;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Setting;
import java.util.Map;
public record RootConfig(String configVersion, ChecksConfig checksConfig, EngineConfig engineConfig, BlockProcessorConfig blockProcessorConfig, DebugConfig debugConfig, UpdateConfig updateConfig, Map<Class<? extends Config>, Config> extensionConfigs) implements Config {
public <T extends Config> T extensionConfig(Class<T> type) {
Config config = extensionConfigs.get(type);
return type.cast(config);
}
@ConfigSerializable
public record RootConfig(
String configVersion,
@Setting("logging") LoggingConfig loggingConfig,
@Setting("checks") ChecksConfig checksConfig,
@Setting("engine") EngineConfig engineConfig,
@Setting("block-processor") BlockProcessorConfig blockProcessorConfig,
@Setting("debug") DebugConfig debugConfig,
@Setting("updates") UpdateConfig updateConfig
) implements Config {
public static final String CURRENT_VERSION = "2.1";
public static final RootConfig DEFAULT = new RootConfig(
CURRENT_VERSION,
LoggingConfig.DEFAULT,
ChecksConfig.DEFAULT,
EngineConfig.DEFAULT,
BlockProcessorConfig.DEFAULT,
DebugConfig.DEFAULT,
UpdateConfig.DEFAULT
);
}
@@ -1,26 +1,25 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright © 2026 Cubicake.
* This file is part of RaycastedAntiESP.
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 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;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;
public record UpdateConfig(boolean checkRelease, boolean checkBeta, boolean checkAlpha, boolean notifyInGame) implements Config {
public static UpdateConfig load(ConfigurationNode root) {
ConfigurationNode node = ConfigReader.node(root, "updates");
return new UpdateConfig(
ConfigReader.bool(ConfigReader.node(node, "check-release"), "updates.check-release"),
ConfigReader.bool(ConfigReader.node(node, "check-beta"), "updates.check-beta"),
ConfigReader.bool(ConfigReader.node(node, "check-alpha"), "updates.check-alpha"),
ConfigReader.bool(ConfigReader.node(node, "notify-in-game"), "updates.notify-in-game")
);
}
@ConfigSerializable
public record UpdateConfig(
boolean checkRelease,
boolean checkBeta,
boolean checkAlpha,
@Comment("When true, players with permission are notified; otherwise only the console is notified.")
boolean notifyInGame
) implements Config {
public static final UpdateConfig DEFAULT = new UpdateConfig(true, true, true, true);
public boolean anyChannelEnabled() {
return checkRelease || checkBeta || checkAlpha;
@@ -1,24 +1,25 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright © 2026 Cubicake.
* This file is part of RaycastedAntiESP.
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 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;
import games.cubi.raycastedantiesp.core.config.Config;
import games.cubi.raycastedantiesp.core.config.ConfigLoadException;
import games.cubi.raycastedantiesp.core.config.ConfigReader;
import org.spongepowered.configurate.ConfigurationNode;
import games.cubi.raycastedantiesp.core.config.ConfigRange;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;
import org.spongepowered.configurate.objectmapping.meta.Setting;
public record AsyncEngineConfig(int asyncProcessingThreads) implements Config {
public static AsyncEngineConfig load(ConfigurationNode node) {
int threads = ConfigReader.integer(ConfigReader.node(node, "processing-threads"), "engine.async.processing-threads");
if (threads < 1) {
throw new ConfigLoadException("engine.async.processing-threads must be at least 1");
}
return new AsyncEngineConfig(threads);
}
@ConfigSerializable
public record AsyncEngineConfig(
@Setting("processing-threads")
@Comment("Number of async processing threads. One is sufficient for hundreds of players.")
@ConfigRange(min = 1, max = 64)
int asyncProcessingThreads
) implements Config {
public static final AsyncEngineConfig DEFAULT = new AsyncEngineConfig(1);
}
@@ -1,28 +1,23 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright © 2026 Cubicake.
* This file is part of RaycastedAntiESP.
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
* See README.md for warranty disclaimer and further information.
* This file is part of RaycastedAntiESP. RaycastedAntiESP is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at
* https://www.gnu.org/licenses/agpl-3.0.html. See README.md for warranty disclaimer and further information.
*/
package games.cubi.raycastedantiesp.core.config.engine;
import games.cubi.raycastedantiesp.core.config.Config;
import games.cubi.raycastedantiesp.core.config.ConfigLoadException;
import games.cubi.raycastedantiesp.core.config.ConfigReader;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Setting;
public record EngineConfig(EngineMode mode, AsyncEngineConfig asyncConfig) implements Config {
public static EngineConfig load(ConfigurationNode root) {
ConfigurationNode node = ConfigReader.node(root, "engine");
String modeName = ConfigReader.string(ConfigReader.node(node, "mode"), "engine.mode");
EngineMode mode = EngineMode.fromString(modeName);
if (mode == null) {
throw new ConfigLoadException("engine.mode has unsupported value '" + modeName + "'");
}
return new EngineConfig(mode, AsyncEngineConfig.load(ConfigReader.node(node, "async")));
}
@ConfigSerializable
public record EngineConfig(
EngineMode mode,
@Setting("async") AsyncEngineConfig asyncConfig
) implements Config {
public static final EngineConfig DEFAULT = new EngineConfig(EngineMode.ASYNC, AsyncEngineConfig.DEFAULT);
public EngineMode getMode() {
return mode;
@@ -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;
@@ -0,0 +1,93 @@
package games.cubi.raycastedantiesp.core.config.raycast;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.regex.Pattern;
/**
* A namespaced block key, optionally restricted by property values. Omitted properties match any value.
*/
public record BlockSelector(String value) {
private static final Pattern NAMESPACE = Pattern.compile("[a-z0-9_.-]+");
private static final Pattern PATH = Pattern.compile("[a-z0-9/._-]+");
private static final Pattern PROPERTY = Pattern.compile("[a-z0-9_]+");
public BlockSelector {
validate(value);
}
public static BlockSelector parse(String input) {
return new BlockSelector(input);
}
public String blockKey() {
int openingBracket = value.indexOf('[');
return openingBracket < 0 ? value : value.substring(0, openingBracket);
}
public boolean matchesAllStates() {
return value.indexOf('[') < 0;
}
@Override
public @NotNull String toString() {
return value;
}
private static void validate(String input) {
Objects.requireNonNull(input, "value");
int openingBracket = input.indexOf('[');
if (openingBracket < 0) {
if (input.indexOf(']') >= 0) {
throw new IllegalArgumentException("Unexpected closing bracket in block selector");
}
validateBlockKey(input);
return;
}
if (!input.endsWith("]") || input.indexOf('[', openingBracket + 1) >= 0
|| input.indexOf(']', openingBracket) != input.length() - 1) {
throw new IllegalArgumentException("Malformed block-state properties");
}
String propertyText = input.substring(openingBracket + 1, input.length() - 1);
if (propertyText.isEmpty()) {
throw new IllegalArgumentException("Block-state properties cannot be empty");
}
validateBlockKey(input.substring(0, openingBracket));
Set<String> properties = new HashSet<>();
for (String assignment : propertyText.split(",", -1)) {
int equals = assignment.indexOf('=');
if (equals <= 0 || equals != assignment.lastIndexOf('=') || equals == assignment.length() - 1) {
throw new IllegalArgumentException("Invalid block-state property '" + assignment + "'");
}
String name = validateProperty(assignment.substring(0, equals), "property name");
validateProperty(assignment.substring(equals + 1), "property value");
if (!properties.add(name)) {
throw new IllegalArgumentException("Duplicate block property '" + name + "'");
}
}
}
private static String validateBlockKey(String blockKey) {
Objects.requireNonNull(blockKey, "blockKey");
int separator = blockKey.indexOf(':');
if (separator <= 0 || separator != blockKey.lastIndexOf(':') || separator == blockKey.length() - 1
|| !NAMESPACE.matcher(blockKey.substring(0, separator)).matches()
|| !PATH.matcher(blockKey.substring(separator + 1)).matches()) {
throw new IllegalArgumentException("Invalid namespaced block key '" + blockKey + "'");
}
return blockKey;
}
private static String validateProperty(String value, String description) {
Objects.requireNonNull(value, description);
if (!PROPERTY.matcher(value).matches()) {
throw new IllegalArgumentException("Invalid block-state " + description + " '" + value + "'");
}
return value;
}
}
@@ -1,24 +1,27 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright © 2026 Cubicake.
* This file is part of RaycastedAntiESP.
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 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;
import games.cubi.raycastedantiesp.core.config.Config;
import games.cubi.raycastedantiesp.core.config.ConfigReader;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;
public record ChunkSectionConfig(boolean enabled, int maxOccludingCount, int alwaysShowRadiusChunks, int visibleRecheckIntervalTicks) implements Config {
public static ChunkSectionConfig load(ConfigurationNode node, String path) {
return new ChunkSectionConfig(
ConfigReader.bool(ConfigReader.node(node, "enabled"), path + ".enabled"),
ConfigReader.integer(ConfigReader.node(node, "max-occluding-count"), path + ".max-occluding-count"),
ConfigReader.integer(ConfigReader.node(node, "always-show-radius-chunks"), path + ".always-show-radius-chunks"),
ConfigReader.integer(ConfigReader.node(node, "visible-recheck-interval-ticks"), path + ".visible-recheck-interval-ticks")
);
}
@ConfigSerializable
public record ChunkSectionConfig(
@Comment("Whether chunk sections are hidden when they cannot be seen. This feature is not implemented yet.")
boolean enabled,
@Comment("Maximum number of occluding blocks permitted by a successful raycast.")
int maxOccludingCount,
@Comment("Radius in chunks within which chunk sections are always visible.")
int alwaysShowRadiusChunks,
@Comment("Ticks between checks of visible chunk sections. -1 disables visible rechecks.")
int visibleRecheckIntervalTicks
) implements Config {
public static final ChunkSectionConfig DEFAULT = new ChunkSectionConfig(false, 6, 2, -1);
}
@@ -1,36 +1,91 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright © 2026 Cubicake.
* This file is part of RaycastedAntiESP.
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 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;
import games.cubi.raycastedantiesp.core.config.ConfigReader;
import org.spongepowered.configurate.ConfigurationNode;
import games.cubi.raycastedantiesp.core.config.ListEntryComments;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;
import org.spongepowered.configurate.objectmapping.meta.Setting;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
public class EntityConfig extends RaycastConfig {
private final Set<String> excludedTypes;
@ConfigSerializable
public record EntityConfig(
@Setting(nodeFromParent = true)
RaycastSettings raycastSettings,
@Comment("Suppress sounds produced by hidden entities.")
boolean hideSoundsWhenHidden,
@Comment("Retain hidden entities client-side instead of destroying them. This will cause a non-moving \"ghost player\" to persist until the real player is visible again, but can reduce network load around large mob farms or bases.")
boolean keepClientEntityWhenHidden,
@Comment("""
Entity types that must always remain visible.
private EntityConfig(RaycastConfig config, List<String> excludedTypes) {
super(config.enabled(), config.hideSoundsWhenHidden(), config.getMaxOccludingCount(), config.getAlwaysShowRadius(),
config.getRaycastRadius(), config.hideOnSpawnDistance(), config.getVisibleRecheckIntervalTicks(),
config.keepClientEntityWhenHidden());
this.excludedTypes = Set.copyOf(excludedTypes);
}
Falling blocks are also often used in custom mechanics, especially by plugins predating display entities. However, they occur in regular gameplay and can reveal information about hidden players, so they are not excluded by default. To exclude them, add minecraft:falling_block.
public static EntityConfig load(ConfigurationNode node, String path) {
RaycastConfig config = RaycastConfig.load(node, path, true, true);
List<String> excludedTypes = ConfigReader.stringList(ConfigReader.node(node, "excluded-types"), path + ".excluded-types");
return new EntityConfig(config, excludedTypes);
}
Add further exclusions using the namespaced entity name accepted by the /summon command.
""")
@ListEntryComments({
@ListEntryComments.Entry(value = "minecraft:arrow", comment =
"Projectiles move very quickly, giving the raycast engine limited time to process them. "
+ "This could leave players without enough time to dodge, so projectiles are always visible by default."),
@ListEntryComments.Entry(value = "minecraft:area_effect_cloud", comment =
"Potions and area-effect clouds can damage players even when not visible. "
+ "A reasonable always-show-radius mitigates this, so exempting them is not always necessary. "
+ "Servers where knowing the exact number of potions another player has used is an unfair advantage may want to remove these exclusions."),
@ListEntryComments.Entry(value = "minecraft:potion", comment =
"The minecraft:potion entity was removed in 1.21.5 and replaced by minecraft:splash_potion and minecraft:lingering_potion. "
+ "On 1.21.4, remove the latter two entries; on 1.21.5 and newer, remove minecraft:potion instead."),
@ListEntryComments.Entry(value = "minecraft:lightning_bolt", comment = "Lightning is short-lived and expected to be visible to players who cannot see the block being struck."),
@ListEntryComments.Entry(value = "minecraft:ender_dragon", comment = "Boss entities are also always visible by default."),
@ListEntryComments.Entry(value = "minecraft:block_display", comment =
"Display, interaction, and mannequin entities are not normally seen in vanilla gameplay and are commonly used for custom mechanics. "
+ "Removing these exclusions is likely to break plugins such as hologram or NPC plugins.")
})
Set<String> excludedTypes
) implements RaycastConfig {
public static final EntityConfig DEFAULT = new EntityConfig(
new RaycastSettings(true, (byte) 3, (short) 8, (short) 92, (short) 24, (short) 5),
false,
false,
new LinkedHashSet<>(List.of(
"minecraft:arrow",
"minecraft:spectral_arrow",
"minecraft:fireball",
"minecraft:dragon_fireball",
"minecraft:small_fireball",
"minecraft:firework_rocket",
"minecraft:wither_skull",
"minecraft:breeze_wind_charge",
"minecraft:wind_charge",
"minecraft:ender_pearl",
"minecraft:evoker_fangs",
"minecraft:shulker_bullet",
"minecraft:area_effect_cloud",
"minecraft:lingering_potion",
"minecraft:splash_potion",
"minecraft:potion",
"minecraft:lightning_bolt",
"minecraft:ender_dragon",
"minecraft:wither",
"minecraft:warden",
"minecraft:block_display",
"minecraft:text_display",
"minecraft:item_display",
"minecraft:interaction",
"minecraft:mannequin"
))
);
public Set<String> excludedTypes() {
return excludedTypes;
public EntityConfig {
excludedTypes = Collections.unmodifiableSet(new LinkedHashSet<>(excludedTypes));
}
}
@@ -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,34 +1,32 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright © 2026 Cubicake.
* This file is part of RaycastedAntiESP.
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 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;
import games.cubi.raycastedantiesp.core.config.ConfigReader;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;
import org.spongepowered.configurate.objectmapping.meta.Setting;
public class PlayerConfig extends RaycastConfig {
private final boolean onlyCheckSneaking;
private PlayerConfig(RaycastConfig config, boolean onlyCheckSneaking) {
super(config.enabled(), config.hideSoundsWhenHidden(), config.getMaxOccludingCount(), config.getAlwaysShowRadius(),
config.getRaycastRadius(), config.hideOnSpawnDistance(), config.getVisibleRecheckIntervalTicks(),
config.keepClientEntityWhenHidden());
this.onlyCheckSneaking = onlyCheckSneaking;
}
public static PlayerConfig load(ConfigurationNode node, String path) {
return new PlayerConfig(
RaycastConfig.load(node, path, true, true),
ConfigReader.bool(ConfigReader.node(node, "only-check-sneaking"), path + ".only-check-sneaking")
);
}
public boolean onlyCheckSneaking() {
return onlyCheckSneaking;
}
@ConfigSerializable
public record PlayerConfig(
@Setting(nodeFromParent = true)
RaycastSettings raycastSettings,
@Comment("Suppress sounds produced by hidden players.")
boolean hideSoundsWhenHidden,
@Comment("Retain hidden players client-side instead of destroying their entities. This will cause a non-moving \"ghost player\" to persist until the real player is visible again.")
boolean keepClientEntityWhenHidden,
@Comment("Only raycast other players while the viewing player is sneaking.")
boolean onlyCheckSneaking
) implements RaycastConfig {
public static final PlayerConfig DEFAULT = new PlayerConfig(
new RaycastSettings(true, (byte) 3, (short) 8, (short) 128, (short) 24, (short) 5),
false,
false,
true
);
}
@@ -1,119 +1,62 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright © 2026 Cubicake.
* This file is part of RaycastedAntiESP.
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 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;
import games.cubi.logs.Logger;
import games.cubi.raycastedantiesp.core.config.Config;
import games.cubi.raycastedantiesp.core.config.ConfigReader;
import org.spongepowered.configurate.ConfigurationNode;
public class RaycastConfig implements Config {
private final boolean enabled;
private final boolean hideSoundsWhenHidden;
private final byte maxOccludingCount;
private final short alwaysShowRadius;
private final short raycastRadius;
private final short hideOnSpawnDistance;
private final short visibleRecheckIntervalTicks;
private final boolean keepClientEntityWhenHidden;
public interface RaycastConfig extends Config {
RaycastSettings raycastSettings();
public RaycastConfig(boolean enabled, boolean hideSoundsWhenHidden, int maxOccludingCount, int alwaysShowRadius,
int raycastRadius, int hideOnSpawnDistance, int visibleRecheckIntervalTicks) {
this(enabled, hideSoundsWhenHidden, maxOccludingCount, alwaysShowRadius, raycastRadius, hideOnSpawnDistance,
visibleRecheckIntervalTicks, false);
default boolean enabled() {
return raycastSettings().enabled();
}
public RaycastConfig(boolean enabled, boolean hideSoundsWhenHidden, int maxOccludingCount, int alwaysShowRadius,
int raycastRadius, int hideOnSpawnDistance, int visibleRecheckIntervalTicks,
boolean keepClientEntityWhenHidden) {
this.enabled = enabled;
this.hideSoundsWhenHidden = hideSoundsWhenHidden;
this.maxOccludingCount = (byte) maxOccludingCount;
this.alwaysShowRadius = (short) alwaysShowRadius;
this.raycastRadius = (short) raycastRadius;
this.hideOnSpawnDistance = (short) hideOnSpawnDistance;
this.visibleRecheckIntervalTicks = (short) visibleRecheckIntervalTicks;
this.keepClientEntityWhenHidden = keepClientEntityWhenHidden;
default boolean hideSoundsWhenHidden() {
return false;
}
protected static RaycastConfig load(ConfigurationNode node, String path, boolean hasHideSoundsWhenHidden) {
return load(node, path, hasHideSoundsWhenHidden, false);
default byte getMaxOccludingCount() {
return raycastSettings().maxOccludingCount();
}
protected static RaycastConfig load(ConfigurationNode node, String path, boolean hasHideSoundsWhenHidden,
boolean hasKeepClientEntityWhenHidden) {
int maxOccludingCount = ConfigReader.integer(ConfigReader.node(node, "max-occluding-count"), path + ".max-occluding-count");
if (maxOccludingCount < 0 || maxOccludingCount > Byte.MAX_VALUE) {
Logger.warning(path + ".max-occluding-count must be between 0 and " + Byte.MAX_VALUE + " but was " + maxOccludingCount +". Defaulting to 3.", 4, RaycastConfig.class);
maxOccludingCount = 3;
}
int alwaysShowRadius = ConfigReader.integer(ConfigReader.node(node, "always-show-radius"), path + ".always-show-radius");
if (alwaysShowRadius < 0 || alwaysShowRadius > Short.MAX_VALUE) {
Logger.warning(path + ".always-show-radius must be between 0 and " + Short.MAX_VALUE + " but was " + alwaysShowRadius +". Defaulting to 8.", 4, RaycastConfig.class);
alwaysShowRadius = 8;
}
int raycastRadius = ConfigReader.integer(ConfigReader.node(node, "raycast-radius"), path + ".raycast-radius");
if (raycastRadius < 0 || raycastRadius > Short.MAX_VALUE) {
Logger.warning(path + ".raycast-radius must be between 0 and " + Short.MAX_VALUE + " but was " + raycastRadius +". Defaulting to 48.", 4, RaycastConfig.class);
raycastRadius = 48;
}
int hideOnSpawnDistance = ConfigReader.integer(ConfigReader.node(node, "hide-on-spawn-distance"), path + ".hide-on-spawn-distance");
if (hideOnSpawnDistance < 0 || hideOnSpawnDistance > Short.MAX_VALUE) {
Logger.warning(path + ".hide-on-spawn-distance must be between 0 and " + Short.MAX_VALUE + " but was " + hideOnSpawnDistance +". Defaulting to 32.", 4, RaycastConfig.class);
hideOnSpawnDistance = 32;
}
int visibleRecheckIntervalTicks = ConfigReader.integer(ConfigReader.node(node, "visible-recheck-interval-ticks"), path + ".visible-recheck-interval-ticks");
if (visibleRecheckIntervalTicks < -1 || visibleRecheckIntervalTicks > Short.MAX_VALUE) {
Logger.warning(path + ".visible-recheck-interval-ticks must be between -1 and " + Short.MAX_VALUE + " but was " + visibleRecheckIntervalTicks +". Defaulting to 5.", 4, RaycastConfig.class);
visibleRecheckIntervalTicks = 5;
}
return new RaycastConfig(
ConfigReader.bool(ConfigReader.node(node, "enabled"), path + ".enabled"),
hasHideSoundsWhenHidden && ConfigReader.bool(ConfigReader.node(node, "hide-sounds-when-hidden"), path + ".hide-sounds-when-hidden"),
maxOccludingCount,
alwaysShowRadius,
raycastRadius,
hideOnSpawnDistance,
visibleRecheckIntervalTicks,
hasKeepClientEntityWhenHidden && ConfigReader.bool(ConfigReader.node(node, "keep-client-entity-when-hidden"), path + ".keep-client-entity-when-hidden")
);
default short getAlwaysShowRadius() {
return raycastSettings().alwaysShowRadius();
}
public boolean enabled() {
return enabled;
default short getRaycastRadius() {
return raycastSettings().raycastRadius();
}
public boolean hideSoundsWhenHidden() {
return hideSoundsWhenHidden;
default short hideOnSpawnDistance() {
return raycastSettings().hideOnSpawnDistance();
}
public byte getMaxOccludingCount() {
return maxOccludingCount;
default short getVisibleRecheckIntervalTicks() {
return raycastSettings().visibleRecheckIntervalTicks();
}
public short getAlwaysShowRadius() {
return alwaysShowRadius;
default boolean keepClientEntityWhenHidden() {
return false;
}
public short getRaycastRadius() {
return raycastRadius;
default int alwaysShowRadiusSquared() {
int radius = getAlwaysShowRadius();
return radius * radius;
}
public short hideOnSpawnDistance() {
return hideOnSpawnDistance;
default int raycastRadiusSquared() {
int radius = getRaycastRadius();
return radius * radius;
}
public short getVisibleRecheckIntervalTicks() {
return visibleRecheckIntervalTicks;
}
public boolean keepClientEntityWhenHidden() {
return keepClientEntityWhenHidden;
default int hideOnSpawnDistanceSquared() {
int distance = hideOnSpawnDistance();
return distance * distance;
}
}
@@ -0,0 +1,27 @@
package games.cubi.raycastedantiesp.core.config.raycast;
import games.cubi.raycastedantiesp.core.config.ConfigRange;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;
@ConfigSerializable
public record RaycastSettings(
@Comment("Whether this category is checked.")
boolean enabled,
@Comment("Maximum number of occluding blocks permitted by a successful raycast.")
@ConfigRange(min = 0, max = Byte.MAX_VALUE)
byte maxOccludingCount,
@Comment("Distance in blocks within which targets are always visible.")
@ConfigRange(min = 0, max = Short.MAX_VALUE)
short alwaysShowRadius,
@Comment("Maximum distance in blocks at which targets are raycasted.")
@ConfigRange(min = 0, max = Short.MAX_VALUE)
short raycastRadius,
@Comment("Distance in blocks beyond which a newly spawned target starts hidden.")
@ConfigRange(min = 0, max = Short.MAX_VALUE)
short hideOnSpawnDistance,
@Comment("Ticks between checks of visible targets. -1 keeps a shown target visible permanently.")
@ConfigRange(min = -1, max = Short.MAX_VALUE)
short visibleRecheckIntervalTicks
) {
}
@@ -1,29 +1,27 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright © 2026 Cubicake.
* This file is part of RaycastedAntiESP.
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 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;
import games.cubi.raycastedantiesp.core.config.Config;
import games.cubi.raycastedantiesp.core.config.ConfigReader;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;
@ConfigSerializable
public record SoundEffectsConfig(
@Comment("Whether sounds should be hidden when their source cannot be seen. This feature is not implemented yet.")
boolean enabled,
@Comment("Maximum number of occluding blocks permitted by a successful sound raycast.")
int maxOccludingCount,
@Comment("Distance in blocks within which sounds are always played.")
int alwaysPlayRadius,
@Comment("Maximum distance in blocks at which sounds are raycasted.")
int raycastRadius
) implements Config {
public static SoundEffectsConfig load(ConfigurationNode node, String path) {
return new SoundEffectsConfig(
ConfigReader.bool(ConfigReader.node(node, "enabled"), path + ".enabled"),
ConfigReader.integer(ConfigReader.node(node, "max-occluding-count"), path + ".max-occluding-count"),
ConfigReader.integer(ConfigReader.node(node, "always-play-radius"), path + ".always-play-radius"),
ConfigReader.integer(ConfigReader.node(node, "raycast-radius"), path + ".raycast-radius")
);
}
public static final SoundEffectsConfig DEFAULT = new SoundEffectsConfig(false, 3, 8, 48);
}
@@ -1,22 +1,36 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright © 2026 Cubicake.
* This file is part of RaycastedAntiESP.
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 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;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;
import org.spongepowered.configurate.objectmapping.meta.Setting;
public class TileEntityConfig extends RaycastConfig {
private TileEntityConfig(RaycastConfig config) {
super(config.enabled(), false, config.getMaxOccludingCount(), config.getAlwaysShowRadius(),
config.getRaycastRadius(), config.hideOnSpawnDistance(), config.getVisibleRecheckIntervalTicks());
}
import java.util.List;
public static TileEntityConfig load(ConfigurationNode node, String path) {
return new TileEntityConfig(RaycastConfig.load(node, path, false));
@ConfigSerializable
public record TileEntityConfig(
@Setting(nodeFromParent = true)
RaycastSettings raycastSettings,
@Comment("Blocks that should not be managed as tile entities. Use namespaced block keys.\n"
+ "\"minecraft:chest\" matches every chest state.\n"
+ "\"minecraft:chest[waterlogged=true]\" matches all waterlogged chests, regardless of facing or chest type.\n"
+ "Omitted properties are wildcards. All specified properties must match. Specify every property to select one exact state.\n"
+ "A block is excluded if any list entry matches. Changes require a server restart.")
List<BlockSelector> excludedBlocks
) implements RaycastConfig {
public static final TileEntityConfig DEFAULT = new TileEntityConfig(
new RaycastSettings(true, (byte) 3, (short) 8, (short) 64, (short) 24, (short) -1),
List.of(BlockSelector.parse("minecraft:beacon"))
);
public TileEntityConfig {
excludedBlocks = List.copyOf(excludedBlocks);
}
}
@@ -1,14 +1,13 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright © 2026 Cubicake.
* This file is part of RaycastedAntiESP.
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
* See README.md for warranty disclaimer and further information.
* This file is part of RaycastedAntiESP. RaycastedAntiESP is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at
* https://www.gnu.org/licenses/agpl-3.0.html. See README.md for warranty disclaimer and further information.
*/
package games.cubi.raycastedantiesp.core.engine;
import games.cubi.locatables.api.ImmutableSpatial;
import games.cubi.locatables.api.Locatable;
import games.cubi.logs.Logger;
import games.cubi.raycastedantiesp.core.config.ConfigManager;
@@ -22,12 +21,11 @@ import games.cubi.raycastedantiesp.core.players.PlayerData;
import games.cubi.raycastedantiesp.core.players.PlayerRegistry;
import games.cubi.raycastedantiesp.core.raycast.ParticleSpawner;
import games.cubi.raycastedantiesp.core.raycast.RaycastUtil;
import games.cubi.raycastedantiesp.core.utils.PrimitiveIntArrayList;
import games.cubi.utils.lists.PrimitiveIntArrayList;
import games.cubi.raycastedantiesp.core.view.BlockView;
import games.cubi.raycastedantiesp.core.view.EntityView;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
@@ -104,7 +102,7 @@ public abstract class AsyncEngine implements Engine {
int latestTick = currentTickSupplier.getAsInt();
if (latestTick > startTick) {
// If running behind, don't yield the thread, just run the next tick immediately
Logger.warning("Tick thread completed tick #" + startTick + " after tick #" + latestTick + " had already begun. Starting next tick immediately instead of yielding thread to scheduler. This is probably safe to ignore but may suggest that your server is overloaded.", 5);
Logger.warning("Tick thread completed tick #" + startTick + " after tick #" + latestTick + " had already begun. Starting next tick immediately instead of yielding thread to scheduler. This is probably safe to ignore but may suggest that your server is overloaded.", 5, AsyncEngine.class);
startTick = latestTick;
scheduledNanos = System.nanoTime();
scheduledTick = latestTick;
@@ -172,13 +170,13 @@ public abstract class AsyncEngine implements Engine {
final int currentTick = startTick;
runningTick.set(currentTick);
claimedRunningTick = true;
Collection<PlayerData> allPlayers = PlayerRegistry.getInstance().getAllPlayerData();
PlayerData[] allPlayers = PlayerRegistry.get().getPlayerDataArray();
EntityConfig entityConfig = config.getEntityConfig();
PlayerConfig playerConfig = config.getPlayerConfig();
TileEntityConfig tileEntityConfig = config.getTileEntityConfig();
if (recordTimings) {
timings = new TickTimings(scheduledTick, scheduledNanos, currentTick, startNanos, threads, allPlayers.size());
timings = new TickTimings(scheduledTick, scheduledNanos, currentTick, startNanos, threads, allPlayers.length);
}
/*
Logger.debug("Tick #" + currentTick);
@@ -194,24 +192,30 @@ public abstract class AsyncEngine implements Engine {
// If only one thread is configured, just use the current async thread to avoid the overhead of scheduling tasks and context switching.
if (threads == 1) {
handedOffToSubTick = true;
subTick(new ArrayList<>(allPlayers), entityConfig, playerConfig, tileEntityConfig, debugConfig, currentTick, timings, tickTimingStats);
subTick(allPlayers, entityConfig, playerConfig, tileEntityConfig, debugConfig, currentTick, timings, tickTimingStats);
return true;
}
List<List<PlayerData>> batches = new ArrayList<>(threads);
List<PlayerData[]> batches = new ArrayList<>(threads);
int playerCount = allPlayers.length;
for (int i = 0; i < threads; i++) {
batches.add(new ArrayList<>());
int batchSize = (playerCount + threads - 1 - i) / threads;
batches.add(new PlayerData[batchSize]);
}
int index = 0;
for (PlayerData playerData : allPlayers) {
batches.get(index++ % threads).add(playerData);
int batchIndex = index % threads;
int position = index / threads;
batches.get(batchIndex)[position] = playerData;
index++;
}
TickTimings tickTimings = timings; // needs to be effectively-final for lambda
int scheduledBatches = 0;
try {
for (List<PlayerData> batch : batches) {
for (PlayerData[] batch : batches) {
asyncRunner.runNow(() -> subTick(batch, entityConfig, playerConfig, tileEntityConfig, debugConfig, currentTick, tickTimings, tickTimingStats));
scheduledBatches++;
}
@@ -244,7 +248,7 @@ public abstract class AsyncEngine implements Engine {
* @param timingStats the timing sink selected when this tick started, so config changes during
* worker execution do not split one tick across sinks.
*/
private void subTick(List<PlayerData> batch, EntityConfig entityConfig, PlayerConfig playerConfig, TileEntityConfig tileEntityConfig, DebugConfig debugConfig, int currentTick, TickTimings timings, TimingStats timingStats) {
private void subTick(PlayerData[] batch, EntityConfig entityConfig, PlayerConfig playerConfig, TileEntityConfig tileEntityConfig, DebugConfig debugConfig, int currentTick, TickTimings timings, TimingStats timingStats) {
TickTimingBatch batchTimings = timings == null ? TickTimingBatchNoOp.INSTANCE : new TickTimingBatch();
long batchStartNanos = batchTimings.startBatch();
try {
@@ -329,7 +333,7 @@ public abstract class AsyncEngine implements Engine {
}
}
private void processTickForPlayers(List<PlayerData> playerDataList, EntityConfig entityConfig, PlayerConfig playerConfig, TileEntityConfig tileEntityConfig,
private void processTickForPlayers(PlayerData[] playerDataList, EntityConfig entityConfig, PlayerConfig playerConfig, TileEntityConfig tileEntityConfig,
boolean debugParticles, int currentTick, TickTimingBatch timings) {
for (PlayerData playerData : playerDataList) {
@@ -382,6 +386,8 @@ public abstract class AsyncEngine implements Engine {
private void checkEntities(PlayerData player, Locatable playerLocation, EntityConfig entityConfig, boolean debugParticles, BlockView blockView, int currentTick, int worldEpoch, TickTimingBatch timings) {
EntityView<?> entityView = player.entityView();
int alwaysShowRadiusSquared = entityConfig.alwaysShowRadiusSquared();
int raycastRadiusSquared = entityConfig.raycastRadiusSquared();
int checked = entityView.forEachNeedingRecheckEntity(entityConfig.getVisibleRecheckIntervalTicks(), currentTick, !(timings instanceof TickTimingBatchNoOp), worldEpoch, entity -> {
if (entity.glowing()) {
@@ -393,7 +399,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(), alwaysShowRadiusSquared, raycastRadiusSquared, debugParticles, entity.getYOffset(), blockView, playerLocation, entity, particleSpawner);
entityView.setVisibility(entity, canSee, currentTick, worldEpoch);
});
timings.addEntityChecked(checked);
@@ -401,6 +407,8 @@ public abstract class AsyncEngine implements Engine {
private void checkPlayers(PlayerData player, Locatable playerLocation, PlayerConfig playerConfig, boolean debugParticles, BlockView blockView, int currentTick, int worldEpoch, TickTimingBatch timings) {
EntityView<?> playerView = player.playerView();
int alwaysShowRadiusSquared = playerConfig.alwaysShowRadiusSquared();
int raycastRadiusSquared = playerConfig.raycastRadiusSquared();
int checked = playerView.forEachNeedingRecheckEntity(playerConfig.getVisibleRecheckIntervalTicks(), currentTick, !(timings instanceof TickTimingBatchNoOp), worldEpoch, otherPlayer -> {
if (otherPlayer.glowing() || (playerConfig.onlyCheckSneaking() && !otherPlayer.sneaking())) {
@@ -411,7 +419,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(), alwaysShowRadiusSquared, raycastRadiusSquared, debugParticles, 1.5f, blockView, playerLocation, otherPlayer, particleSpawner);
playerView.setVisibility(otherPlayer, canSee, currentTick, worldEpoch);
});
timings.addPlayerChecked(checked);
@@ -422,7 +430,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);
@@ -431,14 +439,16 @@ public abstract class AsyncEngine implements Engine {
private void checkTileEntities(PlayerData player, Locatable playerLocation, TileEntityConfig tileEntityConfig, boolean debugParticles, BlockView blockView, int currentTick, int worldEpoch, TickTimingBatch timings) {
long modeToken = blockView.tileEntityCheckModeToken();
int alwaysShowRadiusSquared = tileEntityConfig.alwaysShowRadiusSquared();
int raycastRadiusSquared = tileEntityConfig.raycastRadiusSquared();
int checked = blockView.updateVisibilityForEachNeedingRecheck(tileEntityConfig.getVisibleRecheckIntervalTicks(), currentTick, modeToken, worldEpoch, tileEntityLocation -> {
if (playerLocation.distanceSquared(tileEntityLocation) > (double) tileEntityConfig.getRaycastRadius() * tileEntityConfig.getRaycastRadius()) {
if (playerLocation.distanceSquared(tileEntityLocation) > raycastRadiusSquared) {
timings.incrementTileRadiusSkipped();
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(), alwaysShowRadiusSquared, 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;
@@ -22,4 +22,6 @@ public interface ParticleSpawner {
void spawnParticleAt(Locatable locatable, Colour colour);
void spawnParticleAt(UUID world, Spatial spatial, Colour colour);
void spawnParticleAt(UUID world, double x, double y, double z, Colour colour);
}
@@ -1,294 +1,125 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright © 2026 Cubicake.
* This file is part of RaycastedAntiESP.
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 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) {
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);
}
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;
}
/*
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.
* 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 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 boolean raycastUnrolledAccumulated(int maxOccluding, final int alwaysShowRadiusSquared, final int maxRaycastRadiusSquared, boolean debug,
float yOffsetEnd, final BlockView snap, final Locatable start, final Spatial end, ParticleSpawner spawner) {
double startX = start.x();
double startY = start.y();
double startZ = start.z();
double endOffset = end instanceof BlockSpatial ? 0.5 : 0.0;
RayDirection direction = RayDirection.from(end.x() + endOffset, end.y() + endOffset + yOffsetEnd, end.z() + endOffset, startX, startY, startZ);
double lengthSquared = direction.getLengthSquared();
if (lengthSquared <= alwaysShowRadiusSquared) return true;
if (lengthSquared > maxRaycastRadiusSquared) return false;
double total = direction.normaliseAndGetLength(lengthSquared);
float finalDist = (float) (total - 1);
RayChunkSection currentChunk = new RayChunkSection().updateFrom(current);
ChunkOcclusionView currentOcclusionView = snap.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
final RayAdvancer rayAdvancer = debug ? new DebugRayAdvancer(startX, startY, startZ, direction, snap, start.world(), spawner) : new RayAdvancer(startX, startY, startZ, direction, snap);
int occluded = 0;
float traveled = 0;
final float fourSteps = stepSize * 4.0f;
while (traveled + fourSteps <= finalDist) {
current.advance(direction);
int blockX = current.blockX();
int blockY = current.blockY();
int blockZ = current.blockZ();
if (blockX >> 4 != currentChunk.chunkX || blockY >> 4 != currentChunk.chunkY || blockZ >> 4 != currentChunk.chunkZ) {
currentChunk.updateFrom(current);
currentOcclusionView = snap.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
}
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded++;
current.advance(direction);
blockX = current.blockX();
blockY = current.blockY();
blockZ = current.blockZ();
if (blockX >> 4 != currentChunk.chunkX || blockY >> 4 != currentChunk.chunkY || blockZ >> 4 != currentChunk.chunkZ) {
currentChunk.updateFrom(current);
currentOcclusionView = snap.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
}
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded++;
current.advance(direction);
blockX = current.blockX();
blockY = current.blockY();
blockZ = current.blockZ();
if (blockX >> 4 != currentChunk.chunkX || blockY >> 4 != currentChunk.chunkY || blockZ >> 4 != currentChunk.chunkZ) {
currentChunk.updateFrom(current);
currentOcclusionView = snap.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
}
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded++;
current.advance(direction);
blockX = current.blockX();
blockY = current.blockY();
blockZ = current.blockZ();
if (blockX >> 4 != currentChunk.chunkX || blockY >> 4 != currentChunk.chunkY || blockZ >> 4 != currentChunk.chunkZ) {
currentChunk.updateFrom(current);
currentOcclusionView = snap.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
}
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded++;
if (occluded >= maxOccluding) return false;
traveled += fourSteps;
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;
}
for (; traveled < finalDist; traveled += stepSize) {
current.advance(direction);
int blockX = current.blockX();
int blockY = current.blockY();
int blockZ = current.blockZ();
if (blockX >> 4 != currentChunk.chunkX || blockY >> 4 != currentChunk.chunkY || blockZ >> 4 != currentChunk.chunkZ) {
currentChunk.updateFrom(current);
currentOcclusionView = snap.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
}
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded++;
}
return occluded < maxOccluding;
while (remainingSteps-- > 0) rayAdvancer.advance();
return rayAdvancer.occluded <= maxOccluding;
}
private static final class RayPosition {
private double x, y, z;
private static sealed class RayAdvancer extends RayPosition permits DebugRayAdvancer {
private final RayDirection direction;
private final BlockView blockView;
private void advance(RayDirection direction) {
x += direction.x;
y += direction.y;
z += direction.z;
private int chunkX, chunkY, chunkZ;
private ChunkOcclusionView currentOcclusionView;
private int occluded = 0;
private RayAdvancer(double startX, double startY, double startZ, RayDirection direction, BlockView blockView) {
super(startX, startY, startZ);
this.direction = direction;
chunkX = blockX() >> 4;
chunkY = blockY() >> 4;
chunkZ = blockZ() >> 4;
currentOcclusionView = blockView.getChunkOcclusionView(chunkX, chunkY, chunkZ);
this.blockView = blockView;
}
private int blockX() {
return (int) Math.floor(x);
private void advance() {
add(direction);
int blockX = blockX();
int blockY = blockY();
int blockZ = blockZ();
if (!isCurrentChunk(blockX, blockY, blockZ)) {
moveToChunk(blockX, blockY, blockZ);
currentOcclusionView = blockView.getChunkOcclusionView(chunkX, chunkY, chunkZ);
}
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) {
occluded++;
particleRed();
} else particleGreen();
}
private int blockY() {
return (int) Math.floor(y);
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 int blockZ() {
return (int) Math.floor(z);
private void moveToChunk(int blockX, int blockY, int blockZ) {
chunkX = blockX >> 4;
chunkY = blockY >> 4;
chunkZ = blockZ >> 4;
}
private int chunkX() {
return blockX() >> 4;
}
void particleGreen() {}
void particleRed() {}
}
private int chunkY() {
return blockY() >> 4;
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 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;
@@ -296,8 +127,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);
}
}
@@ -310,28 +155,21 @@ 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 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;
Loaded 100 of 182 files, more files were not shown because too many files have changed in this diff. Show more