Skip to content

Spear 5.46.0 ​

class · pocketmine\item\Spear · source

Extends TieredTool
Implements Releasable

Spears (https://minecraft.wiki/w/Spear). Jab = normal attack; holding "use" charges and hits whatever the spear points at, dealing damage proportional to the relative speed.

Bedrock stats per tier (jab damage / durability / enchantability = the tier's sword damage - 3 / tool durability / tool enchantability): wooden 2/60/15, stone 3/132/5, copper 3/191/13, iron 4/251/14, golden 2/33/22, diamond 5/1562/10, netherite 6/2032/15. The jab starts a use cooldown shared by all spears (13/15/17/19/19/21/23 ticks).

Charge attack: after an activation delay the spear is "engaged" (damage + knockback, and the target is knocked off its mount), then "tired" (damage + knockback), then "disengaged" (damage only), then the charge ends. Damage = tier multiplier * relative speed in blocks/second, not affected by Strength or Weakness; Bedrock waits 10 ticks between charge hits. Not documented for Bedrock, so Java values are used: minimum speed for damage 4.6 b/s and for knockback 5.1 b/s (wooden spear values, applied to every tier); durability loss per hit (1, like swords).

Lunge (https://minecraft.wiki/w/Lunge): each jab pushes the player 0.458 blocks/tick per level horizontally along where it looks, costs 4 exhaustion per level and 1 durability; needs at least 7 hunger points and doesn't work while gliding or in water.

Constants ​

CHARGE_HIT_INTERVAL_TICKS ​

php
public const CHARGE_HIT_INTERVAL_TICKS = 10

CHARGE_MIN_DAMAGE_SPEED ​

php
public const CHARGE_MIN_DAMAGE_SPEED = 4.6

CHARGE_MIN_KNOCKBACK_SPEED ​

php
public const CHARGE_MIN_KNOCKBACK_SPEED = 5.1

CHARGE_REACH ​

php
public const CHARGE_REACH = 4.0

LUNGE_EXHAUSTION_PER_LEVEL ​

php
public const LUNGE_EXHAUSTION_PER_LEVEL = 4.0

LUNGE_IMPULSE_PER_LEVEL ​

php
public const LUNGE_IMPULSE_PER_LEVEL = 0.458

LUNGE_MIN_FOOD ​

php
public const LUNGE_MIN_FOOD = 7

STAGE_DISENGAGED ​

php
public const STAGE_DISENGAGED = 3

STAGE_ENDED ​

php
public const STAGE_ENDED = 4

STAGE_ENGAGED ​

php
public const STAGE_ENGAGED = 1

STAGE_NONE ​

php
public const STAGE_NONE = 0

STAGE_TIRED ​

php
public const STAGE_TIRED = 2

Methods ​

calculateChargeDamage() ​

php
public function calculateChargeDamage(float $relativeSpeed) : float

Returns the damage of a charge hit at the given relative speed (blocks/second), or 0 if too slow.

canChargeKnockBack() ​

php
public static function canChargeKnockBack(int $stage, float $relativeSpeed) : bool

canStartUsingItem() ​

php
public function canStartUsingItem(\pocketmine\player\Player $player) : bool

getAttackPoints() ​

php
public function getAttackPoints() : int

getChargeDamageMultiplier() ​

php
public function getChargeDamageMultiplier() : float

Returns the charge damage per block/second of relative speed.

getChargeStage() ​

php
public function getChargeStage(int $useDuration) : int

Returns the charge stage (STAGE_*) after holding the spear for the given number of ticks.

getChargeTimings() ​

php
public function getChargeTimings() : array

Returns the ticks the use button must be held before the charge starts hitting, followed by the durations of the engaged, tired and disengaged stages.

getCooldownTag() ​

php
public function getCooldownTag() : ?string

getJabCooldownTicks() ​

php
public function getJabCooldownTicks() : int

Returns the use cooldown started by a jab, in ticks (Bedrock).

getLungeImpulse() ​

php
public function getLungeImpulse() : float

Returns the horizontal speed (blocks/tick) a jab with Lunge gives, or 0 without Lunge.

isValidRepairMaterial() ​

php
public function isValidRepairMaterial(\pocketmine\item\Item $item) : bool

Returns whether the given item can repair this spear in an anvil.

onAttackEntity() ​

php
public function onAttackEntity(\pocketmine\entity\Entity $victim, array &$returnedItems) : bool

onDestroyBlock() ​

php
public function onDestroyBlock(\pocketmine\block\Block $block, array &$returnedItems) : bool

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.