net.minecraftforge.client.settings.KeyConflictContext Java Examples

The following examples show how to use net.minecraftforge.client.settings.KeyConflictContext. 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: ClientEventHandler.java    From HoloInventory with MIT License 5 votes vote down vote up
public static void init()
{
    if (instance != null) MinecraftForge.EVENT_BUS.unregister(instance);
    instance = new ClientEventHandler();
    MinecraftForge.EVENT_BUS.register(new ClientEventHandler());

    keyHold = new KeyBinding("Hold to show", KeyConflictContext.IN_GAME, Keyboard.KEY_H, HoloInventory.MODID);
    keyToggle = new KeyBinding("Toggle to show", KeyConflictContext.IN_GAME, 0, HoloInventory.MODID);
    ClientRegistry.registerKeyBinding(keyHold);
    ClientRegistry.registerKeyBinding(keyToggle);
}
 
Example #2
Source File: KeyBindings.java    From YouTubeModdingTutorial with MIT License 4 votes vote down vote up
public static void init() {
    wandMode = new KeyBinding("key.wandmode", KeyConflictContext.IN_GAME, Keyboard.KEY_M, "key.categories.mymod");
    ClientRegistry.registerKeyBinding(wandMode);
}
 
Example #3
Source File: CyberwareMenuHandler.java    From Cyberware with MIT License 4 votes vote down vote up
@SubscribeEvent
public void tick(ClientTickEvent event)
{
	if(event.phase == Phase.START)
	{
		if (!KeyBinds.menu.isPressed() && mc.currentScreen == null && wasInScreen > 0)
		{
			KeyConflictContext inGame = KeyConflictContext.IN_GAME;
			mc.gameSettings.keyBindForward.setKeyConflictContext(inGame);
			mc.gameSettings.keyBindLeft.setKeyConflictContext(inGame);
			mc.gameSettings.keyBindBack.setKeyConflictContext(inGame);
			mc.gameSettings.keyBindRight.setKeyConflictContext(inGame);
			mc.gameSettings.keyBindJump.setKeyConflictContext(inGame);
			mc.gameSettings.keyBindSneak.setKeyConflictContext(inGame);
			mc.gameSettings.keyBindSprint.setKeyConflictContext(inGame);
			
			if (wasSprinting)
			{
				mc.thePlayer.setSprinting(wasSprinting);
			}
			wasInScreen--;
		}

	}
	if(event.phase == Phase.END)
	{
		
		if (mc.thePlayer != null && mc.currentScreen == null)
		{

			ICyberwareUserData data = CyberwareAPI.getCapability(mc.thePlayer);
			
			for (int keyCode : data.getHotkeys())
			{
				if (isPressed(data, keyCode))
				{
					pressed.add(keyCode);
					if (!lastPressed.contains(keyCode))
					{
						ClientUtils.useActiveItemClient(mc.thePlayer, data.getHotkey(keyCode));
					}
				}
			}
			
			lastPressed = pressed;
			pressed = new ArrayList<Integer>();
		
			
		}
		
		if (mc.thePlayer != null && CyberwareAPI.getCapability(mc.thePlayer).getNumActiveItems() > 0 && KeyBinds.menu.isPressed() && mc.currentScreen == null)
		{

			KeyConflictContext gui = KeyConflictContext.GUI;
			mc.gameSettings.keyBindForward.setKeyConflictContext(gui);
			mc.gameSettings.keyBindLeft.setKeyConflictContext(gui);
			mc.gameSettings.keyBindBack.setKeyConflictContext(gui);
			mc.gameSettings.keyBindRight.setKeyConflictContext(gui);
			mc.gameSettings.keyBindJump.setKeyConflictContext(gui);
			mc.gameSettings.keyBindSneak.setKeyConflictContext(gui);
			mc.gameSettings.keyBindSprint.setKeyConflictContext(gui);
			
			mc.displayGuiScreen(new GuiCyberwareMenu());
			CyberwareAPI.getCapability(mc.thePlayer).setOpenedRadialMenu(true);
			CyberwarePacketHandler.INSTANCE.sendToServer(new OpenRadialMenuPacket());

			wasInScreen = 5;
		}
		else if (wasInScreen > 0 && mc.currentScreen instanceof GuiCyberwareMenu)
		{
			wasSprinting = mc.thePlayer.isSprinting();
		}
		
	}
}