Holds all information that may be obtainable from a loot table roll, allowing for identifying key information.

Not all parameters are present at all times, for obvious reasons. For example, information related to an entity will not be available if the loot table being rolled is the one for a block.

Importing the class

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

import crafttweaker.api.loot.LootContext;


NombreTypeHas GetterHas SetterDescription
blockStateMCBlockState?truefalseGets the block state that was broken, if present; null otherwise.
damageSourceDamageSource?truefalseGets the damage source that caused the death of the current entity, if present; null otherwise.
directKillerEntityMCEntity?truefalseGets the entity that effectively killed the current entity, if present; null otherwise.

The difference between this and killerEntity resides on the direct-ness of the entity. For example,
if a player kills a skeleton with an arrow, the player will be the killerEntity, while the arrow
will be the directKillerEntity.
explosionRadiusfloattruefalseGets the explosion radius that caused the death of the entity or the destruction of the block, if present; 0.0
killerEntityMCEntity?truefalseGets the entity that caused the death of the current entity, if present; null otherwise.

The entity may or may not be a player. To get only the player, refer to lastDamagePlayer.
lastDamagePlayerMCPlayerEntity?truefalseGets the last player that damaged the current entity, if present; null otherwise.
lootTableIdUbicaciĆ³n MCResourcetruefalseGets the loot table id of the current one being rolled, if available; a place-holder otherwise.
lootingModifierinttruefalseGets the looting modifier, calculated based on the current parameters.
luckfloattruefalseGets the luck factor of the player, as computed by the current parameters.
originMCVector3d?truefalseGets the origin, or location, of the loot roll, if present; null otherwise.
randomRandomtruefalseGets the random generator used in loot table rolling
thisEntityMCEntity?truefalseGets the current entity, if present; null otherwise.
tileEntityMCTileEntity?truefalseGets the block entity that was present at the location of the broken block, if present; null otherwise.
toolIItemStacktruefalseGets the tool that was used to break the block or perform additional behavior, if present; an empty stack
worldMCServerWorldtruefalseGets the world where the interaction happened.