RegionalDifficulty 5.47.0
Regional (local) difficulty: how dangerous the world is at a place, used by mob spawn equipment (the Bedrock loot conditions random_regional_difficulty_chance and the enchant_random_gear function).
Port of Java DifficultyInstance: the effective difficulty grows with the time of day counter of the world (after the first 3 days, over 60 days), the time players spent in the chunk and the moon phase, scaled by the difficulty. The "special multiplier" maps it to 0-1 (0 below 2.0, 1 above 4.0).
PocketMine keeps no chunk inhabited time: it is taken as 0, so the local part only comes from the moon phase (at most 0.25 of the world age part). Regional difficulty is only computed when a mob spawns.
Constants
MOON_BRIGHTNESS
public const MOON_BRIGHTNESS = [1.0, 0.75, 0.5, 0.25, 0.0, 0.25, 0.5, 0.75]Moon brightness by moon phase (0 = full moon), vanilla DimensionType.MOON_BRIGHTNESS_PER_PHASE.
Methods
calculate()
public static function calculate(int $difficulty, int $dayTime, int $inhabitedTime, float $moonBrightness) : floatReturns the effective difficulty (0 on Peaceful, up to 1.5 on Easy, 4.0 on Normal and 6.75 on Hard).
getEffectiveAt()
public static function getEffectiveAt(\pocketmine\world\World $world, \pocketmine\math\Vector3 $pos) : floatReturns the effective difficulty at a position of the world.
getSpecialMultiplier()
public static function getSpecialMultiplier(float $effectiveDifficulty) : floatReturns the clamped regional difficulty (Java DifficultyInstance.getSpecialMultiplier()): 0 below an effective difficulty of 2.0, 1 above 4.0, linear in between.
getSpecialMultiplierAt()
public static function getSpecialMultiplierAt(\pocketmine\world\World $world, \pocketmine\math\Vector3 $pos) : floatReturns the clamped regional difficulty (0-1) at a position of the world.
