Interface CombatService
public interface CombatService
The combat rules: hits, damage, blocking, knockback and death, registered as a
service so plugins can replace them.
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptionbooleanattack(LivingEntity attacker, Entity target) Makes an entity hit another with the item in its main hand, as a player does when they click an entity, or a mob when it strikes its target.intattackCooldownTicks(Player attacker) Returns the ticks a swing of this player takes to recharge, from their attack speed.floatattackDamage(LivingEntity attacker) Returns the damage a fully charged melee hit of this entity deals, before enchantments.doubleattackKnockback(LivingEntity attacker) Returns the extra knockback a melee hit of this entity deals.floatattackStrengthScale(Player attacker) Returns the charge of the next hit of a player, between0and1.booleandamage(LivingEntity target, DamageSource source, float amount) Hurts an entity, running the full pipeline: invulnerability frames, shield, armor, Resistance, enchantments, absorption, events, client packets and death.voiddisableBlocking(LivingEntity entity, float seconds) Lowers the shield of an entity and keeps it from raising it again for a while, as an axe does.booleanisBlocking(LivingEntity entity) Returnstrueif this entity holds a raised shield, past its raising delay, that is not disabled.voidkill(LivingEntity target, @Nullable Entity killer) Kills an entity outright, bypassing armor, shields, totems and invulnerability.voidknockback(LivingEntity target, double strength, double fromX, double fromZ) Pushes an entity away from a point, the way a hit does.booleanpvpEnabled(World world) sources()Returns the factory of the damage sources this service understands.
-
Method Details
-
sources
DamageSourceFactory sources()Returns the factory of the damage sources this service understands.- Returns:
- the factory of the damage sources this service understands
- Since:
- 0.1.0
-
attack
Makes an entity hit another with the item in its main hand, as a player does when they click an entity, or a mob when it strikes its target.- Parameters:
attacker- the entity swingingtarget- the entity being hit- Returns:
trueif damage was actually dealt- Since:
- 0.1.0
-
damage
Hurts an entity, running the full pipeline: invulnerability frames, shield, armor, Resistance, enchantments, absorption, events, client packets and death.- Parameters:
target- the entity taking the hitsource- the origin of the damageamount- damage in half-hearts before reduction; values<= 0are ignored- Returns:
trueif the hit hurt the entity, even when armor took all of it;falsewhen it was refused or cancelled, absorbed by the invulnerability left by the last hit, or blocked by a shield- Since:
- 0.1.0
-
knockback
Pushes an entity away from a point, the way a hit does.- Parameters:
target- the entity to pushstrength- the horizontal knockback strength;<= 0does nothingfromX- the x coordinate the push originates fromfromZ- the z coordinate the push originates from- Since:
- 0.1.0
-
kill
Kills an entity outright, bypassing armor, shields, totems and invulnerability.- Parameters:
target- the entity to killkiller- the entity credited with the kill, ornull- Since:
- 0.1.0
-
attackDamage
Returns the damage a fully charged melee hit of this entity deals, before enchantments.: itsminecraft:attack_damageattribute, the weapon in its main hand and its effects included- Parameters:
attacker- the attacking entity- Returns:
- the damage a fully charged melee hit of this entity deals, before enchantments
- Since:
- 0.1.0
-
attackKnockback
Returns the extra knockback a melee hit of this entity deals.: itsminecraft:attack_knockbackattribute, plus one for a sprinting player- Parameters:
attacker- the attacking entity- Returns:
- the extra knockback a melee hit of this entity deals
- Since:
- 0.1.0
-
attackStrengthScale
Returns the charge of the next hit of a player, between0and1.- Parameters:
attacker- the attacking player- Returns:
- the charge of the next hit of a player, between
0and1 - Since:
- 0.1.0
-
attackCooldownTicks
Returns the ticks a swing of this player takes to recharge, from their attack speed.- Parameters:
attacker- the attacking player- Returns:
- the ticks a swing of this player takes to recharge, from their attack speed
- Since:
- 0.1.0
-
isBlocking
Returnstrueif this entity holds a raised shield, past its raising delay, that is not disabled.- Parameters:
entity- the entity- Returns:
trueif this entity holds a raised shield, past its raising delay, that is not disabled- Since:
- 0.1.0
-
disableBlocking
Lowers the shield of an entity and keeps it from raising it again for a while, as an axe does.- Parameters:
entity- the entityseconds- how long the shield stays disabled;<= 0does nothing- Since:
- 0.1.0
-
pvpEnabled
- Parameters:
world- the world- Returns:
truewhen players are allowed to damage each other in this world- Since:
- 0.1.0
-