Posted April 6, 201510 yr 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?
April 6, 201510 yr 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.
April 6, 201510 yr 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/
April 8, 201510 yr Author 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
April 8, 201510 yr 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.
April 8, 201510 yr Author 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");
April 8, 201510 yr 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.
April 8, 201510 yr Author 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)
April 8, 201510 yr 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/
April 8, 201510 yr Author 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....
April 8, 201510 yr 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/
April 8, 201510 yr Author 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; } }
April 8, 201510 yr Author 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.
April 8, 201510 yr 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.
April 8, 201510 yr Author I realized that it isnt a packet problem the onRenderPlayer.pre event only fires when player is not in first person
April 8, 201510 yr Do you know where the actual calculation for the camera position occur after F5 has been pressed. I cant seem to find it. I think it is orientCamera() method in EntityRenderer class. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
April 9, 201510 yr Author Yikes it seems everything I would need to change to do custom camera movements is private, I havent used reflections yet.
April 9, 201510 yr Author 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?
April 9, 201510 yr Author I think this is where I have to start but again I am not sure EntityRenderer entityRenderer = Minecraft.getMinecraft().entityRenderer; entityRenderer.getClass();
April 9, 201510 yr Author 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(); }
April 9, 201510 yr Author 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(); } }
April 9, 201510 yr 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.