-
Notifications
You must be signed in to change notification settings - Fork 4
1.19.2 Types
EquipmentSlot.MAINHAND
EquipmentSlot.OFFHAND
EquipmentSlot.FEET
EquipmentSlot.LEGS
EquipmentSlot.CHEST
EquipmentSlot.HEAD
LootType.UNKNOWN
LootType.BLOCK
LootType.ENTITY
LootType.CHEST
LootType.FISHING
LootType.GIFT
Holds information for the current loot drop. Is mostly used for .apply().
Returns the LootType
.
Returns an EntityJS
or null
if no entity exists for the context.
Returns an EntityJS
for the killer or null
if no entity exists for the context.
Returns a PlayerJS
or null
if no player exists for the context. An example of null
would be when a Skeleton shoots a Creeper.
Returns a DamageSourceJS
or null
if no source exists.
Returns an ItemStackJS
for the tool
. If no tool
exists in the context, it will return an empty
item.
Returns a BlockContainerJS
for block loot. Will be null
for every other loot type.
Returns true
if the loot drop happens by an explosion.
Returns the explosion radius. If isExploded()
returns false
, the radius is 0.
Returns the LevelJS
.
Returns the ServerJS
.
Iterates over each item
and calls the given callback
for it.
// callback example
const callback = (item) => {
console.log(item);
};
Entity tags can also be passed when using #
as a prefix. Example: #skeletons
.
Matching the mount for the current entity. LootJS
provides an EntityPredicateBuilderJS
for the callback
.
LootJS.modifiers((event) => {
event
.addLootTypeModifier([LootType.ENTITY])
.matchEntity((entity) => {
entity.anyType("#skeletons");
entity.matchMount((mount) => {
mount.anyType("minecraft:spider");
});
})
.addLoot("minecraft:magma_cream");
});
This example shows a Skeleton riding a Spider, also known as a spider jockey.
Matching the targeted entity for the current entity. LootJS
provides a EntityPredicateBuilderJS
for the callback
.
Returns true
if the slot
contains the specified ItemFilter.
Returns true
if at least one type
matches. Possible types are: "inFire"
, "lightningBolt"
, "onFire"
, "lava"
, "hotFloor"
, "inWall"
, "cramming"
, "drown"
, "starve"
, "cactus"
, "fall"
, "flyIntoWall"
, "outOfWorld"
, "generic"
, "magic"
, "wither"
, "anvil"
, "fallingBlock"
, "dragonBreath"
, "dryout"
, "sweetBerryBush"
and there might be more types added by other mods.
Matching the direct entity. LootJS
provides a EntityPredicateBuilderJS
for the callback
.
Matching the source entity. LootJS
provides a EntityPredicateBuilderJS
for the callback
.
ItemFilters can be used as filters for different functions in LootJS
. Though everywhere where ItemFilter
is needed, you can also use the KubeJS methods Item.of()
and Ingredient.of()
.
ItemFilter
additionally supports these quick filters:
- ItemFilter.ALWAYS_FALSE
- ItemFilter.ALWAYS_TRUE
- ItemFilter.SWORD
- ItemFilter.PICKAXE
- ItemFilter.AXE
- ItemFilter.SHOVEL
- ItemFilter.HOE
- ItemFilter.TOOL
- ItemFilter.POTION;
- ItemFilter.HAS_TIER;
- ItemFilter.PROJECTILE_WEAPON
- ItemFilter.ARMOR;
- ItemFilter.WEAPON;
- Matches all swords, tools, trident and projectile weapons
- ItemFilter.HEAD_ARMOR
- ItemFilter.CHEST_ARMOR
- ItemFilter.LEGS_ARMOR
- ItemFilter.FEET_ARMOR
- ItemFilter.FOOD
- ItemFilter.DAMAGEABLE
- ItemFilter.DAMAGED
- ItemFilter.ENCHANTABLE
- ItemFilter.ENCHANTED
- ItemFilter.BLOCK
- Matches if the item can be placed as block
- ItemFilter.hasEnchantment(enchantment, minLevel, maxLevel) & ItemFilter.hasEnchantment(enchantment)
- Check if an item has an enchantment
On Forge only you can also use:
- ForgeItemFilter.canPerformAnyAction(...action)
- ForgeItemFilter.canPerformAction(...action)
- Existing default actions on Forge:
"axe_dig"
,"pickaxe_dig"
,"shovel_dig"
,"hoe_dig"
,"sword_dig"
,"shears_dig"
,"axe_strip"
,"axe_scrape"
,"axe_wax_off"
,"shovel_flatten"
,"sword_sweep"
,"shears_harvest"
,"shears_carve"
,"shears_disarm"
,"till"
,"shield_block"
,"fishing_rod_cast"
. Mods can add their own actions.
- Existing default actions on Forge:
NumberProvider
is a vanilla object which gets type wrapped by KubeJS. If a function takes a number provider, you can pass a simple number to use a constant value, an array with a min and a max value [min, max] -> [3, 10]
or if you want to have a binomial distribution, you can use { n: a, p: b} -> { n: 3, p: 0.5 }
.