#Struggling to know where to start looking for player viewport to hijack

10 messages · Page 1 of 1 (latest)

civic quarry
#

I'm trying to tap into the viewport to make a kind of scifi camera type deal. In short, point in a direction, use custom item, and it'll log all living entities in view.

I'm guessing custom item that raycasts onUse - but it seems silly to do it all myself since the game is doing it behind the scenes anyway when it checks if you looked at an enderman.

I'm thinking use item > mixin to whatever check happens moment to moment and grab entity data from there?

I'm still quite nooby so feel free to point me in a decent direction to research if I'm on the wrong track!

cosmic echo
#

I would start by defining what "in view" means.
If "in view" means "I can raycast from my eyes to the entities eyes" that would exclude quite a few cases (think mobfarms).
If it means "I can actually visually see a part of them" I am not even sure if a proper check for that even exists (might exist, but could be very expensive)
How do you handle FoV? would someone on quake pro get more entities highlighted?

After that I would look into raycasts anyway, since I am relativly sure the enderman thing is just an enderman thing (although I cannot currently find the code responsible for that).

And then, I would suggest figuring out how you want to highlight your entities, and try to get that running, so, probably a look at the docs pages for rendering there.

Hope that helps?

blazing spindle
#

do you mean the iron man like “analysis mode” where there are boxes around specific things?

civic quarry
#

I hadn't thought about FOV much to be honest so that's a good call. In view in my case would definitely mean more just having any part in view, I guess I could have made my initial post a lot clearer - using the word scifi didn't help either

I'm not saying this is exactly what I'm going for but lets say for the sake of clarity - let's pretend the only thing I want to do is get a text log of every mob on screen when I use an item. I know how to make custom items, and the log can just be LOGGER.info for now.

I guess I was naively hoping that since the game literally has to render the mob models so the player can see them, there'd be some way of tapping into it. I've never really messed with render code before so I'm way out of my depth.

cosmic echo
#

I dont think tapping into anything rendering related to draw data out of that is a good idea, since that data can change rapidly, and may or may not be innacurate.

That being said, try looking at WorldRenderer#getEntitiesToRender - do note that that is client side only.

#

do note that a entity being rendered does not actually mean it is visible

civic quarry
#

That's a great start though thanks! Yeah I realized even in the last few minutes I will have to do some of my own raycasting no matter what, but being able to narrow down the pool a bit will hopefully make it less expensive. I've got a rough theory of how it might work but I'm out of time tonight to fiddle so I'll take another look at the weekend. I'll comment back here if I get something going though

cosmic echo
#

gl!

wheat wave
#

You might also checkout the debug renderers

wheat wave