mirror of
https://github.com/Cubicake/RaycastedAntiESP.git
synced 2026-11-17 14:29:40 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a73c2509a | ||
|
|
e3731f76f0 | ||
|
|
bd1f6ad482 | ||
|
|
951e4f4ad9 | ||
|
|
114746aeaf | ||
|
|
9dc9652917 | ||
|
|
b97f675159 | ||
|
|
f5e16fc75d | ||
|
|
c228cef24a | ||
|
|
098aab5e31 | ||
|
|
31b500bc7b | ||
|
|
d5e3281cf2 | ||
|
|
98dbefd576 | ||
|
|
4dce9b3278 |
No files matched your search
+2
-2
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'games.cubi'
|
||||
version = '1.6.0'
|
||||
version = '1.6.1'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -22,7 +22,7 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
|
||||
compileOnly("com.github.retrooper:packetevents-spigot:2.8.0") //Latest is 2.9.4, but using 2.8.0 api still works and allows for compatibility with older versions
|
||||
compileOnly("com.github.retrooper:packetevents-spigot:2.8.0")
|
||||
}
|
||||
|
||||
def targetJavaVersion = 21
|
||||
|
||||
@@ -3,6 +3,7 @@ package games.cubi.raycastedEntityOcclusion;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
public class Logger {
|
||||
private final static String PREFIX = "<hover:show_text:'Raycasted Entity Occlusions'><click:suggest_command:'/reo'><grey>[<gold>REO<grey>]</click></hover><reset> ";
|
||||
@@ -28,6 +29,13 @@ public class Logger {
|
||||
forwardLog(/* PREFIX_ERROR+ */ message, Level.ERROR);
|
||||
}
|
||||
|
||||
public static void debug(String message, @Range(from = 1, to = 10) int level) {
|
||||
int debugLevel = 2; // TODO: grab real debug level from config
|
||||
if (debugLevel <= level) {
|
||||
forwardLog(message, Level.INFO);
|
||||
}
|
||||
}
|
||||
|
||||
private static void forwardLog(String message, Level severity) {
|
||||
if (plugin == null) {
|
||||
plugin = JavaPlugin.getProvidingPlugin(Logger.class);
|
||||
|
||||
@@ -16,13 +16,15 @@ public class PacketsListener implements PacketListener {
|
||||
@Override
|
||||
public void onPacketSend(PacketSendEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Server.PLAYER_INFO_REMOVE) {
|
||||
if (packetProcessor == null) {
|
||||
// Initialize the PacketProcessor if it hasn't been initialized yet since the initialization of the PacketsListener is on load, not on enable.
|
||||
packetProcessor = plugin.getPacketProcessor();
|
||||
}
|
||||
initializePacketProcessor();
|
||||
packetProcessor.processPlayerInfoRemovePacket(event);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializePacketProcessor() {
|
||||
if (packetProcessor == null) {
|
||||
packetProcessor = plugin.getPacketProcessor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ import org.bukkit.Color;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -23,12 +25,16 @@ import java.util.HashSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
public class Engine {
|
||||
|
||||
public static ConcurrentHashMap<Location, Set<Player>> canSeeTileEntity = new ConcurrentHashMap<>();
|
||||
public static Set<Chunk> syncRecheck = ConcurrentHashMap.newKeySet();
|
||||
|
||||
private final static BlockData STONE = Material.STONE.createBlockData();
|
||||
private final static BlockData DEEPSLATE = Material.DEEPSLATE.createBlockData();
|
||||
|
||||
private static class RayJob {
|
||||
final Player player;
|
||||
final Entity target;
|
||||
@@ -54,6 +60,17 @@ public class Engine {
|
||||
visible = v;
|
||||
}
|
||||
}
|
||||
private static class TileResult {
|
||||
final Player player;
|
||||
final Location loc;
|
||||
final boolean visible;
|
||||
|
||||
TileResult(Player p, Location location, boolean v) {
|
||||
player = p;
|
||||
loc = location;
|
||||
visible = v;
|
||||
}
|
||||
}
|
||||
|
||||
public static void runEngine(ConfigManager cfg, ChunkSnapshotManager snapMgr, MovementTracker tracker, RaycastedEntityOcclusion plugin) {
|
||||
// ----- PHASE 1: SYNC GATHER -----
|
||||
@@ -63,6 +80,8 @@ public class Engine {
|
||||
for (Chunk c : syncRecheck) {
|
||||
if (c.isLoaded()) {
|
||||
plugin.getChunkSnapshotManager().snapshotChunk(c);
|
||||
syncRecheck.remove(c);
|
||||
Logger.info("Successfully rechecked chunk " + c.getX() + ", " + c.getZ() + " in world " + c.getWorld().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,6 +158,8 @@ public class Engine {
|
||||
|
||||
}
|
||||
|
||||
private static ConcurrentLinkedQueue<TileResult> results = new ConcurrentLinkedQueue<>();
|
||||
|
||||
public static void runTileEngine(ConfigManager cfg, ChunkSnapshotManager snapMgr, MovementTracker tracker, RaycastedEntityOcclusion plugin) {
|
||||
if (cfg.checkTileEntities) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
@@ -147,6 +168,7 @@ public class Engine {
|
||||
//get player's chunk location
|
||||
int chunkX = p.getLocation().getBlockX() >> 4;
|
||||
int chunkZ = p.getLocation().getBlockZ() >> 4;
|
||||
|
||||
//async run with vars passed in
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
int chunksRadius = (cfg.searchRadius + 15) / 16;
|
||||
@@ -167,26 +189,25 @@ public class Engine {
|
||||
|
||||
double distSquared = loc.distanceSquared(p.getLocation());
|
||||
if (distSquared > cfg.searchRadius * cfg.searchRadius) {
|
||||
hideTileEntity(p, loc);
|
||||
results.add(new TileResult(p, loc,false));
|
||||
continue;
|
||||
}
|
||||
if (distSquared < cfg.alwaysShowRadius * cfg.alwaysShowRadius) {
|
||||
showTileEntity(p, loc);
|
||||
results.add(new TileResult(p, loc,true));
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean result = RaycastUtil.raycast(p.getEyeLocation(), loc, cfg.maxOccludingCount, cfg.debugMode, snapMgr);
|
||||
if (cfg.engineMode == 2) {
|
||||
boolean visible = RaycastUtil.raycast(p.getEyeLocation(), loc, cfg.maxOccludingCount, cfg.debugMode, snapMgr);
|
||||
if (cfg.engineMode == 2 && !visible) {
|
||||
Location predEye = tracker.getPredictedLocation(p);
|
||||
if (predEye != null) {
|
||||
boolean result2 = RaycastUtil.raycast(predEye, loc, cfg.maxOccludingCount, cfg.debugMode, snapMgr);
|
||||
if (result2) {
|
||||
result = true;
|
||||
visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
syncToggleTileEntity(p, loc, result, plugin);
|
||||
if (result) {
|
||||
if (visible) {
|
||||
canSeeTileEntity.computeIfAbsent(loc, k -> ConcurrentHashMap.newKeySet()).add(p);
|
||||
} else {
|
||||
Set<Player> seenPlayers = canSeeTileEntity.get(loc);
|
||||
@@ -197,36 +218,46 @@ public class Engine {
|
||||
}
|
||||
}
|
||||
}
|
||||
results.add(new TileResult(p, loc, visible));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
for (TileResult r : results) {
|
||||
Player p = r.player;
|
||||
Location loc = r.loc;
|
||||
boolean visible = r.visible;
|
||||
|
||||
public static void hideTileEntity(Player p, Location location) {
|
||||
if (p.hasPermission("raycastedentityocclusions.bypass")) return;
|
||||
BlockData fake;
|
||||
if (location.getBlockY() < 0) {
|
||||
fake = Material.DEEPSLATE.createBlockData();
|
||||
}
|
||||
else {
|
||||
fake = Material.STONE.createBlockData();
|
||||
}
|
||||
p.sendBlockChange(location, fake);
|
||||
}
|
||||
public static void showTileEntity(Player p, Location location) {
|
||||
Block block = location.getBlock();
|
||||
BlockData data = block.getBlockData();
|
||||
p.sendBlockChange(location, data);
|
||||
|
||||
}
|
||||
public static void syncToggleTileEntity(Player p, Location loc, boolean bool, RaycastedEntityOcclusion plugin) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
if (bool) {
|
||||
showTileEntity(p, loc);
|
||||
} else {
|
||||
hideTileEntity(p, loc);
|
||||
syncToggleTileEntity(p, loc, visible, plugin);
|
||||
results.remove(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void hideTileEntity(Player p, Location location, RaycastedEntityOcclusion plugin) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
if (p.hasPermission("raycastedentityocclusions.bypass")) return;
|
||||
if (location.getBlockY() < 0) p.sendBlockChange(location, DEEPSLATE);
|
||||
else p.sendBlockChange(location, STONE);
|
||||
});
|
||||
}
|
||||
public static void showTileEntity(Player p, Location location, RaycastedEntityOcclusion plugin) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
Block block = location.getBlock();
|
||||
BlockState data = block.getState();
|
||||
if (data instanceof TileState tileData) {
|
||||
p.sendBlockChange(location, block.getBlockData());
|
||||
p.sendBlockUpdate(location, tileData);
|
||||
}
|
||||
else throw new RuntimeException("Attempting to show a block which isn't a tile entity");
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
public static void syncToggleTileEntity(Player p, Location loc, boolean show, RaycastedEntityOcclusion plugin) {
|
||||
if (show) {
|
||||
showTileEntity(p, loc, plugin);
|
||||
} else {
|
||||
hideTileEntity(p, loc, plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
-6
@@ -59,9 +59,7 @@ public class ChunkSnapshotManager {
|
||||
if (now - e.getValue().lastRefresh >= cfg.snapshotRefreshInterval * 1000L && chunksRefreshed < chunksToRefreshMaximum) {
|
||||
chunksRefreshed++;
|
||||
String key = e.getKey();
|
||||
//String[] parts = key.split(":");
|
||||
Chunk c = getKeyChunk(key);
|
||||
e.setValue(takeSnapshot(c, now));
|
||||
snapshotChunk(key);
|
||||
}
|
||||
}
|
||||
if (cfg.debugMode) {
|
||||
@@ -85,6 +83,9 @@ public class ChunkSnapshotManager {
|
||||
}
|
||||
dataMap.put(key(c), takeSnapshot(c, System.currentTimeMillis()));
|
||||
}
|
||||
public void snapshotChunk(String key) {
|
||||
snapshotChunk(getKeyChunk(key));
|
||||
}
|
||||
public void removeChunkSnapshot(Chunk c) {
|
||||
if (cfg.debugMode) {
|
||||
Logger.info("ChunkSnapshotManager: Removing snapshot of chunk " + c.getWorld().getName() + ":" + c.getX() + ":" + c.getZ());
|
||||
@@ -99,7 +100,7 @@ public class ChunkSnapshotManager {
|
||||
}
|
||||
Data d = dataMap.get(key(loc.getChunk()));
|
||||
if (d != null) {
|
||||
d.delta.put(loc, m);
|
||||
d.delta.put(blockLoc(loc), m);
|
||||
if (cfg.checkTileEntities) {
|
||||
// Check if the block is a tile entity
|
||||
BlockState data = loc.getBlock().getState();
|
||||
@@ -114,6 +115,7 @@ public class ChunkSnapshotManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
else {Logger.error("Data map value empty, ignoring block update!");}
|
||||
}
|
||||
|
||||
private Data takeSnapshot(Chunk c, long now) {
|
||||
@@ -145,7 +147,7 @@ public class ChunkSnapshotManager {
|
||||
return c.getWorld().getName() + ":" + c.getX() + ":" + c.getZ();
|
||||
}
|
||||
public String key(World world, int x, int z) {
|
||||
return world + ":" + x + ":" + z;
|
||||
return world.getName() + ":" + x + ":" + z;
|
||||
}
|
||||
public int getKeyX(String key) {
|
||||
String[] parts = key.split(":");
|
||||
@@ -176,8 +178,9 @@ public class ChunkSnapshotManager {
|
||||
if (yLevel < d.minHeight || yLevel > d.maxHeight) {
|
||||
return null;
|
||||
}
|
||||
Material dm = d.delta.get(loc);
|
||||
Material dm = d.delta.get(blockLoc(loc));
|
||||
if (dm != null) {
|
||||
if (cfg.debugMode) Logger.info("Using delta");
|
||||
return dm;
|
||||
}
|
||||
int x = loc.getBlockX() & 0xF;
|
||||
@@ -201,4 +204,11 @@ public class ChunkSnapshotManager {
|
||||
//created to use in a debug command maybe
|
||||
}
|
||||
|
||||
public static Location blockLoc(Location fullLoc) {
|
||||
Location blockLoc = fullLoc.toBlockLocation();
|
||||
blockLoc.setYaw(0);
|
||||
blockLoc.setPitch(0);
|
||||
return blockLoc;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class UpdateChecker {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
|
||||
final String url = "https://api.modrinth.com/v2/project/raycasted-entity-occlusions/version?featured=true";
|
||||
final String url = "https://api.modrinth.com/v2/project/bCjNZu0C/version?featured=true";
|
||||
try (final InputStreamReader reader = new InputStreamReader(new URL(url).openConnection().getInputStream())) {
|
||||
final JsonArray array = new JsonArray();
|
||||
array.add(new BufferedReader(reader).readLine());
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
config-version: 1.0 # Do not change this value, it is used internally by the plugin to determine if the config is up to date.
|
||||
|
||||
checks:
|
||||
entities:
|
||||
enabled: true
|
||||
max-occluding-count: 3
|
||||
raycast-radius: 48
|
||||
always-show-radius: 16 # radius to always show entities
|
||||
recheck-interval: 50 # ticks between forced rechecks for visible entities
|
||||
engine-mode: 1 # 1 = straight-line; 2 = predictive and straight-line
|
||||
tile-entities:
|
||||
enabled: true
|
||||
max-occluding-count: 3
|
||||
raycast-radius: 48
|
||||
always-show-radius: 16
|
||||
recheck-interval: 0 # seconds between forced rechecks for visible tile entities. If set to 0, they will never be rechecked.
|
||||
engine-mode: 1 # 1 = straight-line; 2 = predictive and straight-line
|
||||
players:
|
||||
enabled: false
|
||||
only-cull-sneaking: false
|
||||
max-occluding-count: 3
|
||||
raycast-radius: 48
|
||||
always-show-radius: 16
|
||||
recheck-interval: 50 # ticks between forced rechecks for visible players
|
||||
engine-mode: 1 # 1 = straight-line; 2 = predictive and straight-line
|
||||
snapshots:
|
||||
chunk-refresh-interval: 60 # seconds between chunk snapshot refresh, won't change without restart
|
||||
debug:
|
||||
log-level: 1 # Scale from 0-10, where larger numbers mean more verbose logging and 0 disables logging
|
||||
particles: false # enable debug particles
|
||||
Reference in new issue
Block a user