net.minecraft.client.gui.GuiVideoSettings Java Examples

The following examples show how to use net.minecraft.client.gui.GuiVideoSettings. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DrawScreenEventHandler.java    From Fullscreen-Windowed-Minecraft with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@SubscribeEvent
public void handleDrawScreenEvent(GuiScreenEvent.DrawScreenEvent event) {
    if(!ConfigurationHandler.instance().isFullscreenWindowedEnabled())
        return;


    boolean newState = isCorrectKeyBinding();
    if(_initialFullscreen && _cooldown >= Reference.DRAW_SCREEN_EVENT_COOLDOWN) {
        _cooldown = 0;
        _initialFullscreen = false;
        FullscreenWindowed.proxy.toggleFullScreen(_initialGoFullScreen, _initialDesiredMonitor);
    }
    else if(_cooldown >= Reference.DRAW_SCREEN_EVENT_COOLDOWN && (_lastState != newState) && newState)
    {
        _cooldown = 0;
        _lastState = newState;
        FullscreenWindowed.proxy.toggleFullScreen(!ClientProxy.fullscreen, ConfigurationHandler.instance().getFullscreenMonitor());
    }

    _lastState = newState;

    if(_cooldown < Reference.DRAW_SCREEN_EVENT_COOLDOWN)
        _cooldown++;

    if(client.getVersion().startsWith("forge-11")){
        //Do it the old way in 1.8 since event.getGui does not exist.
        if(client.currentScreen instanceof GuiVideoSettings && client.fullscreen != ClientProxy.fullscreen) {
            FullscreenWindowed.proxy.toggleFullScreen(client.fullscreen);
        }
    }else{
        try {
            if (event.getGui() instanceof GuiVideoSettings && client.fullscreen != ClientProxy.fullscreen) {
                FullscreenWindowed.proxy.toggleFullScreen(client.fullscreen);
            }
        // In certain scenarios of 1.8, client mods further change the version and the previous check fails.
        // In those scenarios, we'll get this error and we will fallback to the old method.
        } catch (NoSuchMethodError error) {
            //Do it the old way in 1.8 since event.getGui does not exist.
            if(client.currentScreen instanceof GuiVideoSettings && client.fullscreen != ClientProxy.fullscreen) {
                FullscreenWindowed.proxy.toggleFullScreen(client.fullscreen);
            }
        }
    }
}