forked from upstream/RaycastedAntiESP
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
419a52db1e
|
||
|
|
bdbcd876a5
|
||
|
|
e6ea795d27 | ||
|
|
7f2b45f97c | ||
|
|
fa7fd4fdd7 | ||
|
|
d8d81c4662 | ||
|
|
b338dc2175 | ||
|
|
3ab250e4ef | ||
|
|
231d2bc7d1 |
No files matched your search
@@ -0,0 +1 @@
|
||||
.gitea/CODEOWNERS linguist-detectable=false
|
||||
@@ -0,0 +1,3 @@
|
||||
# Pull requests request review from the eligible staff team(s).
|
||||
# One approval from either an Admin or Developer satisfies branch protection.
|
||||
* @trueog/Admins @trueog/Developers
|
||||
@@ -1,4 +1,6 @@
|
||||
This is a simple server-side plugin for PaperMC (May also work with Spigot, this is untested) that hides entities from players if they do not have line-of-sight. All raycasts are run async to reduce performance impact.
|
||||
RaycastedAntiESP-OG is an MIT Licensed fork of [RaycastedAntiESP](https://github.com/Cubicake/RaycastedAntiESP) maintained by [TrueOG Network](https://trueog.net) for Purpur 1.19.4.
|
||||
|
||||
This is a simple server-side plugin for PaperMC (May also work with Spigot, this is untested) that hides/culls entities from players if they do not have line-of-sight. All raycasts are run async to reduce performance impact.
|
||||
Use cases:
|
||||
|
||||
- To prevent mob nametags from being visible through walls
|
||||
@@ -9,18 +11,26 @@ Use cases:
|
||||
- Reduce client lag
|
||||
- In servers with large megabases full of item frames, armour stands and other entities, RaycastedEntityOcclusion will prevent these entities from lagging the client unless they are within line-of-sight
|
||||
|
||||
Config info:
|
||||
Default Config:
|
||||
|
||||
The config has three settings:
|
||||
|
||||
AlwaysShowRadius: 4
|
||||
RaycastRadius: 64
|
||||
SearchRadius: 72
|
||||
- AlwaysShowRadius: 8
|
||||
- RaycastRadius: 48
|
||||
- SearchRadius: 52
|
||||
- MoreChecks: false
|
||||
- OccludePlayers: false
|
||||
- RecheckInterval: 20
|
||||
|
||||
Entities inside the AlwaysShowRadius are always shown, even if occluded. This is to prevent nasty surprises when turning a corner quickly.
|
||||
The SearchRadius is a misnomer, it's actually a cubic bounding box around the player within which entities will be checked. If an entity is within the SearchRadius but not the RaycastRadius, it will be automatically hidden.
|
||||
The RaycastRadius is the radius where entities will be checked. If an entity is currently hidden it will run a raycast every tick. This is to quickly detect when the entity becomes visible. If the entity is currently visible, it will only ruun the raycast every 10 ticks to reduce performance impact.
|
||||
|
||||
The SearchRadius is a cubic bounding box around the player within which entities will be checked. If an entity is within the SearchRadius but not the RaycastRadius, it will be automatically hidden.
|
||||
|
||||
The RaycastRadius is the radius where entities will be checked. If an entity is currently hidden it will run a raycast every tick. This is to quickly detect when the entity becomes visible. If the entity is currently visible, it will only run the raycast every {RecheckInterval} ticks to reduce performance impact.
|
||||
|
||||
MoreChecks toggles between two raycasting modes. By default (MoreChecks = false) the plugin runs one raycast from the center of each mob to the player. This means that if the center of the mob is hidden but some parts should be visible, the player won't be able to see the mob at all. Enabling MoreChecks runs a raycast from the top, bottom, left and right of the entity to the player.
|
||||
|
||||
OccludePlayers toggles whether players will be checked. Enabling this prevents ESP mods from revealing players.
|
||||
|
||||
Known issues:
|
||||
- Players are also occluded. This itself is not an issue, however hiding players also removes them from the tab list and command autocomplete.
|
||||
- Due to the nature of the plugin, there will be a short delay once an entity should be visible before it appears, causing it to appear like it "popped" into view
|
||||
- Due to the nature of the plugin, there will be a short delay once an entity should be visible before it appears, causing it to appear like it "popped" into view. This issue is partially resolved by turning MoreChecks on
|
||||
- If OccludePlayers is set to true any occluded players will be removed from tablist
|
||||
- When updating the plugin to a version with more config versions, no checks are performed to detect this and add the new configs to config.yml. This means that the config file will be missing several options. (This is an issue when updating to v1.1.0 or v1.2.0). To fix, just copy the new config options from the Default Config section above.
|
||||
+1
-1
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'games.cubi'
|
||||
version = '1.2.0'
|
||||
version = '1.3.0-dev'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
@@ -19,7 +19,8 @@ public class CheckEntityVisibility {
|
||||
private int raycastRadius;
|
||||
private int searchRadius;
|
||||
private boolean moreChecks;
|
||||
private boolean occludePlayers;
|
||||
private boolean cullPlayers;
|
||||
private boolean sneakCull;
|
||||
private int recheckInterval;
|
||||
private int tickCounter = 0;
|
||||
//ConcurrentHashMap allows for Thread-safe operations. Don't use regular hashmaps
|
||||
@@ -32,7 +33,8 @@ public class CheckEntityVisibility {
|
||||
this.raycastRadius = plugin.raycastRadius;
|
||||
this.searchRadius = plugin.searchRadius;
|
||||
this.moreChecks = plugin.moreChecks;
|
||||
this.occludePlayers = plugin.occludePlayers;
|
||||
this.cullPlayers = plugin.cullPlayers;
|
||||
this.sneakCull = plugin.sneakCull;
|
||||
this.recheckInterval = plugin.recheckInterval;
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
@@ -54,6 +56,16 @@ public class CheckEntityVisibility {
|
||||
}.runTaskTimer(plugin, 0L, 1L);
|
||||
}
|
||||
|
||||
public void updateConfigValues() {
|
||||
this.alwaysShowRadius = plugin.alwaysShowRadius;
|
||||
this.raycastRadius = plugin.raycastRadius;
|
||||
this.searchRadius = plugin.searchRadius;
|
||||
this.moreChecks = plugin.moreChecks;
|
||||
this.cullPlayers = plugin.cullPlayers;
|
||||
this.sneakCull = plugin.sneakCull;
|
||||
this.recheckInterval = plugin.recheckInterval;
|
||||
}
|
||||
|
||||
public void runVisibilityCheck(Player player) {
|
||||
World world = player.getWorld();
|
||||
List<Entity> nearbyEntities = player.getNearbyEntities(searchRadius, searchRadius, searchRadius);
|
||||
@@ -62,7 +74,10 @@ public class CheckEntityVisibility {
|
||||
if (world != player.getWorld()) {
|
||||
return;
|
||||
}
|
||||
if (entity instanceof Player && !occludePlayers) {
|
||||
if (entity instanceof Player && !cullPlayers) {
|
||||
continue;
|
||||
}
|
||||
if (entity instanceof Player p && sneakCull && !p.isSneaking()) {
|
||||
continue;
|
||||
}
|
||||
double distance = player.getLocation().distance(entity.getLocation());
|
||||
@@ -76,7 +91,10 @@ public class CheckEntityVisibility {
|
||||
addEntityToHide(player, entity);
|
||||
continue;
|
||||
}
|
||||
if (!player.canSee(entity) || plugin.tickCounter % recheckInterval == 0) {
|
||||
Boolean canSee = player.canSee(entity);
|
||||
int check = tickCounter % recheckInterval;
|
||||
//plugin.getLogger().info("check: " + check + " cansee " + canSee);
|
||||
if (!canSee || check == 0) {
|
||||
//check whether to run intensive or light checks
|
||||
Double height = entity.getHeight();
|
||||
if (moreChecks) {
|
||||
@@ -122,12 +140,14 @@ public class CheckEntityVisibility {
|
||||
}
|
||||
|
||||
|
||||
private void addEntityToShow(Player player, Entity entity) {
|
||||
|
||||
|
||||
public void addEntityToShow(Player player, Entity entity) {
|
||||
entitiesToShow.computeIfAbsent(player, k -> ConcurrentHashMap.newKeySet()).add(entity);
|
||||
entitiesToHide.computeIfAbsent(player, k -> ConcurrentHashMap.newKeySet()).remove(entity);
|
||||
}
|
||||
|
||||
private void addEntityToHide(Player player, Entity entity) {
|
||||
public void addEntityToHide(Player player, Entity entity) {
|
||||
entitiesToHide.computeIfAbsent(player, k -> ConcurrentHashMap.newKeySet()).add(entity);
|
||||
entitiesToShow.computeIfAbsent(player, k -> ConcurrentHashMap.newKeySet()).remove(entity);
|
||||
}
|
||||
@@ -137,13 +157,19 @@ public class CheckEntityVisibility {
|
||||
for (Map.Entry<Player, Set<Entity>> entry : entitiesToShow.entrySet()) {
|
||||
Player player = entry.getKey();
|
||||
for (Entity entity : entry.getValue()) {
|
||||
player.showEntity(plugin, entity);
|
||||
if (entity instanceof Player p) {
|
||||
player.showPlayer(plugin, p);
|
||||
}
|
||||
else player.showEntity(plugin, entity);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<Player, Set<Entity>> entry : entitiesToHide.entrySet()) {
|
||||
Player player = entry.getKey();
|
||||
for (Entity entity : entry.getValue()) {
|
||||
player.hideEntity(plugin, entity);
|
||||
if (entity instanceof Player p) {
|
||||
player.hidePlayer(plugin, p);
|
||||
}
|
||||
else player.hideEntity(plugin, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,19 @@ public class CommandHandler implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args.length != 0 && args[0].equalsIgnoreCase("reload")) {
|
||||
plugin.loadConfig();
|
||||
plugin.getCheckEntityVisibility().updateConfigValues();
|
||||
sender.sendMessage("RaycastedEntityOcclusion config reloaded.");
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage("RaycastedEntityOcclusion v" + plugin.getDescription().getVersion());
|
||||
|
||||
return false;
|
||||
sender.sendMessage("AlwaysShowRadius: " + plugin.alwaysShowRadius);
|
||||
sender.sendMessage("RaycastRadius: " + plugin.raycastRadius);
|
||||
sender.sendMessage("SearchRadius: " + plugin.searchRadius);
|
||||
sender.sendMessage("MoreChecks: " + plugin.moreChecks);
|
||||
sender.sendMessage("CullPlayers: " + plugin.cullPlayers);
|
||||
sender.sendMessage("RecheckInterval: " + plugin.recheckInterval);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -44,4 +44,29 @@ public class Raycast {
|
||||
private static boolean isOccluding(Material material) {
|
||||
return material.isOccluding();
|
||||
}
|
||||
|
||||
public static boolean syncRaycast(Location start, Location end, RaycastedEntityOcclusion plugin) {
|
||||
Vector direction = end.toVector().subtract(start.toVector()).normalize();
|
||||
double distance = start.distance(end);
|
||||
|
||||
|
||||
// Perform the ray trace
|
||||
RayTraceResult result = start.getWorld().rayTraceBlocks(start, direction, distance,
|
||||
FluidCollisionMode.NEVER, // Ignore fluids
|
||||
true, // Pass through transparent blocks
|
||||
// Check if the block is occluding
|
||||
(block) -> isOccluding(block.getType())
|
||||
);
|
||||
|
||||
// Check if the ray hit a solid block or reached the player
|
||||
if (result == null || result.getHitBlock() == null) {
|
||||
// No solid block was hit, so the ray reached the player
|
||||
return true;
|
||||
} else {
|
||||
// A solid block was hit
|
||||
return false;
|
||||
//plugin.getLogger().info("Raycast hit a solid block: " + result.getHitBlock().getType() + " at " + result.getHitBlock().getLocation());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package games.cubi.raycastedEntityOcclusion;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public final class RaycastedEntityOcclusion extends JavaPlugin {
|
||||
@@ -8,11 +9,12 @@ public final class RaycastedEntityOcclusion extends JavaPlugin {
|
||||
public int raycastRadius;
|
||||
public int searchRadius;
|
||||
public boolean moreChecks;
|
||||
public boolean occludePlayers;
|
||||
public boolean cullPlayers;
|
||||
public int recheckInterval;
|
||||
public int tickCounter = 0;
|
||||
public boolean sneakCull;
|
||||
public RaycastedEntityOcclusion plugin = this;
|
||||
public CheckEntityVisibility checkEntityVisibility;
|
||||
public SneakListener sneakListener;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@@ -22,8 +24,10 @@ public final class RaycastedEntityOcclusion extends JavaPlugin {
|
||||
new Metrics(this, pluginId);
|
||||
|
||||
checkEntityVisibility = new CheckEntityVisibility(plugin);
|
||||
sneakListener = new SneakListener(plugin);
|
||||
|
||||
getCommand("raycastedentityocclusion").setExecutor(new CommandHandler(plugin));
|
||||
getServer().getPluginManager().registerEvents(sneakListener, plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,22 +36,44 @@ public final class RaycastedEntityOcclusion extends JavaPlugin {
|
||||
}
|
||||
|
||||
|
||||
private void loadConfig() {
|
||||
public void loadConfig() {
|
||||
saveDefaultConfig();
|
||||
reloadConfig();
|
||||
FileConfiguration config = getConfig();
|
||||
|
||||
alwaysShowRadius = getConfig().getInt("AlwaysShowRadius", 4);
|
||||
raycastRadius = getConfig().getInt("RaycastRadius", 64);
|
||||
searchRadius = getConfig().getInt("SearchRadius", 72);
|
||||
moreChecks = getConfig().getBoolean("MoreChecks", false);
|
||||
occludePlayers = getConfig().getBoolean("OccludePlayers", false);
|
||||
recheckInterval = getConfig().getInt("RecheckInterval", 10);
|
||||
alwaysShowRadius = config.getInt("AlwaysShowRadius", 4);
|
||||
raycastRadius = config.getInt("RaycastRadius", 48);
|
||||
searchRadius = config.getInt("SearchRadius", 48);
|
||||
moreChecks = config.getBoolean("MoreChecks", false);
|
||||
cullPlayers = config.getBoolean("CullPlayers", false);
|
||||
sneakCull = config.getBoolean("OnlyCullSneakingPlayers", false);
|
||||
|
||||
recheckInterval = config.getInt("RecheckInterval", 20);
|
||||
|
||||
// This ensures that if the config is not set, it will be set to the default value
|
||||
if (alwaysShowRadius == 4) config.set("AlwaysShowRadius", 4);
|
||||
if (raycastRadius == 48) config.set("RaycastRadius", 48);
|
||||
if (searchRadius == 48) config.set("SearchRadius", 48);
|
||||
if (!moreChecks) config.set("MoreChecks", false);
|
||||
if (!cullPlayers) config.set("CullPlayers", false);
|
||||
if (!sneakCull) config.set("OnlyCullSneakingPlayers", false);
|
||||
if (recheckInterval == 20) config.set("RecheckInterval", 20);
|
||||
|
||||
|
||||
getLogger().info("AlwaysShowRadius: " + alwaysShowRadius);
|
||||
getLogger().info("RaycastRadius: " + raycastRadius);
|
||||
getLogger().info("SearchRadius: " + searchRadius);
|
||||
getLogger().info("MoreChecks: " + moreChecks);
|
||||
getLogger().info("OccludePlayers: " + occludePlayers);
|
||||
getLogger().info("CullPlayers: " + cullPlayers);
|
||||
getLogger().info("OnlyCullSneakingPlayers: " + sneakCull);
|
||||
getLogger().info("RecheckInterval: " + recheckInterval);
|
||||
|
||||
saveConfig();
|
||||
}
|
||||
public CheckEntityVisibility getCheckEntityVisibility() {
|
||||
return checkEntityVisibility;
|
||||
}
|
||||
public SneakListener getSneakListener() {
|
||||
return sneakListener;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package games.cubi.raycastedEntityOcclusion;
|
||||
|
||||
import jdk.jfr.Label;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SneakListener implements Listener {
|
||||
RaycastedEntityOcclusion plugin;
|
||||
public SneakListener(RaycastedEntityOcclusion plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@EventHandler
|
||||
public void onSneak(org.bukkit.event.player.PlayerToggleSneakEvent event) {
|
||||
if (plugin.sneakCull) {
|
||||
Player player = event.getPlayer();
|
||||
int searchRadius = plugin.searchRadius;
|
||||
List<Player> nearbyPlayers = player.getNearbyEntities(searchRadius, searchRadius, searchRadius).stream()
|
||||
.filter(entity -> entity instanceof Player)
|
||||
.map(entity -> (Player) entity)
|
||||
.toList();
|
||||
for (Player nearbyPlayer : nearbyPlayers) {
|
||||
if (plugin.moreChecks){
|
||||
double height = nearbyPlayer.getHeight();
|
||||
double width = player.getWidth();
|
||||
Location checkOne = player.getLocation().add(0, height - 0.01, 0);
|
||||
Location checkTwo = player.getLocation().add(0, 0.01, 0);
|
||||
Location checkThree = player.getLocation().add(width / 2, height / 2, 0);
|
||||
Location checkFour = player.getLocation().add(-width / 2, height / 2, 0);
|
||||
CheckEntityVisibility checkEntityVisibility = plugin.getCheckEntityVisibility();
|
||||
Raycast.asyncRaycast(nearbyPlayer.getEyeLocation(), checkOne, plugin, canSeePlayer -> {
|
||||
if (canSeePlayer) {
|
||||
checkEntityVisibility.addEntityToShow(nearbyPlayer, player);
|
||||
} else {
|
||||
Raycast.asyncRaycast(player.getEyeLocation(), checkTwo, plugin, canSeePlayer2 -> {
|
||||
if (canSeePlayer2) checkEntityVisibility.addEntityToShow(nearbyPlayer, player);
|
||||
else {
|
||||
Raycast.asyncRaycast(player.getEyeLocation(), checkThree, plugin, canSeePlayer3 -> {
|
||||
if (canSeePlayer3) checkEntityVisibility.addEntityToShow(nearbyPlayer, player);
|
||||
else {
|
||||
Raycast.asyncRaycast(player.getEyeLocation(), checkFour, plugin, canSeePlayer4 -> {
|
||||
if (canSeePlayer4) checkEntityVisibility.addEntityToShow(nearbyPlayer, player);
|
||||
else checkEntityVisibility.addEntityToHide(nearbyPlayer, player);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
Raycast.asyncRaycast(nearbyPlayer.getEyeLocation(), player.getEyeLocation(), plugin, canSeePlayer -> {
|
||||
if (canSeePlayer) {
|
||||
plugin.checkEntityVisibility.addEntityToShow(nearbyPlayer, player);
|
||||
} else {
|
||||
plugin.checkEntityVisibility.addEntityToHide(nearbyPlayer, player);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
AlwaysShowRadius: 8
|
||||
RaycastRadius: 48
|
||||
SearchRadius: 52
|
||||
SearchRadius: 48
|
||||
MoreChecks: false #This will enable more raycasts per mob, increasing performance hit but showing partially visible mobs
|
||||
OccludePlayers: false #This will disable occlusion checks for players. Setting this to true is the interim fix for players being removed from tab list
|
||||
CullPlayers: false #Enabling this will make the plugin cull hidden players alongside entities
|
||||
OnlyCullSneakingPlayers: false #Enabling this will make the plugin only cull hidden players that are sneaking. Note that CullPlayers must also be true.
|
||||
RecheckInterval: 20 #Time in ticks between rechecking visible mobs
|
||||
Reference in new issue
Block a user