Class PlayerPartyStorage

All Implemented Interfaces:
BankAccount, RarityTweak, Iterable<Pokemon>

public class PlayerPartyStorage extends PartyStorage implements BankAccount, RarityTweak
  • Field Details

    • playerName

      protected String playerName
      The name of the player whose storage this is.
    • trainerCardColor

      public EnumTrainerCardColor trainerCardColor
      The color of the players Trainer Card.
    • teleportPos

      public TeleportPosition teleportPos
      The player's current teleport position with the Teleport/Fly external moves.
    • pokeDollars

      protected BigDecimal pokeDollars
      The amount of money the player has.
    • playerPokedex

      public PlayerPokedex playerPokedex
      The player's Pokédex.
    • stats

      public PlayerStats stats
      The player's battle stats.
    • guiOpened

      public boolean guiOpened
      Whether the player is looking at a GUI.
    • battleScreenDisabled

      public BattleScreenMode battleScreenDisabled
      Whether the player is viewing the battle through their player's eyes.
    • freeToMoveDuringBattle

      public boolean freeToMoveDuringBattle
      Whether the player can move around in the world after they have entered a battle.
    • battleEnabled

      public boolean battleEnabled
      Whether the owner of the storage can battle.
    • starterPicked

      public boolean starterPicked
      Whether the player has picked a starter yet
    • oldGen

      public boolean oldGen
      Whether the player is in Mega/Z mode or not.
    • playerData

      public PlayerData playerData
    • lastBattle

      protected BattleLog lastBattle
    • openStorage

      protected PokemonStorage openStorage
    • cooldowns

      protected Map<net.minecraft.resources.ResourceLocation,Long> cooldowns
    • transientData

      public transient TransientData transientData
  • Constructor Details

    • PlayerPartyStorage

      public PlayerPartyStorage(UUID uuid, boolean shouldSendUpdates)
    • PlayerPartyStorage

      public PlayerPartyStorage(UUID uuid)
  • Method Details

    • getIdentifier

      public UUID getIdentifier()
      Description copied from interface: BankAccount
      Gets the unique identifier of the given entity
      Specified by:
      getIdentifier in interface BankAccount
      Returns:
      The identifier
    • getEntity

      public net.minecraft.world.entity.Entity getEntity()
      Overrides:
      getEntity in class PartyStorage
    • addAndGetPosition

      @Nullable public StoragePosition addAndGetPosition(Pokemon pokemon)
      Description copied from class: PokemonStorage
      Adds a Pokemon to the storage and returns the StoragePosition that it was added to. Similarly to PokemonStorage.add(Pokemon), if the storage is full, then in the case that it is a PlayerPartyStorage then it will attempt to add to the PC and pass back the return value from there.
      Overrides:
      addAndGetPosition in class PokemonStorage
      Parameters:
      pokemon - The Pokemon to add to the storage.
      Returns:
      The position that the Pokemon was added to. Null if the Pokemon could not be added.
    • addSilently

      public TriBoolean addSilently(Pokemon pokemon)
      Advanced method for adding Pokémon to player storage. Returns a tristate enum representing what happened. Does not send any messages to the player, you're expected to handle this yourself here.
      Parameters:
      pokemon - Pokémon object to add to storage.
      Returns:
      TRUE = added to party, FALSE = added to PC, NULL = failed to add
    • tryUpdatePlayerName

      public void tryUpdatePlayerName()
    • getPlayer

      @Nullable public net.minecraft.server.level.ServerPlayer getPlayer()
    • getPlayerName

      @Nullable public String getPlayerName()
    • getPlayerUUID

      public UUID getPlayerUUID()
    • set

      public void set(StoragePosition position, Pokemon pokemon)
      Description copied from class: PokemonStorage
      Sets the given pokemon at the given position in the storage
      Overrides:
      set in class PartyStorage
      Parameters:
      position - the position to set the pokemon
      pokemon - the pokemon to set
    • 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
      Overrides:
      writeToNBT in class PartyStorage
      Parameters:
      nbt - the NBT tag to write to
      Returns:
      the NBT tag with the storage written to it
    • readFromNBT

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

      public boolean getShouldSave()
      Overrides:
      getShouldSave in class PokemonStorage
    • getCurryData

      public int[] getCurryData()
      Overrides:
      getCurryData in class PokemonStorage
    • updateSingleCurryData

      public void updateSingleCurryData(EnumCurryKey curryKey, EnumBerryFlavor cookingFlavor, EnumCurryRating rating)
      Overrides:
      updateSingleCurryData in class PokemonStorage
    • fillOneCurryDexFlavor

      public void fillOneCurryDexFlavor(int curryDexPage, int curryDexFlavor, int curryDexRating)
      Fills in one flavor entry for one curry dish with the given rating.
      Parameters:
      curryDexPage - The page number the desired curry dish is on.
      curryDexFlavor - The position of the desired flavor on a page.
      curryDexRating - The rating to be given to the desired flavor.
    • fillOneCurryDexPage

      public void fillOneCurryDexPage(int curryDexPage, int curryDexRating)
      Fills in one page of the curry dex with the given rating.
      Parameters:
      curryDexPage - The page number of the curry dish to be filled in.
      curryDexRating - The rating to be given to the entire page.
    • fillEntireCurryDex

      public void fillEntireCurryDex(int curryDexRating)
      Fills in the entire curry dex with the given rating.
      Parameters:
      curryDexRating - The rating to be given to the entire dex.
    • isMegaItemObtained

      public boolean isMegaItemObtained(Species pokemon, Stats form)
    • obtainedItem

      public void obtainedItem(Species pokemon, Stats form, net.minecraft.server.level.ServerPlayer player)
    • setMegaItem

      public void setMegaItem(EnumMegaItem megaItem, boolean giveChoice)
    • unlockMega

      public void unlockMega(boolean giveChoice)
    • lockMega

      public void lockMega()
    • unlockDynamax

      public void unlockDynamax(boolean giveChoice)
    • lockDynamax

      public void lockDynamax()
    • setMegaItemsUnlocked

      public void setMegaItemsUnlocked(EnumMegaItemsUnlocked megaItemsUnlocked)
    • setShinyCharm

      public void setShinyCharm(EnumFeatureState shinyCharm)
    • setOvalCharm

      public void setOvalCharm(EnumFeatureState ovalCharm)
    • setExpCharm

      public void setExpCharm(EnumFeatureState expCharm)
    • setCatchingCharm

      public void setCatchingCharm(EnumFeatureState catchingCharm)
    • setMarkCharm

      public void setMarkCharm(EnumFeatureState markCharm)
    • setHweenRobe

      @Deprecated public void setHweenRobe(EnumFeatureState hweenRobe)
      Deprecated.
    • canEquipMegaItem

      public boolean canEquipMegaItem()
    • getMegaItem

      public EnumMegaItem getMegaItem()
    • getMegaItemsUnlocked

      public EnumMegaItemsUnlocked getMegaItemsUnlocked()
    • getShinyCharm

      public EnumFeatureState getShinyCharm()
    • getOvalCharm

      public EnumFeatureState getOvalCharm()
    • getExpCharm

      public EnumFeatureState getExpCharm()
    • getCatchingCharm

      public EnumFeatureState getCatchingCharm()
    • getMarkCharm

      public EnumFeatureState getMarkCharm()
    • getHweenRobe

      @Deprecated public EnumFeatureState getHweenRobe()
      Deprecated.
    • getServerCosmetics

      public Set<ServerCosmetics> getServerCosmetics()
    • setServerCosmetics

      public void setServerCosmetics(Set<ServerCosmetics> cosmetics)
    • grantServerCosmetics

      public void grantServerCosmetics(ServerCosmetics... cosmetics)
    • revokeServerCosmetics

      public void revokeServerCosmetics(ServerCosmetics... cosmetics)
    • getLureStack

      public net.minecraft.world.item.ItemStack getLureStack()
    • getLure

      @Nullable public LureItem getLure()
    • setLureStack

      public void setLureStack(net.minecraft.world.item.ItemStack stack)
    • setLure

      public void setLure(LureItem lure)
    • dropLureInLureSlot

      public void dropLureInLureSlot(net.minecraft.server.level.ServerPlayer player)
      If the player has a lure in their lureSlot make it drop from their inventory.
    • hasBalance

      public boolean hasBalance(BigDecimal amount)
      Description copied from interface: BankAccount
      Checks if the account has more than the given amount
      Specified by:
      hasBalance in interface BankAccount
      Parameters:
      amount - Amount to check
      Returns:
      True if the account has more
    • getBalance

      public BigDecimal getBalance()
      Description copied from interface: BankAccount
      Gets balance of the account
      Specified by:
      getBalance in interface BankAccount
      Returns:
      The amount of money
    • setBalance

      public void setBalance(BigDecimal amount)
      Description copied from interface: BankAccount
      Sets the balance of the account
      Specified by:
      setBalance in interface BankAccount
      Parameters:
      amount - The new balance
    • add

      public boolean add(BigDecimal amount)
      Description copied from interface: BankAccount
      Adds the amount to the current balance Returns false if the transaction fails for any given reason (check console logs) DO NOT PASS NEGATIVE VALUES
      Specified by:
      add in interface BankAccount
      Parameters:
      amount - The amount being added
      Returns:
      true if successful
    • take

      public boolean take(BigDecimal amount)
      Description copied from interface: BankAccount
      Take the amount to the current balance Returns false if the transaction fails for any given reason (check console logs) DO NOT PASS NEGATIVE VALUES
      Specified by:
      take in interface BankAccount
      Parameters:
      amount - The amount being taken
      Returns:
      true if successful
    • updatePartyCache

      public void updatePartyCache()
      Updates the cache of pokemonLevel data in the storage.
    • getTicksTillEncounter

      public int getTicksTillEncounter()
      Gets the number of ticks until Pixelmon grass spawns a Pokémon against the player.
      Returns:
      The number of ticks until Pixelmon grass spawns a Pokémon against the player.
    • updateTicksTillEncounter

      public void updateTicksTillEncounter()
      Ticks the number of ticks until Pixelmon grass spawns a Pokémon against the player. Resets the counter if it reaches 1.
    • checkPokerus

      public void checkPokerus()
      NOTE: I could probably make this more optimized, thanks to the new storage
    • getMultiplier

      public float getMultiplier(AbstractSpawner spawner, SpawnInfo spawnInfo, float sum, float rarity)
      Specified by:
      getMultiplier in interface RarityTweak
    • closeBattleSafely

      public void closeBattleSafely()
      Safely shuts down battles on the client.
    • addTaskForBattleEnd

      public BattleEndTaskResult addTaskForBattleEnd(BattleEndTaskType type, Consumer<Optional<BattleController>> consumer)
      Add a task to be executed once the client has left the battle UI. Careful, the battle controller may be null!
    • battle

      public BattleController battle(net.minecraft.server.level.ServerPlayer player)
    • battle

      public BattleController battle(net.minecraft.server.level.ServerPlayer player, BattleType type)
    • battle

      public BattleController battle(net.minecraft.server.level.ServerPlayer target, BattleRules rules)
    • getLastExecutionTime

      public long getLastExecutionTime(@NotNull @NotNull net.minecraft.resources.ResourceLocation key)
      Gets the last recorded time that the associated key has stored
      This will return 0 if the key has not been recorded before
      Parameters:
      key - The key to check the last execution time for
      Returns:
      The last recorded time that the associated key has stored
    • setLastExecutionTime

      public void setLastExecutionTime(@NotNull @NotNull net.minecraft.resources.ResourceLocation key)
      Sets the last recorded time that the associated key has stored to the current time
      Parameters:
      key - The key to set the last execution time for
    • setLastExecutionTime

      public void setLastExecutionTime(@NotNull @NotNull net.minecraft.resources.ResourceLocation key, long time)
      Sets the last recorded time that the associated key has stored
      Parameters:
      key - The key to set the last execution time for
      time - The time to set the last execution time to
    • onCooldown

      public boolean onCooldown(@NotNull @NotNull net.minecraft.resources.ResourceLocation key, long cooldown, @NotNull @NotNull TimeUnit timeUnit)
      Checks if the amount of time in has passed since the last recorded time that the associated key has stored
      Parameters:
      key - The key to check the cooldown for
      cooldown - The amount of time to check for
      timeUnit - The time unit to check the cooldown in
      Returns:
      If the amount of time in has passed since the last recorded time that the associated key has stored
    • onCooldown

      public boolean onCooldown(@NotNull @NotNull net.minecraft.resources.ResourceLocation key, long cooldown)
      Checks if the amount of time (in milliseconds) has passed since the last recorded time that the associated key has stored
      Parameters:
      key - The key to check the cooldown for
      cooldown - The amount of time to check for
      Returns:
      If the amount of time has passed since the last recorded time that the associated key has stored
    • removeCooldown

      public void removeCooldown(@NotNull @NotNull net.minecraft.resources.ResourceLocation key)
      Removes the cooldown of the associated key
      Parameters:
      key - The key to remove the cooldown of
    • clearCooldowns

      public void clearCooldowns()
      Clears all cooldowns
    • queryResourceLocationExistence

      public void queryResourceLocationExistence(net.minecraft.resources.ResourceLocation resource, Consumer<Boolean> result)
      Query existence of a ResourceLocation on the client.
      Parameters:
      resource - ResourceLocation to be queried.
      result - Consumer to be executed with the result of the query.
    • receiveResourceLocationQueryResult

      public void receiveResourceLocationQueryResult(UUID query, boolean result)
    • registerKeyListener

      public void registerKeyListener(PlayerKeyListener keyListener)
      Registers a key listener that will receive key input events from the client.
      This will only work when the player is in an inventory that has a PixelmonItems.ui_element in it.
      Parameters:
      keyListener - The key listener to register
    • receiveKeyInput

      @Internal public void receiveKeyInput(int keyCode, int scanCode, int modifiers)
      Receives key input events from the client and forwards them to the registered key listeners.
      This method is called by the client when a key input event is received.
      This should only be called by the packets
      Parameters:
      keyCode - The key code of the key that was pressed
      scanCode - The scan code of the key that was pressed
      modifiers - The modifiers of the key that was pressed
    • deRegisterKeyListeners

      public void deRegisterKeyListeners()
      De-registers all key listeners from the player.
    • deRegisterKeyListener

      public void deRegisterKeyListener(PlayerKeyListener keyListener)
      De-registers a key listener from the player.
      Parameters:
      keyListener - The key listener to de-register
    • getSelectedSlot

      public int getSelectedSlot()
    • setSelectedSlot

      public void setSelectedSlot(int selectedSlot)
    • setSelectedSlot

      public void setSelectedSlot(int selectedSlot, boolean sendPacket)
    • getSelectedPokemon

      public Pokemon getSelectedPokemon()
    • sendClientUpdatePacket

      public void sendClientUpdatePacket()
    • sendClientUpdateSelectedPacket

      public void sendClientUpdateSelectedPacket()
    • getDayCare

      public PlayerDayCare getDayCare()
    • setDayCare

      public void setDayCare(PlayerDayCare dayCare)
    • getLastBattle

      public BattleLog getLastBattle()
    • setLastBattle

      public void setLastBattle(BattleLog lastBattle)
    • getOpenStorage

      public PokemonStorage getOpenStorage()
    • setOpenStorage

      public void setOpenStorage(PokemonStorage openStorage)