net.minecraftforge.fml.common.gameevent.InputEvent Java Examples

The following examples show how to use net.minecraftforge.fml.common.gameevent.InputEvent. 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: BoingHandler.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
@SubscribeEvent
public static void onJump(InputEvent.KeyInputEvent event) {
    if(jump.isPressed()) {
        EntityPlayerSP player = Minecraft.getMinecraft().player;
        BlockPos pos = new BlockPos(player.posX, player.posY, player.posZ);
        int level = EnchantmentHelper.getMaxEnchantmentLevel(BiJump.BOINGBOING, player);

        if(player.world.getBlockState(pos).getBlock().equals(Blocks.AIR) &&
                player.world.getBlockState(pos.add(0, -2, 0)).getBlock().equals(Blocks.AIR) &&
                !jumpybois.contains(player) &&  level > 0) {
            player.sprintingTicksLeft += 40;
            player.addVelocity(0, 1.2 * Math.sqrt(level), 0);
            jumpybois.add(player);
            new Timer().schedule(new TimerTask(){ @Override public void run(){ jumpybois.remove(player);}}, 7000);
        }
    }
}
 
Example #2
Source File: HotKeyHandler.java    From I18nUpdateMod with MIT License 6 votes vote down vote up
@SubscribeEvent
public void onKeyPressNoGui(InputEvent.KeyInputEvent e) {
    // 最开始,检测是否启用国际化配置
    if (I18nConfig.internationalization.openI18n && !I18nUtils.isChinese()) {
        return;
    }

    // 接下来检测是否关闭键位
    if (I18nConfig.key.closedKey) {
        return;
    }

    // 取消重复显示
    if (showed) {
        if (keyCodeCheck(reloadKey.getKeyCode()) && !Keyboard.isKeyDown(reloadKey.getKeyCode())) {
            showed = false;
        }
        return;
    }
    showed = reloadLocalization();
}
 
Example #3
Source File: MacroCommand.java    From ForgeHax with MIT License 6 votes vote down vote up
@SubscribeEvent
public void onKeyboardEvent(InputEvent.KeyInputEvent event) {
  MACROS
    .stream()
    .filter(macro -> !macro.isAnonymous())
    .filter(macro -> macro.getBind().isPressed())
    .forEach(this::executeMacro);
  
  // execute anonymous macros
  if (Keyboard.getEventKeyState()) { // on press
    MACROS
      .stream()
      .filter(MacroEntry::isAnonymous)
      .filter(macro -> macro.getKey() == Keyboard.getEventKey())
      .forEach(this::executeMacro);
  }
}
 
Example #4
Source File: PlayerListener.java    From SkyblockAddons with MIT License 6 votes vote down vote up
/**
 * This method handles key presses while the player is in-game.
 * For handling of key presses while a GUI (e.g. chat, pause menu, F3) is open,
 * see {@link GuiScreenListener#onKeyInput(GuiScreenEvent.KeyboardInputEvent)}
 *
 * @param e the {@code KeyInputEvent}
 */
@SubscribeEvent(receiveCanceled = true)
public void onKeyInput(InputEvent.KeyInputEvent e) {
    if (main.getOpenSettingsKey().isPressed()) {
        main.getUtils().setFadingIn(true);
        main.getRenderListener().setGuiToOpen(EnumUtils.GUIType.MAIN, 1, EnumUtils.GuiTab.MAIN);
    } else if (main.getOpenEditLocationsKey().isPressed()) {
        main.getUtils().setFadingIn(false);
        main.getRenderListener().setGuiToOpen(EnumUtils.GUIType.EDIT_LOCATIONS, 0, null);
    } else if (Keyboard.getEventKey() == DevUtils.DEV_KEY && Keyboard.getEventKeyState()) {
        // Copy Mob Data
        if (main.isDevMode()) {
            EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
            List<Entity> entityList = Minecraft.getMinecraft().theWorld.loadedEntityList;

            DevUtils.copyMobData(player, entityList);
        }
    }
}
 
