Jump to content

[1.7.10] Changing the camera - how to force 3rd person view


Recommended Posts

Posted

Hi Everyone

 

I have been researching how to change the camera (things like zoom, camera height, position, yaw, roll, pitch etc etc) and have found very little information about it. Apparently it is fairly difficult. I was wondering if anyone has any experience in this. I want to do some custom camera manipulation (force third person and change the zoom level and camera positions) and also I want to force third person view. I currently have figured out how to change the players model (dont know how to change hitbox yet but im working on that) and I need a way to force the camera view to be always third person  when the player has this different model and to have a different zoom than the default since my model is fairly large. Does anyone know where to look/ how to achieve this/has any input?

Posted

Hm, I don't have experience with it but, I would think you'd need to look at the keybinding for changing the camera view and figure out how the game does it. Then, when the model is changed, force the view by changing it as if they pressed F5 then, disable that key until the player changes back.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

I think maybe you can just change Minecraft.getMinecraft().gameSettings.thirdPersonView. You'd need to do this on client side only.

 

EDIT: Actually I tried that and it sort of works, but it makes it look like the player is hovering in the air for some reason.

 

Okay, maybe you should check out this thread here: http://www.minecraftforge.net/forum/index.php?topic=17968.0

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Ya I have seen that thread and I have read through it, I couldn't replicate their results. I have tried the third person view suggestion you made and ran into the same problem where the player seems to hover weirdly

Posted

When you run while the player looks like he's hovering, does the particles for the ground display? In that case it could be the texture is being misplaced?

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

Do you know what package the actual code for toggling the camera perspective is in. I found in the game settings the registration for the key  this.keyBindTogglePerspective = new KeyBinding("key.togglePerspective", 63, "key.categories.misc");

Posted

Well, that's where it's defined. Is there some way to make the computer think you pressed the key then, disable it?

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

That is where it is registered yes but where is the logic that says (whenever this key is pressed change the view of the camera)

 

In Eclipse, select that field and right-click and choose Call Hierarchy. It will tell you everywhere it is used.

 

interestingly, in 1.8 I tried to put the following into the PlayerTickEvent handler:

		EntityPlayer thePlayer = event.player;
	World world = thePlayer.worldObj;

	if (world.isRemote)
	{
    	Minecraft.getMinecraft().gameSettings.thirdPersonView = 2;
    	// thePlayer.posY -= thePlayer.eyeHeight;
	}

 

And the position is correct but it displays a girl skin instead of the "steve" normal skin!

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Hmm Ya thats what I tried also but im in 1.7.10.

 

I found this in the vanilla code

 

/**
     * Runs the current tick.
     */
    public void runTick()
    {
//.... A lot of stuff... then this
    if (this.gameSettings.keyBindTogglePerspective.isPressed())
                        {
                            ++this.gameSettings.thirdPersonView;

                            if (this.gameSettings.thirdPersonView > 2)
                            {
                                this.gameSettings.thirdPersonView = 0;
                            }
                        }

//...Alot more stuff....

Posted

it's weird to me that setting the third person view field isn't enough to make it work. Because unless someone presses F5 again, it should be stable even with respect to the rendering timing. I understand that if we were trying to overwrite the value while Minecraft was also trying to overwrite it, but I don't see how that is the case here.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Ya I find that weird also, Do you know where the actual calculation for the camera position occur after F5 has been pressed. I cant seem to find it. I tried to put the following into my RenderPlayerEvent.Pre pre event to force the view to be third person only when I become my new model and the view doesn't change unless I hit F5 then it changes and remains stable. which is weird.

@SubscribeEvent
public void onRenderPlayerPre(RenderPlayerEvent.Pre pre) {

	//my code for becoming my other model is here
//just for testing
		if (pre.entityPlayer.worldObj.isRemote)
		{
	    	Minecraft.getMinecraft().gameSettings.thirdPersonView = 1;
	    	}
	}

Posted

Even weirder I created two keys one which sets a boolean to true and one which sets that same boolean to false (the boolean is playerIsInFirstPerson). For some reason when im in third person and I want to go to first person (i do a check for my boolean to be false) and if the boolean is false the view should change from third person to first person - this updates the view perfectly fine  when I set the boolean and it updates my view  no problems.

 

However the weird problem occurs in reverse if I am already in first person and want to go to third person (i do this by clicking the key to set the boolean to true) -the boolean gets set to true on both client and server but the view doesnt update.. I have to click the F5 key to force it to update and then after that it is fine.

Posted

I think you maybe would need to send a packet to the server that would change the boolean then, update the client.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

I have just been looking into reflections as I have never used them. I am not sure how to approach this, since I dont know how the EntityRenderer works. The fields to change the camera view, angle, rotation, pitch etc etc are all private. I know that I need to use reflection on an object of the EntityRenderer class but I am not sure how to get the object of this class so that I can apply reflection to it. Any ideas?

Posted

I think this is where I have to start but again I am not sure

 

EntityRenderer entityRenderer = Minecraft.getMinecraft().entityRenderer;

entityRenderer.getClass();

Posted

This seems to change the zoom level of the camera. Bear in mind this is the first time im using reflection so this is just me messing around. I placed this block of code into an if statement inside a render player event

EntityRenderer entRenderer = Minecraft.getMinecraft().entityRenderer;
		try {
			entRenderer.getClass().getField("cameraZoom").setAccessible(true);
			try {
				entRenderer.getClass().getField("cameraZoom").set(entRenderer, 0.;// I think the default is 1, a negative number flips the camera view a higher number zooms in
			} catch (IllegalArgumentException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			};
		} catch (NoSuchFieldException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

Posted

If anyone knows of a better way to access camera fields please post below I believe my method isnt great.

This method changes the zoom to whatever you want

public void cameraZoom(double zoomValue){
	EntityRenderer entRenderer = Minecraft.getMinecraft().entityRenderer;

		try {
			entRenderer.getClass().getField("cameraZoom").set(entRenderer, zoomValue);
			System.out.println();
			} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchFieldException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

Posted

There is FOVUpdateEvent (or something similar), you can use that to change zoom.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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