LootContext
A loot context contains all information of the current rolled loot table. You can retrieve information about the block which was destroyed, the entity which was killed, etc.
getId
Get the id of the loot table which was rolled.
- Syntax:
.getId()
.id
isType
Checks the type of the loot table. Valid types are chest
, block
, entity
, fishing
, archaeology
, gift
, vault
, shearing
, piglin_barter
- Syntax:
.isType(type: LootType)
getType
Get the type of the loot table which was rolled.
- Syntax:
.getType()
.type
getPosition
Get the position where the loot table was rolled. When opening a chest it's the position of the chest, when killing an entity it's the position of the entity, etc.
- Syntax:
.getPosition()
, returns aVec3
withx
,y
andz
values.position
getEntity
May return null
, depending on the type of the loot table.
- Syntax:
.getEntity()
.entity
LootJS.modifiers(event => {
event.addTypeModifier("chest").customAction((context, loot) => {
console.log(context.entity)
})
})
getAttackingEntity
May return null
, depending on the type of the loot table.
- Syntax:
.getAttackingEntity()
.attackingEntity
LootJS.modifiers(event => {
event.addTypeModifier("entity").customAction((context, loot) => {
console.log(context.attackingEntity)
})
})
getDamageSource
May return null
, depending on the type of the loot table.
- Syntax:
.getDamageSource()
.damageSource
LootJS.modifiers(event => {
event.addTypeModifier("entity").customAction((context, loot) => {
console.log(context.damageSource)
})
})
getTool
- Syntax:
.getTool()
.tool
LootJS.modifiers(event => {
event.addTypeModifier("block").customAction((context, loot) => {
console.log(context.tool)
})
})
isExploded
- Syntax:
.isExploded()
getExplosionRadius
- Syntax:
.getExplosionRadius()
.explosionRadius
getRandom
Can be used for further randomization.
- Syntax:
.getRandom()
.random
getLuck
- Syntax:
.getLuck()
.luck
getLevel
- Syntax:
.getLevel()
.level
getServer
- Syntax:
.getServer()
.server