程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

用Python操控Minecraft我的世界 1.安裝Spigot服務器並添加RaspberryJuice插件

編輯:Python

這次,我們要學習如何用Python程序,連接並操控自己的服務器

前幾篇文章,我們創建的服務器都是從mcversions.net獲取的,是原汁原味的服務端,這一次,我們要創建另外一種服務器——Spigot,Spigot服務器有一個小小的缺點,就是沒辦法裝模組,但是它比原版服務端好的地方就是它可以安裝插件,這次我們要讓python來操控我的世界,就需要用到一個插件——RaspberryJuice

讓我們開始吧!


首先,我們先下載服務器的jar文件,來到getBukkit網站

Get Bukkit | Download CraftBukkit 1.19.1 | Download Spigot 1.19.1Download the latest version of CraftBukkit and Spigot for your Minecraft server!https://getbukkit.org/這次,我們還是以1.16.3的版本為例,點擊右上角download中的spigot,或者直接進入下方鏈接直達

SpigotDownload the latest version of Spigot for your Minecraft server!https://getbukkit.org/download/spigot

點擊對應版本的download按鍵 

然後點擊Spigot-1.16.3.jar這個文字(注意不是Create a Server)進行下載

然後把jar放入一個文件夾中

創建一個bat文件,寫入以下內容

@echo off
java -jar spigot-1.16.3.jar
pause

第一次運行,服務器自動終止(正常)

將eula.txt的eula=false改為true

再次運行

輸出以下內容就是成功運行啦!

