Interface ChallengeHelper


@NonExtendable public interface ChallengeHelper
Provides commonly used fields and methods for mob challenge scaling.
Since:
1.1.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    An NBT key that tells an entity to force-enable challenge scaling.
    static final String
    An NBT key that tells an entity to ignore challenge scaling.
    static final net.minecraft.util.math.BlockPos
    The block position used as the world origin.
    static final net.minecraft.registry.tag.TagKey<net.minecraft.entity.EntityType<?>>
    A tag that determines which entities are scaled.
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static double
    getAttackAdditive(net.minecraft.world.World world)
    Returns the world's configured attack additive value.
    static int
    getChunkStep(net.minecraft.world.World world)
    Returns the world's configured chunk step size.
    static double
    getHealthAdditive(net.minecraft.world.World world)
    Returns the world's configured health additive value.
    static double
    getScaledAdditive(net.minecraft.entity.Entity entity, double additive)
    Returns a statistic additive that has been scaled using the world's challenge configuration.
    static float
    getScaledAttack(net.minecraft.entity.Entity entity, float attack)
    Returns the given entity's scaled attack damage.
    static float
    getScaledExplosion(net.minecraft.entity.Entity entity, float max, float power)
    Returns the given entity's scaled explosion power.
    static double
    getSpawnDistance(net.minecraft.entity.Entity entity)
    Returns the given entity's distance from the world's configured origin.
    static boolean
    isEnabled(net.minecraft.world.World world)
    Returns whether challenge scaling is enabled in the current world.
    static boolean
    shouldApplyScaling(net.minecraft.entity.Entity entity)
    Determines whether a given entity should have challenge scaling applied to them.
    static boolean
    useWorldSpawn(net.minecraft.world.World world)
    Returns whether challenge scaling should use the world's spawnpoint, rather than the world origin.
  • Field Details

    • ORIGIN

      static final net.minecraft.util.math.BlockPos ORIGIN
      The block position used as the world origin.

      The Y value does not matter, as it is overwritten, but just for sanity's sake it's set to sea level.

      Since:
      1.1.1
    • IGNORE_KEY

      static final String IGNORE_KEY
      An NBT key that tells an entity to ignore challenge scaling.

      If this is set, the entity will never be scaled.

      Since:
      1.1.0
      See Also:
    • FORCE_KEY

      static final String FORCE_KEY
      An NBT key that tells an entity to force-enable challenge scaling.

      If this is set, the entity will *always* be scaled (if supported).

      Since:
      1.1.0
      See Also:
    • SCALED_ENTITIES

      static final net.minecraft.registry.tag.TagKey<net.minecraft.entity.EntityType<?>> SCALED_ENTITIES
      A tag that determines which entities are scaled.

      If an entity is not present within this tag, it will never be scaled (unless set through NBT).

      Since:
      1.1.0
  • Method Details

    • shouldApplyScaling

      static boolean shouldApplyScaling(net.minecraft.entity.Entity entity)
      Determines whether a given entity should have challenge scaling applied to them.
      Parameters:
      entity - The target entity.
      Returns:
      Whether to enable scaling for the entity.
      Since:
      2.0.0
    • isEnabled

      static boolean isEnabled(net.minecraft.world.World world)
      Returns whether challenge scaling is enabled in the current world.
      Parameters:
      world - The current world.
      Returns:
      Whether scaling is enabled in this world.
      Since:
      1.1.0
    • useWorldSpawn

      static boolean useWorldSpawn(net.minecraft.world.World world)
      Returns whether challenge scaling should use the world's spawnpoint, rather than the world origin.
      Parameters:
      world - The current world.
      Returns:
      Whether the world's spawnpoint should be used.
      Since:
      2.0.0
    • getAttackAdditive

      static double getAttackAdditive(net.minecraft.world.World world)
      Returns the world's configured attack additive value.

      This value is used within scaling calculations to determine an entity's added attack damage.

      Parameters:
      world - The current world.
      Returns:
      The world's configured attack additive.
      Since:
      1.1.0
    • getHealthAdditive

      static double getHealthAdditive(net.minecraft.world.World world)
      Returns the world's configured health additive value.

      This value is used within scaling calculations to determine an entity's added health value.

      Parameters:
      world - The current world.
      Returns:
      The world's configured health additive.
      Since:
      1.1.0
    • getScaledAdditive

      static double getScaledAdditive(net.minecraft.entity.Entity entity, double additive)
      Returns a statistic additive that has been scaled using the world's challenge configuration.
      Parameters:
      entity - The target entity.
      additive - The statistical additive.
      Returns:
      The scaled additive.
      Since:
      1.1.1
    • getChunkStep

      static int getChunkStep(net.minecraft.world.World world)
      Returns the world's configured chunk step size.

      This is the main factor that determines how distance affects additives.

      Parameters:
      world - The current world.
      Returns:
      The world's configured chunk step.
      Since:
      1.1.0
    • getSpawnDistance

      static double getSpawnDistance(net.minecraft.entity.Entity entity)
      Returns the given entity's distance from the world's configured origin.

      The origin will either be (0, 0), or the world's spawnpoint, depending on the configured gamerule.

      This method ignores height differences, only considering horizontal distance.

      Parameters:
      entity - The target entity.
      Returns:
      The entity's distance from the origin.
      Since:
      1.1.0
    • getScaledAttack

      static float getScaledAttack(net.minecraft.entity.Entity entity, float attack)
      Returns the given entity's scaled attack damage.
      Parameters:
      entity - The source entity.
      attack - The original attack damage.
      Returns:
      The scaled attack damage.
      Since:
      2.0.0
    • getScaledExplosion

      static float getScaledExplosion(net.minecraft.entity.Entity entity, float max, float power)
      Returns the given entity's scaled explosion power.
      Parameters:
      entity - The source entity.
      max - The maximum allowed power.
      power - The original power.
      Returns:
      The scaled power.
      Since:
      2.0.0