Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -414,3 +414,9 @@ build/
tmp*/
_server_asset_probe/
server-data/

# Nix
result
result-*
.direnv/
.xwin-cache/
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

if(NOT WIN32)
message(FATAL_ERROR "This CMake build currently supports Windows only.")
if(NOT WIN32 AND NOT CMAKE_CROSSCOMPILING)
message(FATAL_ERROR "This CMake build currently supports Windows only. For cross-compilation from Linux, use the clang-cl toolchain.")
endif()

if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
Expand Down
116 changes: 114 additions & 2 deletions COMPILE.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,119 @@ cd .\build\windows64\Minecraft.Server\Debug
```

Notes:
- The CMake build is Windows-only and x64-only.
- Contributors on macOS or Linux need a Windows machine or VM to build the project. Running the game via Wine is separate from having a supported build environment.
- Post-build asset copy is automatic for `Minecraft.Client` in CMake (Debug and Release variants).
- The game relies on relative paths (for example `Common\Media\...`), so launching from the output directory is required.

## CMake (Linux x64 Cross-Compile with Clang)

Cross-compile Windows x64 binaries on Linux using LLVM/Clang and the Windows SDK obtained via xwin.

### Prerequisites

Install the following packages (example for Ubuntu):

```bash
sudo apt install clang lld llvm cmake ninja-build rsync cargo
```

Install xwin for downloading the Windows SDK:

```bash
cargo install xwin
```

### Download Windows SDK

Download and extract the Windows SDK and CRT:

```bash
xwin --accept-license splat --output ~/.cache/xwin/splat
```

Create symlinks to account for Linux filesystems being case sensitive:

```bash
WINSDK=~/.cache/xwin/splat
ln -sf $WINSDK/sdk/include/shared/sdkddkver.h $WINSDK/sdk/include/shared/SDKDDKVer.h
ln -sf $WINSDK/sdk/lib/um/x86_64/xinput9_1_0.lib $WINSDK/sdk/lib/um/x86_64/XInput9_1_0.lib
ln -sf $WINSDK/sdk/lib/um/x86_64/ws2_32.lib $WINSDK/sdk/lib/um/x86_64/Ws2_32.lib
```

### Configure

Set environment variables and configure CMake:

```bash
export WINSDK=~/.cache/xwin/splat
export INCLUDE="$WINSDK/crt/include;$WINSDK/sdk/include/um;$WINSDK/sdk/include/ucrt;$WINSDK/sdk/include/shared"
export LIB="$WINSDK/crt/lib/x86_64;$WINSDK/sdk/lib/um/x86_64;$WINSDK/sdk/lib/ucrt/x86_64"

