Jump to content

nicknico00

Members
  • Posts

    4
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

nicknico00's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. 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 , 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
  2. 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
  3. Unfortunately i'm in 1.7.10 Any other splution?
  4. 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.
×
×
  • Create New...

Important Information

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