private void checkKeys() {
   for (KeyBinding key : this.keys) {
     if (key != null && this.isKeyActive(key.getKeyCode())) {
       this.keyPressed(key);
     }
   }
 }
Example #2
0
 @Override
 public void handleKeyboardInput() {
   super.handleKeyboardInput();
   if (Keyboard.getEventKeyState()) {
     int key = Keyboard.getEventKey();
     if (key == Keyboard.KEY_UP) {
       navigateMap(0, navigateStep);
     } else if (key == Keyboard.KEY_DOWN) {
       navigateMap(0, -navigateStep);
     } else if (key == Keyboard.KEY_LEFT) {
       navigateMap(navigateStep, 0);
     } else if (key == Keyboard.KEY_RIGHT) {
       navigateMap(-navigateStep, 0);
     } else if (key == Keyboard.KEY_ADD || key == Keyboard.KEY_EQUALS) {
       setMapScale(mapScale * 2);
     } else if (key == Keyboard.KEY_SUBTRACT || key == Keyboard.KEY_MINUS) {
       setMapScale(mapScale / 2);
     }
     // Close the GUI if a hotbar key is pressed
     else {
       KeyBinding[] hotbarKeys = mc.gameSettings.keyBindsHotbar;
       for (KeyBinding bind : hotbarKeys) {
         if (key == bind.getKeyCode()) {
           close();
           break;
         }
       }
     }
   }
 }
Example #3
0
  public static void func_74506_a() {
    Iterator var0 = field_74516_a.iterator();

    while (var0.hasNext()) {
      KeyBinding var1 = (KeyBinding) var0.next();
      var1.func_74505_d();
    }
  }
Example #4
0
 @SubscribeEvent
 public static void keyPress(KeyInputEvent event) {
   for (KeyBinding k : ClientKeyHelper.mcToPe.keySet()) {
     if (k.isPressed()) {
       PacketHandler.sendToServer(new KeyPressPKT(ClientKeyHelper.mcToPe.get(k)));
     }
   }
 }
Example #5
0
 /**
  * This will only subscribe when NotEnoughKeys is not installed.
  *
  * @param event
  */
 @SubscribeEvent
 public void onKey(KeyInputEvent event) {
   if (!nekLoaded()) {
     for (KeyBinding key : keys) {
       if (key.isPressed()) {
         onKey(key);
       }
     }
   }
 }
Example #6
0
 @Override
 public void renderTick(EntityPlayerCustom playerCustom) {
   if (playerCustom.isRolling
       || (Util.isCube(
               Minecraft.getMinecraft()
                   .theWorld
                   .getBlock(
                       MathHelper.floor_double(Minecraft.getMinecraft().thePlayer.posX),
                       MathHelper.floor_double(Minecraft.getMinecraft().thePlayer.posY),
                       MathHelper.floor_double(Minecraft.getMinecraft().thePlayer.posZ)))
           && playerCustom.wasRolling)) {
     int x1 = MathHelper.floor_double(Minecraft.getMinecraft().thePlayer.posX);
     int y1 = MathHelper.floor_double(Minecraft.getMinecraft().thePlayer.posY);
     int z1 = MathHelper.floor_double(Minecraft.getMinecraft().thePlayer.posZ);
     ExtendedBlockStorage ebs =
         ((ExtendedBlockStorage[])
                 ObfuscationReflectionHelper.getPrivateValue(
                     Chunk.class,
                     Minecraft.getMinecraft().thePlayer.worldObj.getChunkFromBlockCoords(x1, z1),
                     2))
             [y1 >> 4];
     if (ebs.getExtSkylightValue((x1 & 15), y1 & 15, (z1 & 15)) == 0) {
       ebs.setExtSkylightValue((x1 & 15), y1 & 15, (z1 & 15), playerCustom.lastLightValue);
     }
     playerCustom.lastLightValue = (byte) ebs.getExtSkylightValue((x1 & 15), y1 & 15, (z1 & 15));
     KeyBinding.setKeyBindState(
         Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), true);
     if (renderer == null) {
       renderer = new EntityRendererCustom(Minecraft.getMinecraft());
     }
     if (Minecraft.getMinecraft().entityRenderer != renderer) {
       // be sure to store the previous renderer
       prevRenderer = Minecraft.getMinecraft().entityRenderer;
       Minecraft.getMinecraft().entityRenderer = renderer;
     }
   } else if (prevRenderer != null
       && Minecraft.getMinecraft().entityRenderer != prevRenderer
       && playerCustom.wasRolling) {
     // reset the renderer
     KeyBinding.setKeyBindState(
         Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), false);
     Minecraft.getMinecraft().entityRenderer = prevRenderer;
     playerCustom.wasRolling = false;
   }
   if (!playerCustom.wasRolling) {
     playerCustom.wasRolling = playerCustom.isRolling;
   }
 }
