Jump to content

(Solved)[1.15.2]Speed.applyModifier doesn't call FOVUpdateEvent


Recommended Posts

Posted (edited)

I want to reset FOV when player is applied speed modifier.

The Game doesn't call onFOVChange method...

  @SubscribeEvent
  public static void setSpeedPlayer(TickEvent.PlayerTickEvent event) {
      player_movement_speed = event.player.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
      player_movement_speed.removeModifier(/*UUID*/);
      player_movement_speed.applyModifier(new AttributeModifier(/*UUID*/, /*Name*/, speed - 1.0f, AttributeModifier.Operation.MULTIPLY_TOTAL));
    }
  }

  @SubscribeEvent
  @OnlyIn(Dist.CLIENT)
  public void onFOVChange(FOVUpdateEvent event) {
    LOGGER.debug("ChangeFOV!");
    if (event.getEntity() instanceof PlayerEntity) {
      PlayerEntity player = event.getEntity();
      EffectInstance speed = player.getActivePotionEffect(Effects.SPEED);
      float fov = 0.9f, sprint_fov = 1.02f;
      if (player.isSprinting())
        event.setNewfov(speed != null ? sprint_fov + ((0.104f * (speed.getAmplifier() + 1))) : sprint_fov);
      else
        event.setNewfov(speed != null ? fov + (0.08f * (speed.getAmplifier() + 1)) : fov);
    }
  }
Edited by kyazuki

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.