New Exhaustion Reason

Discussion in 'Programming' started by TANG_N, Jun 11, 2021 at 8:45 AM.

  1. I have searched the source code about EntityExhaustionEvent and ExhaustionReason.
    I want to add a new reason to it (For example shooting arrow will be an exhaustion event)
    but I'm kinda new to Java and not sure if I could just add a reason to it by creating a new Event that extends EntityExhaustionEvent and create an nested enum
    Code (Text):

    public class ShootingEvent extends EntityExhaustionEvent {
      ...

      public enum ExhaustionReason {

         ATTACK,

         SRPINT,

         (other original enum type),

         // The new enum
         SHOOTING
      }

    }
     
    Or do I have to do something to toggle the exhaustion event?


    btw is it possible to change the exhaustion level for some original event?
    For example something similar
    Code (Text):


    if(player.getInventory.getItemInMainHand() == something && player.isSprinting()) {
      player.setExhaustion(getExhaustion(SRPINT) + 0.1);
    }

     
     
    #1 TANG_N, Jun 11, 2021 at 8:45 AM
    Last edited: Jun 11, 2021 at 8:53 AM