[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / enchantment/melee

# enchantment/melee

## Interfaces

### MeleeEnchantmentBonus

Defined in: [packages/prismarine/src/enchantment/melee.ts:37](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/enchantment/melee.ts#L37)

What the weapon's enchantments are worth on one swing.

#### Properties

##### damage

> `readonly` **damage**: `number`

Defined in: [packages/prismarine/src/enchantment/melee.ts:39](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/enchantment/melee.ts#L39)

Half-hearts on top of the base, before the critical multiplier.

##### knockbackLevels

> `readonly` **knockbackLevels**: `number`

Defined in: [packages/prismarine/src/enchantment/melee.ts:41](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/enchantment/melee.ts#L41)

Knockback levels on top of the sprint.

***

### MeleeEnchantmentInput

Defined in: [packages/prismarine/src/enchantment/melee.ts:23](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/enchantment/melee.ts#L23)

What one swing is worked out from.

#### Properties

##### content

> `readonly` **content**: [`ServerContent`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/ServerContent/index.md#servercontent) \| `undefined`

Defined in: [packages/prismarine/src/enchantment/melee.ts:25](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/enchantment/melee.ts#L25)

The content build, or undefined when the server has none.

##### source

> `readonly` **source**: [`LootKill`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/mobLoot/index.md#lootkill)

Defined in: [packages/prismarine/src/enchantment/melee.ts:33](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/enchantment/melee.ts#L33)

The blow, as the damage source predicates read it.

##### victim

> `readonly` **victim**: [`ViewableEntity`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/predicateView/index.md#viewableentity)

Defined in: [packages/prismarine/src/enchantment/melee.ts:29](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/enchantment/melee.ts#L29)

Who is being hit.

##### victimEquipment?

> `readonly` `optional` **victimEquipment?**: [`ViewableEquipment`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/predicateView/index.md#viewableequipment)

Defined in: [packages/prismarine/src/enchantment/melee.ts:31](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/enchantment/melee.ts#L31)

What the victim is wearing, which the victim's own conditions read.

##### weapon

> `readonly` **weapon**: [`Item`](https://jsprismarine.dev/api/@jsprismarine/prismarine/item/Item/classes/Item.md) \| `undefined`

Defined in: [packages/prismarine/src/enchantment/melee.ts:27](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/enchantment/melee.ts#L27)

The stack doing the hitting, or undefined for a bare hand.

## Functions

### meleeEnchantmentBonus()

> **meleeEnchantmentBonus**(`input`, `base`): [`MeleeEnchantmentBonus`](#meleeenchantmentbonus)

Defined in: [packages/prismarine/src/enchantment/melee.ts:57](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/enchantment/melee.ts#L57)

The bonus one swing carries.

#### Parameters

##### input

[`MeleeEnchantmentInput`](#meleeenchantmentinput)

##### base

`number`

The weapon's own damage, which `minecraft:damage` folds over.
  The bonus is the difference, because Java scales the base by the attack
  charge and the enchantment part linearly - see `attackDamage` in
  `@jsprismarine/item-behaviors`.

#### Returns

[`MeleeEnchantmentBonus`](#meleeenchantmentbonus)

Zeroes when the server built no content, when the hand is empty, or
  when the weapon carries no enchantment.

***

### meleePostAttackEffects()

> **meleePostAttackEffects**(`input`, `random?`): readonly [`EffectRun`](https://jsprismarine.dev/api/@jsprismarine/enchantments/index.md#effectrun)[]

Defined in: [packages/prismarine/src/enchantment/melee.ts:84](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/enchantment/melee.ts#L84)

The `post_attack` effects a landed blow sets off: the weapon's, which Fire Aspect's ignite is
among, and the victim's armor's, which Thorns' hurt is among.

#### Parameters

##### input

[`MeleeEnchantmentInput`](#meleeenchantmentinput)

##### random?

[`RandomSource`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#randomsource)

#### Returns

readonly [`EffectRun`](https://jsprismarine.dev/api/@jsprismarine/enchantments/index.md#effectrun)[]

Each effect with the side it acts on.

#### Java See

EnchantmentHelper.doPostAttackEffects
