Skip to content

Commit

Permalink
Add Minecraft Bedrock server
Browse files Browse the repository at this point in the history
  • Loading branch information
evilmarty committed Dec 14, 2024
1 parent 4ef36a8 commit 732b96e
Show file tree
Hide file tree
Showing 9 changed files with 446 additions and 11 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/build-minecraft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,25 @@ on:
paths:
- minecraft/Dockerfile
- minecraft/rootfs/**
- minecraft_bedrock/Dockerfile
- minecraft_bedrock/rootfs/**

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
addon: [minecraft, minecraft_bedrock]
steps:
- uses: actions/checkout@v4
- id: config
name: Extract config version
run: |
awk ' /image:/ { print "image=" $2 }' minecraft/config.yaml | tr -d '"' >> "$GITHUB_OUTPUT"
awk ' /version:/ { print "version=" $2 }' minecraft/config.yaml | tr -d '"' >> "$GITHUB_OUTPUT"
awk ' /image:/ { print "image=" $2 }' "$CONFIG_PATH" | tr -d '"' >> "$GITHUB_OUTPUT"
awk ' /version:/ { print "version=" $2 }' "$CONFIG_PATH" | tr -d '"' >> "$GITHUB_OUTPUT"
env:
CONFIG_PATH: "${{ matrix.addon }}/config.yaml"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand All @@ -31,7 +39,7 @@ jobs:
name: Push container
uses: docker/build-push-action@v6
with:
context: minecraft
context: ${{ matrix.addon }}
platforms: linux/amd64
push: true
tags: |
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ A personal repository for home-assistant.io.

These are the addons:

* [Livebook](livebook/README.md) - Run Livebook within Home Assistant.
* [Minecraft](minecraft/README.md) - Run a Minecraft: Java Edition Server within Home Assistant.
* [Sonarr](sonarr/README.md) - Run Sonarr within Home Assistant.
* [Radarr](radarr/README.md) - Run Radarr within Home Assistant.
* [Lidarr](lidarr/README.md) - Run Lidarr within Home Assistant.
* [SABnzbd](sabnzbd/README.md) - Run SABnzbd within Home Assistant.
* [Eufy Security](eufy-security/README.md) - Eufy Security MQTT Gateway.
* [Let's Encrypt](letsencrypt/README.md) - Similar to the official addon but uses the Let's Encrypt Go Client, which supports more DNS providers. **Unmaintained**
- [Livebook](livebook/README.md) - Run Livebook within Home Assistant.
- [Minecraft (Java)](minecraft/README.md) - Run a Minecraft: Java Edition Server within Home Assistant.
- [Minecraft (Bedrock)](minecraft_bedrock/README.md) - Run a Minecraft: Bedrock Edition Server within Home Assistant.
- [Sonarr](sonarr/README.md) - Run Sonarr within Home Assistant.
- [Radarr](radarr/README.md) - Run Radarr within Home Assistant.
- [Lidarr](lidarr/README.md) - Run Lidarr within Home Assistant.
- [SABnzbd](sabnzbd/README.md) - Run SABnzbd within Home Assistant.
- [Eufy Security](eufy-security/README.md) - Eufy Security MQTT Gateway.
- [Let's Encrypt](letsencrypt/README.md) - Similar to the official addon but uses the Let's Encrypt Go Client, which supports more DNS providers. **Unmaintained**
29 changes: 29 additions & 0 deletions minecraft_bedrock/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ubuntu:noble
ARG BASHIO_VERSION="0.14.3"
ARG BEDROCK_SERVER_VERSION="1.21.51.01"
ARG BUILD_VERSION="${BEDROCK_SERVER_VERSION}"
ARG BUILD_ARCH="amd64"
ENV LD_LIBRARY_PATH /opt/minecraft
COPY rootfs /
WORKDIR /opt/minecraft/
RUN apt-get update \
&& apt-get install -y --no-install-recommends jq curl ca-certificates unzip \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /usr/src/*
RUN mkdir -p /usr/src/bashio \
&& curl -s -L "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \
| tar -xzf - --strip 1 -C /usr/src/bashio \
&& mv /usr/src/bashio/lib /usr/lib/bashio \
&& ln -s /usr/lib/bashio/bashio /usr/bin/bashio
RUN curl -L \
-H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.2903.86" \
-O "https://www.minecraft.net/bedrockdedicatedserver/bin-linux/bedrock-server-${BEDROCK_SERVER_VERSION}.zip" \
&& unzip -q bedrock-server-${BEDROCK_SERVER_VERSION}.zip \
&& rm -f bedrock-server-${BEDROCK_SERVER_VERSION}.zip
CMD ["/opt/minecraft/run.sh"]
VOLUME /data /share
WORKDIR /data
LABEL \
io.hass.version="${BUILD_VERSION}" \
io.hass.type="addon" \
io.hass.arch="${BUILD_ARCH}"
29 changes: 29 additions & 0 deletions minecraft_bedrock/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Home Assistant Add-on: Minecraft

Minecraft servers allow players to play online or via a local area network with other people. Internally, the game runs a server for single-player games, this was done in order to make the single-player game experience consistent with the multiplayer experience and make it so that changes made to the game such as bug fixes apply to both single-player games and multiplayer games.

![Supports amd64 Architecture][amd64-shield]

## About

This add-on allows you to run Minecraft: Bedrock Edition server within Home Assistant.

## Installation

Follow these steps to get the add-on installed on your system:

1. Navigate in your Home Assistant frontend to Supervisor -> Add-on Store.
2. Find the "Minecraft: Bedrock Edition Server" add-on and click it.
3. Click on the "INSTALL" button.

## How to use

Update the configuration to your specification and then start the add-on.

## Configuration

Via the application's settings page.

## Support

While there is no warranty or support, you are welcome to raise an [Issue](https://github.com/evilmarty/hassio-addons/issues).
80 changes: 80 additions & 0 deletions minecraft_bedrock/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: "Minecraft: Bedrock Edition Server"
version: "1.21.51.01-a"
slug: "minecraft_bedrock"
description: "Run a private server for Minecraft: Bedrock Edition."
url: "https://github.com/evilmarty/hassio-addons/tree/master/minecraft_bedrock"
image: "ghcr.io/evilmarty/hassio-minecraft-bedrock"
arch:
- amd64
startup: "application"
init: true
boot: "auto"
watchdog: "tcp://[HOST]:[PORT:19132]"
ports:
"19132/tcp": 19132
"19133/tcp": 19133
ports_description:
"19132/tcp": "Used for gameplay and LAN discovery"
"19133/tcp": "Used for gameplay"
map:
- config:rw
environment:
PUID: "0"
PGID: "0"
options:
server-name: My World
gamemode: survival
force-gamemode: false
difficulty: easy
allow-cheats: false
max-players: 10
level-name: Bedrock level
online-mode: true
allow-list: false
view-distance: 32
player-idle-timeout: 30
max-threads: 8
tick-distance: 4
default-player-permission-level: member
texturepack-required: false
compression-threshold: 1
compression-algorithm: zlib
server-authoritative-movement: server-auth
player-position-acceptance-threshold: 0.5
player-movement-action-direction-threshold: 0.85
server-authoritative-block-breaking: false
server-authoritative-block-breaking-pick-range-scalar: 1.5
chat-restriction: None
disable-player-interaction: false
client-side-chunk-generation-enabled: true
block-network-ids-are-hashes: true
disable-custom-skins: false
schema:
server-name: str
gamemode: list(survival|creative|adventure|spectator)
force-gamemode: bool
difficulty: list(peaceful|easy|normal|hard)
allow-cheats: bool
max-players: int(0,)
level-name: str
level-seed: str?
online-mode: bool
allow-list: bool
view-distance: int(3,32)
player-idle-timeout: int
max-threads: int(0,)
tick-distance: int(4,12)
default-player-permission-level: list(visitor|member|operator)
texturepack-required: bool
compression-threshold: int(0,)
compression-algorithm: list(zlib|snappy)
server-authoritative-movement: list(client-auth|server-auth|server-auth-with-rewind)
player-position-acceptance-threshold: float(0.0,)
player-movement-action-direction-threshold: float
server-authoritative-block-breaking: bool
server-authoritative-block-breaking-pick-range-scalar: float(1.0,)
chat-restriction: list(None|Dropped|Disabled)
disable-player-interaction: bool
client-side-chunk-generation-enabled: bool
block-network-ids-are-hashes: bool
disable-custom-skins: bool
Binary file added minecraft_bedrock/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added minecraft_bedrock/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions minecraft_bedrock/rootfs/opt/minecraft/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bashio

SERVER_PROPERTIES_PATH="server.properties"
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
BIN_PATH="${SCRIPT_DIR}/bedrock_server"
SERVER_FOLDERS=("behavior_packs" "definitions" "resource_packs")

main() {
bashio::log.debug "Working directory is ${PWD}"

write_server_properties "${SERVER_PROPERTIES_PATH}"
add_ports_to_server_properties "${SERVER_PROPERTIES_PATH}"
copy_folders_to_working_dir "$SCRIPT_DIR" "${SERVER_FOLDERS[@]}"

bashio::log.debug "Starting bedrock server..."
exec "$BIN_PATH"
}

write_server_properties() {
local path config
path="$1"
config=$(bashio::addon.config)
bashio::jq "${config}" 'to_entries|map("\(.key)=\(.value)")|join("\n")' >"${path}"
bashio::log.debug "Updated ${path} with config"
}

add_ports_to_server_properties() {
local path port portv6
path="$1"
port=$(bashio::addon.port 19132)
portv6=$(bashio::addon.port 19133)

touch "$path"
echo "server-port=${port}" >>"$path"
echo "server-portv6=${portv6}" >>"$path"
bashio::log.debug "Added server ports to ${path}"
}

copy_folders_to_working_dir() {
local src item
src="$1"
for item in "${@:1}"; do
bashio::log.debug "Checking if working directory has ${item}..."
if [ ! -d "$item" ]; then
bashio::log.debug "Copying ${item} to working directory"
cp -r "${src}/${item}" .
fi
done
}

main "$@"
Loading

0 comments on commit 732b96e

Please sign in to comment.