Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hi,

 

I currently have a GUI which opens when a key is pressed.

But the key binding also intercepts the key when the player write in the chat.

 

Which condition should i impose to check if the chat is used and avoid opening my GUI ?

 

thanks.

 

NB : current code is

package PLCmods.robotica.commands;

import java.util.EnumSet;

import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.EntityPlayer;

import org.lwjgl.input.Keyboard;

import PLCmods.robotica.Robotica;
import PLCmods.trashbin.LoggerKeyTickHandler;
import cpw.mods.fml.client.registry.KeyBindingRegistry;
import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler;
import cpw.mods.fml.common.TickType;
import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;

public class LoggerKeys extends KeyHandler
{
    private EnumSet tickType = EnumSet.of(TickType.CLIENT);
    private boolean open;
    
    public static final KeyBinding[] key = {new KeyBinding("Logger GUI", Keyboard.KEY_L), new KeyBinding("Logger switch", Keyboard.KEY_O)};
    public static final boolean[] repeat = {false,false};

    public LoggerKeys()
    {
        super(key,repeat);
        KeyBindingRegistry.registerKeyBinding(this);
        open = false;
    }

    @Override
    public String getLabel()
    {
        return "Logger Key";
    }

    @Override
    public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat)
    {
        if(!tickEnd)
        {
            EntityClientPlayerMP e = Minecraft.getMinecraft().thePlayer;
            
            if(kb.keyCode == Keyboard.KEY_L)
            {
                if(open)
                    e.closeScreen();
                else
                    e.openGui(Robotica.modInstance, Robotica.GUI.LogControl, e.worldObj, 0, 0, 0);
                
                open = !open;
            }
            else if(kb.keyCode == Keyboard.KEY_O)
                e.sendChatMessage("/log switch");
        }
    }

    @Override
    public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd)
    {}

    @Override
    public EnumSet<TickType> ticks()
    {
        return tickType;
    }
}

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.