*** Error, this build is outdated ***
*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***
*** Server will start in 20 seconds ***
Loading libraries, please wait...
[14:04:00] [main/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', name='PROD'
[14:04:00] [main/INFO]: Found new data pack file/bukkit, loading it automatically
[14:04:01] [main/INFO]: Reloading ResourceManager: Default, bukkit
[14:04:01] [Worker-Main-12/INFO]: Loaded 7 recipes
[14:04:00] [main/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', name='PROD'
[14:04:00] [main/INFO]: Found new data pack file/bukkit, loading it automatically
[14:04:01] [main/INFO]: Reloading ResourceManager: Default, bukkit
[14:04:01] [Worker-Main-12/INFO]: Loaded 7 recipes
[14:04:01] [Server thread/INFO]: Starting minecraft server version 1.16.3
[14:04:01] [Server thread/INFO]: Loading properties
[14:04:02] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-2740d5a-890130b (MC: 1.16.3) (Implementing API version 1.16.3-R0.1-SNAPSHOT)
[14:04:02] [Server thread/INFO]: Debug logging is disabled
[14:04:02] [Server thread/INFO]: Server Ping Player Sample Count: 12
[14:04:02] [Server thread/INFO]: Using 4 threads for Netty based IO
[14:04:02] [Server thread/INFO]: Default game type: SURVIVAL
[14:04:02] [Server thread/INFO]: Generating keypair
[14:04:02] [Server thread/INFO]: Starting Minecraft server on *:25565
[14:04:02] [Server thread/INFO]: Using default channel type
[14:04:02] [Server thread/INFO]: Preparing level "world"
[14:04:02] [Server thread/INFO]: -------- World Settings For [world] --------
[14:04:02] [Server thread/INFO]: Arrow Despawn Rate: 1200 Trident Respawn Rate:1200
[14:04:02] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
[14:04:02] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
[14:04:02] [Server thread/INFO]: Item Despawn Rate: 6000
[14:04:02] [Server thread/INFO]: Item Merge Radius: 2.5
[14:04:02] [Server thread/INFO]: View Distance: 10
[14:04:02] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
[14:04:02] [Server thread/INFO]: Cactus Growth Modifier: 100%
[14:04:02] [Server thread/INFO]: Cane Growth Modifier: 100%
[14:04:02] [Server thread/INFO]: Melon Growth Modifier: 100%
[14:04:02] [Server thread/INFO]: Mushroom Growth Modifier: 100%
[14:04:02] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
[14:04:02] [Server thread/INFO]: Sapling Growth Modifier: 100%
[14:04:02] [Server thread/INFO]: Beetroot Growth Modifier: 100%
[14:04:02] [Server thread/INFO]: Carrot Growth Modifier: 100%
[14:04:02] [Server thread/INFO]: Potato Growth Modifier: 100%
[14:04:02] [Server thread/INFO]: Wheat Growth Modifier: 100%
[14:04:02] [Server thread/INFO]: NetherWart Growth Modifier: 100%
[14:04:02] [Server thread/INFO]: Vine Growth Modifier: 100%
[14:04:02] [Server thread/INFO]: Cocoa Growth Modifier: 100%
[14:04:02] [Server thread/INFO]: Bamboo Growth Modifier: 100%
[14:04:02] [Server thread/INFO]: SweetBerry Growth Modifier: 100%
[14:04:02] [Server thread/INFO]: Kelp Growth Modifier: 100%
[14:04:02] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Ra 48 / Mi 16 / Tiv true
[14:04:02] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1
[14:04:02] [Server thread/INFO]: Experience Merge Radius: 3.0
[14:04:02] [Server thread/INFO]: Mob Spawn Range: 6
[14:04:02] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
[14:04:02] [Server thread/INFO]: Custom Map Seeds: Village: 10387312 Desert: 14357617 Igloo: 14357618 Jungle: 14357619 Swamp: 14357620 Monument: 10387313 Ocean: 14357621 Shipwreck: 165745295 End City: 10387313 Slime: 987234911 Bastion: 30084232 Fortress: 30084232 Mansion: 10387319 Fossil: 14357921 Portal: 34222645
[14:04:02] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
[14:04:02] [Server thread/INFO]: Max TNT Explosions: 100
[14:04:04] [Server thread/INFO]: -------- World Settings For [world_nether] --------
[14:04:04] [Server thread/INFO]: Arrow Despawn Rate: 1200 Trident Respawn Rate:1200
[14:04:04] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
[14:04:04] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
[14:04:04] [Server thread/INFO]: Item Despawn Rate: 6000
[14:04:04] [Server thread/INFO]: Item Merge Radius: 2.5
[14:04:04] [Server thread/INFO]: View Distance: 10
[14:04:04] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
[14:04:04] [Server thread/INFO]: Cactus Growth Modifier: 100%
[14:04:04] [Server thread/INFO]: Cane Growth Modifier: 100%
[14:04:04] [Server thread/INFO]: Melon Growth Modifier: 100%
[14:04:04] [Server thread/INFO]: Mushroom Growth Modifier: 100%
[14:04:04] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
[14:04:04] [Server thread/INFO]: Sapling Growth Modifier: 100%
[14:04:04] [Server thread/INFO]: Beetroot Growth Modifier: 100%
[14:04:04] [Server thread/INFO]: Carrot Growth Modifier: 100%
[14:04:04] [Server thread/INFO]: Potato Growth Modifier: 100%
[14:04:04] [Server thread/INFO]: Wheat Growth Modifier: 100%
[14:04:04] [Server thread/INFO]: NetherWart Growth Modifier: 100%
[14:04:04] [Server thread/INFO]: Vine Growth Modifier: 100%
[14:04:04] [Server thread/INFO]: Cocoa Growth Modifier: 100%
[14:04:04] [Server thread/INFO]: Bamboo Growth Modifier: 100%
[14:04:04] [Server thread/INFO]: SweetBerry Growth Modifier: 100%
[14:04:04] [Server thread/INFO]: Kelp Growth Modifier: 100%
[14:04:04] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Ra 48 / Mi 16 / Tiv true
[14:04:04] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1
[14:04:04] [Server thread/INFO]: Experience Merge Radius: 3.0
[14:04:04] [Server thread/INFO]: Mob Spawn Range: 6
[14:04:04] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
[14:04:04] [Server thread/INFO]: Custom Map Seeds: Village: 10387312 Desert: 14357617 Igloo: 14357618 Jungle: 14357619 Swamp: 14357620 Monument: 10387313 Ocean: 14357621 Shipwreck: 165745295 End City: 10387313 Slime: 987234911 Bastion: 30084232 Fortress: 30084232 Mansion: 10387319 Fossil: 14357921 Portal: 34222645
[14:04:04] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
[14:04:04] [Server thread/INFO]: Max TNT Explosions: 100
[14:04:04] [Server thread/WARN]: Unable to find spawn biome
[14:04:05] [Server thread/INFO]: -------- World Settings For [world_the_end] --------
[14:04:05] [Server thread/INFO]: Arrow Despawn Rate: 1200 Trident Respawn Rate:1200
[14:04:05] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
[14:04:05] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
[14:04:05] [Server thread/INFO]: Item Despawn Rate: 6000
[14:04:05] [Server thread/INFO]: Item Merge Radius: 2.5
[14:04:05] [Server thread/INFO]: View Distance: 10
[14:04:05] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
[14:04:05] [Server thread/INFO]: Cactus Growth Modifier: 100%
[14:04:05] [Server thread/INFO]: Cane Growth Modifier: 100%
[14:04:05] [Server thread/INFO]: Melon Growth Modifier: 100%
[14:04:05] [Server thread/INFO]: Mushroom Growth Modifier: 100%
[14:04:05] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
[14:04:05] [Server thread/INFO]: Sapling Growth Modifier: 100%
[14:04:05] [Server thread/INFO]: Beetroot Growth Modifier: 100%
[14:04:05] [Server thread/INFO]: Carrot Growth Modifier: 100%
[14:04:05] [Server thread/INFO]: Potato Growth Modifier: 100%
[14:04:05] [Server thread/INFO]: Wheat Growth Modifier: 100%
[14:04:05] [Server thread/INFO]: NetherWart Growth Modifier: 100%
[14:04:05] [Server thread/INFO]: Vine Growth Modifier: 100%
[14:04:05] [Server thread/INFO]: Cocoa Growth Modifier: 100%
[14:04:05] [Server thread/INFO]: Bamboo Growth Modifier: 100%
[14:04:05] [Server thread/INFO]: SweetBerry Growth Modifier: 100%
[14:04:05] [Server thread/INFO]: Kelp Growth Modifier: 100%
[14:04:05] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Ra 48 / Mi 16 / Tiv true
[14:04:05] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1
[14:04:05] [Server thread/INFO]: Experience Merge Radius: 3.0
[14:04:05] [Server thread/INFO]: Mob Spawn Range: 6
[14:04:05] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
[14:04:05] [Server thread/INFO]: Custom Map Seeds: Village: 10387312 Desert: 14357617 Igloo: 14357618 Jungle: 14357619 Swamp: 14357620 Monument: 10387313 Ocean: 14357621 Shipwreck: 165745295 End City: 10387313 Slime: 987234911 Bastion: 30084232 Fortress: 30084232 Mansion: 10387319 Fossil: 14357921 Portal: 34222645
[14:04:05] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
[14:04:05] [Server thread/INFO]: Max TNT Explosions: 100
[14:04:05] [Server thread/WARN]: Unable to find spawn biome
[14:04:05] [Server thread/INFO]: Preparing start region for dimension minecraft:overworld
[14:04:05] [Worker-Main-11/INFO]: Preparing spawn area: 0%
[14:04:05] [Worker-Main-11/INFO]: Preparing spawn area: 4%
[14:04:06] [Worker-Main-10/INFO]: Preparing spawn area: 15%
[14:04:06] [Worker-Main-11/INFO]: Preparing spawn area: 24%
[14:04:07] [Worker-Main-13/INFO]: Preparing spawn area: 44%
[14:04:07] [Worker-Main-9/INFO]: Preparing spawn area: 57%
[14:04:08] [Worker-Main-12/INFO]: Preparing spawn area: 69%
[14:04:08] [Worker-Main-11/INFO]: Preparing spawn area: 89%
[14:04:09] [Server thread/INFO]: Time elapsed: 3837 ms
[14:04:09] [Server thread/INFO]: Preparing start region for dimension minecraft:the_nether
[14:04:09] [Worker-Main-10/INFO]: Preparing spawn area: 0%
[14:04:09] [Worker-Main-10/INFO]: Preparing spawn area: 5%
[14:04:10] [Worker-Main-14/INFO]: Preparing spawn area: 17%
[14:04:10] [Worker-Main-14/INFO]: Preparing spawn area: 30%
[14:04:11] [Worker-Main-14/INFO]: Preparing spawn area: 43%
[14:04:11] [Worker-Main-9/INFO]: Preparing spawn area: 58%
[14:04:12] [Worker-Main-8/INFO]: Preparing spawn area: 75%
[14:04:12] [Worker-Main-12/INFO]: Preparing spawn area: 90%
[14:04:12] [Server thread/INFO]: Time elapsed: 3751 ms
[14:04:12] [Server thread/INFO]: Preparing start region for dimension minecraft:the_end
[14:04:12] [Worker-Main-12/INFO]: Preparing spawn area: 0%
[14:04:13] [Worker-Main-12/INFO]: Preparing spawn area: 66%
[14:04:13] [Server thread/INFO]: Time elapsed: 684 ms
[14:04:13] [Server thread/INFO]: Done (10.612s)! For help, type "help"
>

但是這樣還不夠,輸入stop並回車,終止服務器 


 為了將python和服務器關聯起來,我們需要用到一個插件RaspberryJuice

進入這個網站,看到如下頁面

點擊Download Now開始下載,這裡不推薦大家使用迅雷,因為文件太小,迅雷一直卡在連接資源,所以浏覽器有迅雷擴展程序的話把它先關了然後才下載,這樣用了不到1秒就能成功下載啦!

下載完畢後,將jar文件復制到服務器目錄下的plugins文件夾中

 然後啟動服務器即可

從輸出中不難發現,RaspberryJuice已經成功被我們添加進去啦!

好了,安裝Spigot服務器並添加RaspberryJuice的教程就到這裡!

下一篇文章我們就來詳細了解如何用Python的第三方庫對Minecraft進行編程~

喜歡的話就點贊關注吧!


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved