Compare commits

..
14 Commits
8 changed files with 106 additions and 20 deletions

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
# These are supported funding model platforms
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
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
issuehunt: # Replace with a single IssueHunt username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
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']
+6 -3
View File
@@ -1,4 +1,4 @@
Latest version: v1.6.0
Latest version: v1.6.1
The latest version can currently only be found on Modrinth https://modrinth.com/plugin/raycasted-entity-occlusions/
@@ -15,7 +15,10 @@ Use cases:
- 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
- If cull-player is set to true any culled players will be removed from tablist. Potential solutions are being investigated, suggestions are welcome.
- 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.
+11 -1
View File
@@ -1,9 +1,10 @@
plugins {
id 'java'
id("xyz.jpenilla.run-paper") version "2.3.1"
}
group = 'games.cubi'
version = '1.6.1'
version = '1.6.2'
repositories {
mavenCentral()
@@ -25,6 +26,15 @@ dependencies {
compileOnly("com.github.retrooper:packetevents-spigot:2.8.0")
}
tasks {
runServer {
// 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")
}
}
def targetJavaVersion = 21
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
@@ -54,7 +54,5 @@ public class Logger {
default:
plugin.getComponentLogger().error("{} | Additionally, severity {} is not supported by the logger.", messageComponent, severity);
}
//Bukkit.getConsoleSender().sendRichMessage(message);
//Bukkit.broadcast(MiniMessage.miniMessage().deserialize(message), "raycastedentityocclusions.receivelogmessages");
}
}
@@ -158,7 +158,7 @@ public class Engine {
}
private static ConcurrentLinkedQueue<TileResult> results = new ConcurrentLinkedQueue<>();
private final static ConcurrentLinkedQueue<TileResult> results = new ConcurrentLinkedQueue<>();
public static void runTileEngine(ConfigManager cfg, ChunkSnapshotManager snapMgr, MovementTracker tracker, RaycastedEntityOcclusion plugin) {
if (cfg.checkTileEntities) {
@@ -168,6 +168,7 @@ public class Engine {
//get player's chunk location
int chunkX = p.getLocation().getBlockX() >> 4;
int chunkZ = p.getLocation().getBlockZ() >> 4;
Location playerLoc = p.getLocation();
//async run with vars passed in
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
@@ -187,7 +188,8 @@ public class Engine {
if (snapMgr.getMaterialAt(loc).equals(Material.BEACON)) continue;
double distSquared = loc.distanceSquared(p.getLocation());
if (!loc.getWorld().equals(playerLoc.getWorld())) continue;
double distSquared = loc.distanceSquared(playerLoc);
if (distSquared > cfg.searchRadius * cfg.searchRadius) {
results.add(new TileResult(p, loc,false));
continue;
@@ -248,7 +250,11 @@ public class Engine {
p.sendBlockChange(location, block.getBlockData());
p.sendBlockUpdate(location, tileData);
}
else throw new RuntimeException("Attempting to show a block which isn't a tile entity");
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.");
canSeeTileEntity.remove(location);
plugin.getChunkSnapshotManager().removeTileEntity(location);
}
});
@@ -7,13 +7,21 @@ import org.bukkit.Particle;
import org.bukkit.util.Vector;
public class RaycastUtil {
public static boolean raycast(Location start, Location end, int maxOccluding, boolean debug, ChunkSnapshotManager snap) {
Particle.DustOptions dustRed = null;
Particle.DustOptions dustGreen = null;
if (debug) {
static Particle.DustOptions dustRed = null;
static Particle.DustOptions dustGreen = null;
private static void initDebugParticles() {
if (dustRed == null) {
dustRed = new Particle.DustOptions(org.bukkit.Color.RED, 1f);
}
if (dustGreen == null) {
dustGreen = new Particle.DustOptions(org.bukkit.Color.GREEN, 1f);
}
}
public static boolean raycast(Location start, Location end, int maxOccluding, boolean debug, ChunkSnapshotManager snap) {
initDebugParticles();
if (!start.getWorld().equals(end.getWorld())) return false;
double total = start.distance(end);
double traveled = 0;
Location curr = start.clone();
@@ -37,11 +37,9 @@ public class ChunkSnapshotManager {
private static final ConcurrentHashMap<String, Data> dataMap = new ConcurrentHashMap<>();
private final ConfigManager cfg;
private final RaycastedEntityOcclusion plugin;
public ChunkSnapshotManager(RaycastedEntityOcclusion plugin) {
cfg = plugin.getConfigManager();
this.plugin = plugin;
//get loaded chunks and add them to dataMap
for (World w : plugin.getServer().getWorlds()) {
for (Chunk c : w.getLoadedChunks()) {
@@ -78,9 +76,9 @@ public class ChunkSnapshotManager {
}
public void snapshotChunk(Chunk c) {
if (cfg.debugMode) {
//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()));
}
public void snapshotChunk(String key) {
@@ -199,6 +197,17 @@ public class ChunkSnapshotManager {
return d.tileEntities;
}
public void removeTileEntity(Location loc) {
Chunk c = loc.getChunk();
Data d = dataMap.get(key(c));
if (d != null) {
d.tileEntities.remove(blockLoc(loc));
Logger.info("ChunkSnapshotManager: Removed tile entity at " + loc);
} else {
Logger.error("ChunkSnapshotManager: No snapshot for " + c + " when removing tile entity at " + loc);
}
}
public int getNumberOfCachedChunks() {
return dataMap.size();
//created to use in a debug command maybe
@@ -54,14 +54,51 @@ public class UpdateChecker {
return future;
}
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("\\.");
if (currentParts.length != 3 || fetchedParts.length != 3) {
return INVALID_VERSION_FORMAT;
}
int majorVersionDifference = Integer.parseInt(currentParts[0]) - Integer.parseInt(fetchedParts[0]);
if (majorVersionDifference == VERSIONS_ARE_EQUAL) {
int minorVersionDifference = Integer.parseInt(currentParts[1]) - Integer.parseInt(fetchedParts[1]);
if (minorVersionDifference == VERSIONS_ARE_EQUAL) {
int patchVersionDifference = Integer.parseInt(currentParts[2]) - Integer.parseInt(fetchedParts[2]);
return patchVersionDifference;
}
return minorVersionDifference;
}
return majorVersionDifference;
}
public static void checkForUpdates(RaycastedEntityOcclusion plugin, CommandSender audience) {
fetchFeaturedVersion(plugin).thenAccept(version -> {
// This runs synchronously when the version is fetched
Bukkit.getScheduler().runTask(plugin, () -> {
if (plugin.getDescription().getVersion().equals(version)) {
int versionCheck = checkIfLaterThan(plugin.getDescription().getVersion(), version);
if (versionCheck == VERSIONS_ARE_EQUAL) {
audience.sendRichMessage("<green>You are using the latest version of Raycasted Entity Occlusions.");
} else {
audience.sendRichMessage("<red>You are not using the latest version of Raycasted Entity Occlusions. Please update to <green>v" + version);
}
if (versionCheck == CURRENT_IS_OLDER) {
audience.sendRichMessage("<red>You are not using the latest version of Raycasted Entity Occlusions. Please update to <green>v" + version+".");
if (audience instanceof Player) audience.sendRichMessage("\n" + "<hover:show_text:'https://modrinth.com/project/bCjNZu0C/versions'><aqua><u><click:open_url:'https://modrinth.com/project/bCjNZu0C/versions'>Click here to download it.</click></u></aqua></hover>");
}
if (versionCheck == CURRENT_IS_NEWER) {
audience.sendRichMessage("<yellow>You are using a development build of Raycasted Entity Occlusions. The latest stable version is <green>v" + version + "<yellow>.");
}
if (versionCheck == INVALID_VERSION_FORMAT) {
audience.sendRichMessage("<red>Unable to check for updates, invalid version format.");
}
});
}).exceptionally(ex -> {