Jump to content

Changing Camera Height and Bounding Box


gegy1000

Recommended Posts

I'm trying to set the Camera Height and Bounding box of the player. That's all working, but after I changed the bounding box the player get's a 'black tint'. This is because I am using player.yOffset to change the camera height. I can't see any ways around this. If you could help me I would be very grateful.

 

Here's my code:

 

package gegy1000.warriors.client.renderer;

import java.util.HashMap;
import java.util.Map;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.entity.player.EntityPlayer;

import org.lwjgl.opengl.GL11;

public class CustomEntityRenderer extends EntityRenderer
{
private final Minecraft mc;

float offsetY = -1.05F;

public CustomEntityRenderer(Minecraft mc)
{
	super(mc, mc.getResourceManager());
	this.mc = mc;
}

public void hurtCameraEffect(float p_78482_1_)
{
}

@Override
public void renderWorld(float p_78471_1_, long p_78471_2_)
{
	GL11.glRotatef(90, 1, 0, 0);
	GL11.glRotatef(90, 0, 1, 0);
	GL11.glRotatef(90, 0, 0, 1);
	super.renderWorld(p_78471_1_, p_78471_2_);
}

@Override
public void updateCameraAndRender(float partialTick)
{
	hurtCameraEffect(partialTick);

	EntityPlayer player = mc.thePlayer;

	if (player == null || player.isPlayerSleeping())
	{
		super.updateCameraAndRender(partialTick);
		return;
	}

	GL11.glRotatef(90, 1, 0, 0);

	player.yOffset -= offsetY;
	super.updateCameraAndRender(partialTick);
	player.yOffset = 1.62F;
}

@Override
public void getMouseOver(float partialTick)
{
	super.getMouseOver(partialTick);
}
}

 

	@SubscribeEvent
public void renderTick(TickEvent.RenderTickEvent event)
{
	Minecraft mc = Minecraft.getMinecraft();

	if (mc.theWorld != null)
	{
		if(event.phase == Phase.START)
		{
			EntityClientPlayerMP player = mc.thePlayer;

			if (renderer == null)
			{
				renderer = new CustomEntityRenderer(mc);
			}
			if (mc.entityRenderer != renderer)
			{
				prevRenderer = mc.entityRenderer;
				mc.entityRenderer = renderer;
			}
		}
		else if(event.phase == Phase.END)
		{
		}
	}
}

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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