Search in sources :

Example 1 with EnumGravity

use of micdoodle8.mods.galacticraft.core.entities.player.EnumGravity in project Galacticraft by micdoodle8.

the class TransformerHooks method orientCamera.

@SideOnly(Side.CLIENT)
public static void orientCamera(float partialTicks) {
    EntityPlayerSP player = ClientProxyCore.mc.thePlayer;
    GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);
    Entity viewEntity = ClientProxyCore.mc.getRenderViewEntity();
    if (player.ridingEntity instanceof ICameraZoomEntity && ClientProxyCore.mc.gameSettings.thirdPersonView == 0) {
        Entity entity = player.ridingEntity;
        float offset = ((ICameraZoomEntity) entity).getRotateOffset();
        if (offset > -10F) {
            offset += PLAYER_Y_OFFSET;
            GL11.glTranslatef(0, -offset, 0);
            float anglePitch = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks;
            float angleYaw = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks;
            GL11.glRotatef(-anglePitch, 0.0F, 0.0F, 1.0F);
            GL11.glRotatef(angleYaw, 0.0F, 1.0F, 0.0F);
            GL11.glTranslatef(0, offset, 0);
        }
    }
    if (viewEntity instanceof EntityLivingBase && viewEntity.worldObj.provider instanceof IZeroGDimension && !((EntityLivingBase) viewEntity).isPlayerSleeping()) {
        float pitch = viewEntity.prevRotationPitch + (viewEntity.rotationPitch - viewEntity.prevRotationPitch) * partialTicks;
        float yaw = viewEntity.prevRotationYaw + (viewEntity.rotationYaw - viewEntity.prevRotationYaw) * partialTicks + 180.0F;
        float eyeHeightChange = viewEntity.width / 2.0F;
        // GL11.glTranslatef(0.0F, -f1, 0.0F);
        GL11.glRotatef(-yaw, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-pitch, 1.0F, 0.0F, 0.0F);
        GL11.glTranslatef(0.0F, 0.0F, 0.1F);
        EnumGravity gDir = stats.getGdir();
        GL11.glRotatef(180.0F * gDir.getThetaX(), 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(180.0F * gDir.getThetaZ(), 0.0F, 0.0F, 1.0F);
        GL11.glRotatef(pitch * gDir.getPitchGravityX(), 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(pitch * gDir.getPitchGravityY(), 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(yaw * gDir.getYawGravityX(), 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(yaw * gDir.getYawGravityY(), 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(yaw * gDir.getYawGravityZ(), 0.0F, 0.0F, 1.0F);
        // GL11.glTranslatef(sneakY * gDir.getSneakVecX(), sneakY * gDir.getSneakVecY(), sneakY * gDir.getSneakVecZ());
        GL11.glTranslatef(eyeHeightChange * gDir.getEyeVecX(), eyeHeightChange * gDir.getEyeVecY(), eyeHeightChange * gDir.getEyeVecZ());
        if (stats.getGravityTurnRate() < 1.0F) {
            GL11.glRotatef(90.0F * (stats.getGravityTurnRatePrev() + (stats.getGravityTurnRate() - stats.getGravityTurnRatePrev()) * partialTicks), stats.getGravityTurnVecX(), stats.getGravityTurnVecY(), stats.getGravityTurnVecZ());
        }
    }
// omit this for interesting 3P views
// GL11.glTranslatef(0.0F, 0.0F, -0.1F);
// GL11.glRotatef(pitch, 1.0F, 0.0F, 0.0F);
// GL11.glRotatef(yaw, 0.0F, 1.0F, 0.0F);
// GL11.glTranslatef(0.0F, f1, 0.0F);
}
Also used : ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) Entity(net.minecraft.entity.Entity) GCPlayerStatsClient(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient) EnumGravity(micdoodle8.mods.galacticraft.core.entities.player.EnumGravity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) IZeroGDimension(micdoodle8.mods.galacticraft.api.world.IZeroGDimension) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

ICameraZoomEntity (micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity)1 IZeroGDimension (micdoodle8.mods.galacticraft.api.world.IZeroGDimension)1 EnumGravity (micdoodle8.mods.galacticraft.core.entities.player.EnumGravity)1 GCPlayerStatsClient (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient)1 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1