raspberry pi4_如何将Raspberry Pi 4用作Minecraft Java服务器

raspberry pi4

raspberry pi4

image

My 14 year old got tired of paying $7.99 for Minecraft Realm so he could host his friends in their world. He was just hosting on his laptop and then forwarding a port but that means his friends can't connect unless he's actively running. I was running a Minecraft Server in a Docker container on my Synology NAS but I thought teaching him how to run Minecraft Server on a Raspberry Pi 4 we had lying around would be a good learning moment.

我14岁的我已经厌倦了为Minecraft Realm支付7.99美元,这样他就可以将朋友带入他们的世界。 他只是在笔记本电脑上托管,然后转发端口,但这意味着他的朋友只有在积极运行的情况下才能连接。 我当时在Synology NAS上的Docker容器中运行Minecraft服务器,但我认为教他如何在我们周围的Raspberry Pi 4上运行Minecraft服务器是一个很好的学习时机。

First, set up your Raspberry Pi. I like NOOBS as it's super easy to setup. If you want to make things faster for setup and possibly set up your Pi without having to connect a monitor, mouse, or keyboard, mount your SSD card and create a new empty file named ssh, without any extension, inside the boot directory to enable ssh on boot. Remember the default user name is pi and the password is raspberry.

首先,设置您的Raspberry Pi。 我喜欢NOOBS,因为它非常容易设置。 如果您想使设置过程变得更快,并且可能不需要连接显示器,鼠标或键盘就可以设置Pi,请安装您的SSD卡并在启动目录中创建一个名为ssh且没有任何扩展名的新空文件,以启用在启动时使用ssh。 请记住,默认用户名为pi,密码为raspberry。

SSH over to your Raspberry Pi. You can use Putty, but I like using Windows 10's built-in SSH. Do your standard update stuff, and also install a JDK:

SSH到您的Raspberry Pi。 您可以使用Putty,但我喜欢使用Windows 10的内置SSH 。 进行标准的更新,并安装一个JDK:

sudo apt update
sudo apt upgrade
sudo apt install default-jdk

There are other Minecraft 3rd party Java Servers you can use, the most popular being Spigot, but the easiest server you can run is the one from Minecraft themselves.

您还可以使用其他Minecraft第三方Java服务器,最受欢迎的是Spigot,但是您可以运行的最简单的服务器是Minecraft本身的服务器。

Go to https://www.minecraft.net/en-us/download/server in a browser. It'll say something like "Download minecraft_server.1.16.2.jar and run it with the following command." That version number and URL will change in the future. Right-click and copy link into your clipboard We are going to PASTE it (right click with your mouse) after the "wget" below. So we'll make a folder, download the server.jar, then run it.

在浏览器中转到https://www.minecraft.net/zh-cn/download/server 。 它会说类似“下载minecraft_server.1.16.2.jar并使用以下命令运行它”。 该版本号和URL将来会更改。 右键单击并将链接复制到剪贴板中,我们将在下面的“ wget”之后粘贴(用鼠标右键单击)它。 因此,我们将创建一个文件夹,下载server.jar,然后运行它。

cd ~
mkdir MinecraftServer
cd MinecraftServer
wget https://launcher.mojang.com/v1/objects/c5f6fb23c3876461d46ec380421e42b289789530/server.jar
java -Xmx2500M -Xms2500M -jar server.jar nogui

You'll get a warning that you didn't accept the EULA, so now open "pico eula.txt" and set eula=true, then hit Ctrl-X and Yes to save the new file. Press the up key and run your command again.

您会收到一条警告,提示您您不接受EULA,因此现在请打开“ pico eula.txt”并设置eula = true,然后按Ctrl-X和“是”以保存新文件。 按向上键,然后再次运行命令。

java -Xmx2500M -Xms2500M -jar server.jar nogui

You could also make a start.sh text file with pico then chmod +x to make it an easier single command way to start your server. Since I have a Raspberry Pi 4 with 4g gigs of RAM and it'll be doing just this one server, I felt 2500 megs of RAM was a sweet spot. Java ran out of memory at 3 gigs.

您还可以使用pico然后使用chmod + x创建一个start.sh文本文件,以使其成为启动服务器的更简单的单命令方式。 由于我有一台Raspberry Pi 4,具有4g的RAM,它将仅用于一台服务器,因此我觉得2500兆的RAM是一个不错的选择。 Java的内存不足以3演出。

You can then run ifconfig at and command line and get your Pi's IP address, or type hostname to get its name. Then you can connect to your world with that name or ip.

然后,您可以在命令行上运行ifconfig并获取Pi的IP地址,或者键入hostname以获得其名称。 然后,您可以使用该名称或ip连接到您的世界。

Running Minecraft Servers

复杂世界的性能问题 (Performance Issues with Complex Worlds)

With very large Minecraft worlds or worlds like my son's with 500+ Iron Golems and Chickens, you may get an error like

在非常大的Minecraft世界或类似我儿子的世界中,有500多个铁Iron和小鸡,您可能会遇到类似以下错误

[Server Watchdog/FATAL]: A single server tick took 60.00 seconds (should be max 0.05)

You can workaround this in a few ways. You can gently overclock your Pi4 if it has a fan by adding this to the end of your /boot/config.txt (read articles on overclocking a Pi to be safe)

您可以通过几种方法解决此问题。 您可以通过将Pi4带有风扇的方式轻轻地超频,方法是将其添加到/boot/config.txt的末尾(为了安全起见,请阅读有关对Pi超频的文章)

over_voltage=3
arm_freq=1850

And/or you can disable the Minecraft internal watchdog for ticks by setting max-tick-time to -1 in your server's server.properties file.

和/或您可以通过在服务器的server.properties文件中将max-tick-time设置为-1来禁用Minecraft内部监视程序。

We solved our issue by killing about 480+ Iron Golems with

我们通过杀死约480多个铁Go来解决我们的问题

/kill @e[type=minecraft:iron_golem]

but that's up to you. Just be aware that the Pi is fast but not thousands of moving entities in Minecraft fast. For us this works great though and is teaching my kids about the command line, editing text files, and ssh'ing into things.

但这取决于你。 请注意,Pi是快速的,但Minecraft中却没有成千上万的移动实体。 对于我们来说,这很好用,并且正在教我的孩子们有关命令行,编辑文本文件以及将内容转换成东西的知识。

翻译自: https://www.hanselman.com/blog/how-to-use-a-raspberry-pi-4-as-a-minecraft-java-server

raspberry pi4

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值