Compare commits

...
25 Commits
Author SHA1 Message Date
Cubicake f4f4e64670 Prepare for release 2026-01-09 18:57:34 +01:00
Cubicake aaee14e4f2 Return air if chunk snapshot null 2026-01-05 17:57:24 +01:00
Cubicake 791ab79f54 Revert "IntelliJ is having another fit?"
This reverts commit af3b5f166d.
2025-12-23 22:40:05 +10:30
Cubicake af3b5f166d IntelliJ is having another fit? 2025-12-23 22:35:31 +10:30
Cubicake bb4d7eebca Potential perf improvement, pending testing 2025-12-15 16:24:42 +10:30
Cubicake 886e2e28a4 Minor changes 2025-12-04 16:42:07 +10:30
Cubicake 9d0f1163e7 Remove use of brigadier redirects [Todo: Pull change to main] 2025-11-12 13:38:17 +10:30
Cubicake eda3fd12f2 Lower minimum version to v1.20.6 2025-11-12 13:37:46 +10:30
Cubicake fb3e1d24f3 Make Async 2025-11-12 13:37:31 +10:30
Cubicake f4878c5afa Make Async 2025-11-12 08:50:39 +10:30
Cubicake 40b99d5c43 Clean up 2025-11-08 16:36:33 +10:30
Cubicake e448e18472 Support lower versions 2025-11-08 16:36:24 +10:30
Cubicake d806ae3c0b Support lower versions 2025-10-21 19:49:51 +10:30
Cubicake 34fe60a7ae Merge remote-tracking branch 'origin/main'
# Conflicts:
#	src/main/java/games/cubi/raycastedEntityOcclusion/Snapshot/ChunkSnapshotManager.java
2025-10-21 19:42:12 +10:30
Cubicake 0ff67e11a7 Improve Regex to handle suffixes ie v1.6.3-beta 2025-10-21 19:38:34 +10:30
Cubicake 98eaf72cae Part of the snapshot changes 2025-10-21 19:37:55 +10:30
Cubicake e5c7f6ef90 Comment 2025-10-21 19:37:27 +10:30
Cubicake da73bb26ec Temporary BlockLocation changes (v1.7.x already has a better system) 2025-10-21 19:37:04 +10:30
Cubicake bd57a9b72c Version bump 2025-10-21 19:36:26 +10:30
Cubicake 116f5e8e03 IntelliJ is having a fit 2025-10-18 16:04:25 +10:30
Cubicake bcfdd731e2 IntelliJ is having a fit 2025-10-18 15:59:17 +10:30
Cubicake e83ec5e6a2 Investigating a bug where tile entities being removed is not properly handled 2025-10-18 15:55:49 +10:30
Cubicake 2b48e7e8d2 Investigating a bug where tile entities being removed is not properly handled 2025-10-18 15:50:37 +10:30
Cubicake 7f1a284eae Remove unused import 2025-10-17 09:56:48 +10:30
Cubicake 87aba0e2b5 Fix minor bug with better version checking 2025-10-16 12:38:43 +10:30
10 changed files with 121 additions and 120 deletions

No files matched your search

-24
View File
@@ -1,24 +0,0 @@
Latest version: v1.6.1
The latest version can currently only be found on Modrinth https://modrinth.com/plugin/raycasted-entity-occlusions/
This is an async plugin for PaperMC and its forks that hides/culls entities (and tile entities) from players if they do not have line-of-sight.
The supported versions are 1.21.x PaperMC and Pufferfish. Other server versions and software may work too.
Use cases:
- Prevent cheating (anti-esp hacks)
- Block usage of pie-ray to locate underground bases
- Prevent mods such as mini-maps or cheat clients from displaying the locations of hidden entities
- 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. REO will cull those entities for the client, reducing the number of entities to process.
- Hide nametags behind walls
- Yes, this plugin is a bit overkill for doing that, yes you can do it anyways.
Dependencies:
- Packetevents (soft depend)
- Only needed if you are using the cull-players option and wish for the players to remain in the tablist
Known issues:
- 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 engine-mode to 2, and is worse for players with higher ping.
+3 -3
View File
@@ -4,7 +4,7 @@ plugins {
}
group = 'games.cubi'
version = '1.6.2'
version = '1.6.5'
repositories {
mavenCentral()
@@ -22,7 +22,7 @@ repositories {
}
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT")
compileOnly("com.github.retrooper:packetevents-spigot:2.8.0")
}
@@ -31,7 +31,7 @@ tasks {
// Configure the Minecraft version for our task.
// This is the only required configuration besides applying the plugin.
// Your plugin's jar (or shadowJar if present) will be used automatically.
minecraftVersion("1.21.10")
minecraftVersion("1.21.11")
}
}
@@ -11,8 +11,6 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
public class CommandsManager {
private final RaycastedEntityOcclusion plugin;
private final ConfigManager cfg;
@@ -22,9 +20,9 @@ public class CommandsManager {
this.cfg = cfg;
}
public LiteralCommandNode<CommandSourceStack> registerCommand() {
public LiteralCommandNode<CommandSourceStack> registerCommand(String commandName) {
//run help command if no context provided
LiteralCommandNode<CommandSourceStack> buildCommand = Commands.literal("raycastedentityocclusions")
LiteralCommandNode<CommandSourceStack> buildCommand = Commands.literal(commandName)
.requires(sender -> sender.getSender().hasPermission("raycastedentityocclusions.command"))
.executes(context -> {
helpCommand(context);
@@ -14,7 +14,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import java.util.Collections;
import java.util.UUID;
import static games.cubi.raycastedEntityOcclusion.UpdateChecker.checkForUpdates;
@@ -51,19 +50,20 @@ public class EventListener implements Listener {
manager.onChunkUnload(e.getChunk());
}
public static final int BREAK = 1; public static final int PLACE = 2;
@EventHandler
public void onPlace(BlockPlaceEvent e) {
manager.onBlockChange(e.getBlock().getLocation(), e.getBlock().getType());
manager.onBlockChange(e.getBlock().getLocation(), e.getBlock().getType(), PLACE);
}
@EventHandler
public void onBreak(BlockBreakEvent e) {
manager.onBlockChange(e.getBlock().getLocation(), Material.AIR);
manager.onBlockChange(e.getBlock().getLocation(), Material.AIR, BREAK);
}
@EventHandler
public void onBurn(BlockBurnEvent e) {
manager.onBlockChange(e.getBlock().getLocation(), Material.AIR);
manager.onBlockChange(e.getBlock().getLocation(), Material.AIR, BREAK);
}
// These events do not cover all cases, but I can't be bothered to figure out a better solution rn. Frequent snapshot refreshes is the solution. If anyone has a solution please let me know.
@@ -76,10 +76,10 @@ public class Engine {
// ----- PHASE 1: SYNC GATHER -----
if (!syncRecheck.isEmpty()) {
Logger.warning(syncRecheck.size() + " chunks failed to snapshot asynchronously, rechecking them now.");
Logger.warning(syncRecheck.size() + " chunks failed to snapshot asynchronously, rechecking them now. This message may also have been triggered if a player teleported into unloaded chunks, in which case it's safe to ignore.");
for (Chunk c : syncRecheck) {
if (c.isLoaded()) {
plugin.getChunkSnapshotManager().snapshotChunk(c);
plugin.getChunkSnapshotManager().snapshotChunkSync(c);
syncRecheck.remove(c);
Logger.info("Successfully rechecked chunk " + c.getX() + ", " + c.getZ() + " in world " + c.getWorld().getName());
}
@@ -248,10 +248,10 @@ public class Engine {
BlockState data = block.getState();
if (data instanceof TileState tileData) {
p.sendBlockChange(location, block.getBlockData());
p.sendBlockUpdate(location, tileData);
//p.sendBlockUpdate(location, tileData);
}
else {
Logger.warning("Tried to show tile entity at " + location + " to "+p.getName()+" but it was not a TileState! Block type: " + block.getType()+". Removing from the list of tile entities.");
//Logger.warning("Tried to show tile entity at " + location + " to "+p.getName()+" but it was not a TileState! Block type: " + block.getType()+". Removing from the list of tile entities.");
canSeeTileEntity.remove(location);
plugin.getChunkSnapshotManager().removeTileEntity(location);
}
@@ -24,6 +24,7 @@ public class RaycastedEntityOcclusion extends JavaPlugin implements CommandExecu
private CommandsManager commands;
private boolean packetEventsPresent = false;
private PacketProcessor packetProcessor = null;
private static RaycastedEntityOcclusion instance;
public int tick = 0;
@@ -42,6 +43,7 @@ public class RaycastedEntityOcclusion extends JavaPlugin implements CommandExecu
@Override
public void onEnable() {
instance = this;
cfg = new ConfigManager(this);
snapMgr = new ChunkSnapshotManager(this);
tracker = new MovementTracker(this, cfg);
@@ -49,18 +51,11 @@ public class RaycastedEntityOcclusion extends JavaPlugin implements CommandExecu
new UpdateChecker(this);
getServer().getPluginManager().registerEvents(new EventListener(this, snapMgr, cfg), this);
//Brigadier API
LiteralCommandNode<CommandSourceStack> buildCommand = commands.registerCommand();
this.getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS, commands -> {
commands.registrar().register(buildCommand);
this.getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS, commandRegistrar -> {
commandRegistrar.registrar().register(commands.registerCommand("raycastedentityocclusions"));
//alias "reo"
commands.registrar().register(Commands.literal("reo")
.requires(sender -> sender.getSender().hasPermission("raycastedentityocclusions.command"))
.executes(context -> {
new CommandsManager(this, cfg).helpCommand(context);
return Command.SINGLE_SUCCESS;
})
.redirect(buildCommand).build());
commandRegistrar.registrar().register(commands.registerCommand("reo"));
});
//bStats
@@ -105,4 +100,7 @@ public class RaycastedEntityOcclusion extends JavaPlugin implements CommandExecu
public PacketProcessor getPacketProcessor() {
return packetProcessor;
}
public static RaycastedEntityOcclusion getInstance() {
return instance;
}
}
@@ -1,6 +1,7 @@
package games.cubi.raycastedEntityOcclusion.Snapshot;
import games.cubi.raycastedEntityOcclusion.ConfigManager;
import games.cubi.raycastedEntityOcclusion.EventListener;
import games.cubi.raycastedEntityOcclusion.Logger;
import games.cubi.raycastedEntityOcclusion.Raycast.Engine;
import games.cubi.raycastedEntityOcclusion.RaycastedEntityOcclusion;
@@ -15,27 +16,28 @@ import org.bukkit.block.BlockState;
import org.bukkit.block.TileState;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.HashSet;
import java.util.Set;
import java.util.Map;
import java.util.Collections;
import java.util.concurrent.ConcurrentHashMap;
public class ChunkSnapshotManager {
public static class Data {
private static class ChunkData {
public final ChunkSnapshot snapshot;
public final ConcurrentHashMap<Location, Material> delta = new ConcurrentHashMap<>();
public final Set<Location> tileEntities = ConcurrentHashMap.newKeySet();
public final ConcurrentHashMap<BlockLocation, Material> delta = new ConcurrentHashMap<>();
public final Set<BlockLocation> tileEntities = ConcurrentHashMap.newKeySet();
public long lastRefresh;
public int minHeight;
public int maxHeight;
public Data(ChunkSnapshot snapshot, long time) {
public ChunkData(ChunkSnapshot snapshot, long time) {
this.snapshot = snapshot;
this.lastRefresh = time;
}
}
private static final ConcurrentHashMap<String, Data> dataMap = new ConcurrentHashMap<>();
private static final ConcurrentHashMap<String, ChunkData> dataMap = new ConcurrentHashMap<>();
private final ConfigManager cfg;
public ChunkSnapshotManager(RaycastedEntityOcclusion plugin) {
@@ -53,7 +55,7 @@ public class ChunkSnapshotManager {
long now = System.currentTimeMillis();
int chunksRefreshed = 0;
int chunksToRefreshMaximum = getNumberOfCachedChunks() / 3;
for (Map.Entry<String, Data> e : dataMap.entrySet()) {
for (Map.Entry<String, ChunkData> e : dataMap.entrySet()) {
if (now - e.getValue().lastRefresh >= cfg.snapshotRefreshInterval * 1000L && chunksRefreshed < chunksToRefreshMaximum) {
chunksRefreshed++;
String key = e.getKey();
@@ -75,11 +77,20 @@ public class ChunkSnapshotManager {
removeChunkSnapshot(c);
}
public void snapshotChunkSync(Chunk c) {
if ((dataMap.get(key(c)).lastRefresh + 100) < System.currentTimeMillis() - cfg.snapshotRefreshInterval * 1000L) {
return;
}
dataMap.put(key(c), takeSnapshot(c, System.currentTimeMillis()));
}
public void snapshotChunk(Chunk c) {
//if (cfg.debugMode) {
//Logger.info("ChunkSnapshotManager: Taking snapshot of chunk " + c.getWorld().getName() + ":" + c.getX() + ":" + c.getZ());
//}
dataMap.put(key(c), takeSnapshot(c, System.currentTimeMillis()));
Bukkit.getScheduler().runTaskAsynchronously(RaycastedEntityOcclusion.getInstance(), () -> {
dataMap.put(key(c), takeSnapshot(c, System.currentTimeMillis()));
});
}
public void snapshotChunk(String key) {
snapshotChunk(getKeyChunk(key));
@@ -92,33 +103,35 @@ public class ChunkSnapshotManager {
}
// Used by EventListener to update the delta map when a block is placed or broken
public void onBlockChange(Location loc, Material m) {
public void onBlockChange(Location loc, Material m, int change) {
if (cfg.debugMode) {
Logger.info("ChunkSnapshotManager: Block change at " + loc + " to " + m);
}
Data d = dataMap.get(key(loc.getChunk()));
ChunkData d = dataMap.get(key(loc.getChunk()));
if (d != null) {
d.delta.put(blockLoc(loc), m);
d.delta.put(BlockLocation.fromLocation(loc), m);
if (cfg.checkTileEntities) {
// Check if the block is a tile entity
BlockState data = loc.getBlock().getState();
loc = loc.clone().add(0.5, 0.5, 0.5);
if (data instanceof TileState) {
if (cfg.debugMode){
if (cfg.debugMode) {
Logger.info("ChunkSnapshotManager: Tile entity at " + loc);
}
d.tileEntities.add(loc);
} else {
d.tileEntities.remove(loc);
if (change == EventListener.PLACE) {
d.tileEntities.add(BlockLocation.fromLocation(loc));
}
if (change == EventListener.BREAK) {
d.tileEntities.remove(BlockLocation.fromLocation(loc));
}
}
}
}
else {Logger.error("Data map value empty, ignoring block update!");}
}
private Data takeSnapshot(Chunk c, long now) {
private ChunkData takeSnapshot(Chunk c, long now) {
World w = c.getWorld();
Data data = new Data(c.getChunkSnapshot(), now);
ChunkData data = new ChunkData(c.getChunkSnapshot(), now);
int chunkX = c.getX() * 16;
int chunkZ = c.getZ() * 16;
int minHeight = w.getMinHeight();
@@ -132,7 +145,7 @@ public class ChunkSnapshotManager {
BlockState bs = data.snapshot.getBlockData(x, y, z).createBlockState();
if (bs instanceof TileState) {
data.tileEntities.add(new Location(w, x+ chunkX +0.5, y+0.5, z + chunkZ+0.5));
data.tileEntities.add(BlockLocation.fromValues(w, x+ chunkX, y, z + chunkZ));
}
}
}
@@ -165,18 +178,18 @@ public class ChunkSnapshotManager {
public Material getMaterialAt(Location loc) {
Chunk chunk = loc.getChunk();
Data d = dataMap.get(key(chunk));
ChunkData d = dataMap.get(key(chunk));
if (d == null) {
Chunk c = loc.getChunk();
Logger.error("ChunkSnapshotManager: No snapshot for " + c+ " If this error persists, please report this on our discord (discord.cubi.games)");
//Chunk c = loc.getChunk();
//Logger.error("ChunkSnapshotManager: No snapshot for " + c+ " If this error persists, please report this on our discord (discord.cubi.games)");
Engine.syncRecheck.add(chunk);
return loc.getBlock().getType();
return Material.AIR;
}
double yLevel = loc.getY();
if (yLevel < d.minHeight || yLevel > d.maxHeight) {
return null;
}
Material dm = d.delta.get(blockLoc(loc));
Material dm = d.delta.get(BlockLocation.fromLocation(loc));
if (dm != null) {
if (cfg.debugMode) Logger.info("Using delta");
return dm;
@@ -190,19 +203,21 @@ public class ChunkSnapshotManager {
//get TileEntity Locations in chunk
public Set<Location> getTileEntitiesInChunk(World world, int x, int z) {
Data d = dataMap.get(key(world, x, z));
ChunkData d = dataMap.get(key(world, x, z));
if (d == null) {
return Collections.emptySet();
}
return d.tileEntities;
return BlockLocation.toLocations(d.tileEntities);
}
public void removeTileEntity(Location loc) {
Chunk c = loc.getChunk();
Data d = dataMap.get(key(c));
ChunkData d = dataMap.get(key(c));
if (d != null) {
d.tileEntities.remove(blockLoc(loc));
Logger.info("ChunkSnapshotManager: Removed tile entity at " + loc);
d.tileEntities.remove(BlockLocation.fromLocation(loc));
if (cfg.debugMode) {
Logger.info("ChunkSnapshotManager: Removed tile entity at " + loc);
}
} else {
Logger.error("ChunkSnapshotManager: No snapshot for " + c + " when removing tile entity at " + loc);
}
@@ -213,11 +228,57 @@ 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;
}
private static class BlockLocation {
private final Location location;
private final int hashCode;
private BlockLocation(Location location) {
this.location = location.toCenterLocation();
this.location.setPitch(0);
this.location.setYaw(0);
hashCode = calculateHashCode();
}
static BlockLocation fromLocation(Location loc) {
return new BlockLocation(loc);
}
static BlockLocation fromValues(World world, double x, double y, double z) {
return new BlockLocation(new Location(world, x, y, z));
}
static Location toLocation(BlockLocation blockLocation) {
return blockLocation.location.clone();
}
static Set<Location> toLocations(Set<BlockLocation> blockLocations) {
Set<Location> locations = new HashSet<>();
for (BlockLocation bl : blockLocations) {
locations.add(toLocation(bl));
}
return locations;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof BlockLocation)) return false;
Location other = ((BlockLocation) o).location;
return (this.location.getX() == other.getX()) && (this.location.getY() == other.getY()) && (this.location.getZ() == other.getZ()) && (this.location.getWorld().equals(other.getWorld()));
}
private int calculateHashCode() {
int result = 17;
result = 31 * result + location.getBlockX();
result = 31 * result + location.getBlockY();
result = 31 * result + location.getBlockZ();
return 31 * result + location.getWorld().getUID().hashCode();
}
@Override
public int hashCode() {
return hashCode;
}
}
}
@@ -7,7 +7,6 @@ import com.google.gson.JsonParser;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import java.io.BufferedReader;
@@ -31,13 +30,12 @@ public class UpdateChecker {
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
final String url = "https://api.modrinth.com/v2/project/bCjNZu0C/version?featured=true";
final String url = "https://api.modrinth.com/v2/project/bCjNZu0C/version?version_type=release";
try (final InputStreamReader reader = new InputStreamReader(new URL(url).openConnection().getInputStream())) {
final JsonArray array = new JsonArray();
array.add(new BufferedReader(reader).readLine());
StringBuilder sb = new StringBuilder();
for (int i = 0; i < array.size(); i++) {
sb.append(array.get(i).getAsString());
}
String apiData = sb.toString();
@@ -57,10 +55,10 @@ public class UpdateChecker {
private static final int INVALID_VERSION_FORMAT = -2; private static final int CURRENT_IS_OLDER = -1; private static final int VERSIONS_ARE_EQUAL = 0; private static final int CURRENT_IS_NEWER = 1;
private static int checkIfLaterThan(String currentVersion, String fetchedVersion) {
String[] currentParts = currentVersion.replace("v", "").split("\\.");
String[] fetchedParts = fetchedVersion.replace("v", "").split("\\.");
String[] currentParts = currentVersion.replace("v", "").split("[.-]");
String[] fetchedParts = fetchedVersion.replace("v", "").split("[.-]");
if (currentParts.length != 3 || fetchedParts.length != 3) {
if (currentParts.length < 3 || fetchedParts.length < 3) {
return INVALID_VERSION_FORMAT;
}
-30
View File
@@ -1,30 +0,0 @@
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
+1 -1
View File
@@ -1,7 +1,7 @@
name: RaycastedEntityOcclusions
version: ${version}
main: games.cubi.raycastedEntityOcclusion.RaycastedEntityOcclusion
api-version: '1.21'
api-version: '1.20.6'
prefix: REO
authors: [ _Cubicake ]
load: STARTUP