#Custom raytracer crashing server
1 messages · Page 1 of 1 (latest)
DBCursor cursor = collection.find();
try {
while(cursor.hasNext()) {
Map res = cursor.next().toMap();
int x = (int) res.get("x");
int y = (int) res.get("y");
int z = (int) res.get("z");
String ownerId = (String) res.get("ownerId");
World world = Bukkit.getWorld(res.get("world").toString());
Player owner = Bukkit.getPlayer(UUID.fromString(res.get("uuid").toString()));
Location cameralocation = new Location(world, x, y,z);
Collection<Entity> possible = Objects.requireNonNull(cameralocation.getWorld()).getNearbyEntities(cameralocation, 10.0, 10.0, 10.0);
for (Entity entity : possible)
if(entity instanceof Player){
// if(entity != owner || owner == null){
if(true){
org.bukkit.util.Vector entityloc = new org.bukkit.util.Vector(entity.getLocation().getBlockX() - cameralocation.getBlockX(), entity.getLocation().getBlockY() - cameralocation.getBlockY(), entity.getLocation().getBlockZ() - cameralocation.getBlockZ());
org.bukkit.util.Vector entitylochead = new org.bukkit.util.Vector(entity.getLocation().getBlockX() - cameralocation.getBlockX(), entity.getLocation().getBlockY() - cameralocation.getBlockY() + 1, entity.getLocation().getBlockZ() - cameralocation.getBlockZ());
try {
List<Block> result = RayTracer.rayTraceBlocks(cameralocation, entityloc, 10);
LOGGER.severe(result.toString());
while (result.iterator().hasNext()) {
Block item = result.iterator().next();
if (item.getType() == Material.PETRIFIED_OAK_SLAB) {
result.remove(item);
if (result.isEmpty()) {
LOGGER.severe("is empty now");
String id = DiscordSRV.getPlugin().getAccountLinkManager().getDiscordId(UUID.fromString((String) res.get("uuid")));
DiscordSRV.getPlugin().getJda().getUserById(id).openPrivateChannel().flatMap(channel -> channel.sendMessage(entity.getName() + " Is near your camera (" + cameralocation.getBlockX() + ", " + cameralocation.getBlockY() + ", " + cameralocation.getBlockZ() + ") You better log on and check")).queue();
break;
}
}
}
}catch (Exception e){
LOGGER.warning(e.toString());
}```
ill put full code in paste bin actually
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
this is my scheduler
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
this is ray tracer code
can you explain a bit about the logic of your system?
like
why do you raytrace
nesting makes it hard to understand
i need to detect if a block(camera) can see a player nearby
but it ignores petrified oak slabs
if that makes sense
Why can't you use World#raytrace
if it hits itself the oak slab it says it cant see me
Theres a while loop
and it dont return all blocks it hits only first
Set the ray size to a smaller number
i have a break right? unless it dont trigger ig
i dont think thats option in blockraytrace
i added an else for the
if (item.getType() == Material.PETRIFIED_OAK_SLAB) {
so it breaks ill see if that worked
ah this code isnt detecting if its hitting a player
ill try using just normal ray trace
I think there is a method to ignore block types when raytracing
theres filter im trying to figure it now
unless theres different method
filter seems to be entity only
you mean oakslab
ill try that
https://commandgeek.boomer.international/TcTWby2q
i think i did it wrong 🤣
not according to https://www.spigotmc.org/threads/1-13-2-world-raytrace-ignore-certain-blocks.361005/