Class HeldItem

java.lang.Object
net.minecraft.world.item.Item
com.pixelmonmod.pixelmon.items.PixelmonItem
com.pixelmonmod.pixelmon.items.HeldItem
All Implemented Interfaces:
ITranslatable, net.minecraft.world.flag.FeatureElement, net.minecraft.world.level.ItemLike, net.minecraftforge.common.extensions.IForgeItem
Direct Known Subclasses:
AirBalloonItem, AmuletCoinItem, AssaultVestItem, BerryItem, BerryJuiceItem, BlackSludgeItem, BlankTechnicalMachineItem, BlunderPolicyItem, BoosterEnergyItem, BrightPowderItem, ChoiceItem, CovertCloakItem, CritEnhancingItem, DeepSeaToothScaleItem, DestinyKnotItem, EjectButtonItem, EjectPackItem, EVAdjusting, ExpertBeltItem, FairyFeatherItem, FlameOrbItem, FloatStoneItem, FocusBandItem, FocusSashItem, GemsItem, HeavyDutyBootsItem, IncensePowerIncreaseItem, IronBallItem, KingsRockItem, LaggingTailItem, LeftoversItem, LifeOrbItem, MailItem, MegaStoneItem, MemoryItem, MentalHerbItem, MetalCoatItem, MetronomeItem, MilcerySweet, MirrorHerbItem, MuscleBandItem, NoItem, OrbItem, OriginFormItem, PowerHerbItem, ProtectivePadsItem, PunchingGloveItem, QuickClawItem, RaiseStatItem, RazorClawItem, RazorFangItem, RedCardItem, RingTargetItem, RockyHelmetItem, RoomServiceItem, RustedShieldItem, RustedSwordItem, SacredAshItem, SafetyGogglesItem, ScopeLensItem, ShellBellItem, SoulDewItem, StatEnhancingItems, StickyBarbItem, TerrainSeedItem, ThroatSprayItem, ToxicOrbItem, TypeEnhancingItems, WeaknessPolicyItem, WhiteHerbItem, WideLensItem, ZCrystalItem, ZoomLensItem

