Record Class BattleAI

java.lang.Object
java.lang.Record
com.pixelmonmod.pixelmon.battles.controller.ai.BattleAI
All Implemented Interfaces:
BattleAILogic

public record BattleAI(net.minecraft.network.chat.Component name, BattleAIBase ai) extends Record implements BattleAILogic
  • Field Details

    • REGISTRY

      public static final net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<BattleAI>> REGISTRY
    • DIRECT_CODEC

      public static final com.mojang.serialization.Codec<BattleAI> DIRECT_CODEC
    • NETWORK_CODEC

      public static final com.mojang.serialization.Codec<BattleAI> NETWORK_CODEC
    • CODEC

      public static final com.mojang.serialization.Codec<net.minecraft.core.Holder<BattleAI>> CODEC
    • RANDOM

      public static final net.minecraft.resources.ResourceKey<BattleAI> RANDOM
    • NO_OP

      public static final net.minecraft.resources.ResourceKey<BattleAI> NO_OP
    • AGGRESSIVE

      public static final net.minecraft.resources.ResourceKey<BattleAI> AGGRESSIVE
    • ADVANCED

      public static final net.minecraft.resources.ResourceKey<BattleAI> ADVANCED
    • RAID

      public static final net.minecraft.resources.ResourceKey<BattleAI> RAID
  • Constructor Details

    • BattleAI

      @Internal public BattleAI(net.minecraft.network.chat.Component name)
    • BattleAI

      public BattleAI(net.minecraft.network.chat.Component name, BattleAIBase ai)
      Creates an instance of a BattleAI record class.
      Parameters:
      name - the value for the name record component
      ai - the value for the ai record component
  • Method Details

    • codec

      public com.mojang.serialization.MapCodec<? extends BattleAIBase> codec()
      Specified by:
      codec in interface BattleAILogic
    • type

      public BattleAIType<? extends BattleAIBase> type()
      Specified by:
      type in interface BattleAILogic
    • getNextMove

      public MoveChoice getNextMove(PixelmonWrapper pw)
      Description copied from interface: BattleAILogic
      Gets the move the AI will make next.
      Specified by:
      getNextMove in interface BattleAILogic
      Parameters:
      pw - The Pokémon to make a move with.
      Returns:
      The move the AI will make next.
    • getNextSwitch

      public UUID getNextSwitch(PixelmonWrapper pw)
      Description copied from interface: BattleAILogic
      Gets a Pokémon to switch to when forced to switch.
      Specified by:
      getNextSwitch in interface BattleAILogic
      Parameters:
      pw - The Pokémon switching out.
      Returns:
      The ID of the Pokémon to switch to.
    • getFaintedPokemonToRevive

      public UUID getFaintedPokemonToRevive(BattleParticipant participant)
      Description copied from interface: BattleAILogic
      Gets a Pokémon to revive when forced to revive.
      Specified by:
      getFaintedPokemonToRevive in interface BattleAILogic
      Returns:
      The ID of the Pokémon to switch to.
    • registerMove

      public void registerMove(PixelmonWrapper user)
      Description copied from interface: BattleAILogic
      Registers an enemy move into the AI's memory.
      Specified by:
      registerMove in interface BattleAILogic
    • registerSwitch

      public void registerSwitch(PixelmonWrapper switchOut, PixelmonWrapper switchIn)
      Description copied from interface: BattleAILogic
      Registers an enemy switch-in into the AI's memory.
      Specified by:
      registerSwitch in interface BattleAILogic
    • getMoveset

      public List<Attack> getMoveset(PixelmonWrapper pw)
      Description copied from interface: BattleAILogic
      Returns the moveset that the AI thinks a Pokémon has.
      Specified by:
      getMoveset in interface BattleAILogic
      Parameters:
      pw - The Pokémon to get moves for.
      Returns:
      The moveset that the AI thinks the Pokémon has.
    • getTopNAttackChoices

      public List<MoveChoice> getTopNAttackChoices(int count, PixelmonWrapper pw)
      Specified by:
      getTopNAttackChoices in interface BattleAILogic
    • weightRandomMove

      public void weightRandomMove(PixelmonWrapper pw, MoveChoice userChoice, List<MoveChoice> possibleChoices)
      Description copied from interface: BattleAILogic
      Weights a move that randomly selects from an assortment of moves.
      Specified by:
      weightRandomMove in interface BattleAILogic
      Parameters:
      pw - The Pokémon using the move.
      userChoice - The move with random selection.
      possibleChoices - The possible moves that the move can select.
    • weightFromUserOptions

      public void weightFromUserOptions(PixelmonWrapper pw, MoveChoice userChoice, List<MoveChoice> bestChoicesBefore, List<MoveChoice> bestChoicesAfter, boolean weightNegative)
      Description copied from interface: BattleAILogic
      Weights a move based on the amount of turns the user takes to KO the opponent after using the move.
      Specified by:
      weightFromUserOptions in interface BattleAILogic
      Parameters:
      pw - The Pokémon using the move.
      userChoice - The move being used.
      bestChoicesBefore - The user's best choices before using the move.
      bestChoicesAfter - The user's best choices after using the move.
      weightNegative - Whether to weight negatively if the move causes the user to take more turns to KO the opponent.
    • weightFromUserOptions

      public void weightFromUserOptions(PixelmonWrapper pw, MoveChoice userChoice, List<MoveChoice> bestChoicesBefore, List<MoveChoice> bestChoicesAfter)
      Description copied from interface: BattleAILogic
      Weights a move based on the amount of turns the user takes to KO the opponent after using the move.
      Specified by:
      weightFromUserOptions in interface BattleAILogic
      Parameters:
      pw - The Pokémon using the move.
      userChoice - The move being used.
      bestChoicesBefore - The user's best choices before using the move.
      bestChoicesAfter - The user's best choices after using the move.
    • getWeightedOffensiveChoices

      public List<MoveChoice> getWeightedOffensiveChoices(PixelmonWrapper pw)
      Description copied from interface: BattleAILogic
      Weights and returns all offensive move choices of a Pokémon.
      Specified by:
      getWeightedOffensiveChoices in interface BattleAILogic
      Parameters:
      pw - The Pokémon to get choices for.
      Returns:
      A list of offensive move choices that can be made by the Pokémon.
    • getBestAttackChoices

      public List<MoveChoice> getBestAttackChoices(PixelmonWrapper pw)
      Description copied from interface: BattleAILogic
      Finds the strongest offensive move choices in the situation. This should only be called when already in simulate mode.
      Specified by:
      getBestAttackChoices in interface BattleAILogic
      Parameters:
      pw - The Pokémon to get the best move choices for.
      Returns:
      The strongest offensive move choices in the situation.
    • getBestAttackChoices

      public List<List<MoveChoice>> getBestAttackChoices(List<PixelmonWrapper> pokemonList)
      Description copied from interface: BattleAILogic
      Gets the best attack choices for multiple Pokémon.
      Specified by:
      getBestAttackChoices in interface BattleAILogic
      Parameters:
      pokemonList - The Pokémon to get attack choices for.
      Returns:
      A list of attack choices for each specified Pokémon.
    • weightFromOpponentOptions

      public void weightFromOpponentOptions(PixelmonWrapper pw, MoveChoice userChoice, List<List<MoveChoice>> bestChoicesBefore, List<List<MoveChoice>> bestChoicesAfter)
      Description copied from interface: BattleAILogic
      Weights a move based on the amount of turns the opponent takes to KO the Pokémon before and after using the move.
      Specified by:
      weightFromOpponentOptions in interface BattleAILogic
      Parameters:
      pw - The Pokémon using the move.
      userChoice - The move being used.
      bestChoicesBefore - The opponent's best options before using the move.
      bestChoicesAfter - The opponent's best options after using the move.
    • weightFromOpponentOptions

      public void weightFromOpponentOptions(PixelmonWrapper pw, MoveChoice userChoice, List<List<MoveChoice>> bestChoicesBefore, List<List<MoveChoice>> bestChoicesAfter, boolean weightNegative)
      Description copied from interface: BattleAILogic
      Weights a move based on the amount of turns the opponent takes to KO the Pokémon before and after using the move.
      Specified by:
      weightFromOpponentOptions in interface BattleAILogic
      Parameters:
      pw - The Pokémon using the move.
      userChoice - The move being used.
      bestChoicesBefore - The opponent's best options before using the move.
      bestChoicesAfter - The opponent's best options after using the move.
      weightNegative - Whether to weight negatively if the move causes the opponent to KO the Pokémon faster.
    • weightTypeChange

      public void weightTypeChange(PixelmonWrapper pw, MoveChoice userChoice, List<net.minecraft.resources.ResourceKey<Type>> possibleTypes, List<MoveChoice> bestUserChoices, List<MoveChoice> bestOpponentChoices)
      Description copied from interface: BattleAILogic
      Weights the effectiveness of a type change.
      Specified by:
      weightTypeChange in interface BattleAILogic
      Parameters:
      pw - The Pokémon using the move.
      userChoice - The move being used.
      possibleTypes - The possible types the Pokémon can become.
      bestUserChoices - The best user choices before the type change.
      bestOpponentChoices - The best opponent choices before the type change.
    • weightTypeChange

      public void weightTypeChange(PixelmonWrapper pw, MoveChoice userChoice, List<net.minecraft.resources.ResourceKey<Type>> possibleTypes, PixelmonWrapper target, List<MoveChoice> bestUserChoices, List<MoveChoice> bestOpponentChoices)
      Description copied from interface: BattleAILogic
      Weights the effectiveness of a type change.
      Specified by:
      weightTypeChange in interface BattleAILogic
      Parameters:
      pw - The Pokémon using the move.
      userChoice - The move being used.
      possibleTypes - The possible types the Pokémon can become.
      target - The Pokémon whose type is being changed.
      bestUserChoices - The best user choices before the type change.
      bestOpponentChoices - The best opponent choices before the type change.
    • weightStatusOpponentOptions

      public void weightStatusOpponentOptions(PixelmonWrapper pw, MoveChoice userChoice, PixelmonWrapper target, StatusBase status, List<PixelmonWrapper> opponents, List<MoveChoice> bestOpponentChoices)
      Description copied from interface: BattleAILogic
      Weights a status based on the damage output of the opponent before and after applying it.
      Specified by:
      weightStatusOpponentOptions in interface BattleAILogic
      Parameters:
      pw - The Pokémon using the move.
      userChoice - The move to be used.
      target - The Pokémon targeted by the status.
      status - The status being applied.
      opponents - The opponents of the move's user.
      bestOpponentChoices - The best choices of the opponent.
    • weightSingleTypeChange

      public void weightSingleTypeChange(PixelmonWrapper pw, MoveChoice userChoice, List<net.minecraft.core.Holder<Type>> newType, PixelmonWrapper target, List<MoveChoice> bestUserChoices, List<MoveChoice> bestOpponentChoices)
      Description copied from interface: BattleAILogic
      Weights the effectiveness of a type change.
      Specified by:
      weightSingleTypeChange in interface BattleAILogic
      Parameters:
      pw - The Pokémon using the move.
      userChoice - The move being used.
      newType - The type that the target will become.
      target - The Pokémon whose type is being changed.
      bestUserChoices - The best user choices before the type change.
      bestOpponentChoices - The best opponent choices before the type change.
    • getRandomAI

      public static net.minecraft.core.Holder<BattleAI> getRandomAI(net.minecraft.core.RegistryAccess registryAccess)
    • getAdvancedAI

      public static net.minecraft.core.Holder<BattleAI> getAdvancedAI(net.minecraft.core.RegistryAccess registryAccess)
    • getNoOpAI

      public static net.minecraft.core.Holder<BattleAI> getNoOpAI(net.minecraft.core.RegistryAccess registryAccess)
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public net.minecraft.network.chat.Component name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • ai

      public BattleAIBase ai()
      Returns the value of the ai record component.
      Returns:
      the value of the ai record component