当前位置:   article > 正文

自己搭建一台MC服务器

mc服务器

你有没有这种想法:

想用自己在网上下载的皮肤,但是网易版不支持,用PCL2、HMCL或BakaXL又不能联机(2023年2月27日)

想自己开一个服务器,让自己成为OP大佬。

内网穿透复杂而贵。

.......

那么,接下来,让我们一步步搭建MC服务器吧!

  1. 首先,准备工作不能少,以下为要准备的东西:

  1. Windows11/10电脑
  2. 正版账号(可有可无)
  3. Minecraft 1.19.3服务器JAR文件(链接:https://piston-data.mojang.com/v1/objects/c9df48efed58511cdd0213c56b9013a7b5c9ac1f/server.jar)
  4. Java19/18
  5. 一个https://frp.starryfrp.com/账号(星空内网穿透账号)
  1. 验证,首先,没有电脑的快去买吧!没正版的我不敢保证可以运行。JAR文件直接点链接。JAVA安装请看下面的教程:

a. 下载安装包,链接:https://download.java.net/java/GA/jdk19.0.2/fdb695a9d9064ad6b064dc6df578380c/7/GPL/openjdk-19.0.2_windows-x64_bin.zip

b. 按照提示一步步来。

  1. 按下Win+R,或者按下Win+X,选择PowerShell或CMD(最好是管理员),输入java -version,如果出现类似于:

java version "19.0.2" 2023-01-17

Java(TM) SE Runtime Environment (build 19.0.2+7-44)

Java HotSpot(TM) 64-Bit Server VM (build 19.0.2+7-44, mixed mode, sharing)

的话就是安装成功,如果出现未知的命令就要按照此方法一步步配置了:

a. 在Windows搜索框里搜索高级系统设置,点击,选择环境变量,点击系统变量中的Path,

点击编辑。

b. 点击新建,输入你的Java安装路径(比如:C:\Program Files\Common Files\Oracle\Java\javapath)

c. 点击新建,输入你的Java安装路径(比如:C:\ProgramData\Oracle\Java\javapath)

  1. 注册账号,看前面。

  1. 前面准备工作做完了,开始真正的搭建吧!

  1. 将下载好的server.jar拷贝至一个空文件夹,将CMD或 PowerShell位置导在那里,输入指令(内存大于6G):

java -server -XX:+UseG1GC  -Xmx4096M -Xms1024M -jar G:/Minecraft_Sever/server.jar nogui
  1. 结束后编辑eula.txt,将false改为true。

  1. 重新运行指令,应出现如下内容:

  1. Starting net.minecraft.server.Main
  2. [11:59:25] [ServerMain/INFO]: Building unoptimized datafixer
  3. [11:59:26] [ServerMain/WARN]: You specified a resource pack without providing a sha1 hash. Pack will be updated on the client only if you change the name of the pack.
  4. [11:59:26] [ServerMain/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
  5. [11:59:28] [ServerMain/INFO]: Loaded 7 recipes
  6. [11:59:28] [ServerMain/INFO]: Loaded 1179 advancements
  7. ^N^N[11:59:29] [Server thread/INFO]: Starting minecraft server version 1.19.3
  8. [11:59:29] [Server thread/INFO]: Loading properties
  9. [11:59:29] [Server thread/INFO]: Default game type: SURVIVAL
  10. [11:59:29] [Server thread/INFO]: Generating keypair
  11. [11:59:29] [Server thread/INFO]: Starting Minecraft server on *:12486
  12. [11:59:29] [Server thread/INFO]: Using default channel type
  13. [11:59:29] [Server thread/WARN]: **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!
  14. [11:59:29] [Server thread/WARN]: The server will make no attempt to authenticate usernames. Beware.
  15. [11:59:29] [Server thread/WARN]: While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.
  16. [11:59:29] [Server thread/WARN]: To change this, set "online-mode" to "true" in the server.properties file.
  17. [11:59:29] [Server thread/INFO]: Preparing level "world"
  18. [11:59:31] [Server thread/INFO]: Preparing start region for dimension minecraft:overworld
  19. [11:59:34] [Worker-Main-5/INFO]: Preparing spawn area: 0%
  20. [11:59:34] [Worker-Main-5/INFO]: Preparing spawn area: 0%
  21. [11:59:34] [Worker-Main-5/INFO]: Preparing spawn area: 0%
  22. [11:59:34] [Worker-Main-5/INFO]: Preparing spawn area: 0%
  23. [11:59:34] [Worker-Main-5/INFO]: Preparing spawn area: 0%
  24. [11:59:34] [Worker-Main-5/INFO]: Preparing spawn area: 0%
  25. [11:59:34] [Worker-Main-5/INFO]: Preparing spawn area: 0%
  26. [11:59:34] [Worker-Main-4/INFO]: Preparing spawn area: 13%
  27. [11:59:35] [Worker-Main-6/INFO]: Preparing spawn area: 95%
  28. [11:59:35] [Server thread/INFO]: Time elapsed: 4053 ms
  29. [11:59:35] [Server thread/INFO]: Done (5.573s)! For help, type "help"
  30. [11:59:35] [Server thread/INFO]: Starting GS4 status listener
  31. [11:59:35] [Server thread/INFO]: Thread Query Listener started
  32. [11:59:35] [Query Listener #1/INFO]: Query running on 0.0.0.0:25565
  33. [12:05:00] [Server thread/INFO]: John_MC_Python[/127.0.0.1:65441] logged in with entity id 181 at (-5.5, 70.0, -7.5)
  34. [12:05:00] [Server thread/INFO]: John_MC_Python joined the game
  35. [12:05:30] [Server thread/INFO]: John_MC_Python lost connection: Disconnected
  36. [12:05:30] [Server thread/INFO]: John_MC_Python left the game
  37. op
  38. [12:06:12] [Server thread/INFO]: Unknown or incomplete command, see below for error
  39. [12:06:12] [Server thread/INFO]: op<--[HERE]
  40. [12:06:45] [Server thread/INFO]: John_MC_Python[/127.0.0.1:65478] logged in with entity id 239 at (-5.5, 70.0, -7.5)
  41. [12:06:45] [Server thread/INFO]: John_MC_Python joined the game
  42. op John_MC_Python
  43. [12:07:19] [Server thread/INFO]: Made John_MC_Python a server operator
  44. [12:07:36] [Server thread/INFO]: [John_MC_Python: Set the time to 1000]
  45. [12:07:43] [Server thread/INFO]: [John_MC_Python: Set the weather to clear]
  46. [12:10:51] [Server thread/INFO]: John_MC_Python lost connection: Disconnected
  47. [12:10:51] [Server thread/INFO]: John_MC_Python left the game
  48. stop
  49. [12:22:17] [Server thread/INFO]: Stopping the server
  50. [12:22:17] [Server thread/INFO]: Stopping server
  51. [12:22:17] [Server thread/INFO]: Saving players
  52. [12:22:17] [Server thread/INFO]: Saving worlds
  53. [12:22:19] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:overworld
  54. [12:22:24] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_nether
  55. [12:22:24] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_end
  56. [12:22:24] [Server thread/INFO]: ThreadedAnvilChunkStorage (world): All chunks are saved
  57. [12:22:24] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
  58. [12:22:24] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
  59. [12:22:24] [Server thread/INFO]: ThreadedAnvilChunkStorage: All dimensions are saved
  60. [12:22:24] [Server thread/INFO]: Thread Query Listener stopped
  61. G:\Minecraft_Sever>java -server -XX:+UseG1GC -Xmx4096M -Xms1024M -jar G:/Minecraft_Sever/server.jar
  62. Starting net.minecraft.server.Main
  63. [12:22:35] [ServerMain/INFO]: Building unoptimized datafixer
  64. [12:22:36] [ServerMain/WARN]: You specified a resource pack without providing a sha1 hash. Pack will be updated on the client only if you change the name of the pack.
  65. [12:22:36] [ServerMain/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
  66. [12:22:38] [ServerMain/INFO]: Loaded 7 recipes
  67. [12:22:38] [ServerMain/INFO]: Loaded 1179 advancements
  68. [12:22:40] [Server thread/INFO]: Starting minecraft server version 1.19.3
  69. [12:22:40] [Server thread/INFO]: Loading properties
  70. [12:22:40] [Server thread/INFO]: Default game type: SURVIVAL
  71. [12:22:40] [Server thread/INFO]: Generating keypair
  72. [12:22:40] [Server thread/INFO]: Starting Minecraft server on *:12486
  73. [12:22:40] [Server thread/INFO]: Using default channel type
  74. [12:22:40] [Server thread/WARN]: **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!
  75. [12:22:40] [Server thread/WARN]: The server will make no attempt to authenticate usernames. Beware.
  76. [12:22:40] [Server thread/WARN]: While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.
  77. [12:22:40] [Server thread/WARN]: To change this, set "online-mode" to "true" in the server.properties file.
  78. [12:22:40] [Server thread/INFO]: Preparing level "world"
  79. [12:22:42] [Server thread/INFO]: Preparing start region for dimension minecraft:overworld
  80. [12:22:45] [Worker-Main-5/INFO]: Preparing spawn area: 0%
  81. [12:22:45] [Worker-Main-5/INFO]: Preparing spawn area: 0%
  82. [12:22:45] [Worker-Main-4/INFO]: Preparing spawn area: 0%
  83. [12:22:45] [Worker-Main-4/INFO]: Preparing spawn area: 0%
  84. [12:22:45] [Worker-Main-4/INFO]: Preparing spawn area: 0%
  85. [12:22:45] [Worker-Main-4/INFO]: Preparing spawn area: 0%
  86. [12:22:45] [Worker-Main-1/INFO]: Preparing spawn area: 8%
  87. [12:22:46] [Worker-Main-7/INFO]: Preparing spawn area: 89%
  88. [12:22:46] [Server thread/INFO]: Time elapsed: 3571 ms
  89. [12:22:46] [Server thread/INFO]: Done (5.475s)! For help, type "help"
  90. [12:22:46] [Server thread/INFO]: Starting GS4 status listener
  91. [12:22:46] [Server thread/INFO]: Thread Query Listener started
  92. [12:22:46] [Query Listener #1/INFO]: Query running on 0.0.0.0:25565
  93. [12:25:29] [Server thread/INFO]: Stopping the server
  94. [12:25:29] [Server thread/INFO]: Stopping server
  95. [12:25:29] [Server thread/INFO]: Saving players
  96. [12:25:29] [Server thread/INFO]: Saving worlds
  97. [12:25:31] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:overworld
  98. [12:25:36] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_end
  99. [12:25:36] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_nether
  100. [12:25:36] [Server thread/INFO]: ThreadedAnvilChunkStorage (world): All chunks are saved
  101. [12:25:36] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
  102. [12:25:36] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
  103. [12:25:36] [Server thread/INFO]: ThreadedAnvilChunkStorage: All dimensions are saved
  104. [12:25:36] [Server thread/INFO]: Thread Query Listener stopped
  105. G:\Minecraft_Sever>java -server -XX:+UseG1GC -Xmx4096M -Xms1024M -jar G:/Minecraft_Sever/server.jar
  106. Starting net.minecraft.server.Main
  107. [12:26:32] [ServerMain/INFO]: Building unoptimized datafixer
  108. [12:26:34] [ServerMain/WARN]: You specified a resource pack without providing a sha1 hash. Pack will be updated on the client only if you change the name of the pack.
  109. [12:26:34] [ServerMain/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
  110. [12:26:35] [ServerMain/INFO]: Loaded 7 recipes
  111. [12:26:36] [ServerMain/INFO]: Loaded 1179 advancements
  112. [12:26:37] [Server thread/INFO]: Starting minecraft server version 1.19.3
  113. [12:26:37] [Server thread/INFO]: Loading properties
  114. [12:26:37] [Server thread/INFO]: Default game type: SURVIVAL
  115. [12:26:37] [Server thread/INFO]: Generating keypair
  116. [12:26:37] [Server thread/INFO]: Starting Minecraft server on *:12486
  117. [12:26:38] [Server thread/INFO]: Using default channel type
  118. [12:26:38] [Server thread/WARN]: **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!
  119. [12:26:38] [Server thread/WARN]: The server will make no attempt to authenticate usernames. Beware.
  120. [12:26:38] [Server thread/WARN]: While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.
  121. [12:26:38] [Server thread/WARN]: To change this, set "online-mode" to "true" in the server.properties file.
  122. [12:26:38] [Server thread/INFO]: Preparing level "world"
  123. [12:26:40] [Server thread/INFO]: Preparing start region for dimension minecraft:overworld
  124. [12:26:43] [Worker-Main-5/INFO]: Preparing spawn area: 0%
  125. [12:26:43] [Worker-Main-2/INFO]: Preparing spawn area: 0%
  126. [12:26:43] [Worker-Main-2/INFO]: Preparing spawn area: 0%
  127. [12:26:43] [Worker-Main-6/INFO]: Preparing spawn area: 0%
  128. [12:26:43] [Worker-Main-2/INFO]: Preparing spawn area: 0%
  129. [12:26:43] [Worker-Main-6/INFO]: Preparing spawn area: 0%
  130. [12:26:43] [Worker-Main-5/INFO]: Preparing spawn area: 0%
  131. [12:26:43] [Worker-Main-3/INFO]: Preparing spawn area: 43%
  132. [12:26:44] [Server thread/INFO]: Time elapsed: 3957 ms
  133. [12:26:44] [Server thread/INFO]: Done (5.565s)! For help, type "help"
  134. [12:26:44] [Server thread/INFO]: Starting GS4 status listener
  135. [12:26:44] [Server thread/INFO]: Thread Query Listener started
  136. [12:26:44] [Query Listener #1/INFO]: Query running on 0.0.0.0:25565

(如果结尾部分有些没出现,属于正常现象。)

  1. 这时 Minecraft服务器就启动成功了,输入stop可以停止(不要Ctrl+C!!!),输入op 玩家名可以设置管理员,可以按照以下内容在停止服务器后用记事本或写字板编辑服务器配置文件server.properties:

allow-nether=true #是否开启地狱

level-name=world #默认世界名称(最好不要改)

enable-query=false #没有什么大用处

allow-flight=false #没有什么大用处

announce-player-achievements=true #意义不明

server-port=25566 #服务器端口(127.0.0.1:25565中的冒号后面是这个server-port的数值)

enable-rcon=false #是否开启rcon监听(没有什么用)

force-gamemode=false #force游戏模式

level-seed= #我的世界地图种子(没有特殊需要就不填)

server-ip= #服务器指向IP(默认不要改放空)

max-build-height=256 #服务器最大建筑高度

spawn-npcs=true #是否有主城NPC

white-list=false #是否开启白名单(开启后在白名单内的玩家才能进入服务器,否则进入不了。不要随便开)

spawn-animals=true #主城是否有动物

snooper-enabled=true #意义不明

hardcore=false #我的世界极限模式是否开启(玩过的都知道)

online-mode=false #是否开启正版验证,需用我的世界官方启动器才能进入

resource-pack= #服务器资源包:填下载地址(不需要就不填)

pvp=true #是否开启服务器PVP

difficulty=1 #服务器难度: 0和平 1简单 2中等 3困难

enable-command-block=false #是否开启命令方块

player-idle-timeout=0 #意义不明

gamemode=0 #玩家默认进入游戏的游戏模式 1创造 0生存 2冒险模式3旁观者

max-players=20 #服务器最大玩家数(超过后玩家无法进入)

spawn-monsters=true #主城是否刷新怪物

view-distance=10 #意义不明

generate-structures=true #意义不明

spawn-protection=16 #服务器最大保护区(玩家破坏建筑不了)

motd=A Minecraft Server MOTD指的是在玩家添加服务器后下面会显示这里面的内容(不能为特殊符号)

motd想要输入中文的话需要点击以下链接:在线 Unicode 编码转换 | 菜鸟工具 (runoob.com)将中文转为Unicode。

前面都是服务器,如果你和你的朋友在同一个网玩,那么在这就可以了,直接让好友输入你的IP,查看方式:输入指令:ipconfig即可。

如果是跨网络游玩,有两种方式,第一种,用联通/电信的可以申请家用公网IP,一般在2000~3000元,第二种,用内网穿透服务,前面都注册完帐号了吧,登录,花两元实名认证,开免费隧道,IP填你的IP,端口是刚才配置文件中server-port的值,用TCP,用#59,下载客户端,启动,让朋友输入客户端提示的域名,如cn-js-zz.starryfrp.com:88888(每天签到领流量,防止流量不够用)。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/169116?site
推荐阅读
相关标签
  

闽ICP备14008679号