Class PartyStorage

java.lang.Object
com.pixelmonmod.pixelmon.api.storage.PokemonStorage
com.pixelmonmod.pixelmon.api.storage.PartyStorage
All Implemented Interfaces:
Iterable<Pokemon>
Direct Known Subclasses:
NPCPartyStorage, PlayerPartyStorage, TrainerPartyStorage

public class PartyStorage extends PokemonStorage
  • Field Details

  • Constructor Details

    • PartyStorage

      public PartyStorage(UUID uuid)
    • PartyStorage

      public PartyStorage(net.minecraft.resources.ResourceLocation storageType, UUID uuid)
  • Method Details

    • encode

      public void encode(net.minecraft.network.FriendlyByteBuf buffer)
      Description copied from class: PokemonStorage
      Writes the storage to the given buffer
      Specified by:
      encode in class PokemonStorage
      Parameters:
      buffer - the buffer to write to
    • decode

      public void decode(net.minecraft.network.FriendlyByteBuf buf)
      Description copied from class: PokemonStorage
      Reads the storage from the given buffer
      Specified by:
      decode in class PokemonStorage
      Parameters:
      buf - the buffer to read from
    • inTemporaryMode

      public boolean inTemporaryMode()
      Checks if the player's party is in "temporary" mode (i.e. the party they're using is temporary for some use)
      Returns:
      True if in temporary mode
    • copyToTemporaryMode

      public void copyToTemporaryMode(Color color)
      Puts the player's party into temporary mode using a deep copy of their existing party (so any changes made won't impact their original party Pokémon)
      Parameters:
      color - The colour on the sidebar
    • enterTemporaryMode

      public void enterTemporaryMode()
      Enters the party into temporary mode using a default RED colour
    • enterTemporaryMode

      public void enterTemporaryMode(Color color)
      Enters the party into the temporary mode with 0 Pokes You can add to their temp mode party using PokemonStorage.add(Pokemon)
      Parameters:
      color - The colour to display on the sidebar
    • setInTemporaryModeClient

      public void setInTemporaryModeClient(boolean tempMode, Color color)
    • setInTemporaryMode

      public void setInTemporaryMode(boolean tempMode, Color color, Pokemon... pokemons)
    • setTempPartyColor

      public void setTempPartyColor(Color tempPartyColor)
    • getTempPartyColor

      public Color getTempPartyColor()
    • getAll

      public Pokemon[] getAll()
      Description copied from class: PokemonStorage
      Gets a array of all pokemon within this storage. May not be the implementations array (e.g it could be copy). So don't expect to be able to edit this. the size of the array should always match the maximum capacity and will obviously contain null elements for slots that are not full.
      Specified by:
      getAll in class PokemonStorage
      Returns:
      An array of all pokemon within this storage. By convention this is not the implementation's array (thus this is a copy). This is preferred because it forces modifications to go through the relevant methods which fire events and flip hasChanged.
    • getAllPositions

      public StoragePosition[] getAllPositions()
      Description copied from class: PokemonStorage
      Same as PokemonStorage.getAll(), but for StoragePositions. Note that this will return every position, regardless of whether or not it contains a Pokemon, for flexibility.
      Specified by:
      getAllPositions in class PokemonStorage
    • maxSize

      public int maxSize()
      Specified by:
      maxSize in class PokemonStorage
      Returns:
      The maximum capacity of the Storage (or the individual containers, in cases like PCStorage)
    • getOriginalParty

      public Pokemon[] getOriginalParty()
      Gets the non-temp mode party (only useful if in temp mode)
      Returns:
      The player's party
    • writeToNBT

      public net.minecraft.nbt.CompoundTag writeToNBT(net.minecraft.nbt.CompoundTag nbt)
      Description copied from class: PokemonStorage
      Writes the storage to the given NBT tag
      Specified by:
      writeToNBT in class PokemonStorage
      Parameters:
      nbt - the NBT tag to write to
      Returns:
      the NBT tag with the storage written to it
    • readFromNBT

      public CompletableFuture<? extends PartyStorage> readFromNBT(net.minecraft.nbt.CompoundTag nbt)
      Description copied from class: PokemonStorage
      Reads the storage from the given NBT tag
      Specified by:
      readFromNBT in class PokemonStorage
      Parameters:
      nbt - the NBT tag to read from
      Returns:
      a future that completes when the storage has been read from the NBT tag
    • getFirstEmptyPosition

      @Nullable public StoragePosition getFirstEmptyPosition()
      Description copied from class: PokemonStorage
      Gets the first position where there is no pokemon in the storage
      Specified by:
      getFirstEmptyPosition in class PokemonStorage
      Returns:
      the first empty position in the storage
    • setOriginal

      public void setOriginal(int slot, Pokemon pokemon)
      A bypass method for setting the original party when the player's party is in temporary mode
      Parameters:
      slot - The slot to set
      pokemon - The Pokémon to set it to
    • setOriginal

      public void setOriginal(StoragePosition position, Pokemon pokemon)
      A bypass method for setting the original party when the player's party is in temporary mode
      Parameters:
      position - The position to set
      pokemon - The Pokémon to set it to
    • set

      public void set(StoragePosition position, Pokemon pokemon)
      Description copied from class: PokemonStorage
      Sets the given pokemon at the given position in the storage
      Specified by:
      set in class PokemonStorage
      Parameters:
      position - the position to set the pokemon
      pokemon - the pokemon to set
    • set

      public void set(int slot, Pokemon pokemon)
    • get

      @Nullable public Pokemon get(StoragePosition position)
      Description copied from class: PokemonStorage
      Gets the pokemon at the given position in the storage
      Will return null if there is no pokemon at the given position
      Specified by:
      get in class PokemonStorage
      Parameters:
      position - the position to get the pokemon from
      Returns:
      the pokemon at the given position
    • get

      @Nullable public Pokemon get(int slot)
    • get

      public Pokemon get(UUID pokemonUUID)
    • getSlot

      public int getSlot(Pokemon pokemon)
    • getSlot

      public int getSlot(UUID pokemonUUID)
    • getTeam

      public List<Pokemon> getTeam()
      Gets a list of all the Pokémon in the player's party that are not eggs
      Returns:
      A list of all the Pokémon in the player's party that are not eggs
    • getTeam

      public List<Pokemon> getTeam(Predicate<Pokemon> predicate)
      Gets a list of all the Pokémon in the player's party that match the given condition
      Parameters:
      predicate - The condition to match
      Returns:
      A list of all the Pokémon in the player's party that match the given condition
    • findFirstPokemon

      @Nullable public @Nullable Pokemon findFirstPokemon()
      Returns:
      The first Pokémon in the party that matches the given condition.
    • findFirst

      @Nullable public @Nullable Pokemon findFirst(@Nullable @Nullable Predicate<Pokemon> condition)
      Parameters:
      condition - The condition to match.
      Returns:
      The first Pokémon in the party that matches the given condition.
    • heal

      public void heal()
    • swap

      public void swap(StoragePosition position1, StoragePosition position2)
      Description copied from class: PokemonStorage
      Swaps the pokemon at the given positions in the storage
      Specified by:
      swap in class PokemonStorage
      Parameters:
      position1 - the first position to swap
      position2 - the second position to swap
    • swap

      public void swap(int slot1, int slot2)
    • getPosition

      public StoragePosition getPosition(Pokemon pokemon)
      Description copied from class: PokemonStorage
      Gets the position of the given pokemon in the storage
      Will return null if the pokemon is not in the storage
      Specified by:
      getPosition in class PokemonStorage
      Parameters:
      pokemon - the pokemon to get the position of
      Returns:
      the position of the given pokemon in the storage
    • countAblePokemon

      public int countAblePokemon()
      Returns:
      The number of Pokémon in the player's party that can battle.
    • getHighestLevel

      public int getHighestLevel()
    • getAverageLevel

      public int getAverageLevel()
    • getLowestLevel

      public int getLowestLevel()
    • getFirstAblePokemon

      public Pokemon getFirstAblePokemon()
    • getFirstBattleReadyPokemon

      public Pokemon getFirstBattleReadyPokemon()
      Alternative to getFirstAblePokemon() that checks if the Pokémon can battle instead of checking if the Pokémon's entity can battle.
      Returns:
      The first Pokémon in the party that can be used for battle.
    • getAndSendOutFirstAblePokemon

      public PixelmonEntity getAndSendOutFirstAblePokemon(net.minecraft.world.entity.Entity parent)
    • isOldGen

      public Quadstate isOldGen(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension)
    • iterator

      @NotNull public @NotNull Iterator<Pokemon> iterator()
    • clear

      public void clear()
      Description copied from class: PokemonStorage
      Clears all the pokemon from the storage
      Specified by:
      clear in class PokemonStorage
    • sendCacheToPlayer

      public void sendCacheToPlayer(net.minecraft.server.level.ServerPlayer player)
      Sends the Pokemon to the client for editing
      Parameters:
      player - The player to send the Pokemon to