Skip to content

server/entity: share the living-entity foundation with the player - #1452

Open
EinBexiii wants to merge 23 commits into
df-mc:masterfrom
EinBexiii:pr/entity-refactor
Open

server/entity: share the living-entity foundation with the player#1452
EinBexiii wants to merge 23 commits into
df-mc:masterfrom
EinBexiii:pr/entity-refactor

Conversation

@EinBexiii

Copy link
Copy Markdown

This is the substance of #1450, with the bug fixes and the UI change pulled out into their own PRs.

A player is an entity, but almost nothing that makes an entity alive sits on the entity side. Damage, armour, effects, air, fall handling, fire ticks, knockback and attack immunity all live on Player, and it's the same logic anything else alive would need, so anything that isn't a player has to duplicate it and the two copies drift apart. This moves that into shared pieces and has the player use them like anything else would: LivingEnt and LivingState as a base, AirSupply and AttackImmunity as components to embed, and FinalDamage, KnockBackVector, ExplosionDamage and Fall as plain functions. Living splits into Damageable and EffectBearer, and player.go gets a good deal shorter along the way.

HandleEntityHurt comes with it because it can't go in alone. There's no single place entity damage passes through upstream, since Hurt sits on Living and every entity implements it itself, so the hook would have nothing to hook into. The shared damage path is what gives it one.

Comment thread server/entity/doc.go
Fall and TickOnFire each named an interface inline in their signature, which
reads as noise and cannot be satisfied on purpose. Both want the same small
thing, an entity that may be hurt, so it is Hurtable now, with FlammableEntity
adding what the fire tick needs on top. CheckEntityLanders returns the distance
it resolved rather than writing through a pointer, and Ent.Unwrap is Ent.Base:
Unwrap reads as error unwrapping in Go, and this returns the embedded base.
@EinBexiii
EinBexiii force-pushed the pr/entity-refactor branch 2 times, most recently from dd8f700 to 5eed4a3 Compare August 30, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants