Jump to content

Recommended Posts

Posted

Please guys HELP MEE!

 

I have been googling for days before I came here and I've tried almost everything, but I didn't find a way to change the third-person-camera position. What I want to do is to move it in front of the player's eyes, like it was in first person, being able to see the player's body. help please: I'm getting crazy  :-\ :'(

 

thank you in advance.

Posted

width=638 height=359http://stech1.firstpost.com/tech2images/640x359/proportional/jpeg/gallery/2013/feb/yunomeme_281836203546.jpg[/img]

 

Y U NO UPDATE?!?!?!??!

 

Seriously tho... we alredy have peek on 1.9, and ppl are still on goddamn 1.7...

 

Solution:

You will have to replace camera entity on game startup. You can find the field in Minecraft.class and replace it with extension with changes you need.

1.7.10 is no longer supported by forge, you are on your own.

Posted

Thank you very much!

 

I spawned a new EntityCamera that extends EntityLiving and set the renderViewEntity to this. It works!

But now the problem is: the entityCamera's position and rotation are based on player's position and rotation, and sometime, when I move my mouse to move the head in game, the camera starts spinning very fast and I can't stop it D:

Do you know what it could be?

 

And sometimes I get an error like invalid entity attacked, when I click, and it crashes.

Any idea?

 

Thank you

Posted

the renderViewEntity have to extend entityLivingBase, so EntityLiving is fine (better EntityFlying).

 

I fixed the first issue: my camera didn't like rotationYaw > 360 or < 0  ;D, so I had to adjust player's rotationYaw before to use it.

Now it doesn't spin anymore ;).

 

The code I used:

 

Camera class

public class MAEntityCamera extends EntityFlying {

public MAEntityCamera(World p_i1595_1_) {
	super(p_i1595_1_);
}

}

 

RenderPlayerBase class (I'm using Player API)

public class MARenderPlayerBase extends RenderPlayerBase {
private MAEntityCamera camera;

public MARenderPlayerBase(RenderPlayerAPI renderPlayerAPI) {
	super(renderPlayerAPI);
}

@Override
public void renderFirstPersonArm(EntityPlayer p_82441_1_) {

	World world = Minecraft.getMinecraft().theWorld;
	EntityPlayer player = Minecraft.getMinecraft().thePlayer;

	if(!(Minecraft.getMinecraft().renderViewEntity instanceof MAEntityCamera))
	{
		//change renderViewEntity to camera
		if(camera != null) Minecraft.getMinecraft().renderViewEntity = camera;

		else
		{
			camera = new MAEntityCamera(world);
			camera.setPositionAndRotation(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
			world.spawnEntityInWorld(camera);

			Minecraft.getMinecraft().renderViewEntity = camera;
		}
	}
}

@Override
public void renderPlayer(AbstractClientPlayer paramAbstractClientPlayer, double paramDouble1, double paramDouble2,
		double paramDouble3, float paramFloat1, float paramFloat2) {

	super.renderPlayer(paramAbstractClientPlayer, paramDouble1, paramDouble2, paramDouble3, paramFloat1, paramFloat2);

	//change renderViewEntity to player when rendering in third-person
	if(Minecraft.getMinecraft().gameSettings.thirdPersonView > 0) Minecraft.getMinecraft().renderViewEntity = Minecraft.getMinecraft().thePlayer;
}
}

 

EventHandler class

public class EventHandler {

@SubscribeEvent
public void updateCamera(RenderHandEvent event) {

	if(Minecraft.getMinecraft().renderViewEntity instanceof MAEntityCamera)
	{
		EntityPlayer player = Minecraft.getMinecraft().thePlayer;

		//place camera in front of players's eyes
		double distanceX = -0.4, distanceY = -0.5,  distanceZ = 0.4;
		double x = Math.sin(Math.toRadians(player.rotationYaw))  * distanceX;
		double y = Math.sin(Math.toRadians(player.rotationPitch)) * distanceY;
		double z = Math.cos(Math.toRadians(player.rotationYaw))  * distanceZ;

		//adjust rotationYaw
		if(player.rotationYaw > 360) player.rotationYaw -= 360;
		if(player.rotationYaw < 0) player.rotationYaw += 360;

		Minecraft.getMinecraft().renderViewEntity.setPositionAndRotation(player.posX + x, player.posY - 1.63 + y, player.posZ + z, player.rotationYaw, player.rotationPitch);
	}
}
}

 

It works good, but I have to optimize it because of a few problems...

For example I can't interact with the blocks i see in the center of the camera, because the player is not watching exactely there, and so i often get the error: "trying to attack an invalid entity".

 

Do you know how could I fix this?

thank you very much

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.