コード例 #1
0
 @SubscribeEvent
 public void onCreativeFall(PlayerFlyableFallEvent event) {
   ZSSPlayerSkills skills = ZSSPlayerSkills.get(event.entityPlayer);
   if (skills.isSkillActive(SkillBase.leapingBlow)) {
     ((LeapingBlow) skills.getPlayerSkill(SkillBase.leapingBlow))
         .onImpact(event.entityPlayer, event.distance);
   }
 }
コード例 #2
0
  /**
   * NOTE: LivingFallEvent is not called in Creative mode, so must also listen for {@link
   * PlayerFlyableFallEvent} Should receive canceled to make sure LeapingBlow triggers/deactivates
   */
  @SubscribeEvent(receiveCanceled = true)
  public void onFall(LivingFallEvent event) {
    if (event.entity instanceof EntityPlayer) {
      EntityPlayer player = (EntityPlayer) event.entity;
      ZSSPlayerInfo info = ZSSPlayerInfo.get(player);
      ZSSPlayerSkills skills = info.getPlayerSkills();
      if (skills.isSkillActive(SkillBase.leapingBlow)) {
        ((LeapingBlow) skills.getPlayerSkill(SkillBase.leapingBlow))
            .onImpact(player, event.distance);
      }

      if (!event.isCanceled() && info.reduceFallAmount > 0.0F) {
        event.distance -= info.reduceFallAmount;
        info.reduceFallAmount = 0.0F;
      }
    }
  }