Example #5
Source File: BindEventService.java    From ForgeHax with MIT License 6 votes vote down vote up
@SubscribeEvent
public void onKeyboardEvent(InputEvent.KeyInputEvent event) {
  getGlobalCommand()
      .getChildrenDeep()
      .stream()
      .filter(command -> command instanceof CommandStub)
      .map(command -> (CommandStub) command)
      .filter(stub -> stub.getBind() != null)
      .forEach(
          stub -> {
            if (stub.getBind().isPressed()) {
              stub.onKeyPressed();
            }
            if (stub.getBind().isKeyDown()) {
              stub.onKeyDown();
            }
          });
}
 
Example #6
Source File: GokiKeyHandler.java    From GokiStats with MIT License 6 votes vote down vote up
@SubscribeEvent
public void keyDown(InputEvent.KeyInputEvent event) {
    Minecraft mc = Minecraft.getMinecraft();
    EntityPlayer player = mc.player;
    if (statsMenu.isPressed()) {
        player.closeScreen();
        player.openGui(GokiStats.instance,
                0,
                player.world,
                (int) player.posX,
                (int) player.posY,
                (int) player.posZ);

    } else if (compatibilityMenu.isPressed()) {
        player.openGui(GokiStats.instance,
                1,
                player.world,
                (int) player.posX,
                (int) player.posY,
                (int) player.posZ);
    }
}
 
Example #7
Source File: SakuraEventLoader.java    From Sakura_mod with MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
   @SubscribeEvent
public static void KeyInput(InputEvent.KeyInputEvent event) {
	if(ClientProxy.ChangeMode.isPressed()){
		ClientProxy.getNetwork().sendToServer(new PacketKeyMessage(SakuraMain.MODID));
	 }
}
 
Example #8
Source File: KeybindProcessor.java    From ForgeWurst with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event)
{
	int keyCode = Keyboard.getEventKey();
	if(keyCode == 0 || !Keyboard.getEventKeyState())
		return;
	
	String commands = keybinds.getCommands(Keyboard.getKeyName(keyCode));
	if(commands == null)
		return;
	
	commands = commands.replace(";", "\u00a7").replace("\u00a7\u00a7", ";");
	for(String command : commands.split("\u00a7"))
	{
		command = command.trim();
		
		if(command.startsWith("."))
			cmdProcessor.runCommand(command.substring(1));
		else if(command.contains(" "))
			cmdProcessor.runCommand(command);
		else
		{
			Hack hack = hax.get(command);
			
			if(hack != null)
				hack.setEnabled(!hack.isEnabled());
			else
				cmdProcessor.runCommand(command);
		}
	}
}
 
Example #9
Source File: InputEventHandler.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onKeyInputEvent(InputEvent.KeyInputEvent event)
{
    int keyCode = Keyboard.getEventKey();
    boolean keyState = Keyboard.getEventKeyState();

    this.onInputEvent(keyCode, keyState);
}
 
Example #10
Source File: KeyBindingHandler.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event)
{
	EntityPlayerSP player = FMLClientHandler.instance().getClient().player;

	if(FMLClientHandler.instance().getClient().inGameHasFocus &&
			FMLClientHandler.instance().getClient().currentScreen == null)
	{
		if(Key_CombatMode.isPressed())
		{

		}
	}
}
 
Example #11
Source File: EventInput.java    From Levels with GNU General Public License v2.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onKeyPress(InputEvent.KeyInputEvent event)
{
	KeyBinding l = ClientProxy.keyBindingL;
	Minecraft mc = Minecraft.getMinecraft();
	EntityPlayer player = mc.player;
	
	if (player != null)
	{
		ItemStack stack = player.inventory.getCurrentItem();
		
		if (stack != null)
		{
			Item current = stack.getItem();
			
			if (current != null)
			{
				if (current instanceof ItemSword || current instanceof ItemTool || current instanceof ItemArmor || current instanceof ItemBow || current instanceof ItemShield)
				{
					if (l.isPressed())
					{
						player.openGui(Levels.instance, GuiHandler.ITEM_INFORMATION, player.getEntityWorld(), (int) player.posX, (int) player.posY, (int) player.posZ);
					}
				}
			}
		}
	}
}
 
