Class PlayerDayCare

java.lang.Object
com.pixelmonmod.pixelmon.api.storage.breeding.PlayerDayCare

public class PlayerDayCare extends Object
All breeding related storage for a Player
Since:
25/06/2022
  • Constructor Details

    • PlayerDayCare

      public PlayerDayCare(PlayerPartyStorage party)
      Default constructor taking just the party
      Parameters:
      party - The player's party
  • Method Details

    • reset

      public void reset()
      Clears the day care data
    • hasPaidFor

      public boolean hasPaidFor(Pokemon pokemon)
      Checks if the player has previously paid for this Pokemon
      Parameters:
      pokemon - Pokemon being checked
      Returns:
      True if paid for, false if not
    • setPaidFor

      public void setPaidFor(Pokemon pokemon)
      Sets the Pokemon as having been paid for (proxy for setPaidFor(Pokemon, boolean)
      Parameters:
      pokemon - The pokemon
    • setPaidFor

      public void setPaidFor(Pokemon pokemon, boolean paidFor)
      Sets if the Pokemon has been paid for previously
      Parameters:
      pokemon - The pokemon
      paidFor - If they have, or have not, previously been paid for
    • setAllowedBoxes

      public void setAllowedBoxes(int allowedBoxes)
      Sets the number of allowed ranch boxes the player can have
      Parameters:
      allowedBoxes - The new number of allowed boxes
    • getAllowedBoxes

      public int getAllowedBoxes()
      Gets the number of allowed ranch boxes the player has
      Returns:
      The number of ranch boxes
    • getOrCreateBox

      public Optional<DayCareBox> getOrCreateBox(int boxId)
      Attempts to get the ranch box at the given index, and creates one if there isn't one there
      Parameters:
      boxId - The ranch box index
      Returns:
      The ranch box found
    • getBox

      public Optional<DayCareBox> getBox(int boxId)
      Attempts to get the ranch box at the given index
      Parameters:
      boxId - The ranch box index
      Returns:
      The ranch box found
    • hasBox

      public boolean hasBox(int boxId)
      Returns true if the daycare has a given box
      Parameters:
      boxId - The ranch box index
      Returns:
      If the ranch has a box at the boxID
    • getFirstEmptyBox

      @Nullable public DayCareBox getFirstEmptyBox()
      Finds the first box that is empty in the Player's Day Care storage "first" being found via logical id (i.e. going from 0 -> max count) Will return null if none found
      Returns:
      The first empty box
    • getParty

      public PlayerPartyStorage getParty()
      Gets the parent party storage
      Returns:
      The parent party storage
    • isFull

      public boolean isFull()
      Checks if the player has any empty boxes in their daycare
      Returns:
      True if the box is not empty
    • setBox

      public void setBox(DayCareBox box)
      Replaces the box with the same id as the one given
      Parameters:
      box - The box being set
    • getHistory

      public List<PokemonBase> getHistory()
      Gets the Pokemon breeding history
      Returns:
      The history
    • addHistory

      public void addHistory(Pokemon pokemon)
      Adds a Pokémon to the history Even if both parents are Ditto it will display as an egg.
      Parameters:
      pokemon - The Pokémon to add as history (will be cloned)
    • addHistory

      public void addHistory(Pokemon pokemon, boolean bothParentsDitto)
      Adds a Pokémon to the history It will not display as an egg unless both of its parents are Ditto.
      Parameters:
      pokemon - The Pokémon to add as history (will be cloned)
      bothParentsDitto - Whether the child is an offspring of two ditto parents.
    • setHistory

      public void setHistory(List<PokemonBase> history)
    • updateHistory

      public void updateHistory(Pokemon pokemon)
      Tries to find the Pokémon in the history and then update it. Created so that when an egg from Ditto x Ditto parents hatch the history will now display the Pokémon that hatched from it instead of the egg sprite.
      Parameters:
      pokemon - The newly hatched Pokémon.
    • getParentOne

      public UUID getParentOne()
      The first parent for the current egg
      Returns:
      The first parent
    • getParentTwo

      public UUID getParentTwo()
      The second parent for the current egg
      Returns:
      The second parent
    • getEgg

      public Pokemon getEgg()
      The last egg sent to the client
      Returns:
      The egg
    • setParentOne

      public void setParentOne(UUID parentOne)
    • setParentTwo

      public void setParentTwo(UUID parentTwo)
    • setEgg

      public void setEgg(Pokemon egg)
    • tick

      public void tick()
      Called to tick the day care boxes and check if the breeding time is complete
    • encode

      public void encode(net.minecraft.network.FriendlyByteBuf buffer)
      Encodes the boxes to the buffer
      Parameters:
      buffer - The packet buffer
    • decode

      public static PlayerDayCare decode(PlayerPartyStorage storage, net.minecraft.network.FriendlyByteBuf buffer)
      Decodes the boxes from the buffer
      Parameters:
      storage - The player's party
      buffer - The buffer encoded to
      Returns:
      The new day care instance
    • writeToNBT

      public void writeToNBT(net.minecraft.nbt.CompoundTag nbt)
      Writes the day care to NBT
      Parameters:
      nbt - The NBT writing to
    • readFromNBT

      public static PlayerDayCare readFromNBT(PlayerPartyStorage party, net.minecraft.nbt.CompoundTag nbt)
      Creates a day care instance from the NBT
      Parameters:
      party - The player party (parent)
      nbt - The NBT reading from
      Returns:
      The day care instance