Will It Host? / Valheim

Can you run a Minecraft server in Valheim?

It hosted#9 of 21 by difficulty

Yes. The Valheim process holds port 25565 and the world you connect to is the Valheim world you are standing in. Terrain comes out of Valheim's own generator at one metre per block, so the coastline you sail is the coastline you fly over. Greylings, boars and trolls walk across it as Minecraft mobs at their real positions, your Viking is in there as a Minecraft player, and taking a hit in Valheim takes hearts off you in Minecraft.

verdict
It hosted
A vanilla Minecraft client connected and played on it.
difficulty
#9 of 21
Ranked against everything else in the series, hardest first.
built withC#
protocolMinecraft 1.8.9
read the source on github β†’

How it works

A BepInEx plugin in C#, speaking the Minecraft 1.8.9 protocol from inside the game process. Three threads and one rule: anything that touches Valheim runs on the main thread, where the per-frame pump snapshots game state, builds chunk columns, syncs creatures and drains the chat queues. Heights come from WorldGenerator with Valheim's sea level at 30 lined up against Minecraft's at 62, so the whole range fits in 1.8 without scaling. Creature sync is a diff every 100ms using Entity Teleport rather than relative move, because a charging troll covers more than four blocks between syncs.

The part that nearly stopped it

This is the first host with a world of its own, and it is alive. Earlier episodes made up a flat land and served it. Here the terrain, the creatures, the clock, the weather and your health bar all belong to Valheim and all have to stay in step while you play, off a main thread that is already running a game.

What got it over the line

A chunk budget. Four columns a frame across all players, because sampling 121 columns of noise in one frame stalls the game for a second, and a world that fills in as you fly looks better anyway. The small details took their own passes: a 1.8 client will not render a player it has never seen in the tab list, so your Viking gets a Player List Item immediately before Spawn Player, and Minecraft health stops at half a heart, because at zero a 1.8 client goes to the death screen and this server has no way to bring it back.

What it cannot do

Minecraft 1.8.9, the same target as most of the series. One way, mostly: Valheim to Minecraft is live, Minecraft to Valheim is chat only. The Minecraft side is a read-only view of the terrain function, so breaking a block changes your own screen and nothing else, and your longhouse is not there because the generator gives the ground, not what is standing on it. Mobs are positions: they slide across the ground, they cannot hit you and you cannot hit them. No saving and no inventory.

Why this is possible at all

A Minecraft Java server is a smaller thing than its reputation suggests. It is a socket, a packet codec and a game loop. The client opens one TCP connection, sends a handshake naming its protocol version, moves through login into the play state, and from then on both sides exchange length-prefixed packets describing chunks, entities and movement. None of that needs a game engine. It needs something that can hold a socket open and put the right bytes on it in the right order, which is why Valheim can be made to do it. In every episode the host is the hard part.

Almost every build in this series targets Minecraft 1.8.9 for one specific reason. In 1.8 a chunk is a flat byte array you can send uncompressed. From 1.9 onward chunk data is palette-encoded into bit-packed longs and the connection expects zlib, which is not something you can hand-write in VBA. 1.8.9 is the last release where the whole protocol is within reach of a scripting runtime that was never meant for it.

We have written both halves of that up properly: how the Minecraft server protocol works covers the wire format, and what a Minecraft server actually needs to run covers the four things a real one cannot do without.

Questions

Can Valheim run a Minecraft server?

Yes, as a BepInEx plugin. The plugin runs in the game process, so the socket on port 25565 belongs to Valheim, and it starts when a world loads and stops when you go back to the main menu. Built against Valheim 0.221.12 and Minecraft 1.8.9. The full source is on GitHub.

Is it really the same world?

The terrain is. Minecraft chunks are built by sampling Valheim's own WorldGenerator at one metre per block, with nine biomes mapped to blocks and water filled to sea level, so the island is the island. Creatures are mirrored wherever Valheim has them loaded, which is around your Viking, so fly far enough in Minecraft and you leave them behind.

The rest of the series

See the full Will It Host? board β†’

Or just host it properly

Valheim is not where your survival world should live. AMD Ryzen 9700X, hard-reserved RAM, NVMe, online in under a minute with a free address, DDoS protection and a 7-day money-back guarantee.