Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Damage outside LivingEntity

Verified against Minecraft 26.3 · Reference · Hand-kept from net/minecraft/world/entity/**.

Entity.hurtServer is abstract, so every branch has to answer for itself. The twenty-two classes are every non-LivingEntity class that declares it, and none of them runs LivingEntity’s rules itself — no armour, no hurt cooldown, no CombatTracker, no death sequence. The lecture that frames them is damage and death; this is the per-class table.

The last column is the client half. Entity.hurtClient has a default — it returns false — and thirteen of the twenty-two inherit it unchanged; eight declare their own and MinecartTNT inherits VehicleEntity’s. It is never handed the damage amount — Entity.hurtOrSimulate drops it on the client — and it answers whether the client should play a hit’s effects itself, for its own swing and for a projectile hit it simulates.

A swing reaches about half of these. The client picks only an entity whose Entity.isPickable is true, which among the twenty-two is Interaction, PrimedTnt, FallingBlockEntity, the three projectiles a player can deflect, the attached blocks, EndCrystal, ShulkerBullet, EnderDragonPart and the vehicles. Two gates follow in Player.attack, which the client runs as it sends the attack and the server runs again — Player.cannotAttack and Player.deflectProjectile (the sword swing owns both). The first refuses a class whose Entity.isAttackable is false (EyeOfEnder, FallingBlockEntity, ExperienceOrb, ItemEntity, and in the projectile row a firework, every arrow and a thrown trident — though the server disconnects a player whose attack names an item, an orb or an arrow before Player.attack runs) or whose Entity.skipAttackInteraction answers true (Interaction while its response flag is off; BlockAttachedEntity answers true outright for a player who may not interact at its position, and otherwise by running its own hurt with no damage). The second deflects those three projectiles, except a player’s WindCharge in its first five ticks, which refuses. Three rows below name their gate in the second column; PrimedTnt is the one nothing row a swing always reaches, and Interaction with its response flag on and a wind charge in its first five ticks reach theirs too; each Entity.hurtServer then does nothing. Entity.hurtOrSimulate is what Player.attack calls after the gates, and it picks Entity.hurtServer or Entity.hurtClient off the level.

classwhat it checks firstwhat it doesreturnsEntity.hurtClient
AreaEffectCloud—nothingfalsefalse
Display—nothingfalsefalse
Interactionnot reached while its response flag is off — Entity.skipAttackInteraction answers the flag’s negation, after recording the attackernothingfalsefalse
LightningBolt—nothingfalsefalse
Marker—nothingfalsefalse
OminousItemSpawner—nothingfalsefalse
PrimedTnt—nothing: a lit TNT block cannot be shot out of the airfalsefalse
EvokerFangs—nothingfalsefalse
EyeOfEndernever reached — Entity.isAttackable returns falsenothingfalsefalse
AbstractHurtingProjectilenot reached but by a player’s wind charge in its first five ticks — a large fireball or a wind charge is otherwise deflected, and the rest are unhittable by Entity.isPickablenothingfalsefalse
ProjectileEntity.isInvulnerableToBaseEntity.markHurt only, so the client is sent the entity’s motion again and nothing changesfalsefalse
FallingBlockEntityEntity.isInvulnerableToBaseEntity.markHurt onlyfalsefalse
ExperienceOrbEntity.isInvulnerableToBasesubtracts the damage from an int of health, Entity.discard at zerotruenot invulnerable
ItemEntityEntity.isInvulnerableToBase, then a Mob source under GameRules.MOB_GRIEFING, then ItemStack.canBeHurtBysame int of health, plus GameEvent.ENTITY_DAMAGE, and ItemStack.onDestroyed before the discardtruenot invulnerable, and ItemStack.canBeHurtBy agrees
BlockAttachedEntityEntity.isInvulnerableToBase, then a Mob source under GameRules.MOB_GRIEFINGBlockAttachedEntity.kill, Entity.markHurt, and BlockAttachedEntity.dropItem — one hit, whatever the amount; a leash knot’s drop is only a soundtruenot invulnerable
Cushiona Player source that may not build, or may not interact at the cushion’s position, is refusedotherwise BlockAttachedEntity’s one hittrue, or false when refused or under BlockAttachedEntity’s own gatesfalse for a player who may not build, then BlockAttachedEntity’s
ItemFrameItemFrame.fixed gates everything: a fixed frame is hurt only by DamageTypeTags.BYPASSES_INVULNERABILITY or a creative playera non-explosion hit on a frame holding something pops the item and stops there; otherwise it falls through to BlockAttachedEntity and the frame breakstruethe fixed gate first, then not invulnerable
EndCrystalEntity.isInvulnerableToBase, then is the source an EnderDragonremoves itself with Entity.RemovalReason.KILLED and explodes with power 6 — unless the source was already an explosion — then EndCrystal.onDestroyedBytruenot invulnerable, and not the dragon
ShulkerBullet—plays SoundEvents.SHULKER_BULLET_HURT, spawns fifteen ParticleTypes.CRIT, destroys itselftruetrue, unconditionally
EnderDragonPartEntity.isInvulnerableToBaseforwards the whole call to EnderDragon.hurt with itself as the part that was hitthe parent’s answerfalse
VehicleEntityalready removed, then Entity.isInvulnerableToBaseVehicleEntity.setDamage adds damage × 10, after flipping the hurt direction and setting ten ticks of hurt time; past 40 it is destroyed. A creative player gets all of that too, and then the vehicle is discarded at once whatever the accumulator reads — Entity.discard, which drops nothingtruetrue, unconditionally
MinecartTNTa burning AbstractArrow as the direct entity explodes it, scaled by the arrow’s speedon that path, nothing else when GameRules.TNT_EXPLODES is on or the cart is primed: the explosion calls Entity.discard, so VehicleEntity.hurtServer returns at its already-removed test. Any other source runs VehicleEntity.hurtServer, except that a fire or explosion source or a burning projectile goes straight to MinecartTNT.destroy, which lights the fuse, even for a creative playertrueinherited: true

Six patterns account for all of it: nothing happens (ten classes), a motion resend and nothing else (two), an int of health with no armour and no hurt cooldown (two), one hit destroys (five, though a non-explosion hit on an unfixed frame holding something takes only the item), an accumulator (two), and forward it to something else (one, the dragon part). Only four classes read the damage amount at all: the pair with an int of health and the accumulator pair. EnderDragonPart passes the number on without looking at it, and everything else is a yes-or-no.


Rules: names, never code · how the system works, not how the code reads · newest version only · every backticked name passes tools/verify_names.py.