Example #7
0
 private void handleConvert() {
   if (convertKey.getIsKeyPressed()) {
     if (Config.debug) Log.playerChat("Beginning conversion!");
     IMessage msg = new ODCPacket.ODCMessage();
     PacketHandler.net.sendToServer(msg);
   }
 }
  public static void unpressAll() {
    for (Map.Entry<String, ControllerBinding> entry : joyBindingsMap.entrySet()) {
      if (entry.getValue().bindingOptions.contains(BindingOptions.IS_TOGGLE))
        entry.getValue().toggleState = false;
    }

    KeyBinding.unPressAllKeys();
    VirtualMouse.unpressAllButtons();
  }
Example #9
0
  @Override
  protected void mouseClicked(int mouseX, int mouseY, int mouseState) {
    super.mouseClicked(mouseX, mouseY, mouseState);
    if (state.is(EXPORTING_IMAGE)) {
      return; // Don't remove the progress bar.
    }

    // If clicked on the map, start dragging
    int mapX = (width - MAP_WIDTH) / 2;
    int mapY = (height - MAP_HEIGHT) / 2;
    boolean isMouseOverMap =
        mouseX >= mapX
            && mouseX <= mapX + MAP_WIDTH
            && mouseY >= mapY
            && mouseY <= mapY + MAP_HEIGHT;
    if (!state.is(NORMAL) && !state.is(HIDING_MARKERS)) {
      if (state.is(PLACING_MARKER) // If clicked on the map, place marker:
          && isMouseOverMap
          && mouseState == 0 /* left click */) {
        markerFinalizer.setMarkerData(
            player.worldObj,
            stack.getItemDamage(),
            player.dimension,
            screenXToWorldX(mouseX),
            screenYToWorldZ(mouseY));
        addChild(markerFinalizer);

        blinkingIcon.setTexture(
            MarkerTextureMap.instance().getTexture(markerFinalizer.selectedType),
            MARKER_SIZE,
            MARKER_SIZE);
        addChildBehind(markerFinalizer, blinkingIcon)
            .setRelativeCoords(
                mouseX - getGuiX() - MARKER_SIZE / 2, mouseY - getGuiY() - MARKER_SIZE / 2);

        // Need to intercept keyboard events to type in the label:
        setInterceptKeyboard(true);

        // Un-press all keys to prevent player from walking infinitely:
        KeyBinding.unPressAllKeys();

      } else if (state.is(DELETING_MARKER) // If clicked on a marker, delete it:
          && toDelete != null
          && isMouseOverMap
          && mouseState == 0) {
        AtlasAPI.getMarkerAPI()
            .deleteMarker(player.worldObj, stack.getItemDamage(), toDelete.getId());
      }
      state.switchTo(NORMAL);
    } else if (isMouseOverMap && selectedButton == null) {
      isDragging = true;
      dragMouseX = mouseX;
      dragMouseY = mouseY;
      dragMapOffsetX = mapOffsetX;
      dragMapOffsetY = mapOffsetY;
    }
  }
Example #10
0
 @SubscribeEvent
 public void onKeyInput(KeyInputEvent event) throws Throwable {
   if (mc.inGameHasFocus) {
     if (keyScreenPost.getIsKeyPressed()) {
       try {
         BufferedImage screenshot = VioletLiveHelper.saveScreenShot();
         if (VioletLiveHelper.poster.isCanPost()) {
           if (VioletLiveHelper.poster instanceof VLHTiebaPoster)
             mc.displayGuiScreen(new VLHGuiPostTieba(VioletLiveHelper.poster, screenshot));
         } else {
           VioletLiveHelper.printMessage("vlh.message.postthread.notconfig");
           VLHImageUtil.setClipboardImage(screenshot);
         }
       } catch (Throwable e) {
         logger.warn("Couldn\'t save screenshot", e);
       }
     }
     if (keyOptions.getIsKeyPressed()) {
       mc.displayGuiScreen(new VLHGuiOptions(VioletLiveHelper.poster));
     }
   }
 }