cmake -S . -B build/windows64-clang \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang-cl \
-DCMAKE_CXX_COMPILER=clang-cl \
-DCMAKE_LINKER=lld-link \
-DCMAKE_RC_COMPILER=llvm-rc \
-DCMAKE_MT=llvm-mt \
-DPLATFORM_DEFINES="_WINDOWS64" \
-DPLATFORM_NAME="Windows64" \
-DIGGY_LIBS="iggy_w64.lib;iggyperfmon_w64.lib;iggyexpruntime_w64.lib" \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded \
-DCMAKE_C_FLAGS="/MT -fms-compatibility -fms-extensions --target=x86_64-pc-windows-msvc -imsvc $WINSDK/crt/include -imsvc $WINSDK/sdk/include/ucrt -imsvc $WINSDK/sdk/include/um -imsvc $WINSDK/sdk/include/shared" \
-DCMAKE_CXX_FLAGS="/MT -fms-compatibility -fms-extensions --target=x86_64-pc-windows-msvc -imsvc $WINSDK/crt/include -imsvc $WINSDK/sdk/include/ucrt -imsvc $WINSDK/sdk/include/um -imsvc $WINSDK/sdk/include/shared" \
-DCMAKE_ASM_MASM_FLAGS="-m64" \
-DCMAKE_EXE_LINKER_FLAGS="-libpath:$WINSDK/crt/lib/x86_64 -libpath:$WINSDK/sdk/lib/um/x86_64 -libpath:$WINSDK/sdk/lib/ucrt/x86_64"
```

### Build

Build Release:

```bash
cmake --build build/windows64-clang --config Release
```

Build specific target:

```bash
cmake --build build/windows64-clang --config Release --target Minecraft.Client
cmake --build build/windows64-clang --config Release --target Minecraft.Server
```

### Run with Wine

Run executable:

```bash
cd build/windows64-clang/Minecraft.Client
wine ./Minecraft.Client.exe
```

Run dedicated server:

```bash
cd build/windows64-clang/Minecraft.Server
wine ./Minecraft.Server.exe -port 25565 -bind 0.0.0.0 -name DedicatedServer
```

### NixOS / Nix

For NixOS or systems with Nix installed, use the provided flake:

```bash
nix build .#client
nix build .#server
```

Or enter the development shell with all dependencies:

```bash
nix develop
```

Notes:
- Requires LLVM 15+ with clang-cl, lld-link, llvm-rc, and llvm-mt.
- The xwin tool downloads ~1GB of SDK files on first run.
- Wine is required to run the compiled Windows executables on Linux.
8 changes: 4 additions & 4 deletions Minecraft.Client/AbstractContainerScreen.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "stdafx.h"
#include "AbstractContainerScreen.h"
#include "ItemRenderer.h"
#include "MultiplayerLocalPlayer.h"
#include "MultiPlayerLocalPlayer.h"
#include "Lighting.h"
#include "GameMode.h"
#include "KeyMapping.h"
#include "Options.h"
#include "..\Minecraft.World\net.minecraft.world.inventory.h"
#include "..\Minecraft.World\net.minecraft.locale.h"
#include "..\Minecraft.World\net.minecraft.world.item.h"
#include "../Minecraft.World/net.minecraft.world.inventory.h"
#include "../Minecraft.World/net.minecraft.locale.h"
#include "../Minecraft.World/net.minecraft.world.item.h"

ItemRenderer *AbstractContainerScreen::itemRenderer = new ItemRenderer();

Expand Down
8 changes: 4 additions & 4 deletions Minecraft.Client/AbstractProjectileDispenseBehavior.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "stdafx.h"
#include "..\Minecraft.World\net.minecraft.core.h"
#include "..\Minecraft.World\net.minecraft.world.entity.projectile.h"
#include "..\Minecraft.World\net.minecraft.world.level.tile.h"
#include "..\Minecraft.World\net.minecraft.world.level.h"
#include "../Minecraft.World/net.minecraft.core.h"
#include "../Minecraft.World/net.minecraft.world.entity.projectile.h"
#include "../Minecraft.World/net.minecraft.world.level.tile.h"
#include "../Minecraft.World/net.minecraft.world.level.h"
#include "AbstractProjectileDispenseBehavior.h"

shared_ptr<ItemInstance> AbstractProjectileDispenseBehavior::execute(BlockSource *source, shared_ptr<ItemInstance> dispensed)
Expand Down
2 changes: 1 addition & 1 deletion Minecraft.Client/AbstractProjectileDispenseBehavior.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "..\Minecraft.World\DefaultDispenseItemBehavior.h"
#include "../Minecraft.World/DefaultDispenseItemBehavior.h"

class Projectile;

Expand Down
4 changes: 2 additions & 2 deletions Minecraft.Client/AbstractTexturePack.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "stdafx.h"
#include "Textures.h"
#include "AbstractTexturePack.h"
#include "..\Minecraft.World\InputOutputStream.h"
#include "..\Minecraft.World\StringHelpers.h"
#include "../Minecraft.World/InputOutputStream.h"
#include "../Minecraft.World/StringHelpers.h"
#include "Common/UI/UI.h"

AbstractTexturePack::AbstractTexturePack(DWORD id, File *file, const wstring &name, TexturePack *fallback) : id(id), name(name)
Expand Down
8 changes: 4 additions & 4 deletions Minecraft.Client/AchievementPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#include "Font.h"
#include "Textures.h"
#include "Lighting.h"
#include "..\Minecraft.World\System.h"
#include "..\Minecraft.World\net.minecraft.locale.h"
#include "..\Minecraft.World\net.minecraft.stats.h"
#include "..\Minecraft.World\SharedConstants.h"
#include "../Minecraft.World/System.h"
#include "../Minecraft.World/net.minecraft.locale.h"
#include "../Minecraft.World/net.minecraft.stats.h"
#include "../Minecraft.World/SharedConstants.h"

AchievementPopup::AchievementPopup(Minecraft *mc)
{
Expand Down
8 changes: 4 additions & 4 deletions Minecraft.Client/AchievementScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#include "Textures.h"
#include "StatsCounter.h"
#include "ItemRenderer.h"
#include "..\Minecraft.World\System.h"
#include "..\Minecraft.World\net.minecraft.locale.h"
#include "..\Minecraft.World\net.minecraft.world.level.tile.h"
#include "..\Minecraft.World\JavaMath.h"
#include "../Minecraft.World/System.h"
#include "../Minecraft.World/net.minecraft.locale.h"
#include "../Minecraft.World/net.minecraft.world.level.tile.h"
#include "../Minecraft.World/JavaMath.h"



Expand Down
2 changes: 1 addition & 1 deletion Minecraft.Client/AchievementScreen.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include "Screen.h"
#include "..\Minecraft.World\net.minecraft.stats.h"
#include "../Minecraft.World/net.minecraft.stats.h"
class StatsCounter;

class AchievementScreen : public Screen
Expand Down
4 changes: 2 additions & 2 deletions Minecraft.Client/ArchiveFile.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "stdafx.h"

#include "..\Minecraft.World\StringHelpers.h"
#include "..\Minecraft.World\compression.h"
#include "../Minecraft.World/StringHelpers.h"
#include "../Minecraft.World/compression.h"

#include "ArchiveFile.h"

Expand Down
4 changes: 2 additions & 2 deletions Minecraft.Client/ArchiveFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include <vector>
#include <unordered_map>

#include "..\Minecraft.World\File.h"
#include "..\Minecraft.World\ArrayWithLength.h"
#include "../Minecraft.World/File.h"
#include "../Minecraft.World/ArrayWithLength.h"

using namespace std;

Expand Down
4 changes: 2 additions & 2 deletions Minecraft.Client/ArrowRenderer.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "stdafx.h"
#include "ArrowRenderer.h"
#include "..\Minecraft.World\net.minecraft.world.entity.projectile.h"
#include "..\Minecraft.World\Mth.h"
#include "../Minecraft.World/net.minecraft.world.entity.projectile.h"
#include "../Minecraft.World/Mth.h"

ResourceLocation ArrowRenderer::ARROW_LOCATION = ResourceLocation(TN_ITEM_ARROWS);

Expand Down
2 changes: 1 addition & 1 deletion Minecraft.Client/BatModel.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "stdafx.h"
#include "..\Minecraft.World\net.minecraft.world.entity.ambient.h"
#include "../Minecraft.World/net.minecraft.world.entity.ambient.h"
#include "BatModel.h"
#include "ModelPart.h"

Expand Down
2 changes: 1 addition & 1 deletion Minecraft.Client/BatRenderer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "stdafx.h"
#include "..\Minecraft.World\net.minecraft.world.entity.ambient.h"
#include "../Minecraft.World/net.minecraft.world.entity.ambient.h"
#include "BatRenderer.h"
#include "BatModel.h"

Expand Down
4 changes: 2 additions & 2 deletions Minecraft.Client/BeaconRenderer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "stdafx.h"
#include "..\Minecraft.World\net.minecraft.world.level.tile.entity.h"
#include "..\Minecraft.World\net.minecraft.world.level.h"
#include "../Minecraft.World/net.minecraft.world.level.tile.entity.h"
#include "../Minecraft.World/net.minecraft.world.level.h"
#include "BeaconRenderer.h"
#include "Tesselator.h"

Expand Down
2 changes: 1 addition & 1 deletion Minecraft.Client/BlazeModel.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "stdafx.h"
#include "..\Minecraft.World\Mth.h"
#include "../Minecraft.World/Mth.h"
#include "BlazeModel.h"
#include "ModelPart.h"

Expand Down
2 changes: 1 addition & 1 deletion Minecraft.Client/BlazeRenderer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "stdafx.h"
#include "BlazeModel.h"
#include "..\Minecraft.World\net.minecraft.world.entity.monster.h"
#include "../Minecraft.World/net.minecraft.world.entity.monster.h"
#include "BlazeRenderer.h"

ResourceLocation BlazeRenderer::BLAZE_LOCATION = ResourceLocation(TN_MOB_BLAZE);
Expand Down
4 changes: 2 additions & 2 deletions Minecraft.Client/BoatRenderer.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "stdafx.h"
#include "BoatRenderer.h"
#include "BoatModel.h"
#include "..\Minecraft.World\net.minecraft.world.entity.item.h"
#include "..\Minecraft.World\Mth.h"
#include "../Minecraft.World/net.minecraft.world.entity.item.h"
#include "../Minecraft.World/Mth.h"

ResourceLocation BoatRenderer::BOAT_LOCATION = ResourceLocation(TN_ITEM_BOAT);

Expand Down
2 changes: 1 addition & 1 deletion Minecraft.Client/BookModel.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "stdafx.h"
#include "..\Minecraft.World\Mth.h"
#include "../Minecraft.World/Mth.h"
#include "BookModel.h"
#include "ModelPart.h"

Expand Down
6 changes: 3 additions & 3 deletions Minecraft.Client/BreakingItemParticle.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "stdafx.h"
#include "BreakingItemParticle.h"
#include "Tesselator.h"
#include "..\Minecraft.World\net.minecraft.world.level.tile.h"
#include "..\Minecraft.World\net.minecraft.world.item.h"
#include "..\Minecraft.World\net.minecraft.world.h"
#include "../Minecraft.World/net.minecraft.world.level.tile.h"
#include "../Minecraft.World/net.minecraft.world.item.h"
#include "../Minecraft.World/net.minecraft.world.h"

void BreakingItemParticle::_init(Item *item, Textures *textures, int data)
{
Expand Down
10 changes: 5 additions & 5 deletions Minecraft.Client/BubbleParticle.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "stdafx.h"
#include "BubbleParticle.h"
#include "..\Minecraft.World\Random.h"
#include "..\Minecraft.World\Mth.h"
#include "..\Minecraft.World\JavaMath.h"
#include "..\Minecraft.World\net.minecraft.world.level.h"
#include "..\Minecraft.World\net.minecraft.world.level.material.h"
#include "../Minecraft.World/Random.h"
#include "../Minecraft.World/Mth.h"
#include "../Minecraft.World/JavaMath.h"
#include "../Minecraft.World/net.minecraft.world.level.h"
#include "../Minecraft.World/net.minecraft.world.level.material.h"

BubbleParticle::BubbleParticle(Level *level, double x, double y, double z, double xa, double ya, double za) : Particle(level, x, y, z, xa, ya, za)
{
Expand Down
4 changes: 2 additions & 2 deletions Minecraft.Client/BufferedImage.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "stdafx.h"
#include "..\Minecraft.World\StringHelpers.h"
#include "../Minecraft.World/StringHelpers.h"
#include "Textures.h"
#include "..\Minecraft.World\ArrayWithLength.h"
#include "../Minecraft.World/ArrayWithLength.h"
#include "BufferedImage.h"

#ifdef _XBOX
Expand Down
8 changes: 4 additions & 4 deletions Minecraft.Client/Camera.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "stdafx.h"
#include "Camera.h"
#include "MemoryTracker.h"
#include "..\Minecraft.World\net.minecraft.world.entity.player.h"
#include "..\Minecraft.World\net.minecraft.world.level.h"
#include "..\Minecraft.World\net.minecraft.world.level.tile.h"
#include "..\Minecraft.World\TilePos.h"
#include "../Minecraft.World/net.minecraft.world.entity.player.h"
#include "../Minecraft.World/net.minecraft.world.level.h"
#include "../Minecraft.World/net.minecraft.world.level.tile.h"
#include "../Minecraft.World/TilePos.h"

float Camera::xPlayerOffs = 0.0f;
float Camera::yPlayerOffs = 0.0f;
Expand Down
4 changes: 2 additions & 2 deletions Minecraft.Client/Camera.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include "..\Minecraft.World\FloatBuffer.h"
#include "..\Minecraft.World\IntBuffer.h"
#include "../Minecraft.World/FloatBuffer.h"
#include "../Minecraft.World/IntBuffer.h"


class TilePos;
Expand Down
8 changes: 4 additions & 4 deletions Minecraft.Client/ChatScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#include "ChatScreen.h"
#include "ClientConnection.h"
#include "Font.h"
#include "MultiplayerLocalPlayer.h"
#include "..\Minecraft.World\SharedConstants.h"
#include "..\Minecraft.World\StringHelpers.h"
#include "..\Minecraft.World\ChatPacket.h"
#include "MultiPlayerLocalPlayer.h"
#include "../Minecraft.World/SharedConstants.h"
#include "../Minecraft.World/StringHelpers.h"
#include "../Minecraft.World/ChatPacket.h"

const wstring ChatScreen::allowedChars = SharedConstants::acceptableLetters;
vector<wstring> ChatScreen::s_chatHistory;
Expand Down
Loading