SpawnMinecartInteraction
Package: com.hypixel.hytale.builtin.mounts.interactions
public class SpawnMinecartInteraction extends SimpleBlockInteractionA block interaction that spawns a minecart entity at the target block. Registered on Interaction.CODEC with the key "SpawnMinecart" by MountPlugin.
public static final BuilderCodec<SpawnMinecartInteraction> CODECExtends SimpleBlockInteraction.CODEC with documentation "Spawns a minecart at the target block" and two additional fields:
Model(String) — the model asset ID for the minecart entity. Validated viaModelAsset.VALIDATOR_CACHE.CartInteractions(Map<InteractionType, String>) — map of interaction types to interaction asset IDs for the spawned cart. Validated viaRootInteraction.VALIDATOR_CACHE.
Behavior
Section titled “Behavior”@Overrideprotected void interactWithBlock( @Nonnull World world, @Nonnull CommandBuffer<EntityStore> commandBuffer, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nullable ItemStack itemInHand, @Nonnull Vector3i targetBlock, @Nonnull CooldownHandler cooldownHandler)- Creates a new entity holder.
- Computes the spawn position at the center of the target block.
- Uses the player’s head rotation for initial yaw.
- If the target block has a
RailConfig, aligns the minecart to the rail using thealignToRailmethod (snaps position and rotation to the closest rail segment). - If no rail config, positions the minecart on top of the block’s bounding box.
- Adds
TransformComponent,UUIDComponent,ModelComponent,PersistentModel,BoundingBox,Interactable,Interactions, and MinecartComponent to the holder. - Spawns the entity via
commandBuffer.addEntity().
Rail Alignment
Section titled “Rail Alignment”The private alignToRail method iterates consecutive rail point pairs, projects the target position onto each line segment, finds the closest point within 0.8 distance, and aligns position and rotation to match the rail direction.
simulateInteractWithBlock
Section titled “simulateInteractWithBlock”No-op.
Related Types
Section titled “Related Types”- MinecartComponent — the component added to spawned minecarts
- MountSystems.EnsureMinecartComponents — ensures supporting components post-spawn
- MountPlugin — registers this interaction
Hydex is an independent community resource. Hytale is a trademark of Hypixel Studios. Hydex is not affiliated with or endorsed by Hypixel Studios.