Class PlayerDayCare
java.lang.Object
com.pixelmonmod.pixelmon.api.storage.breeding.PlayerDayCare
All breeding related storage for a Player
- Since:
- 25/06/2022
-
Constructor Summary
ConstructorDescriptionPlayerDayCare
(PlayerPartyStorage party) Default constructor taking just the party -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHistory
(Pokemon pokemon) Adds a Pokémon to the history Even if both parents are Ditto it will display as an egg.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.static PlayerDayCare
decode
(PlayerPartyStorage storage, net.minecraft.network.FriendlyByteBuf buffer) Decodes the boxes from the buffervoid
encode
(net.minecraft.network.FriendlyByteBuf buffer) Encodes the boxes to the bufferint
Gets the number of allowed ranch boxes the player hasgetBox
(int boxId) Attempts to get the ranch box at the given indexgetEgg()
The last egg sent to the clientFinds the first box that is empty in the Player's Day Care storage "first" being found via logical id (i.e.Gets the Pokemon breeding historygetOrCreateBox
(int boxId) Attempts to get the ranch box at the given index, and creates one if there isn't one thereThe first parent for the current eggThe second parent for the current egggetParty()
Gets the parent party storageboolean
hasBox
(int boxId) Returns true if the daycare has a given boxboolean
hasPaidFor
(Pokemon pokemon) Checks if the player has previously paid for this Pokemonboolean
isFull()
Checks if the player has any empty boxes in their daycarestatic PlayerDayCare
readFromNBT
(PlayerPartyStorage party, net.minecraft.nbt.CompoundTag nbt) Creates a day care instance from the NBTvoid
reset()
Clears the day care datavoid
setAllowedBoxes
(int allowedBoxes) Sets the number of allowed ranch boxes the player can havevoid
setBox
(DayCareBox box) Replaces the box with the same id as the one givenvoid
void
setHistory
(List<PokemonBase> history) void
setPaidFor
(Pokemon pokemon) Sets the Pokemon as having been paid for (proxy forsetPaidFor(Pokemon, boolean)
void
setPaidFor
(Pokemon pokemon, boolean paidFor) Sets if the Pokemon has been paid for previouslyvoid
setParentOne
(UUID parentOne) void
setParentTwo
(UUID parentTwo) void
tick()
Called to tick the day care boxes and check if the breeding time is completevoid
updateHistory
(Pokemon pokemon) Tries to find the Pokémon in the history and then update it.void
writeToNBT
(net.minecraft.nbt.CompoundTag nbt) Writes the day care to NBT
-
Constructor Details
-
PlayerDayCare
Default constructor taking just the party- Parameters:
party
- The player's party
-
-
Method Details
-
reset
public void reset()Clears the day care data -
hasPaidFor
Checks if the player has previously paid for this Pokemon- Parameters:
pokemon
- Pokemon being checked- Returns:
- True if paid for, false if not
-
setPaidFor
Sets the Pokemon as having been paid for (proxy forsetPaidFor(Pokemon, boolean)
- Parameters:
pokemon
- The pokemon
-
setPaidFor
Sets if the Pokemon has been paid for previously- Parameters:
pokemon
- The pokemonpaidFor
- 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
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
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
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
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
Replaces the box with the same id as the one given- Parameters:
box
- The box being set
-
getHistory
Gets the Pokemon breeding history- Returns:
- The history
-
addHistory
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
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
-
updateHistory
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
The first parent for the current egg- Returns:
- The first parent
-
getParentTwo
The second parent for the current egg- Returns:
- The second parent
-
getEgg
The last egg sent to the client- Returns:
- The egg
-
setParentOne
-
setParentTwo
-
setEgg
-
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 partybuffer
- 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
-