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
FieldsModifier 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 doublecalculateBallBonus(PokeBall pokeBall, PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Calculates the ball bonus for thePokeBallbeing used.default CaptureValuescalculateCapture(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 intcalculateCatchRate(PokeBall pokeBall, PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Calculates the catch rate of thePokemonbeing caught.default voidcaptureCalculation(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 theCaptureValuesaccordingly.default CaptureValuesconstructValues(PokeBall pokeBall, PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Creates a newCaptureValuesto be used by the rest of the capture calculation.default voidcriticalCaptureCheck(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 theCaptureValuesaccordingly.default booleanpreCaptureChecks(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 booleanpreRaidCaptureChecks(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 voidshakeCountCheck(CaptureValues values, CaptureHealth health, PokeBall pokeBall, PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Performs shake checks and sets theCaptureValuesaccordingly.default doublestatusEffectCheck(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 thePokemonbeing 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- TheCaptureHealthfor this capture attempt.pokeBall- ThePokeBallbeing used in this capture attempt.pokeBallEntity- ThePokeBallEntitybeing used for this capture attempt, if one exists.raid- TheRaidDatathis capture attempt is part of, if one exists.thrower- The player performing this capture attempt.pokemon- ThePokemonbeing caught.mode- ThePokeBallModeof this capture attempt.- Returns:
- The
CaptureValuesinstance 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 thePokemonbeing caught. Generally, this would just want to be deferred to thePokeBallas this has its own logic for this, but this method allows this standard way to be changed if required.- Parameters:
pokeBall- ThePokeBallbeing used in this capture attempt.pokeBallEntity- ThePokeBallEntitybeing used for this capture attempt, if one exists.thrower- The player performing this capture attempt.pokemon- ThePokemonbeing caught.mode- ThePokeBallModeof this capture attempt.- Returns:
- The modified catch rate of the
Pokemonbeing 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 thePokeBallbeing used. Generally, this would just want to be deferred to thePokeBallas this has its own logic for this, but this method allows this standard way to be changed if required.- Parameters:
pokeBall- ThePokeBallbeing used in this capture attempt.pokeBallEntity- ThePokeBallEntitybeing used for this capture attempt, if one exists.thrower- The player performing this capture attempt.pokemon- ThePokemonbeing caught.mode- ThePokeBallModeof this capture attempt.- Returns:
- The ball bonus of the
PokeBallbeing used.
-
constructValues
default CaptureValues constructValues(PokeBall pokeBall, @Nullable PokeBallEntity pokeBallEntity, net.minecraft.server.level.ServerPlayer thrower, Pokemon pokemon, PokeBallMode mode) Creates a newCaptureValuesto 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- ThePokeBallbeing used in this capture attempt.pokeBallEntity- ThePokeBallEntitybeing used for this capture attempt, if one exists.thrower- The player performing this capture attempt.pokemon- ThePokemonbeing caught.mode- ThePokeBallModeof this capture attempt.- Returns:
- The starting
CaptureValuesof 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- TheCaptureValuesfor this capture attempt.health- TheCaptureHealthfor this capture attempt.pokeBall- ThePokeBallbeing used in this capture attempt.pokeBallEntity- ThePokeBallEntitybeing used for this capture attempt, if one exists.thrower- The player performing this capture attempt.pokemon- ThePokemonbeing caught.mode- ThePokeBallModeof this capture attempt.- Returns:
- The starting
CaptureValuesof 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- TheCaptureValuesfor this capture attempt.health- TheCaptureHealthfor this capture attempt.pokeBall- ThePokeBallbeing used in this capture attempt.pokeBallEntity- ThePokeBallEntitybeing used for this capture attempt, if one exists.raid- TheRaidDatathis capture attempt is part of.thrower- The player performing this capture attempt.pokemon- ThePokemonbeing caught.mode- ThePokeBallModeof this capture attempt.- Returns:
- The starting
CaptureValuesof 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 thePokemonbeing caught. This can then be used by later steps of the capture calculation to modify what is required for that step.- Parameters:
values- TheCaptureValuesfor this capture attempt.health- TheCaptureHealthfor this capture attempt.pokeBall- ThePokeBallbeing used in this capture attempt.pokeBallEntity- ThePokeBallEntitybeing used for this capture attempt, if one exists.thrower- The player performing this capture attempt.pokemon- ThePokemonbeing caught.mode- ThePokeBallModeof 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 theCaptureValuesaccordingly. Not all capture calculations will perform this check, so it may not necessarily be called for every capture.- Parameters:
values- TheCaptureValuesfor this capture attempt.health- TheCaptureHealthfor this capture attempt.pokeBall- ThePokeBallbeing used in this capture attempt.pokeBallEntity- ThePokeBallEntitybeing used for this capture attempt, if one exists.thrower- The player performing this capture attempt.pokemon- ThePokemonbeing caught.mode- ThePokeBallModeof 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 theCaptureValuesaccordingly. 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- TheCaptureValuesfor this capture attempt.health- TheCaptureHealthfor this capture attempt.pokeBall- ThePokeBallbeing used in this capture attempt.pokeBallEntity- ThePokeBallEntitybeing used for this capture attempt, if one exists.thrower- The player performing this capture attempt.pokemon- ThePokemonbeing caught.mode- ThePokeBallModeof 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 theCaptureValuesaccordingly. 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, theCaptureValuesshould 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- TheCaptureValuesfor this capture attempt.health- TheCaptureHealthfor this capture attempt.pokeBall- ThePokeBallbeing used in this capture attempt.pokeBallEntity- ThePokeBallEntitybeing used for this capture attempt, if one exists.thrower- The player performing this capture attempt.pokemon- ThePokemonbeing caught.mode- ThePokeBallModeof 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 theCaptureValuesaccordingly, 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- TheCaptureValuesfor this capture attempt.health- TheCaptureHealthfor this capture attempt.pokeBall- ThePokeBallbeing used in this capture attempt.pokeBallEntity- ThePokeBallEntitybeing used for this capture attempt, if one exists.thrower- The player performing this capture attempt.pokemon- ThePokemonbeing caught.mode- ThePokeBallModeof this capture attempt.
-