Example #11
0
 @SubscribeEvent
 public void onKeyInput(InputEvent.KeyInputEvent event) {
   if (toggle.isPressed()) {
     if (!isEnabled) {
       mc.thePlayer.addChatMessage(
           new TextComponentString(
               TextFormatting.DARK_AQUA + "[SkyNet] " + TextFormatting.GRAY + "SkyNet Enabled"));
       isEnabled = true;
     } else if (isEnabled) {
       mc.thePlayer.addChatMessage(
           new TextComponentString(
               TextFormatting.DARK_AQUA + "[SkyNet] " + TextFormatting.GRAY + "SkyNet Disabled"));
       isEnabled = false;
     }
   }
 }
Example #12
0
 public static void func_74510_a(int p_74510_0_, boolean p_74510_1_) {
   KeyBinding var2 = (KeyBinding) field_74514_b.func_76041_a(p_74510_0_);
   if (var2 != null) {
     var2.field_74513_e = p_74510_1_;
   }
 }
  @SubscribeEvent
  public void keyDown(TickEvent.ClientTickEvent event) {
    if (Battlegear.battlegearEnabled) {
      // null checks to prevent any crash outside the world (and to make sure we have no screen
      // open)
      if (mc.thePlayer != null && mc.theWorld != null && mc.currentScreen == null) {
        EntityPlayer player = mc.thePlayer;
        if (event.phase == TickEvent.Phase.START) {
          if (!specialDone
              && special.isKeyDown()
              && ((IBattlePlayer) player).getSpecialActionTimer() == 0) {
            ItemStack quiver = QuiverArrowRegistry.getArrowContainer(player);

            if (quiver != null) {
              FMLProxyPacket p =
                  new BattlegearAnimationPacket(EnumBGAnimations.SpecialAction, player)
                      .generatePacket();
              Battlegear.packetHandler.sendPacketToServer(p);
              ((IBattlePlayer) player).setSpecialActionTimer(2);
            } else if (((IBattlePlayer) player).isBattlemode()) {
              ItemStack offhand =
                  ((InventoryPlayerBattle) player.inventory).getCurrentOffhandWeapon();

              if (offhand != null && offhand.getItem() instanceof IShield) {
                float shieldBashPenalty =
                    0.33F
                        - 0.06F
                            * EnchantmentHelper.getEnchantmentLevel(
                                BaseEnchantment.bashWeight, offhand);

                if (blockBar >= shieldBashPenalty) {
                  FMLProxyPacket p =
                      new BattlegearAnimationPacket(EnumBGAnimations.SpecialAction, player)
                          .generatePacket();
                  Battlegear.packetHandler.sendPacketToServer(p);
                  ((IBattlePlayer) player)
                      .setSpecialActionTimer(((IShield) offhand.getItem()).getBashTimer(offhand));

                  blockBar -= shieldBashPenalty;
                }
              }
            }
            specialDone = true;
          } else if (specialDone && !special.isKeyDown()) {
            specialDone = false;
          }
          if (!drawDone && drawWeapons.isKeyDown()) {
            if (((IBattlePlayer) player).isBattlemode()) {
              previousBattlemode = player.inventory.currentItem;
              player.inventory.currentItem = previousNormal;
            } else {
              previousNormal = player.inventory.currentItem;
              player.inventory.currentItem = previousBattlemode;
            }
            mc.playerController.syncCurrentPlayItem();
            drawDone = true;
          } else if (drawDone && !drawWeapons.isKeyDown()) {
            drawDone = false;
          }
          inBattle = ((IBattlePlayer) player).isBattlemode();
        } else {
          if (inBattle && !((IBattlePlayer) player).isBattlemode()) {
            for (int i = 0; i < InventoryPlayerBattle.WEAPON_SETS; ++i) {
              if (mc.gameSettings.keyBindsHotbar[i].isKeyDown()) {
                previousBattlemode = InventoryPlayerBattle.OFFSET + i;
              }
            }
            player.inventory.currentItem = previousBattlemode;
            mc.playerController.syncCurrentPlayItem();
          }
        }
      }
    }
  }