Example #12
Source File: ModKeybinds.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void onKey(InputEvent.KeyInputEvent event) {
	if (!Keyboard.isCreated()) return;

	EntityPlayer player = Minecraft.getMinecraft().player;
	if (player == null) return;

	if (pearlSwapping.isKeyDown() && player.getHeldItemMainhand().getItem() instanceof IPearlSwappable && !BaublesSupport.getItem(player, IPearlStorageHolder.class).isEmpty()) {
		player.openGui(Wizardry.instance, 1, player.world, (int) player.posX, (int) player.posY, (int) player.posZ);
	}
}
 
Example #13
Source File: CraftingKeys.java    From CraftingKeys with MIT License 5 votes vote down vote up
@SuppressWarnings("UnusedParameters")
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
    if (KeyBindings.openGuiBinding.isPressed()) {
        Logger.info("onKeyInput(e)", "Open Crafting Keys Config Gui.");
        Util.client.player.openGui(instance, GuiConfig.GuiID, Util.client.world,
                ((int) Util.client.player.posX), (int) Util.client.player.posY,
                (int) Util.client.player.posZ);
    }

}
 
Example #14
Source File: KeyInputEventHandler.java    From Fullscreen-Windowed-Minecraft with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@SubscribeEvent
public void handleKeyInputEvent(InputEvent.KeyInputEvent event)
{

    if(isCorrectKeyBinding())
    {

        FullscreenWindowed.proxy.toggleFullScreen(!ClientProxy.fullscreen, ConfigurationHandler.instance().getFullscreenMonitor());
    }
}
 
Example #15
Source File: AutoFishMod.java    From ForgeHax with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onMouseEvent(InputEvent.MouseInputEvent event) {
  if (MC.gameSettings.keyBindUseItem.isKeyDown() && ticksHookDeployed > 0) {
    ticksCastDelay = casting_delay.get();
  }
}
 
Example #16
Source File: ClientEventHandler.java    From HoloInventory with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event)
{
    if (keyToggle.isPressed()) toggleState = !toggleState;
    if (keyHold.isKeyDown()) enabled = true;
}
 
Example #17
Source File: KeyBindings.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
	final Minecraft minecraft = FMLClientHandler.instance().getClient();
	final EntityPlayerSP player = minecraft.player;


	//Prevent control when a GUI is open
	if(Minecraft.getMinecraft().currentScreen != null)// && Minecraft.getMinecraft().currentScreen instanceof GuiChat)
		return;
	
	
	//EntityRocket rocket;
	//If the space bar is pressed then send a packet to the server and launch the rocket
	/*if(/*launch.isPressed()* / false && player.ridingEntity instanceof EntityRocket && !(rocket = (EntityRocket)player.ridingEntity).isInFlight()) {
		PacketHandler.sendToServer(new PacketEntity(rocket, (byte)EntityRocket.PacketType.LAUNCH.ordinal()));
		rocket.launch();
	}*/
	
	if(player.getRidingEntity() != null && player.getRidingEntity() instanceof EntityRocket) {
		EntityRocket rocket = (EntityRocket)player.getRidingEntity();
		if(!rocket.isInFlight() && Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
			if(Minecraft.getMinecraft().inGameHasFocus && player.equals(Minecraft.getMinecraft().player)) {
				rocket.prepareLaunch();
			}
		}
		
	}
	
	if(toggleJetpack.isPressed()) {
		if(player.isSneaking())
			PacketHandler.sendToServer(new PacketChangeKeyState(1, false));
		else
			PacketHandler.sendToServer(new PacketChangeKeyState(0, false));
	}
	
	if(openRocketUI.isPressed()) {
		if(player.getRidingEntity() instanceof EntityRocketBase) {
			PacketHandler.sendToServer(new PacketEntity((INetworkEntity) player.getRidingEntity(), (byte)EntityRocket.PacketType.OPENGUI.ordinal()));
		}
	}
	
	if(Keyboard.isKeyDown(Keyboard.KEY_SPACE) != prevState) {
		prevState = Keyboard.isKeyDown(Keyboard.KEY_SPACE);
		InputSyncHandler.updateKeyPress(player, Keyboard.KEY_SPACE, prevState);
		PacketHandler.sendToServer(new PacketChangeKeyState(Keyboard.KEY_SPACE, prevState));
	}
}
 
