Class PartyStorage
java.lang.Object
com.pixelmonmod.pixelmon.api.storage.PokemonStorage
com.pixelmonmod.pixelmon.api.storage.PartyStorage
- Direct Known Subclasses:
NPCPartyStorage,PlayerPartyStorage
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StoragePositionprotected net.minecraft.world.entity.Entitystatic final intprotected Pokemon[]static final intprotected Pokemon[]protected ColorFields inherited from class com.pixelmonmod.pixelmon.api.storage.PokemonStorage
hasChanged, shouldSendUpdates, storageType, trackingPlayers, uuid -
Constructor Summary
ConstructorsConstructorDescriptionPartyStorage(UUID uuid) PartyStorage(net.minecraft.resources.ResourceLocation storageType, UUID uuid) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all the pokemon from the storagevoidcopy(PartyStorage partyStorage) voidcopyToTemporaryMode(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)intvoiddecode(net.minecraft.network.RegistryFriendlyByteBuf buf) Reads the storage from the given buffervoidencode(net.minecraft.network.RegistryFriendlyByteBuf buffer) Writes the storage to the given buffervoidEnters the party into temporary mode using a default RED colourvoidenterTemporaryMode(Color color) Enters the party into the temporary mode with 0 Pokes You can add to their temp mode party usingPokemonStorage.add(Pokemon)@Nullable Pokemon@Nullable Pokemonget(int slot) get(StoragePosition position) Gets the pokemon at the given position in the storage
Will return null if there is no pokemon at the given positionPokemon[]getAll()Gets an array of all Pokémon within this storage.Same asPokemonStorage.getAll(), but forStoragePositions.getAndSendOutFirstAblePokemon(net.minecraft.world.entity.Entity parent) intnet.minecraft.world.entity.EntityAlternative to getFirstAblePokemon() that checks if the Pokémon can battle instead of checking if the Pokémon's entity can battle.Gets the first position where there is no pokemon in the storageintintPokemon[]Gets the non-temp mode party (only useful if in temp mode)getPosition(Pokemon pokemon) Gets the position of the given pokemon in the storage
Will return null if the pokemon is not in the storagePokemon[]Gets a raw array of all pokemon within this storage.intintgetTeam()Gets a list of all the Pokémon in the player's party that are not eggsGets a list of all the Pokémon in the player's party that match the given conditionvoidheal()booleanChecks if the player's party is in "temporary" mode (i.e.isOldGen(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension) iterator()intmaxSize()CompletableFuture<? extends PartyStorage> readFromNBT(net.minecraft.nbt.CompoundTag nbt, net.minecraft.core.HolderLookup.Provider registryAccess) Reads the storage from the given NBT tagvoidsendCacheToPlayer(net.minecraft.server.level.ServerPlayer player) Sends the Pokemon to the client for editingvoidvoidset(StoragePosition position, Pokemon pokemon) Sets the given pokemon at the given position in the storagevoidsetEntity(net.minecraft.world.entity.Entity entity) voidsetInTemporaryMode(boolean tempMode, Color color, Pokemon... pokemons) voidsetInTemporaryModeClient(boolean tempMode, Color color) voidsetOriginal(int slot, Pokemon pokemon) A bypass method for setting the original party when the player's party is in temporary modevoidsetOriginal(StoragePosition position, Pokemon pokemon) A bypass method for setting the original party when the player's party is in temporary modevoidsetTempPartyColor(Color tempPartyColor) voidswap(int slot1, int slot2) voidswap(StoragePosition position1, StoragePosition position2) Swaps the pokemon at the given positions in the storagenet.minecraft.nbt.CompoundTagwriteToNBT(net.minecraft.nbt.CompoundTag nbt, net.minecraft.core.HolderLookup.Provider registryAccess) Writes the storage to the given NBT tagMethods inherited from class com.pixelmonmod.pixelmon.api.storage.PokemonStorage
add, addAndGetPosition, canTransfer, clone, countAll, countAll, countAll, countEggs, countEmpty, countPokemon, find, findAll, findAll, findAllPositions, findAllPositions, findOne, findOne, getAllNonNull, getCurryData, getOwner, getShouldSave, getStorageType, getUniqueId, hasSpace, initialize, isTracking, notifyListeners, open, retrieveAll, setHasChanged, setNeedsSaving, shouldSendUpdates, shouldSendUpdates, toString, track, trackingPlayers, transfer, untrack, updateSingleCurryData, validateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
PARTY_BOX_INDEX
public static final int PARTY_BOX_INDEX- See Also:
-
MAX_PARTY
public static final int MAX_PARTY- See Also:
-
party
-
tempParty
-
tempPartyColor
-
entity
protected net.minecraft.world.entity.Entity entity -
cachePosition
-
-
Constructor Details
-
PartyStorage
-
PartyStorage
-
-
Method Details
-
getEntity
public net.minecraft.world.entity.Entity getEntity() -
setEntity
public void setEntity(net.minecraft.world.entity.Entity entity) -
copy
-
encode
public void encode(net.minecraft.network.RegistryFriendlyByteBuf buffer) Description copied from class:PokemonStorageWrites the storage to the given buffer- Specified by:
encodein classPokemonStorage- Parameters:
buffer- the buffer to write to
-
decode
public void decode(net.minecraft.network.RegistryFriendlyByteBuf buf) Description copied from class:PokemonStorageReads the storage from the given buffer- Specified by:
decodein classPokemonStorage- 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
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
Enters the party into the temporary mode with 0 Pokes You can add to their temp mode party usingPokemonStorage.add(Pokemon)- Parameters:
color- The colour to display on the sidebar
-
setInTemporaryModeClient
-
setInTemporaryMode
-
setTempPartyColor
-
getTempPartyColor
-
getAll
Description copied from class:PokemonStorageGets an array of all Pokémon within this storage. This may not be the implementation's backing array (e.g. it could be a copy), so don't expect to be able to edit this. The size of the array should always match the maximum capacity and will contain null elements for slots that are not full.- Specified by:
getAllin classPokemonStorage- Returns:
- An array of all Pokémon 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.
-
getRawAll
Description copied from class:PokemonStorageGets a raw array of all pokemon within this storage. This is the implementation's array and should not be modified.
This is useful for when you need to iterate over the array and don't need to modify it.- Specified by:
getRawAllin classPokemonStorage- Returns:
- An array of all pokemon within this storage. This is the implementation's array and should not be modified.
-
getAllPositions
Description copied from class:PokemonStorageSame asPokemonStorage.getAll(), but forStoragePositions. Note that this will return every position, regardless of whether or not it contains a Pokemon, for flexibility.- Specified by:
getAllPositionsin classPokemonStorage
-
maxSize
public int maxSize()- Specified by:
maxSizein classPokemonStorage- Returns:
- The maximum capacity of the Storage (or the individual containers, in cases like PCStorage)
-
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, net.minecraft.core.HolderLookup.Provider registryAccess) Description copied from class:PokemonStorageWrites the storage to the given NBT tag- Specified by:
writeToNBTin classPokemonStorage- 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, net.minecraft.core.HolderLookup.Provider registryAccess) Description copied from class:PokemonStorageReads the storage from the given NBT tag- Specified by:
readFromNBTin classPokemonStorage- Parameters:
nbt- the NBT tag to read from- Returns:
- a future that completes when the storage has been read from the NBT tag
-
getFirstEmptyPosition
Description copied from class:PokemonStorageGets the first position where there is no pokemon in the storage- Specified by:
getFirstEmptyPositionin classPokemonStorage- Returns:
- the first empty position in the storage
-
setOriginal
A bypass method for setting the original party when the player's party is in temporary mode- Parameters:
slot- The slot to setpokemon- The Pokémon to set it to
-
setOriginal
A bypass method for setting the original party when the player's party is in temporary mode- Parameters:
position- The position to setpokemon- The Pokémon to set it to
-
set
Description copied from class:PokemonStorageSets the given pokemon at the given position in the storage- Specified by:
setin classPokemonStorage- Parameters:
position- the position to set the pokemonpokemon- the pokemon to set
-
set
-
get
Description copied from class:PokemonStorageGets the pokemon at the given position in the storage
Will return null if there is no pokemon at the given position- Specified by:
getin classPokemonStorage- Parameters:
position- the position to get the pokemon from- Returns:
- the pokemon at the given position
-
get
-
get
-
getSlot
-
getSlot
-
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
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
- Returns:
- The first Pokémon in the party that matches the given condition.
-
findFirst
- Parameters:
condition- The condition to match.- Returns:
- The first Pokémon in the party that matches the given condition.
-
heal
public void heal() -
swap
Description copied from class:PokemonStorageSwaps the pokemon at the given positions in the storage- Specified by:
swapin classPokemonStorage- Parameters:
position1- the first position to swapposition2- the second position to swap
-
swap
public void swap(int slot1, int slot2) -
getPosition
Description copied from class:PokemonStorageGets the position of the given pokemon in the storage
Will return null if the pokemon is not in the storage- Specified by:
getPositionin classPokemonStorage- 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
-
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
-
isOldGen
public Quadstate isOldGen(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension) -
iterator
-
clear
public void clear()Description copied from class:PokemonStorageClears all the pokemon from the storage- Specified by:
clearin classPokemonStorage
-
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
-