public class HeldItem extends PixelmonItem implements ITranslatable
Item representation of a held item.
  • Constructor Details

    • HeldItem

      public HeldItem(EnumHeldItems heldItemType, net.minecraft.world.item.Item.Properties properties)
      Constructs the held item with predefined and defined attributes.
      Parameters:
      heldItemType - Type of held item.
  • Method Details

    • getHeldItemType

      public EnumHeldItems getHeldItemType()
      Returns the type of held item.
      Returns:
      The type of held item.
    • isItemOfType

      public static boolean isItemOfType(net.minecraft.world.item.ItemStack itemStack, EnumHeldItems type)
      Returns whether an item is a certain held item.
      Parameters:
      itemStack - The item to check.
      type - The desired held item type.
      Returns:
      Whether the item is of the desired held item type.
    • interact

      public boolean interact(PixelmonEntity pokemon, net.minecraft.world.item.ItemStack itemstack, net.minecraft.world.entity.player.Player player)
      Overrides the standard held item interaction (equipping the held item) if needed.
      Parameters:
      pokemon - The Pokémon being given the item.
      itemstack - The itemstack used to interact.
      player - The player using the item.
      Returns:
      Whether the item was used.
    • applyStartOfTurnEffect

      public void applyStartOfTurnEffect(PixelmonWrapper pw)
      Triggers at the start of the turn, after switches and evolutions.
      Parameters:
      pw - The Pokémon holding this.
    • onStartOfBattle

      public void onStartOfBattle(PixelmonWrapper pw)
      Triggers at the start of the battle (wherever this is).
      Parameters:
      pw - The Pokémon holding this.
    • onEndOfBattle

      public void onEndOfBattle(PixelmonWrapper pw)
      Triggers at the end of the battle.
      Parameters:
      pw - The Pokémon in battle at the battle's end.
    • dealtDamage

      public void dealtDamage(PixelmonWrapper attacker, PixelmonWrapper defender, Attack attack, DamageTypeEnum damageType)
      Triggers when the holder deals damage.
      Parameters:
      attacker - The source of the damage.
      defender - The target of the damage.
      attack - The attack used by the attacker.
      damageType - The type of damage that was dealt.
    • tookDamage

      public void tookDamage(PixelmonWrapper attacker, PixelmonWrapper defender, float damage, DamageTypeEnum damageType)
      Triggers when the holder takes damage.
      Parameters:
      attacker - The source of the damage.
      defender - The target of the damage.
      damage - The damage dealt.
      damageType - The type of damage that was dealt.
    • onAttackUsed

      public void onAttackUsed(PixelmonWrapper user, Attack attack)
      Triggers when the holder uses an attack.
      Parameters:
      user - The attack's user.
      attack - The attack.
    • preProcessDamagingAttackUser

      public double preProcessDamagingAttackUser(PixelmonWrapper attacker, PixelmonWrapper target, Attack attack, double damage)
      Triggers before the holder uses a damaging attack.
      Parameters:
      attacker - The attack's user.
      target - The attack's target.
      attack - The attack.
      damage - The damage to be dealt.
      Returns:
      The modified damage.
    • preProcessDamagingAttackTarget

      public double preProcessDamagingAttackTarget(PixelmonWrapper attacker, PixelmonWrapper target, Attack attack, double damage)
      Triggers before the holder is struck by a damaging attack.
      Parameters:
      attacker - The attack's user.
      target - The attack's target.
      attack - The attack.
      damage - The damage to be dealt.
      Returns:
      The modified damage.
    • postProcessAttackUser

      public void postProcessAttackUser(PixelmonWrapper attacker, PixelmonWrapper target, Attack attack)
      Triggers after the holder uses an attack.
      Parameters:
      attacker - The attack's user.
      target - The attack's target.
      attack - The attack.
    • postProcessDamagingAttackUser

      public void postProcessDamagingAttackUser(PixelmonWrapper attacker, PixelmonWrapper target, Attack attack, float damage)
      Triggers after the holder uses a damaging attack.
      Parameters:
      attacker - The attack's user.
      target - The attack's target.
      attack - The attack.
      damage - The damage dealt.
    • postProcessDamagingAttackTarget

      public void postProcessDamagingAttackTarget(PixelmonWrapper attacker, PixelmonWrapper target, Attack attack, float damage, DamageTypeEnum damageType)
      Triggers after the holder is hit by a damaging attack.
      Parameters:
      attacker - The attack's user.
      target - The attack's target.
      attack - The attack.
      damage - The damage dealt.
      damageType - The type of damage dealt.
    • modifyDamageIncludeFixed

      public double modifyDamageIncludeFixed(double damage, PixelmonWrapper attacker, PixelmonWrapper target, Attack attack)
      Modifies damage done on the holder by damaging attacks, including fixed damage.
      Parameters:
      damage - The damage dealt.
      attacker - The attack's user.
      target - The attack's target.
      attack - The attack.
      Returns:
      The modified damage.
    • modifyConfusionDamage

      public int modifyConfusionDamage(int damage, PixelmonWrapper pw)
      Triggers when the Pokémon takes would take Confusion damage.
      Parameters:
      damage - The amount of damage dealt.
      pw - The Pokémon taking damage.
      Returns:
      The modified damage.
    • applyEffectAfterAllTargets

      public void applyEffectAfterAllTargets(PixelmonWrapper user)
      Triggers after a Pokemon attacks all of its targets.
      Parameters:
      user - The move's user.
    • onMiss

      public void onMiss(PixelmonWrapper attacker, PixelmonWrapper target, Attack attack)
      Triggers if the holder misses an attack.
      Parameters:
      attacker - The attack's user.
      target - The attack's intended target.
      attack - The attack used.
    • allowsIncomingAttack

      public boolean allowsIncomingAttack(PixelmonWrapper pokemon, PixelmonWrapper user, Attack a)
      Determines whether the holder can be hit by an incoming attack.
      Parameters:
      pokemon - The holder.
      user - The attack's user.
      a - The attack.
      Returns:
      Whether the attack can hit the holder.
    • allowsIncomingAttackMessage

      public void allowsIncomingAttackMessage(PixelmonWrapper pokemon, PixelmonWrapper user, Attack a)
      Sends a battle message when the Pokémon's Ability nullifies an attack.
      Parameters:
      pokemon - The Pokémon with the Ability.
      user - The attack's user.
      a - The attack.
    • applySwitchInEffect

      public void applySwitchInEffect(PixelmonWrapper newPokemon)
      Triggers when the holder switches in and when a Pokémon receives a held item in battle.
      Parameters:
      newPokemon - The Pokémon switching in.
    • applyPostSwitchEffect

      public void applyPostSwitchEffect(PixelmonWrapper newPokemon)
      Triggers after all the Pokémon switch in at the start of turn.
      Parameters:
      newPokemon - The Pokémon switching in.
    • applySwitchOutEffect

      public void applySwitchOutEffect(PixelmonWrapper pw)
      Triggers when the holder switches out.
      Parameters:
      pw - The Pokémon switching out.
    • onStatusAdded

      public void onStatusAdded(PixelmonWrapper user, PixelmonWrapper opponent, StatusBase status)
      Triggers when the holder is statused.
      Parameters:
      user - The statused Pokémon.
      opponent - The Pokémon that caused the status.
      status - The new status.
    • onGlobalStatusAdded

      public void onGlobalStatusAdded(PixelmonWrapper itemHolder, GlobalStatusBase globalStatus)
      Triggers when a global status is added to the battle.
      Parameters:
      itemHolder - The Pokémon holding the item.
      globalStatus - The new status.
    • onStatIncrease

      public void onStatIncrease(PixelmonWrapper pokemon, PixelmonWrapper affected, int amount, BattleStatsType stat)
      Triggers when a Pokémon's stat is increased.
      Parameters:
      pokemon - The Pokémon whose item it is.
      affected - The Pokémon whose stat was increased.
      amount - The size of the increase.
      stat - The stat that was increased.
    • onStatDecrease

      public void onStatDecrease(PixelmonWrapper pokemon, PixelmonWrapper affected, int amount, BattleStatsType stat)
      Triggers when a Pokémon's stat is decreased.
      Parameters:
      pokemon - The Pokémon whose item it is.
      affected - The Pokémon whose stat was decreased.
      amount - The size of the decrease.
      stat - The stat that was decreased.
    • onStatModified

      public void onStatModified(PixelmonWrapper itemHolder, PixelmonWrapper affected)
      Triggers when a Pokémon's stats are modified.
      Parameters:
      itemHolder - The Pokémon holding the item.
      affected - The Pokémon whose stats were just modified.
    • onTerrainSwitch

      public void onTerrainSwitch(BattleController bc, PixelmonWrapper user, Terrain terrain)
      Triggers when the terrain is changed in battle.
      Parameters:
      bc - The battle controller.
      user - The Pokémon whose holding this item.
      terrain - The terrain being switched in.
    • onWeatherSwitch

      public void onWeatherSwitch(BattleController bc, PixelmonWrapper user, Weather weather)
      Triggers when the weather is changed in battle.
      Parameters:
      bc - The battle controller.
      user - The Pokémon whose holding this item.
      weather - The weather being switched in.
    • adjustCritStage

      public int adjustCritStage(PixelmonWrapper user)
      Modifies the holder's critical hit ratio.
      Parameters:
      user - The holder.
    • applyRepeatedEffect

      public void applyRepeatedEffect(PixelmonWrapper pokemon)
      Triggers at the end of every turn.
      Parameters:
      pokemon - The holder.
    • applyRepeatedEffectAfterStatus

      public void applyRepeatedEffectAfterStatus(PixelmonWrapper pokemon)
      Triggers at the end of every turn after residual status damage has been applied.
      Parameters:
      pokemon - The holder.
    • applyEffectOnContact

      public void applyEffectOnContact(PixelmonWrapper pokemon, PixelmonWrapper opponent)
      Triggers when a Pokémon makes contact with the holder.
      Parameters:
      pokemon - The attack's user.
      opponent - The attack's target.
    • applyEffectInDaycare

      public void applyEffectInDaycare(Pokemon pokemon, Pokemon partner)
      Triggers when a Pokémon is put in a daycare with another Pokémon.
      Parameters:
      pokemon - The holder.
      partner - The holder's partner in the daycare.
    • getEffectiveTypes

      public List<Element> getEffectiveTypes(PixelmonWrapper user, PixelmonWrapper target)
      Returns the types that will be used in calculating the Pokémon's attack's type effectiveness.
      Parameters:
      user - The attack's user.
      target - The attack's target.
      Returns:
      The target's modified types.
    • eatBerry

      public void eatBerry(PixelmonWrapper user)
      Called within Berry classes after determining whether or not the Berry will be eaten. Also called directly by certain moves (e.g., Bug Bite, Pluck).
      Parameters:
      user - The Pokémon consuming the Berry.
    • canEatBerry

      public static boolean canEatBerry(PixelmonWrapper user)
      Determines whether the Pokémon can eat Berries.
      Parameters:
      user - The holder.
      Returns:
      Whether the Pokémon can eat Berries.
    • modifyPowerAndAccuracyUser

      public int[] modifyPowerAndAccuracyUser(int[] modifiedMoveStats, PixelmonWrapper user, PixelmonWrapper target, Attack a)
      Modifies the power and accuracy of the Pokémon's attack.
      Parameters:
      modifiedMoveStats - The attack's power and accuracy.
      user - The attack's user.
      target - The attack's target.
      a - The attack.
      Returns:
      The modified power and accuracy.
    • modifyPowerAndAccuracyTarget

      public int[] modifyPowerAndAccuracyTarget(int[] modifiedMoveStats, PixelmonWrapper user, PixelmonWrapper target, Attack a)
      Modifies the power and accuracy of the attack about to hit the Pokémon.
      Parameters:
      modifiedMoveStats - The attack's power and accuracy.
      user - The attack's user.
      target - The attack's target.
      a - The attack.
      Returns:
      The modified power and accuracy.
    • modifyStats

      public int[] modifyStats(PixelmonWrapper user, int[] stats)
      Modifies the Pokémon's stats at the beginning of a battle turn.
      Parameters:
      user - The Pokémon.
      stats - The Pokémon's stats.
      Returns:
      The modified stats.
    • modifyPriority

      public float modifyPriority(PixelmonWrapper pokemon, float priority, MutableBoolean triggered)
      Modifies the holder's attack's priority.
      Parameters:
      pokemon - The attack's user.
      priority - The attack's priority.
      triggered - Whether an ability before this also modified priority.
      Returns:
      The modified priority.
    • affectMultiturnMove

      public boolean affectMultiturnMove(PixelmonWrapper user)
      Determines whether the held item affects multi-turn moves.
      Parameters:
      user - The holder.
      Returns:
      Whether the held item affects multi-turn moves.
    • modifyMoveEffects

      public void modifyMoveEffects(PixelmonWrapper user, PixelmonWrapper target, List<EffectBase> effects)
      Allows the user's held item to adjust the move's effects, such as adding Flinch from King's Rock
      Parameters:
      user - The item holder and attacking Pokemon.
      target - The Pokemon being attacked.
      effects - The current effects of the attack.
    • modifyMoveEffectChanceUser

      public void modifyMoveEffectChanceUser(PixelmonWrapper user, PixelmonWrapper target, List<EffectBase> effects)
      Allows the user's held item to adjust the move's effects, such as adding Flinch from King's Rock
      Parameters:
      user - The item holder and attacking Pokemon.
      target - The Pokemon being attacked.
      effects - The current effects of the attack.
    • modifyMoveEffectChanceTarget

      public void modifyMoveEffectChanceTarget(PixelmonWrapper user, PixelmonWrapper target, List<EffectBase> effects)
      Allows the target's held item to adjust the move's effects, such as disabling effects from CovertCloak
      Parameters:
      user - The item holder and attacking Pokemon.
      target - The Pokemon being attacked.
      effects - The current effects of the attack.
    • modifyWeight

      public float modifyWeight(float initWeight)
      Modifies the Pokémon's weight.
      Parameters:
      initWeight - The Pokémon's weight.
      Returns:
      The modified weight.
    • hasNegativeEffect

      public boolean hasNegativeEffect()
      Checks if the held item has a negative battle effect.
      Returns:
      Whether the held item has a negative battle effect.
    • isBerry

      public boolean isBerry()
      Determines whether the held item is a Berry.
      Returns:
      Whether the held item is a Berry.
    • canUseItem

      public static boolean canUseItem(PixelmonWrapper user)
      Determines whether the Pokémon can use held items.
      Parameters:
      user - The Pokémon.
      Returns:
      Whether the Pokémon can use held items.
    • getItemHeld

      public static HeldItem getItemHeld(net.minecraft.world.item.ItemStack itemStack)
      Gets the type of held item for an item stack.
      Parameters:
      itemStack - The item stack to get a held item for.
      Returns:
      The type of the item for the specified item stack.
    • getTranslationKey

      public String getTranslationKey()
      Specified by:
      getTranslationKey in interface ITranslatable
    • getLocalizedName

      public String getLocalizedName()
      Description copied from class: PixelmonItem
      Gets the localized name of the item.
      Specified by:
      getLocalizedName in interface ITranslatable
      Overrides:
      getLocalizedName in class PixelmonItem
      Returns:
      The localized name of the item.