コード例 #1
0
 /** Counter the bow use fov jerkyness with the draw enchantment */
 @SubscribeEvent
 public void onBowFOV(FOVUpdateEvent event) {
   ItemStack stack = event.entity.getItemInUse();
   if (EnchantmentHelper.getEnchantmentLevel(BaseEnchantment.bowCharge, stack) > 0) {
     int i = event.entity.getItemInUseDuration();
     float f1 = (float) i / 20.0F;
     if (f1 > 1.0F) {
       f1 = 1.0F;
     } else {
       f1 *= f1;
     }
     event.newfov /= 1.0F - f1 * 0.15F;
   }
 }
コード例 #2
0
  @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();
          }
        }
      }
    }
  }