LootContext 5.46.0
Everything a loot table may look at while rolling (vanilla's LootContext and LootParams): the random source, the luck, and the optional parameters (origin, entities, tool, explosion...). Conditions that need a parameter that is not set fail, like in vanilla.
Checks that depend on things the loot engine does not model (entity predicates, damage sources, locations, block states, dynamic drops) are delegated to the optional resolver closures; without a resolver they fail.
Properties
$attackingEntity
public ?\pocketmine\entity\Entity $attackingEntityATTACKING_ENTITY: the entity whose attack killed $thisEntity (the shooter for projectiles)
$biomeAt
public ?\Closure $biomeAtJava biome id at a position, for location checks: fn(int $x, int $y, int $z) : ?string
$blockId
public ?string $blockId$blockProperties
public ?array $blockPropertiesJava block id and string properties of the BLOCK_STATE parameter (blocks broken), or null.
$damageSourcePredicate
public ?\Closure $damageSourcePredicateminecraft:damage_source_properties: fn(array $predicate) : bool
$directAttackingEntity
public ?\pocketmine\entity\Entity $directAttackingEntityDIRECT_ATTACKING_ENTITY: the entity that dealt the damage (the projectile for projectiles)
$dynamicDrops
public ?\Closure $dynamicDropsminecraft:dynamic entries ("contents", "sherds"): fn(string $name, \Closure(LootStack) : void $output) : void
$entityEnchantmentLevel
public ?\Closure $entityEnchantmentLevelEnchantment level of a living entity's equipment (EnchantmentHelper.getEnchantmentLevel), used by looting-like functions: fn(Entity $entity, string $javaEnchantmentId) : int. Defaults to the held item of humans.
$entityPredicate
public ?\Closure $entityPredicateminecraft:entity_properties: fn(string $target, array $predicate) : bool, $target being "this", "attacker", "direct_attacker" or "attacking_player".
$explosionRadius
public ?float $explosionRadiusEXPLOSION_RADIUS: set when the loot comes from a block destroyed by an explosion
$lastDamagePlayer
public ?\pocketmine\player\Player $lastDamagePlayerLAST_DAMAGE_PLAYER: set when a player took part in the kill (killed_by_player)
$locationPredicate
public ?\Closure $locationPredicateminecraft:location_check: fn(array $predicate, int $offsetX, int $offsetY, int $offsetZ) : bool. Without a resolver only "biomes" predicates are checked, with $biomeAt.
$luck
public float $luck$origin
public ?\pocketmine\math\Vector3 $origin$random
public readonly \pocketmine\world\generator\vanilla\random\LegacyRandom $random$thisEntity
public ?\pocketmine\entity\Entity $thisEntityTHIS_ENTITY: the entity that died, the player opening a container, the player brushing...
$tool
public ?\pocketmine\loot\LootStack $toolTOOL: the item used to break a block, brush, shear...
$visited
public array $visitedLoot tables and predicates being evaluated (recursion guard, like vanilla's visited elements).
$world
public ?\pocketmine\world\World $worldMethods
__construct()
public function __construct(\pocketmine\world\generator\vanilla\random\LegacyRandom $random)create()
public static function create() : selfA context with a random seed.
getEntityEnchantmentLevel()
public function getEntityEnchantmentLevel(?\pocketmine\entity\Entity $entity, string $enchantment) : intEnchantment level of an entity's equipment.
randomSeed()
public static function randomSeed() : intseeded()
public static function seeded(int $seed) : selfA context whose random is seeded like vanilla's LootContext.Builder.withOptionalRandomSeed(): a seed of 0 means "no seed" (a random one is used).
