Jump to content

How do you create a Camera and render whatever it sees on a custom GUI?


Recommended Posts

Posted
4 minutes ago, _vertig0 said:

public static final boolean isMultiplayer = !Minecraft.getMinecraft().isSingleplayer();

This will obviously not work.

 

5 minutes ago, _vertig0 said:

public class ClientViewPlayer extends EntityPlayer {

Why? You can't just extend EntityPlayer and call it good. Why are you using EntityPlayer anyway? renderViewEntity can be anything that is an Entity.

 

9 minutes ago, _vertig0 said:

KeyInputEvent

Don't use KeyInputEvent, use a TickEvent of some kind.

 

Try a simpler setup. Can you replicate the issue if you just set the renderViewEntity to, say, a mob you punch? Without the rest of the code. 

Posted

 

 

27 minutes ago, V0idWa1k3r said:

This will obviously not work.

I did kind of have doubts for the isMultiplayer Boolean from the start since I heard from other forge threads before I started trying to make a mod that it's highly unreliable, so I didn't use it in any part of the mod (Fortunately I didn't have to use it after all)

27 minutes ago, V0idWa1k3r said:

Why? You can't just extend EntityPlayer and call it good. Why are you using EntityPlayer anyway? renderViewEntity can be anything that is an Entity.

I'd heard from another thread that while the renderer Minecraft uses can take any kind of living entity as the renderViewEntity, it would always cast the renderViewEntity to an EntityPlayer, and there was no instanceof Check at all. I thought this possibly could be the solution, but EntityOtherPlayerMP and EntityPlayer SP just crashed my game when I attempted to use it, and all the other types of EntityPlayer (I wonder why there are so many honestly) cannot be instantiated. I extended EntityPlayer eventually, but in the end got the same spazz camera result

27 minutes ago, V0idWa1k3r said:

Don't use KeyInputEvent, use a TickEvent of some kind.

It does work but I'll take that advice, thanks! (Maybe this could be the solution, who knows?)

27 minutes ago, V0idWa1k3r said:

Try a simpler setup. Can you replicate the issue if you just set the renderViewEntity to, say, a mob you punch? Without the rest of the code. 

Sure, I'll try that and get back with the result

Posted
6 minutes ago, _vertig0 said:

it would always cast the renderViewEntity to an EntityPlayer, and there was no instanceof Check at all.

This is plainly not true. It might have been at some time but I can tell you for certain that it isn't the case at most since 1.8.

 

 

  • Like 1
Posted
6 minutes ago, V0idWa1k3r said:

This is plainly not true. It might have been at some time but I can tell you for certain that it isn't the case at most since 1.8.

 

 

I can only try testing it tomorrow, but I have a bad feeling that it only works if you properly spawn the entity, meaning actually add it to the world, and you can't just do Entity entity = new Entity(); and get away with it like that. I really hope that's not the case

Posted

Can you post your code as a GitHub repository?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
On 12/17/2018 at 10:21 PM, V0idWa1k3r said:

This is plainly not true. It might have been at some time but I can tell you for certain that it isn't the case at most since 1.8.

 

 

I tried with a simple setup, didn't work, same result

 

Curiously however, putting this line in a method that's called every frame:
if(view.rotationYaw > 360) view.rotationYaw -= 360;

if(view.rotationYaw < 0) view.rotationYaw += 360;

Drastically reduces the mad spinning to a much gentler although still choppy camera snapping. But that's still not enough, it has to be completely still

 

On 12/18/2018 at 6:39 AM, Cadiboo said:

Can you post your code as a GitHub repository?

I don't know how to use github but I could put it here. It's a very smallish mod with only 3 classes

Posted
On 12/17/2018 at 10:21 PM, V0idWa1k3r said:

This is plainly not true. It might have been at some time but I can tell you for certain that it isn't the case at most since 1.8.

 

 

Oh my god the solution was so f*cking simple... literally this code was all that was needed to stabilise the render Entity:

@SubscribeEvent
	public void onView(CameraSetup event) {
		if(event.getEntity() == view) {
			System.out.println("Util entity " + event.getEntity().getName() + " set as camera viewport");
			event.setPitch(90.0f);
			event.setYaw(180.0f);
		}
	}
//Stabilises the camera every frame 

I am happy and infuriated that the fix was so simple!! But again, thanks so much for the help, really appreciate it :D

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.