java.lang.Object
com.pixelmonmod.pixelmon.api.storage.PokemonStorage
com.pixelmonmod.pixelmon.api.storage.PCBox
All Implemented Interfaces:
Iterable<Pokemon>
Direct Known Subclasses:
PCBoxSearch

public class PCBox extends PokemonStorage
  • Field Details

    • POKEMON_PER_BOX

      public static final int POKEMON_PER_BOX
      See Also:
    • pc

      protected transient PCStorage pc
    • boxNumber

      protected transient int boxNumber
    • pokemon

      protected Pokemon[] pokemon
    • name

      protected String name
    • wallpaper

      protected String wallpaper
    • cachePosition

      protected transient StoragePosition cachePosition
    • hasChangedClientSide

      public transient boolean hasChangedClientSide
  • Constructor Details

    • PCBox

      public PCBox()
      Only use this for JSON deserialization.
    • PCBox

      public PCBox(UUID uuid)
    • PCBox

      public PCBox(PCStorage pc, int boxNumber)
  • 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
    • 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)
    • 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<PCBox> 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
    • 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
    • trackingPlayers

      public List<net.minecraft.server.level.ServerPlayer> trackingPlayers()
      Description copied from class: PokemonStorage
      Gets the list of players that are tracking the storage
      Overrides:
      trackingPlayers in class PokemonStorage
      Returns:
      the list of players that are tracking the storage
    • getSlot

      public int getSlot(Pokemon pokemon)
    • 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
    • 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)
    • 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)
    • sendContents

      public void sendContents(net.minecraft.server.level.ServerPlayer player)
    • shouldSendUpdates

      public boolean shouldSendUpdates()
      Description copied from class: PokemonStorage
      Gets if the storage should send updates to the tracking entities
      Overrides:
      shouldSendUpdates in class PokemonStorage
      Returns:
      if the storage should send updates
    • getName

      public String getName()
    • getWallpaper

      public String getWallpaper()
    • 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
    • getPC

      public PCStorage getPC()
    • getBoxNumber

      public int getBoxNumber()
    • sendChangesToServer

      public void sendChangesToServer()
    • setName

      public void setName(String name)
    • setWallpaper

      public void setWallpaper(String wallpaper)