[GH-ISSUE #6273] Native mods: an entity mounting or dismounting a vehicle, EntityMountEvent #2040

Closed
opened 2026-11-02 15:51:32 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @levzzz5154 on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6273

Originally assigned to: @levzzz5154 on GitHub.

🤖 Filed by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally.

Part of #4953 ("Entity: tick, mount, size, projectile impact").

A native mod that keeps players out of vehicles (a protected boat, a mount that belongs to its owner, a no-riding region) or keeps them in (a cart ride that can't be left), or that reacts to a mob being seated, has no hook: nothing tells a mod that an entity is about to get on or off a vehicle, and nothing lets it say no.

Vanilla and NeoForge 26.3:

  • Vanilla Entity.startRiding(vehicle, force, sendEventAndTriggers) seats an entity and Entity.removeVehicle/stopRiding lets it off; players and mobs both go through them.
  • NeoForge posts EntityMountEvent (entity mounting, entity being mounted, isMounting) from startRiding (before the canRide check, so a mod sees attempts too) and from removeVehicle (isMounting false). Cancelling means the entity does not mount, or does not dismount.

Horizon has no one startRiding: each vehicle keeps its own rider state (riding for the player, extra.mount for a mob). So the hook is asked at each place an entity is seated or let off, before the state changes:

  • native_entity_mount(dimension, entity, kind, vehicle, vehicle_kind, mounting, canceled) (EntityMountEvent): entity and vehicle are entity ids, with their types (minecraft:player, minecraft:oak_boat, minecraft:horse, minecraft:cushion...). Set canceled and the rider does not board, or keeps riding; a /ride that is canceled fails like vanilla's failed ride.
  • Player boarding: boats, minecarts, cushions, saddled pigs and striders, horses and kin (doPlayerRide), llamas, nautili, happy ghasts, /ride ... mount. Getting off: the sneak/dismount input for each of them, /ride ... dismount, a stab, a buck, a teleport, spectator mode.
  • Mobs: mount_mob (jockeys, raiders on a ravager, /ride) and dismount_mob (/ride, a stab).
  • Not told: a rider whose vehicle is removed or dies, and riders loaded with a save. Server-side only (the single player server thread and a dedicated server); the deprecated in-frame path and clients never fire it.

The dismount guards ask only when the rider is still seated, so a rail that already cleared the seat (activator rail) does not tell the mod about a dismount that did not happen. API from a fragment.

Originally created by @levzzz5154 on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6273 Originally assigned to: @levzzz5154 on GitHub. > 🤖 Filed by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. Part of #4953 ("Entity: tick, mount, size, projectile impact"). A native mod that keeps players out of vehicles (a protected boat, a mount that belongs to its owner, a no-riding region) or keeps them in (a cart ride that can't be left), or that reacts to a mob being seated, has no hook: nothing tells a mod that an entity is about to get on or off a vehicle, and nothing lets it say no. Vanilla and NeoForge 26.3: - Vanilla `Entity.startRiding(vehicle, force, sendEventAndTriggers)` seats an entity and `Entity.removeVehicle`/`stopRiding` lets it off; players and mobs both go through them. - NeoForge posts `EntityMountEvent` (entity mounting, entity being mounted, `isMounting`) from `startRiding` (before the `canRide` check, so a mod sees attempts too) and from `removeVehicle` (`isMounting` false). Cancelling means the entity does not mount, or does not dismount. Horizon has no one `startRiding`: each vehicle keeps its own rider state (`riding` for the player, `extra.mount` for a mob). So the hook is asked at each place an entity is seated or let off, before the state changes: - `native_entity_mount(dimension, entity, kind, vehicle, vehicle_kind, mounting, canceled)` (`EntityMountEvent`): `entity` and `vehicle` are entity ids, with their types (`minecraft:player`, `minecraft:oak_boat`, `minecraft:horse`, `minecraft:cushion`...). Set `canceled` and the rider does not board, or keeps riding; a `/ride` that is canceled fails like vanilla's failed ride. - Player boarding: boats, minecarts, cushions, saddled pigs and striders, horses and kin (`doPlayerRide`), llamas, nautili, happy ghasts, `/ride ... mount`. Getting off: the sneak/dismount input for each of them, `/ride ... dismount`, a stab, a buck, a teleport, spectator mode. - Mobs: `mount_mob` (jockeys, raiders on a ravager, `/ride`) and `dismount_mob` (`/ride`, a stab). - Not told: a rider whose vehicle is removed or dies, and riders loaded with a save. Server-side only (the single player server thread and a dedicated server); the deprecated in-frame path and clients never fire it. The dismount guards ask only when the rider is still seated, so a rail that already cleared the seat (activator rail) does not tell the mod about a dismount that did not happen. API from a fragment.
Author
Owner

@levzzz5154 commented on GitHub (Nov 1, 2026):

/claim

<!-- gh-comment-id:6562264569 --> @levzzz5154 commented on GitHub (Nov 1, 2026): /claim
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2040
No description provided.