Interface CaptureMethod
public interface CaptureMethod
Interface representing a capture method.
Methods here are broken down to such a degree on purpose so that a new capture method doesn't need to implement
duplicate logic where it isn't necessary, and can instead just use the default implementations provided here, or
the implementation provided by another capture method, such as those in CaptureMethods
.
New capture methods can be registered for use in config and PokeBall
instances via CaptureMethodRegistry
.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final List<StatusType>
List of major status effects for purposes of catch calculation.static final List<StatusType>
List of minor status effects for purposes of catch calculation. -
Method Summary
Modifier and TypeMethodDescriptiondefault double
calculateBallBonus
(PokeBall pokeBall, PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Calculates the ball bonus for thePokeBall
being used.default CaptureValues
calculateCapture
(CaptureHealth health, PokeBall pokeBall, PokeBallEntity pokeBallEntity, RaidData raid, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) The main method of capture calculations.default int
calculateCatchRate
(PokeBall pokeBall, PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Calculates the catch rate of thePokemon
being caught.default void
captureCalculation
(CaptureValues values, CaptureHealth health, PokeBall pokeBall, PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Performs the main capture calculation and sets theCaptureValues
accordingly.default CaptureValues
constructValues
(PokeBall pokeBall, PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Creates a newCaptureValues
to be used by the rest of the capture calculation.default void
criticalCaptureCheck
(CaptureValues values, CaptureHealth health, PokeBall pokeBall, PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Performs a critical capture check and sets theCaptureValues
accordingly.default boolean
preCaptureChecks
(CaptureValues values, CaptureHealth health, PokeBall pokeBall, PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Performs pre-capture checks for a regular capture attempt (not a raid).default boolean
preRaidCaptureChecks
(CaptureValues values, CaptureHealth health, PokeBall pokeBall, PokeBallEntity pokeBallEntity, RaidData raid, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Performs pre-capture checks for a raid capture attempt.default void
shakeCountCheck
(CaptureValues values, CaptureHealth health, PokeBall pokeBall, PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Performs shake checks and sets theCaptureValues
accordingly.default double
statusEffectCheck
(CaptureValues values, CaptureHealth health, PokeBall pokeBall, PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Returns a value based on the current status effect of thePokemon
being caught.tryCapture
(CaptureValues values, CaptureHealth health, PokeBall pokeBall, PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Method that spins off into all the methods above.
-
Field Details
-
MAJOR_STATUSES
List of major status effects for purposes of catch calculation. -
MINOR_STATUSES
List of minor status effects for purposes of catch calculation.
-
-
Method Details
-
calculateCapture
default CaptureValues calculateCapture(CaptureHealth health, PokeBall pokeBall, @Nullable PokeBallEntity pokeBallEntity, @Nullable RaidData raid, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) The main method of capture calculations. This is called by Poké Balls and Raid Dens when they want to get the result of a catch attempt. As such, this method should ultimately spin off into all the methods required to perform every step of the calculation.- Parameters:
health
- TheCaptureHealth
for this capture attempt.pokeBall
- ThePokeBall
being used in this capture attempt.pokeBallEntity
- ThePokeBallEntity
being used for this capture attempt, if one exists.raid
- TheRaidData
this capture attempt is part of, if one exists.thrower
- The player performing this capture attempt.pokemon
- ThePokemon
being caught.mode
- ThePokeBallMode
of this capture attempt.- Returns:
- The
CaptureValues
instance created by this capture attempt, with the results of this attempt contained within.
-
calculateCatchRate
default int calculateCatchRate(PokeBall pokeBall, @Nullable PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Calculates the catch rate of thePokemon
being caught. Generally, this would just want to be deferred to thePokeBall
as this has its own logic for this, but this method allows this standard way to be changed if required.- Parameters:
pokeBall
- ThePokeBall
being used in this capture attempt.pokeBallEntity
- ThePokeBallEntity
being used for this capture attempt, if one exists.thrower
- The player performing this capture attempt.pokemon
- ThePokemon
being caught.mode
- ThePokeBallMode
of this capture attempt.- Returns:
- The modified catch rate of the
Pokemon
being caught.
-
calculateBallBonus
default double calculateBallBonus(PokeBall pokeBall, @Nullable PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Calculates the ball bonus for thePokeBall
being used. Generally, this would just want to be deferred to thePokeBall
as this has its own logic for this, but this method allows this standard way to be changed if required.- Parameters:
pokeBall
- ThePokeBall
being used in this capture attempt.pokeBallEntity
- ThePokeBallEntity
being used for this capture attempt, if one exists.thrower
- The player performing this capture attempt.pokemon
- ThePokemon
being caught.mode
- ThePokeBallMode
of this capture attempt.- Returns:
- The ball bonus of the
PokeBall
being used.
-
constructValues
default CaptureValues constructValues(PokeBall pokeBall, @Nullable PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Creates a newCaptureValues
to be used by the rest of the capture calculation. By default, this is just populated with the modified catch rate and ball bonus, but this method allows this logic to be changed if required.- Parameters:
pokeBall
- ThePokeBall
being used in this capture attempt.pokeBallEntity
- ThePokeBallEntity
being used for this capture attempt, if one exists.thrower
- The player performing this capture attempt.pokemon
- ThePokemon
being caught.mode
- ThePokeBallMode
of this capture attempt.- Returns:
- The starting
CaptureValues
of this capture attempt.
-
preCaptureChecks
default boolean preCaptureChecks(CaptureValues values, CaptureHealth health, PokeBall pokeBall, @Nullable PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Performs pre-capture checks for a regular capture attempt (not a raid). This should fire events, check boss state, check flags, anything that would ultimately prevent a capture from succeeding without needing to perform the full capture calculation.- Parameters:
values
- TheCaptureValues
for this capture attempt.health
- TheCaptureHealth
for this capture attempt.pokeBall
- ThePokeBall
being used in this capture attempt.pokeBallEntity
- ThePokeBallEntity
being used for this capture attempt, if one exists.thrower
- The player performing this capture attempt.pokemon
- ThePokemon
being caught.mode
- ThePokeBallMode
of this capture attempt.- Returns:
- The starting
CaptureValues
of this capture attempt.
-
preRaidCaptureChecks
default boolean preRaidCaptureChecks(CaptureValues values, CaptureHealth health, PokeBall pokeBall, @Nullable PokeBallEntity pokeBallEntity, RaidData raid, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Performs pre-capture checks for a raid capture attempt. This should fire events, check boss state, check flags, anything that would ultimately prevent a capture from succeeding without needing to perform the full capture calculation.- Parameters:
values
- TheCaptureValues
for this capture attempt.health
- TheCaptureHealth
for this capture attempt.pokeBall
- ThePokeBall
being used in this capture attempt.pokeBallEntity
- ThePokeBallEntity
being used for this capture attempt, if one exists.raid
- TheRaidData
this capture attempt is part of.thrower
- The player performing this capture attempt.pokemon
- ThePokemon
being caught.mode
- ThePokeBallMode
of this capture attempt.- Returns:
- The starting
CaptureValues
of this capture attempt.
-
statusEffectCheck
default double statusEffectCheck(CaptureValues values, CaptureHealth health, PokeBall pokeBall, @Nullable PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Returns a value based on the current status effect of thePokemon
being caught. This can then be used by later steps of the capture calculation to modify what is required for that step.- Parameters:
values
- TheCaptureValues
for this capture attempt.health
- TheCaptureHealth
for this capture attempt.pokeBall
- ThePokeBall
being used in this capture attempt.pokeBallEntity
- ThePokeBallEntity
being used for this capture attempt, if one exists.thrower
- The player performing this capture attempt.pokemon
- ThePokemon
being caught.mode
- ThePokeBallMode
of this capture attempt.- Returns:
- A value based on the
Pokemon
's current status effect.
-
criticalCaptureCheck
default void criticalCaptureCheck(CaptureValues values, CaptureHealth health, PokeBall pokeBall, @Nullable PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Performs a critical capture check and sets theCaptureValues
accordingly. Not all capture calculations will perform this check, so it may not necessarily be called for every capture.- Parameters:
values
- TheCaptureValues
for this capture attempt.health
- TheCaptureHealth
for this capture attempt.pokeBall
- ThePokeBall
being used in this capture attempt.pokeBallEntity
- ThePokeBallEntity
being used for this capture attempt, if one exists.thrower
- The player performing this capture attempt.pokemon
- ThePokemon
being caught.mode
- ThePokeBallMode
of this capture attempt.
-
captureCalculation
default void captureCalculation(CaptureValues values, CaptureHealth health, PokeBall pokeBall, @Nullable PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Performs the main capture calculation and sets theCaptureValues
accordingly. This method may not necessarily set shake/capture values directly, as there is a later method that does this. Instead, this method is intended to be used to create and set the variables needed in order to calculate the end result at that later stage.- Parameters:
values
- TheCaptureValues
for this capture attempt.health
- TheCaptureHealth
for this capture attempt.pokeBall
- ThePokeBall
being used in this capture attempt.pokeBallEntity
- ThePokeBallEntity
being used for this capture attempt, if one exists.thrower
- The player performing this capture attempt.pokemon
- ThePokemon
being caught.mode
- ThePokeBallMode
of this capture attempt.
-
shakeCountCheck
default void shakeCountCheck(CaptureValues values, CaptureHealth health, PokeBall pokeBall, @Nullable PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Performs shake checks and sets theCaptureValues
accordingly. This method is what ultimately will decide if the current capture attempt succeeds or fails if it reaches this stage, and at the end of the method, theCaptureValues
should be in its finalized state ready to be handed back to the initiator of this capture attempt for processing. It is highly likely that variables set incaptureCalculation(com.pixelmonmod.pixelmon.api.pokemon.catching.CaptureValues, com.pixelmonmod.pixelmon.api.pokemon.catching.CaptureHealth, com.pixelmonmod.pixelmon.api.pokemon.item.pokeball.PokeBall, com.pixelmonmod.pixelmon.entities.pokeballs.PokeBallEntity, net.minecraft.server.level.ServerPlayer, com.pixelmonmod.pixelmon.api.pokemon.Pokemon, com.pixelmonmod.pixelmon.entities.pokeballs.PokeBallMode)
will be used here in order to determine the number of shake checks that occur and if they pass or not.- Parameters:
values
- TheCaptureValues
for this capture attempt.health
- TheCaptureHealth
for this capture attempt.pokeBall
- ThePokeBall
being used in this capture attempt.pokeBallEntity
- ThePokeBallEntity
being used for this capture attempt, if one exists.thrower
- The player performing this capture attempt.pokemon
- ThePokemon
being caught.mode
- ThePokeBallMode
of this capture attempt.
-
tryCapture
CaptureValues tryCapture(CaptureValues values, CaptureHealth health, PokeBall pokeBall, @Nullable PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Method that spins off into all the methods above. Is the only anonymous method of this interface, as it is the only one where no true default implementation is possible. In general, it will check if the current ball is guaranteed to catch, and sets theCaptureValues
accordingly, otherwise will spin off intopreCaptureChecks(com.pixelmonmod.pixelmon.api.pokemon.catching.CaptureValues, com.pixelmonmod.pixelmon.api.pokemon.catching.CaptureHealth, com.pixelmonmod.pixelmon.api.pokemon.item.pokeball.PokeBall, com.pixelmonmod.pixelmon.entities.pokeballs.PokeBallEntity, net.minecraft.server.level.ServerPlayer, com.pixelmonmod.pixelmon.api.pokemon.Pokemon, com.pixelmonmod.pixelmon.entities.pokeballs.PokeBallMode)
followed bycaptureCalculation(com.pixelmonmod.pixelmon.api.pokemon.catching.CaptureValues, com.pixelmonmod.pixelmon.api.pokemon.catching.CaptureHealth, com.pixelmonmod.pixelmon.api.pokemon.item.pokeball.PokeBall, com.pixelmonmod.pixelmon.entities.pokeballs.PokeBallEntity, net.minecraft.server.level.ServerPlayer, com.pixelmonmod.pixelmon.api.pokemon.Pokemon, com.pixelmonmod.pixelmon.entities.pokeballs.PokeBallMode)
,criticalCaptureCheck(com.pixelmonmod.pixelmon.api.pokemon.catching.CaptureValues, com.pixelmonmod.pixelmon.api.pokemon.catching.CaptureHealth, com.pixelmonmod.pixelmon.api.pokemon.item.pokeball.PokeBall, com.pixelmonmod.pixelmon.entities.pokeballs.PokeBallEntity, net.minecraft.server.level.ServerPlayer, com.pixelmonmod.pixelmon.api.pokemon.Pokemon, com.pixelmonmod.pixelmon.entities.pokeballs.PokeBallMode)
if applicable, andshakeCountCheck(com.pixelmonmod.pixelmon.api.pokemon.catching.CaptureValues, com.pixelmonmod.pixelmon.api.pokemon.catching.CaptureHealth, com.pixelmonmod.pixelmon.api.pokemon.item.pokeball.PokeBall, com.pixelmonmod.pixelmon.entities.pokeballs.PokeBallEntity, net.minecraft.server.level.ServerPlayer, com.pixelmonmod.pixelmon.api.pokemon.Pokemon, com.pixelmonmod.pixelmon.entities.pokeballs.PokeBallMode)
.- Parameters:
values
- TheCaptureValues
for this capture attempt.health
- TheCaptureHealth
for this capture attempt.pokeBall
- ThePokeBall
being used in this capture attempt.pokeBallEntity
- ThePokeBallEntity
being used for this capture attempt, if one exists.thrower
- The player performing this capture attempt.pokemon
- ThePokemon
being caught.mode
- ThePokeBallMode
of this capture attempt.
-