Class Pokemon

java.lang.Object
com.pixelmonmod.pixelmon.api.pokemon.PokemonBase
com.pixelmonmod.pixelmon.api.pokemon.Pokemon
All Implemented Interfaces:
ITranslatable

public class Pokemon extends PokemonBase
Default implementation of a Pokemon
  • Field Details

    • SYNC_GROWTH

      public static final DataSync<? extends AbstractBaseEntity,EnumGrowth> SYNC_GROWTH
    • SYNC_LEVEL

      public static final DataSync<? extends AbstractBaseEntity,Integer> SYNC_LEVEL
    • SYNC_EXP

      public static final DataSync<? extends AbstractBaseEntity,Integer> SYNC_EXP
    • SYNC_ENTITY_UUID

      public static final DataSync<? extends AbstractBaseEntity,Optional<UUID>> SYNC_ENTITY_UUID
    • SYNC_NICK_NAME

      public static final DataSync<? extends AbstractBaseEntity,net.minecraft.network.chat.Component> SYNC_NICK_NAME
    • SYNC_RIBBON

      public static final DataSync<? extends AbstractBaseEntity,Ribbon> SYNC_RIBBON
    • SYNC_HEALTH

      public static final DataSync<? extends AbstractBaseEntity,Float> SYNC_HEALTH
    • SYNC_FLAGS

      public static final DataSync<? extends AbstractBaseEntity,String[]> SYNC_FLAGS
    • STATS

      public static final EnumUpdateType[] STATS
    • ABILITY

      public static final EnumUpdateType[] ABILITY
    • FORM

      public static final EnumUpdateType[] FORM
    • EMPTY

      public static final EnumUpdateType[] EMPTY
    • EGG

      public static final net.minecraft.network.chat.MutableComponent EGG
    • uuid

      protected UUID uuid
    • moveset

      protected Moveset moveset
    • nature

      protected Nature nature
    • slot

      protected int slot
    • ha

      protected boolean ha
    • mintNature

      protected Nature mintNature
    • growth

      protected EnumGrowth growth
    • friendship

      protected int friendship
    • pokemonLevelContainer

      protected PokemonLevel pokemonLevelContainer
    • level

      protected int level
    • experience

      protected int experience
    • dynamaxLevel

      protected int dynamaxLevel
    • gigantamaxFactor

      protected boolean gigantamaxFactor
    • permanentStats

      protected PermanentStats permanentStats
    • bonusStats

      protected BonusStats bonusStats
    • eggSteps

      protected Integer eggSteps
    • heldItem

      protected net.minecraft.world.item.ItemStack heldItem
    • status

      protected StatusPersist status
    • extraStats

      protected ExtraStats extraStats
    • nickname

      protected net.minecraft.network.chat.MutableComponent nickname
    • originalTrainerName

      protected String originalTrainerName
    • originalTrainerUUID

      protected UUID originalTrainerUUID
    • pokerus

      protected Pokerus pokerus
    • health

      protected int health
    • doesLevel

      protected boolean doesLevel
    • moveSkillCooldownData

      protected volatile HashMap<String,net.minecraft.util.Tuple<Long,Long>> moveSkillCooldownData
    • flags

      protected List<String> flags
    • ribbons

      protected List<Ribbon> ribbons
    • displayedRibbon

      protected Ribbon displayedRibbon
    • persistentData

      protected net.minecraft.nbt.CompoundTag persistentData
    • lastBattleCrits

      public int lastBattleCrits
    • dimension

      protected transient net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension
    • entityID

      protected transient int entityID
    • storage

      protected transient PokemonStorage storage
    • position

      protected transient StoragePosition position
  • Constructor Details

    • Pokemon

      protected Pokemon()
      This constructor is STRONGLY discouraged, and exists only for JSON deserialization.
    • Pokemon

      protected Pokemon(UUID uuid)
    • Pokemon

      protected Pokemon(UUID uuid, Species species)
  • Method Details

    • getPixelmonEntity

      public Optional<PixelmonEntity> getPixelmonEntity()
    • getPixelmonWrapper

      public Optional<PixelmonWrapper> getPixelmonWrapper()
      Returns:
      The battle wrapper for the entity, if one exists
    • getPixelmonWrapperFromPlayer

      @Deprecated public Optional<PixelmonWrapper> getPixelmonWrapperFromPlayer()
      Deprecated.
      Use {@link this#getPixelmonWrapper()}
      Returns:
      The battle wrapper for the entity, if one exists via the owner
    • getOrSpawnPixelmon

      public PixelmonEntity getOrSpawnPixelmon(net.minecraft.world.level.Level world, double x, double y, double z, float rotationYaw, float rotationPitch)
      Gets the entity attached to this Pokémon, or spawns it if it does not exist in the given world.

      Caveats:

    • If the entity exists but in a different world to that given, it will be killed and a new entity will be spawned in the appropriate world.
    • If the given world is null, then it won't do the above and instead just return the Pokémon wherever it may be.
    • In addition to the previous behaviour, a null world argument and nonexistent entity will result in the new entity being created in the zero dimension world.
    • Parameters:
      world - The world the entity is needed in.
      Returns:
      An entity in the given world, or in the overworld if world is null.
    • getOrSpawnPixelmon

      public PixelmonEntity getOrSpawnPixelmon(net.minecraft.world.level.Level world, double x, double y, double z)
    • getOrSpawnPixelmon

      public PixelmonEntity getOrSpawnPixelmon(net.minecraft.world.entity.Entity parent)
    • getOrCreatePixelmon

      public PixelmonEntity getOrCreatePixelmon(net.minecraft.world.level.Level world, double x, double y, double z, float rotationYaw, float rotationPitch)
      Gets the entity attached to this Pokémon, or spawns it if it does not exist in the given world.

      Caveats:

    • If the entity exists but in a different world to that given, it will be killed and a new entity will be spawned in the appropriate world.
    • If the given world is null, then it won't do the above and instead just return the Pokémon wherever it may be.
    • In addition to the previous behaviour, a null world argument and nonexistent entity will result in the new entity being created in the zero dimension world.
    • Parameters:
      world - The world the entity is needed in.
      Returns:
      An entity in the given world, or in the overworld if world is null.
    • getOrCreatePixelmon

      public PixelmonEntity getOrCreatePixelmon(net.minecraft.world.level.Level world, double x, double y, double z)
    • getOrCreatePixelmon

      public PixelmonEntity getOrCreatePixelmon()
    • getOrCreatePixelmon

      public PixelmonEntity getOrCreatePixelmon(net.minecraft.world.entity.Entity parent)
    • updateDimensionAndEntityID

      public void updateDimensionAndEntityID(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension, int entityID)
    • getEntityID

      public int getEntityID()
    • getWorld

      public net.minecraft.world.level.Level getWorld()
    • ifEntityExists

      public boolean ifEntityExists(Consumer<PixelmonEntity> action)
      Executes code if the entity representing this Pokémon exists.
      Parameters:
      action - The action to carry out if the entity exists.
      Returns:
      true if the entity existed, otherwise false.
    • initialize

      public Pokemon initialize(InitializeCategory... initializeCategories)
    • makeEgg

      public Pokemon makeEgg()
      Description copied from class: PokemonBase
      Turns the pokemon into an egg
      Overrides:
      makeEgg in class PokemonBase
      Returns:
      Itself
    • makeEggAndKeepCurrentLevel

      public Pokemon makeEggAndKeepCurrentLevel()
    • evolve

      public void evolve(PokemonSpecification to)
    • getUUID

      public UUID getUUID()
    • setUUID

      public Pokemon setUUID(UUID uuid)
    • getOwnerTrainerUUID

      public UUID getOwnerTrainerUUID()
    • getOwnerTrainer

      public NPCTrainer getOwnerTrainer()
    • getOwnerPlayerUUID

      public UUID getOwnerPlayerUUID()
    • getOwnerPlayer

      @Nullable public net.minecraft.server.level.ServerPlayer getOwnerPlayer()
    • getDisplayName

      public net.minecraft.network.chat.MutableComponent getDisplayName()
    • getDisplayNameWithRibbon

      public net.minecraft.network.chat.Component getDisplayNameWithRibbon()
    • getNickname

      public net.minecraft.network.chat.Component getNickname()
      Gets the formatted nickname of the Pokemon
      Returns:
      The formatted nickname
    • hasNickname

      public boolean hasNickname()
      If the Pokemon has a nickname
      Returns:
      If the Pokemon has a nickname
    • removeNickname

      public void removeNickname()
      Removes the Pokemon's current nickname
    • setNickname

      public void setNickname(String nickname)
      Sets the Pokemon's nickname to the new Component
      Parameters:
      nickname - The new nickname
    • setNickname

      public void setNickname(net.minecraft.network.chat.Component nickname)
      Sets the Pokemon's nickname to the new Component
      Parameters:
      nickname - The new nickname
    • getOwnerName

      public net.minecraft.network.chat.MutableComponent getOwnerName()
    • setSpecies

      public void setSpecies(RegistryValue<Species> species, boolean doSpeciesInitialization)
    • setSpecies

      public void setSpecies(Species species, boolean doSpeciesInitialization)
    • setForm

      public void setForm(Stats form)
      Overrides:
      setForm in class PokemonBase
    • setForm

      public boolean setForm(String form)
      Overrides:
      setForm in class PokemonBase
    • setGender

      public void setGender(Gender gender)
    • setToOppositeGender

      public void setToOppositeGender()
      Quick way to swamp male Pokémon to female and vice versa. Does nothing with to Pokémon with no gender.
    • setEggCycles

      public void setEggCycles(Integer eggCycles, boolean event)
      Description copied from class: PokemonBase
      Sets the egg cycles of the pokemon
      Overrides:
      setEggCycles in class PokemonBase
      Parameters:
      eggCycles - The new egg cycles number
    • getEggSteps

      public int getEggSteps()
    • setEggSteps

      public void setEggSteps(Integer eggSteps)
    • addEggSteps

      public void addEggSteps(int steps, int cycleMultiplier)
    • hatchEgg

      public void hatchEgg()
    • hatchEgg

      public void hatchEgg(boolean force)
    • getEggDescription

      public String getEggDescription()
      Gets the PokéChecker description translation key of an Egg.
      Returns:
      The PokéChecker description translation key of the Egg.
    • getHeldItem

      @Nonnull public net.minecraft.world.item.ItemStack getHeldItem()
    • getHeldItemAsItemHeld

      @Nonnull public HeldItem getHeldItemAsItemHeld()
      Gets the ItemHeld type of the item the Pokémon is holding.
      Returns:
      The type of the item the Pokémon is holding. Will be NoItem if this is not holding anything.
    • setHeldItem

      public boolean setHeldItem(net.minecraft.world.item.ItemStack stack)
      Sets the Pokémon's held item after firing HeldItemChangedEvent. For out-of-battle use only; use the PixelmonWrapper version for in-battle.
      Parameters:
      stack - The held item to set. Null or ItemStack.EMPTY to remove.
      Returns:
      true if the held item was set, otherwise false.
    • getGrowth

      public EnumGrowth getGrowth()
    • setGrowth

      public void setGrowth(EnumGrowth growth)
    • getNature

      public Nature getNature()
      Gives the active nature of this pokemon, Use either getBaseNature() or getMintNature() if you need a specific value.
      Returns:
      The active nature, if the pokemon has a mint it will be the mint nature.
    • getBaseNature

      public Nature getBaseNature()
    • getMintNature

      @Nullable public Nature getMintNature()
    • setNature

      public void setNature(Nature nature)
    • setMintNature

      public void setMintNature(Nature nature)
    • getPokerus

      @Nullable public Pokerus getPokerus()
    • setPokerus

      public void setPokerus(Pokerus pokerus)
    • getAbility

      public Ability getAbility()
    • getAbilityName

      public String getAbilityName()
    • setAbility

      public void setAbility(Ability ability)
    • setAbility

      public void setAbility(Optional<Ability> ability)
    • setAbility

      public void setAbility(RegistryValue<Ability> ability)
    • getIVs

      public IVStore getIVs()
    • getEVs

      public EVStore getEVs()
    • getBonusStats

      public BonusStats getBonusStats()
    • setBonusStats

      public void setBonusStats(BonusStats bonusStats)
    • getHighestOffensiveStat

      public int getHighestOffensiveStat()
    • getStat

      public int getStat(BattleStatsType stat)
    • getStats

      public PermanentStats getStats()
    • getExtraStats

      @Nullable public ExtraStats getExtraStats()
    • getExtraStats

      public <T extends ExtraStats> Optional<T> getExtraStats(Class<T> type)
    • setExperience

      public void setExperience(int experience)
    • getExperience

      public int getExperience()
    • getExperienceToLevelUp

      public int getExperienceToLevelUp()
    • getExperienceFraction

      public float getExperienceFraction()
    • getStatus

      @Nonnull public StatusPersist getStatus()
    • setStatus

      public void setStatus(StatusPersist status)
    • getPokemonLevel

      public int getPokemonLevel()
    • getPokemonLevelContainer

      public PokemonLevel getPokemonLevelContainer()
    • setLevelNum

      public void setLevelNum(int level)
    • setLevel

      public void setLevel(int level)
    • getDynamaxLevel

      public int getDynamaxLevel()
    • setDynamaxLevel

      public void setDynamaxLevel(int dynamaxLevel)
    • changeDynamaxLevel

      public void changeDynamaxLevel(int dynamaxLevel)
    • hasGigantamaxFactor

      public boolean hasGigantamaxFactor()
    • canGigantamax

      public boolean canGigantamax()
    • setGigantamaxFactor

      public void setGigantamaxFactor(boolean gigantamaxFactor)
    • canBattle

      public boolean canBattle()
    • isLegendary

      public boolean isLegendary()
    • isLegendary

      public boolean isLegendary(boolean excludeMythicals)
    • isMythical

      public boolean isMythical()
    • isUltraBeast

      public boolean isUltraBeast()
    • isMega

      public boolean isMega()
    • setPalette

      public boolean setPalette(PaletteProperties paletteProperties)
      Description copied from class: PokemonBase
      Sets the palette properties for the Pokemon
      Overrides:
      setPalette in class PokemonBase
      Parameters:
      paletteProperties - The new palette properties
      Returns:
      Successful (always true)
    • setPalette

      public boolean setPalette(String palette)
    • setPalette

      public boolean setPalette(String palette, boolean sync)
    • setShiny

      public boolean setShiny()
    • setShiny

      public boolean setShiny(boolean shiny)
    • getMoveset

      public Moveset getMoveset()
    • setHA

      public void setHA(boolean isHiddenAbility)
    • setAbilitySlot

      public void setAbilitySlot(int abilitySlot)
    • getFriendship

      public int getFriendship()
    • setFriendship

      public void setFriendship(int friendship)
    • increaseFriendship

      public void increaseFriendship(int amount)
    • decreaseFriendship

      public void decreaseFriendship(int amount)
    • isFriendshipHighEnoughToEvolve

      public boolean isFriendshipHighEnoughToEvolve()
    • getOriginalTrainer

      @Nullable public String getOriginalTrainer()
    • getOriginalTrainerUUID

      @Nullable public UUID getOriginalTrainerUUID()
    • setOriginalTrainer

      public void setOriginalTrainer(UUID originalTrainerUUID, String originalTrainerName)
    • setOriginalTrainer

      public void setOriginalTrainer(net.minecraft.world.entity.player.Player player)
    • isOriginalTrainer

      public boolean isOriginalTrainer(net.minecraft.world.entity.player.Player player)
    • setBall

      public void setBall(PokeBall caughtBall)
      Description copied from class: PokemonBase
      Sets the ball the pokemon is in
      Overrides:
      setBall in class PokemonBase
      Parameters:
      caughtBall - The new pokeball
    • getHealth

      public int getHealth()
    • getHealthPercentage

      public float getHealthPercentage()
    • hasFullHealth

      public boolean hasFullHealth()
    • heal

      public void heal()
    • setHealthCache

      public void setHealthCache(int health)
    • setHealth

      public void setHealth(int health)
    • setHealthPercentage

      public void setHealthPercentage(float healthPercentage)
    • getMaxHealth

      public int getMaxHealth()
    • doesLevel

      public boolean doesLevel()
    • setDoesLevel

      public void setDoesLevel(boolean doesLevel)
    • getRelearnableMoves

      public Set<ImmutableAttack> getRelearnableMoves()
    • getEvolutions

      public <T extends Evolution> ArrayList<T> getEvolutions(Class<T> type)
    • tryEvolution

      public void tryEvolution()
      Attempts to evolve the Pokémon if possible.
    • getPersistentData

      public net.minecraft.nbt.CompoundTag getPersistentData()
    • retrieve

      public void retrieve(String pokemonRetrievedEventReason)
    • setStorage

      public void setStorage(PokemonStorage storage, StoragePosition position)
    • getStorage

      @Nullable public PokemonStorage getStorage()
    • getPosition

      @Nullable public StoragePosition getPosition()
    • getStorageAndPosition

      @Nullable public net.minecraft.util.Tuple<PokemonStorage,StoragePosition> getStorageAndPosition()
    • isMoveSkillCoolingDown

      public boolean isMoveSkillCoolingDown(MoveSkill moveSkill)
    • getMoveSkillCooldownTicks

      public int getMoveSkillCooldownTicks(MoveSkill moveSkill)
    • getMoveSkillCooldownRatio

      public double getMoveSkillCooldownRatio(MoveSkill moveSkill)
    • setMoveSkillCooldown

      public void setMoveSkillCooldown(MoveSkill moveSkill, int cooldownTicks)
    • addFlag

      public void addFlag(String key)
    • removeFlag

      public void removeFlag(String key)
    • hasFlag

      public boolean hasFlag(String key)
    • markDirty

      public void markDirty(EnumUpdateType... dataTypes)
    • getRibbons

      public List<Ribbon> getRibbons()
      Gets an unmodifiable list of the ribbons that this pokemon has managed to collect
      Returns:
      An unmodifiable list of this Pokemon's ribbons.
      See Also:
    • getDisplayedRibbon

      @Nullable public Ribbon getDisplayedRibbon()
      Gets the Pokemon's selected (displayed) ribbon If this returns null it means there is no displayed ribbon
      Returns:
      The currently displayed ribbon
    • setDisplayedRibbon

      public void setDisplayedRibbon(Ribbon ribbon)
      Sets the ribbon that will be displayed on this Pokemon.
      Parameters:
      ribbon - The ribbon to set.
    • addRibbon

      public boolean addRibbon(RibbonType ribbonType)
    • addRibbon

      public boolean addRibbon(RibbonType ribbonType, boolean displayRibbon)
    • addRibbon

      public boolean addRibbon(Ribbon ribbon)
      Adds a ribbon to this Pokémon and sets it as the displayed ribbon.
      Parameters:
      ribbon - The ribbon type to add.
      Returns:
      true if this ribbon was added, false if it already had the ribbon or could not be added.
    • addRibbon

      public boolean addRibbon(Ribbon ribbon, boolean shouldDisplayRibbon)
      Adds a ribbon to this Pokémon.
      Parameters:
      ribbon - The ribbon type to add.
      shouldDisplayRibbon - If the ribbon added should be immediately displayed. (defaults = true)
      Returns:
      true if this ribbon was added, false if it already had the ribbon or could not be added.
    • removeRibbon

      public boolean removeRibbon(Ribbon ribbon)
      Removes a ribbon from this Pokémon.
      Parameters:
      ribbon - The ribbon type to remove.
      Returns:
      true if the ribbon was removed, false if this Pokémon did not have the ribbon.
    • getSprite

      public net.minecraft.resources.ResourceLocation getSprite()
      Description copied from class: PokemonBase
      Gets the relevant sprite for the PokemonBase
      Overrides:
      getSprite in class PokemonBase
      Returns:
      The ResourceLocation of the sprite
    • getPalette

      public PaletteProperties getPalette()
      Description copied from class: PokemonBase
      Gets the palette of the pokemon
      Overrides:
      getPalette in class PokemonBase
      Returns:
      The palette
    • isFainted

      public boolean isFainted()
      Checks if the Pokemon has fainted
      Returns:
      If their health is less than or equal to 0
    • isUnbreedable

      public boolean isUnbreedable()
      Checks if the Pokemon is unbreedable Quick redirect for hasFlag(String)
      Returns:
      True if the pokemon cannot be bread
    • isUntradeable

      public boolean isUntradeable()
      Checks if the Pokemon is untradeable Quick redirect for hasFlag(String)
      Returns:
      True if the pokemon cannot be traded
    • isUncatchable

      public boolean isUncatchable()
      Checks if the Pokemon is uncatchable Quick redirect for hasFlag(String)
      Returns:
      True if the pokemon cannot be caught
    • isUnbattleable

      public boolean isUnbattleable()
      Checks if the Pokemon is unbattleable Quick redirect for hasFlag(String)
      Returns:
      True if the pokemon cannot be battled
    • hasNoDrops

      public boolean hasNoDrops()
      Checks if the Pokemon has no drops
      Returns:
      True if the Pokemon doesn't drop anything
    • writeToByteBuffer

      public void writeToByteBuffer(net.minecraft.network.FriendlyByteBuf buf, EnumUpdateType... data)
    • readFromByteBuffer

      public Pokemon readFromByteBuffer(net.minecraft.network.FriendlyByteBuf buf, EnumUpdateType... data)
    • readFromNBT

      public void readFromNBT(net.minecraft.nbt.CompoundTag nbt)
    • writeToNBT

      public net.minecraft.nbt.CompoundTag writeToNBT(net.minecraft.nbt.CompoundTag nbt)
      Description copied from class: PokemonBase
      Writes the values of this class into an CompoundTag
      Overrides:
      writeToNBT in class PokemonBase
      Parameters:
      nbt - The nbt being written to
      Returns:
      The nbt with updated content
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hasHiddenAbility

      public boolean hasHiddenAbility()
    • getAbilitySlot

      public int getAbilitySlot()
    • recordAbilitySlot

      public void recordAbilitySlot(Ability ability)
      Finds the ability slot used for the Pokémon to persist through ability losses
      Parameters:
      ability - The ability to find
    • overrideAbilitySlot

      public void overrideAbilitySlot()
      Ignores the previously found ability slot for the Pokémon and finds the new one
    • resetAbility

      public void resetAbility()
      Sets a random ability and records the ability slot for future evolutions.
    • setMoveset

      public void setMoveset(Moveset moveset)
    • rerollMoveset

      public void rerollMoveset()
    • getFlags

      public List<String> getFlags()
    • startEvolution

      public void startEvolution(Evolution evolution, String cause)
      Starts the Pokémon's evolution.
      Parameters:
      evolution -
      cause -
    • isNearlyIdenticalTo

      public boolean isNearlyIdenticalTo(Pokemon secondPokemon)
      Checks if this Pokémon is nearly identical to the Pokémon passed in.

      This doesn't check if the two Pokémon have identical UUIDs, identical originalTrainers, or identical Persistent Stats.

      Parameters:
      secondPokemon - The Pokémon to be compared to.
      Returns:
      True if nearly identical.