Example #18
Source File: AntiAfkMod.java    From ForgeHax with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onMouseEvent(InputEvent.MouseInputEvent event) {
  reset();
}
 
Example #19
Source File: AntiAfkMod.java    From ForgeHax with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onKeyboardInput(InputEvent.KeyInputEvent event) {
  reset();
}
 
Example #20
Source File: KeyInputHandler.java    From YouTubeModdingTutorial with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
    if (KeyBindings.wandMode.isPressed()) {
        Messages.INSTANCE.sendToServer(new PacketToggleMode());
    }
}
 
Example #21
Source File: KeybindInputHandler.java    From MediaMod with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Fired when a key is pressed
 *
 * @param event - KeyInputEvent
 * @see InputEvent.KeyInputEvent
 */
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
    if (KeybindManager.INSTANCE.disableKeybind.isPressed()) {
        if (!Settings.SHOW_PLAYER) {
            PlayerMessager.sendMessage("Player Visible");
            Settings.SHOW_PLAYER = true;
        } else {
            PlayerMessager.sendMessage("Player Hidden");
            Settings.SHOW_PLAYER = false;
        }
        Settings.saveConfig();
    } else if (KeybindManager.INSTANCE.menuKeybind.isPressed()) {
        TickScheduler.INSTANCE.schedule(0, () -> Minecraft.getMinecraft().displayGuiScreen(new GuiMediaModSettings()));
    }
    if(ServiceHandler.INSTANCE.getCurrentMediaHandler() != null) {
        if (KeybindManager.INSTANCE.skipKeybind.isPressed()) {
            if(!ServiceHandler.INSTANCE.getCurrentMediaHandler().handlerReady()) {
                PlayerMessager.sendMessage(ChatColor.RED + "You can not skip when no services are playing music!", true);
            } else {
                if(ServiceHandler.INSTANCE.getCurrentMediaHandler().supportsSkipping()) {
                    if(ServiceHandler.INSTANCE.getCurrentMediaHandler().skipTrack()) {
                        PlayerMessager.sendMessage(ChatColor.GREEN + "Song skipped!", true);
                    }
                } else {
                    PlayerMessager.sendMessage(ChatColor.RED + "This service does not support skipping songs", true);
                }
            }
        } else if (KeybindManager.INSTANCE.pausePlayKeybind.isPressed()) {
            if(!ServiceHandler.INSTANCE.getCurrentMediaHandler().handlerReady()) {
                PlayerMessager.sendMessage(ChatColor.RED + "You can't pause or resume a song when no services are playing music!", true);
            } else {
                if(ServiceHandler.INSTANCE.getCurrentMediaHandler().supportsPausing()) {
                    if(ServiceHandler.INSTANCE.getCurrentMediaHandler().pausePlayTrack()) {
                        PlayerMessager.sendMessage(ChatColor.GREEN + "Song paused/resumed!", true);
                    }
                } else {
                    PlayerMessager.sendMessage(ChatColor.RED + "This service does not support pausing or resuming songs", true);
                }
            }
        }
    }
}