设为首页收藏官网网盘国家资源立人课堂 今天是: 2022-09-09    美好的一天,从现在开始投稿

立人创客乐享社区

 找回密码
 立即注册
立人创客乐享社区 首页 游戏编程 查看内容

Minecraft的API

2020-12-20 21:46| 发布者: 信息中心| 查看: 540| 评论: 7|原作者: 信息中心

摘要: API,就是应用程序接口。MinecraftAPI就是Minecraft的编程接口。链接上MinecraftAPI,就可以把Minecraft玩得更嗨~~import mcpi.minecraft as minecraft首先要将API包包导入进来,才可以开始使用MinecraftAPI,否则是 ...
360截图-43541578.png

API,就是应用程序接口。MinecraftAPI就是Minecraft的编程接口。链接上MinecraftAPI,就可以把Minecraft玩得更嗨~~

import mcpi.minecraft as minecraft

首先要将API包包导入进来,才可以开始使用MinecraftAPI,否则是玩不成的。

mc = minecraft.Minecraft.create()

得到Minecraft对象,使用这个对象来进行进一步的调用。

pos = mc.player.getTilePos()

这个API 是与玩家“player”相关的,意思是得到玩家当前的坐标。坐标在Minecraft里是非常重要的基础数据,很多时候编程要围绕着坐标展开。

b = mc.getBlock(pos.x, pos.y-1, pos.z)

此API可以根据坐标来取得与坐标相关的方块ID,所以说坐标真的是十分重要。

if b == block.AIR.id or b == block.WATER_STATIONARY.id or b == block.WATER_FLOWING.id:mc.postToChat("not safe")

上面意思就是如果取得的方块ID是空气或者是水,则弹出对话框“not safe”。

360截图-43556703.png

events = mc.events.pollBlockHits()

这是Minecraft与事件相关的API,表示的是与玩家打击一个方块相关的事件(鼠标右键,不是左键)。

360截图-43567968.png

pos = e.pos

取得这个事件发生的坐标位置。还得再强调一次坐标在Minecraft中的重要性。

if pos.x == diamond_pos.x and pos.y == diamond_pos.y and pos.z == diamond_pos.z: mc.postToChat("HIT")

例如下图,如果玩家机打的是确定某个位置的钻石方块,则提示“HIT”。


Minecraft的API种类非常非常丰富,一点点去了解,会让我们玩起来其乐无穷~



路过
1

雷人

握手

鲜花

鸡蛋

刚表态过的朋友 (1 人)

发表评论

最新评论

信息中心 2020-12-20 22:00
/give给予人物品id数量-给予某人物品,如果bai不写数量则给予数量默认为64
/nickID名称-给某人改一个名ID是加白名单的名字
/backup-运行备份命令
/fireball-发射一个火球(会破坏方块)
/healname-治疗某人
/invseename-查看某人的包裹
/lingtningname-天谴(不填写名字会雷击鼠标指向的地方)
/mutename-禁言某人
/ping-乒乓
/seenname-查看某人最后退出的时间
/tpname1name2-将人物1传送至人物2身旁
/tpname-将自己传送至某人身旁
/tpherename-将某人传送至自己身旁
/tpall-将服务器内的所有人传送至自己身旁(大传送阵)
(上面四个命令需要对方在线,不需要对方同意)
/unlimitedid-给予自己无限的某物品
/weatherstorm/suntime-改变天气,雷雨或晴天
/mmoeditnamesknamerank-如果安装了MCRPG插件可以用这个命令改变某人的某项技能等级unarmed【箭术】-Archery
【斧头技能】-Axes
【采矿】-mining
【修理】-Repair
/forestgen-在自己身旁形成森林
/pumpkins-在自己身旁形成南瓜林(带叶子的南瓜林)
/snow-在自己的身旁成为雪后的样子
/thaw-融雪(和冰)
/butcher-杀死附近的怪物
/tree树形-生成一棵树(树形不填也可以)
树形:big-大树ewquoia-红木Tallsequoia-高大的红木
Birch-衫树Random-随机
/up高度-将自己提升到某高度,脚下用一块可能悬空的玻璃支撑WorldEdit:
手拿木斧,左键一角,右键一角,两角之间的长方体为选择区域:
//setid-将选中的区域变为某物品(如果是不可放置或者没有放置点的物品会成为被扔出的状态)
//undo-还原上一次的WorldEdit行动
//redo-还原上一次的//undo(这个说明可能有误)
//movex-将区域移动x块。移动时需正对着区域与NEWS。
//movexup-将区域向上移动x块
//movexdown-将区域向下移动x块
替换指令://replacexxxyyy(xxx是原来方块,yyy是替换方块)
复制指令//copy(你站在哪里复制的,等一下粘贴也会是相同位置出现)
粘贴指令://paste(注意站好位置)
输入围墙指令://wallsxxxascend-把自己提升到上一个平台
bind<KEYCODE值><命令>{命令关键字}-设置一键命令
clear-清空控制台
damage-关闭或者开启伤害即无敌
descend-把自己移动到下面一个的平台
destroy[all]-破坏当前的东西(背包)
defuse[all]-拆弹(拆除已经点燃了的TNT炸药)
diff<VALUE>-X
difficulty<VALUE>-设置游戏难度
dropstore-在身边创建一个储物柜
*drops-开关物品掉落,关闭的话采矿打怪不掉东西。
dupe[all]-复制东西
duplicate[all]-复制手上的东西并丢出来
explode[范围]-设置一个地方爆炸(在自家慎用)
extinguish[all]-熄灭周围所有的火
ext[all]-一样是熄灭火
falldamage-开关高空落下伤害
firedamage-开关火的伤害
fly-飞行模式
*freeze-冻结怪物
give<物品>[数量]-给一样物品
goto<名字>-去一个地方
grow[all]-让立即小麦成长
h[COMMAND]-命令列表/帮助
heal<HEALTH>-补指定的血
health<MIN|MAX|INFINITE>-设置生命值
help[COMMAND]-命令列表/帮助
home回到出生点
i<物品代码>[数量]-刷东西
instantmine-开关即时采矿(采矿无延迟)
item<物品代码|物品名称>[数量][费用]给玩家物品,如果不指定则是最大的数量
itemname-显示当前手上的物品名称
itemstack<物品代码>[数量]-给玩家指定数量的物品
kill自杀不解释
jump-瞬移到鼠标所指的地方
killnpc[all]-杀死周围全部NPC或者叫杀了附近所有除自己外的活体生物
l-X
*light-把光永久性关闭
listwaypoints-列出所有路径点
macro<文件名>{参数}-允许运行宏
maxstack[物品ID|物品名称|全部][数量]-最大的把某物品堆起来
*mobdamage-怪物不会给你伤害
msg<消息>-添加一个消息到控制台
music[音量]-播放音乐
noclip-穿墙
p-显示当前坐标
pos现在玩家的坐标
reach<DISTANCE>-玩家到指定地方
return-传送到之前传送的地方
rem<NAME>-删除指定路点
removedrops[all]-删掉地上物品
*rename<COMMANDNAME><NEWNAME>-修改命令名称
replenish[all]-X
repair[all]-修复当前物品耐久
reset-恢复默认设置
s<名字>-Sameas/set
search<关键词>-搜索物品名称
set<名字>-在这世界标记一个路径点
setjump[JUMP|reset]-设置跳跃的高度落地伤害和移动1:1
setspawn[<X><Y><Z>]设置当前位置X轴Y轴Z轴
setspeed[速度|重置]-设置移动速度
spawn<NAME|ID|random|list>[QTY]-产生一个生物
spawnstack<NAME|ID|random|list>{NAME|ID|random}-产生一个合体的怪物NPC
*superheat[all]-Turnsitemswhicharefurnace-ableintotheirfurnacedform
t<X><Y><Z>-Sameas/tele
tele<X><Y><Z>-传送到此坐标
time[set|get|day|night[minute|hour|day[TIME]]]-设置指定时间得到物品
timeschedule<reset|<TIME1><TIME2>>-设定一段时间段,让世界永远保持在这段时间之间--《凉宫春日漫无止境的八月》
unbind<KEYCODE值>-解除一个命令
useportal-传送到地狱
waterdamage-开关潜水伤害
world<load|save|seed|new|exit|list>-世界情报
worldload<FILENAME>-加载指定的文件
worldsave-保存退出游戏
worldseed[SEED]-给你看看你世界里有多少个方块
worldnew[FILENAME][SEED]-在指定位置创建新地图
worldexit-不保存退出游戏
worldlist-列出所有存档你可以去这看
扩展资料
你在控制台上打下/?或/help就有出现所有的指令
至于随机让人死亡的代码是没有的但可以让指令方块随机选择玩家传送到某地导致某玩家死亡达到随机让人死亡的目的(在指令方块输入kill是无效的)
信息中心 2020-12-20 22:12
版权归作者所有,任何形式转载请联系作者。
作者:国王KING(来自豆瓣)
来源:https://www.douban.com/note/548305689/

CONTENTS
序言

1-传送地毯

2-水面行走

3-通天金塔

4-神罗天征

5-摩西分海

6-登天之路

7-地爆天星

序言
一座迷宫、一座房屋、一艘外星船……
这些东西,仅仅使用几条简单的代码就可以弄出来了!
如果你喜欢《我的世界》,也喜欢Python,请继续阅读下去吧……


Minecraft
在用Python编程时,你需要准备好以下东西:
①编程工具——Python2
②游戏——我的世界1.6.4
③服务器bukkit,及编程插件配置
④一些编程基本知识

①②相信大家都可以准备好,③的话,可以去【这儿】(←戳一下),找到【Starter Kit PC】下载(见下图);


下载完成后,点击start.bat即可运行bukkit。

如果你没有任何编程知识,但却渴望用编程玩MC,你可以:

- 阅读《零基础学Minecraft编程》 | https://book.douban.com/subject/26613247/

- 阅读《知乎周刊·编程小白学Python》 | https://read.douban.com/ebook/16691849/?dcs=book-search

上面这些准备好之后,就可以开始编程了~

Q:我该怎样编程?
A:打开你在③下载好的文件里的start.bat(出现Done的字样表示开服成功)→运行MC,选择多人游戏,点击直接连接,输入localhost→进入成功→打开Python开始编程→切换回游戏即可看见效果!

Q:MC编程可以干什么?
A:追踪玩家移动,检测玩家位置,建筑自动化,与方块交互,赋予方块以独立思维,Minecraft电梯……只有你想不到,没有做不到!不要问「它可以干什么」,要思考「我想干什么」。

Q:我该怎样学习MC编程?
A:掌握mcpi里常用的几个模块(我以后会总结);还可以阅读《零基础学Minecraft编程》这本书……好吧是有点广告之嫌,不过这书真的很好……

最后,愿你也能爱上Python,爱上Minecraft~

1-传送地毯
#MC版本:1.6.4

#Python版本:2.7.8

一个传送地毯,用if函数实现。

主要用途:当玩家站在白地毯时,会被传送到红地毯上。


代码如下:

#-*- coding:936 -*-

import mcpi.minecraft as minecraft

import time

mc = minecraft.Minecraft.create()

while True:

    time.sleep(3)

    pos = mc.player.getTilePos()  #得到玩家目前坐标

    print pos.x, pos.y, pos.z

    if pos.x>=14 and pos.z>=-2:

        mc.player.setTilePos(13,6,5)  #假若玩家当前坐标符合上面的判断条件,则会被传送到红地毯上面

        mc.postToChat('change!!!')  #传送成功就在窗口打出“change!!!”

    else:

        pass

2-水面行走
#MC版本:1.6.4

#Python版本:2.7.8

利用mcpi里的block实现。

当玩家在海面上(或者陆地)行走时,会在玩家脚下生成一个玻璃。

假若玩家不断走动,玻璃桥也会不断增长。


代码如下:

#-*- coding:936 -*-

import mcpi.minecraft as minecraft

import mcpi.block as block

mc = minecraft.Minecraft.create()

while True:

pos = mc.player.getTilePos()

mc.setBlock(pos.x, pos.y-1, pos.z, block.GLASS.id)  #将玩家脚下的方块替换成玻璃

3-通天金塔
#MC版本:1.6.4

#Python版本:2.7.8

一座金塔,用for循环实现。


代码如下:

#-*- coding:936 -*-

import mcpi.minecraft as minecraft

import mcpi.block as block

mc = minecraft.Minecraft.create()

pos = mc.player.getTilePos()

for a in range(30):

mc.setBlock(pos.x+3, pos.y+a, pos.z, block.GOLD_BLOCK.id)

上述代码中,for循环执行了30次,于是出现了一座30层的金塔。

#关于物品的英文ID,参考【这儿】。(←点一下)


红箭处指示的才是编程时用的物品ID,记得字母全体大写。

4-神罗天征
#MC版本:1.6.4

#Python版本:2.7.8

清空玩家附近的物体,主要利用mcpi的setBlocks。

代码使用了while函数,基本上是走到哪儿就清空哪儿,破坏力非常惊人。


代码如下:

#-*- coding:936 -*-

import mcpi.minecraft as minecraft

import mcpi.block as block

mc = minecraft.Minecraft.create()

while True:

pos = mc.player.getTilePos()

mc.setBlocks(pos.x, pos.y, pos.z, pos.x+30, pos.y+30, pos.z+30, block.AIR.id)

注:神罗天征,《火影忍者 NARUTO》中佩恩使用的招式,以自己为中心将周围的一切物体弹开,进阶利用是以自己为中心制造斥力场,产生类似排斥的能力。


setBlocks(注意大小写,注意复数)函数适用于3D区域,需要两组坐标。

一个是3D空间的一个角坐标,另一个是它的对角坐标。

一共需要6个数字来向MC描述一个3D的空间。

5-摩西分海
#MC版本:1.6.4

#Python版本:2.7.8

同样利用setBlocks进行设置。

重现故事《摩西分海》。


代码如下:

#-*- coding:936 -*-

import mcpi.minecraft as minecraft

import mcpi.block as block

#构建红海。我能想到的替代只有岩浆了……_(:зゝ∠)_

mc = minecraft.Minecraft.create()

pos = mc.player.getTilePos()

mc.setBlocks(pos.x, pos.y, pos.z, pos.x+50, pos.y+50, pos.z+50, block.LAVA.id)

#分海。进入「红海」后,由于block变化,会出现一条「通路」。

while True:

pos = mc.player.getTilePos()

mc.setBlocks(pos.x, pos.y, pos.z, pos.x+10, pos.y+70, pos.z+10, block.AIR.id)


6-登天之路
#MC版本:1.6.4
#Python版本:2.7.8

在玩家面前出现一条阶梯(?)。


代码如下:
#-*- coding:CP936 -*-
import mcpi.minecraft as minecraft
import mcpi.block as block
import mcpi.minecraftstuff as minecraftstuff

mc = minecraft.Minecraft.create()
mcdrawing = minecraftstuff.MinecraftDrawing(mc)
size = 10

def line():
pos = mc.player.getTilePos()
mcdrawing.drawLine(pos.x, pos.y, pos.z,
pos.x+size, pos.y+size, pos.z+size,
block.WOOL.id, 3)
while True:
for a in range(3):
line()
size+=1

drawLine函数同样需要6个数字,描述空间的起点和终点。

绘制圆环
在玩家面前绘制圆环。


代码如下:

#-*- coding:CP936 -*-
import mcpi.minecraft as minecraft
import mcpi.block as block
import mcpi.minecraftstuff as minecraftstuff

mc = minecraft.Minecraft.create()
pos = mc.player.getTilePos()
mcdrawing = minecraftstuff.MinecraftDrawing(mc)
mcdrawing.drawCircle(pos.x, pos.y+20, pos.z,
10,block.WOOL.id, 3)
在drawCirlcle函数里,(x, y, z)为圆心,后面接的数字为半径。

7-地爆天星
#MC版本:1.6.4
#Python版本:2.7.8

在玩家上空生成一个圆球。


代码如下:

#-*- coding:CP936 -*-
import mcpi.minecraft as minecraft
import mcpi.block as block
import random
import time
import mcpi.minecraftstuff as minecraftstuff

mc = minecraft.Minecraft.create()
pos = mc.player.getTilePos()
mcdrawing = minecraftstuff.MinecraftDrawing(mc)
mcdrawing.drawSphere(pos.x+10, pos.y+20, pos.z,
50,block.TNT.id)

突发奇想于是把圆球的属性换成TNT(炸药),手持打火石的我点燃了最上面的TNT……

然后只见一片火花烟雾,电脑差点要死机_(:зゝ∠)_

信息中心 2020-12-20 22:24
  1. # 金字塔.py
  2. # 导入库
  3. import mcpi.block as block
  4. import mcpi.minecraft as minecraft

  5. # 获取玩家位置
  6. mc = minecraft.Minecraft.create()
  7. pos = mc.player.getTilePos()

  8. x = pos.x
  9. y = pos.y
  10. z = pos.z

  11. # 金字塔底长
  12. width = 100
  13. high = 0

  14. while True:
  15.     """金字塔建造"""
  16.     for a in range(width):
  17.         for b in range(width):
  18.             mc.setBlock(x + a + high, pos.y + high, pos.z + b + high,
  19.                         block.SANDSTONE.id)

  20.     width -= 2
  21.     high += 1

  22.     if width <= 0:
  23.         break
复制代码


信息中心 2020-12-20 22:42
Minecraft API
This is a reference of Minecraft Python API Library, which is supported on Minecraft: Pi edition and the PC version using the RaspberryJuice plugin.

If you want to know more about how to use the API, including tutorials, see my projects and download code, visit my minecraft page.

Structure
minecraft.py
Class Minecraft - main class for connecting and interacting with the game
Class camera - changing camera angle and postion
Class player - getting and changing the players position and setting
Class entity - getting and changing entities position and setting
Class events - retreiving events which have occured in the game
block.py
Class Block - definition of a block, specifically its type
event.py
Class BlockEvent - definition of a block event, specifically what event, what block and what player
vec3.py
Class Vec3 - generic class for managing a 3 dimension vector (i.e. x,y,z)
connection.py - internal module used by the api
util.py - internal module used by the api

Compatability
Not all functions and block types are available on all version of the api, by each function you will see a logo which shows whether that function is available:

Available on Minecraft: Pi edition

Available on RaspberryJuice

Minecraft
"Main class for interacting with the Minecraft world, includes functions for creating a connection, modifying players and blocks and capturing events"

.create(address = "localhost", port = 4711)
"Create connection to Minecraft (address, port) => Minecraft object"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#use default address and port
mc = minecraft.Minecraft.create()
#specify ip address and port
mc = minecraft.Minecraft.create("192.168.1.1", 4711)

.getBlock(x,y,z)
"Get block (x,y,z) => id:int"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#retrieves the block type for the block at 0,0,0
blockType = mc.getBlock(0,0,0)

.getBlocks(x0,y0,z0,x1,y1,z1)
"Get a cuboid of blocks (x0,y0,z0,x1,y1,z1) => [id:int]"
Available on RaspberryJuice
#get the block id's in a cuboid
blocks = mc.getBlocks(-1,-1,-1,1,1,1)
for block in blocks:
    print block

.getBlockWithData(x,y,z)
"Get block with data (x,y,z) => Block"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#retrieves a block object for the block at 0,0,0
blockObj = mc.getBlockWithData(0,0,0)

.setBlock(x,y,z)
"Set block (x,y,z,id,[data])"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#sets a block at an x, y, z co-ordinate to a particular type
mc.setBlock(0,0,0,block.DIRT.id)
#sets a block to a particular type and 'subtype'
mc.setblock(0,0,0,block.WOOD.id, 1)

.setBlocks(x0,y0,z0,x1,y1,z1,blockType, blockData)
"Set a cuboid of blocks (x0,y0,z0,x1,y1,z1,id,[data])"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#sets many blocks at a time, filling the gap between 2 sets of x, y, z co-ordinates
mc.setBlocks(-1, -1, -1, 1, 1, 1, block.STONE.id)

.getHeight(x,z)
"Get the height of the world (x,z) => int"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#find the y (vertical) of an x, z co-ordinate which represents the 'highest' (non-air) block
y = mc.getHeight(0,0)

.getPlayerEntityIds()
"Get the entity ids of the connected players => [id:int]"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#get the entity id's of the players connected to the game
entityIds = mc.getPlayerEntityIds()
for entityId in entityIds:
    print entityId

.getPlayerEntityId(playerName)
"Get the entity id for a named player => [id:int]"
Available on RaspberryJuice
#get the entity id of a name player 'martinohanlon'
entityId = mc.getPlayerEntityId("martinohanlon")
print entityId

.saveCheckpoint()
"Save a checkpoint that can be used for restoring the world"
Available on Minecraft: Pi Edition
mc.saveCheckpoint()

.restoreCheckpoint()
"Restore the world state to the checkpoint"
Available on Minecraft: Pi Edition
mc.restoreCheckpoint()

.postToChat(message)
"Post a message to the game chat"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#write 'Hello Minecraft World' to the chat window
mc.postToChat("Hello Minecraft World")

.setting(setting, status)
"Set a world setting (setting, status). keys: world_immutable, nametags_visible"
Available on Minecraft: Pi Edition
#change world immutable to True
mc.setting("world_immutable", True)
#change nametags_visible setting to False
mc.setting("nametags_visible", False)

Minecraft.player
.getPos()
"Gets the player's position in the world as a Vec3 of floats (decimal numbers), if the player is in the middle of a block x.5 is returned"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#get players position as floats
playerPos = mc.player.getPos()

.setPos(x,y,z)
"Moves the player to a position in the world by passing co-ordinates ([x,y,z])"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#set the players position as floats
mc.player.setPos(0.0,0.0,0.0)

.getTilePos()
"Gets the position of the 'tile' the player is currently on."
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#get the position of the tile the players is on
playerTile = mc.player.getTilePos()

.setTilePos(x,y,z)
"Move the player to a tile position in the world by passing co-ordinates ([x,y,z])"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#set the position of the tile the player is on
mc.player.setTilePos(0,0,0)

.setting(setting, status)
"Set a player setting (setting, status). keys: autojump"
Available on Minecraft: Pi Edition
#change the autojump setting to True
mc.player.setting("autojump", True)

.getRotation()
"Get the rotational angle (0 to 360) for the player => [angle:float]"
Available on RaspberryJuice
#get the rotation of the player
angle = mc.player.getRotation()
print angle

.getPitch()
"Get the pitch angle (-90 to 90) for the player => [pitch:float]"
Available on RaspberryJuice
#get the pitch for the player
pitch = mc.player.getPitch()
print pitch

.getDirection()
"Get unit vector of x,y,z for the player's direction => [Vec3]"
Available on RaspberryJuice
#get the player's direction
direction = mc.player.getDirection()
print direction


Minecraft.entity
The entity functions are used in conjunction with the .getPlayerEntityIds() function to interact with the entity (or players) in a game.  Entity functions are useful for multiplayer games.  

#get the entity id's of the players connected to the game
entityIds = mc.getPlayerEntityIds()
1stEntityId = entityIds[0]
2ndEntityId = entityIds[1]
...

.getPos(entityId)
"Gets an entities position in the world as a Vec3 of floats (decimal numbers), if the entity is in the middle of a block x.5 is returned"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#get first entity position as floats
entityPos = mc.entity.getPos(entityId)

.setPos(entityId,x,y,z)
"Moves the entity to a position in the world by passing co-ordinates ([x,y,z])"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#set the players position as floats
mc.player.setPos(entityId,0.0,0.0,0.0)

.getTilePos(entityId)
"Gets the position of the 'tile' the entity is currently on."
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#get the position of the tile the entity is on
entityTile = mc.entity.getTilePos(entityId)

.setTilePos(entityId, x,y,z)
"Move the entity to a tile position in the world by passing co-ordinates ([x,y,z])"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#set the position of the tile the entity is on
mc.player.setTilePos(entityId,0,0,0)

.getRotation(entityId)
"Get the rotational angle (0 to 360) for an entity => [angle:float]"
Available on RaspberryJuice
#get the rotation of an entity
angle = mc.entity.getRotation(entityId)
print angle

.getPitch(entityId)
"Get the pitch angle (-90 to 90) for an entity => [pitch:float]"
Available on RaspberryJuice
#get the pitch for an entity
pitch = mc.entity.getPitch(entityId)
print pitch

.getDirection(entityId)
"Get unit vector of x,y,z for an entities direction => [Vec3]"
Available on RaspberryJuice
#get and entities direction
direction = mc.entity.getDirection(entityId)
print direction

Minecraft.camera
.setNormal(entityId)
"Set camera mode to normal Minecraft view ([entityId])"
Available on Minecraft: Pi Edition
#set camera mode to normal for a specific player
mc.camera.setNormal(entityId)

.setFixed()
"Set camera mode to fixed view"
Available on Minecraft: Pi Edition
#set camera mode to fixed
mc.camera.setFixed()

.setFollow(entityId)
"Set camera mode to follow an entity ([entityId])"
Available on Minecraft: Pi Edition
#set camera mode to follow for a specific player
mc.camera.setFollow(entityId)

.setPos(x,y,z)
"Set camera entity position (x,y,z)"
Available on Minecraft: Pi Edition
#set camera position to a specific position of x, y, z
mc.camera.setPos(0,0,0)

Minecraft.events
.pollBlockHits()
"Block Hits (Only triggered by sword) => [BlockEvent]"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#get block event hits that have occured since the last time the function was run
blockEvents = mc.events.pollBlockHits()
for blockEvent in blockEvents:
    print blockEvent

.pollChatPosts()
"Chat posts => [ChatEvent]"
Available on RaspberryJuice
#get chat post events (messages) since the last time the function was run
chatEvents = mc.events.pollChatPosts()
for chatEvent in chatEvents:
    print chatEvents

.clearAll()
"Clear all old events"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#clear all events that have happened since the events where last got
mc.events.clearAll()

Block
"The definition of a Block in Minecraft, used to describe a block type and (if applicable) its data; also contains constants for the blocks type id's, e.g. BLOCK.AIR.id"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
#create block of a specific type
blockObj = block.Block(id)
#create a block of a specific type and apply a data value
blockObj = block.Block(id, data)

.id
"The id (or type) of block"

AIR                 = Block(0)
STONE               = Block(1)
GRASS               = Block(2)
DIRT                = Block(3)
COBBLESTONE         = Block(4)
WOOD_PLANKS         = Block(5)
SAPLING             = Block(6)
BEDROCK             = Block(7)
WATER_FLOWING       = Block(8)
WATER               = WATER_FLOWING
WATER_STATIONARY    = Block(9)
LAVA_FLOWING        = Block(10)
LAVA                = LAVA_FLOWING
LAVA_STATIONARY     = Block(11)
SAND                = Block(12)
GRAVEL              = Block(13)
GOLD_ORE            = Block(14)
IRON_ORE            = Block(15)
COAL_ORE            = Block(16)
WOOD                = Block(17)
LEAVES              = Block(18)
GLASS               = Block(20)
LAPIS_LAZULI_ORE    = Block(21)
LAPIS_LAZULI_BLOCK  = Block(22)
SANDSTONE           = Block(24)
BED                 = Block(26)
COBWEB              = Block(30)
GRASS_TALL          = Block(31)
WOOL                = Block(35)
FLOWER_YELLOW       = Block(37)
FLOWER_CYAN         = Block(38)
MUSHROOM_BROWN      = Block(39)
MUSHROOM_RED        = Block(40)
GOLD_BLOCK          = Block(41)
IRON_BLOCK          = Block(42)
STONE_SLAB_DOUBLE   = Block(43)
STONE_SLAB          = Block(44)
BRICK_BLOCK         = Block(45)
TNT                 = Block(46)
BOOKSHELF           = Block(47)
MOSS_STONE          = Block(48)
OBSIDIAN            = Block(49)
TORCH               = Block(50)
FIRE                = Block(51)
STAIRS_WOOD         = Block(53)
CHEST               = Block(54)
DIAMOND_ORE         = Block(56)
DIAMOND_BLOCK       = Block(57)
CRAFTING_TABLE      = Block(58)
FARMLAND            = Block(60)
FURNACE_INACTIVE    = Block(61)
FURNACE_ACTIVE      = Block(62)
DOOR_WOOD           = Block(64)
LADDER              = Block(65)
STAIRS_COBBLESTONE  = Block(67)
DOOR_IRON           = Block(71)
REDSTONE_ORE        = Block(73)
SNOW                = Block(78)
ICE                 = Block(79)
SNOW_BLOCK          = Block(80)
CACTUS              = Block(81)
CLAY                = Block(82)
SUGAR_CANE          = Block(83)
FENCE               = Block(85)
GLOWSTONE_BLOCK     = Block(89)
BEDROCK_INVISIBLE   = Block(95)
STONE_BRICK         = Block(98)
GLASS_PANE          = Block(102)
MELON               = Block(103)
FENCE_GATE          = Block(107)
GLOWING_OBSIDIAN    = Block(246)
NETHER_REACTOR_CORE = Block(247)

.data
"The data (or sub-type) of a block"

Data Values of blocks:
WOOL:
0: White
1: Orange
2: Magenta
3: Light Blue
4: Yellow
5: Lime
6: Pink
7: Grey
8: Light grey
9: Cyan
10: Purple
11: Blue
12: Brown
13: Green
14: Red
15:Black

WOOD:
0: Oak (up/down)
1: Spruce (up/down)
2: Birch (up/down)
(below not on Pi)
3: Jungle (up/down)
4: Oak (east/west)
5: Spruce (east/west)
6: Birch (east/west)
7: Jungle (east/west)
8: Oak (north/south)
9: Spruce (north/south)
10: Birch (north/south)
11: Jungle (north/south)
12: Oak (only bark)
13: Spruce (only bark)
14: Birch (only bark)
15: Jungle (only bark)

WOOD_PLANKS (Not on Pi):
0: Oak
1: Spruce
2: Birch
3: Jungle

SAPLING:
0: Oak
1: Spruce
2: Birch
3: Jungle (Not on Pi)

GRASS_TALL:
0: Shrub
1: Grass
2: Fern
3: Grass (color affected by biome) (Not on Pi)

TORCH:
1: Pointing east
2: Pointing west
3: Pointing south
4: Pointing north
5: Facing up

STONE_BRICK:
0: Stone brick
1: Mossy stone brick
2: Cracked stone brick
3: Chiseled stone brick

STONE_SLAB / STONE_SLAB_DOUBLE:
0: Stone
1: Sandstone
2: Wooden
3: Cobblestone
4: Brick
5: Stone Brick
Below - not on Pi
6: Nether Brick
7: Quartz

Not on Pi
SNOW_BLOCK:
0-7: Height of snow, 0 being the lowest, 7 being the highest.

TNT:
0: Inactive
1: Ready to explode

LEAVES:
1: Oak leaves
2: Spruce leaves
3: Birch leaves

SANDSTONE:
0: Sandstone
1: Chiseled sandstone
2: Smooth sandstone

STAIRS_[COBBLESTONE, WOOD]:
0: Ascending east
1: Ascending west
2: Ascending south
3: Ascending north
4: Ascending east (upside down)
5: Ascending west (upside down)
6: Ascending south (upside down)
7: Ascending north (upside down)

LADDERS, CHESTS, FURNACES, FENCE_GATE:
2: Facing north
3: Facing south
4: Facing west
5: Facing east

[WATER, LAVA]_STATIONARY:
0-7: Level of the water, 0 being the highest, 7 the lowest

NETHER_REACTOR_CORE:
0: Unused
1: Active
2: Stopped / used up

BlockEvent
"The definition of a BlockEvent in Minecraft, used to describe an event in Minecraft affecting blocks; returned by the Minecraft.events.pollBlockHits() method."

blockEvent = mc.events.pollBlockHits()

.type
"Type of block event; there is only 1 event currently implemented BlockEvent.HIT"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
blockEventType = blockEvent.type

BlockEvent types:
0: BlockEvent.HIT

.pos
"The position of the block where the event occured, i.e. the block which was hit.  .pos returns a Vec3 object of x,y,z co-ordinates"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
blockEventPos = BlockEvent.pos

.face
"The face of the block where the event occured"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
blockEventFace = BlockEvent.face

.entityId
"entityId of the player who caused the block event, i.e. the player who hit the block"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
blockEventPlayer - BlockEvent.entityId
ChatEvent
"The definition of a ChatEvent in Minecraft, used to describe an event when a message is posted to the chat bar in Minecraft, returned by Minecraft.events.pollBlockHits() method."

chatEvent = mc.events.pollChatPosts()

.type
"Type of block event; there is only 1 event currently implemented ChatEvent.POST"
Available on RaspberryJuice
chatEventType = chatEvent.type

ChatEvent types:
0: ChatEvent.POST

.message
"The message which was posted to the chat window."
Available on RaspberryJuice
chatEventMessage = ChatEvent.message

.entityId
"entityId of the player who posted the message to the chat."
Available on RaspberryJuice
blockEventPlayer - BlockEvent.entityId
Vec3
"The definition of a 3 part vector in Minecraft, i.e. a set of x, y, z co-ordinates; x and z are the horizontal positions, y the vertical"

position = vec3.Vec(0,0,0)

.x
"x position"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
xPos = position.x
.y
"y position"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
yPos = position.y
.z
"z position"
Available on Minecraft: Pi EditionAvailable on RaspberryJuice
zPos = position.z
信息中心 2020-12-20 22:44
案例:检测玩家所在位置第一步:通过API接口连接游戏1.1什么是API接口

我们的程序和Minecraft游戏可以理解为两个分隔两地的人,两者之间要进行沟通怎么办?
是不是要借助某种工具?比如电话、微信、QQ等等。
这种工具是否需要两者都能够使用?
Minecraft API即Minecraft的应用程序接口,可以理解为Minecraft游戏留给我们用程序跟游戏沟通的工具!
备注:我们用的Minecraft API就是第1节课讲的mcpi目录的文件,这也是为什么.py程序必须创建在mcpi目录的同级目录中。

1.2 连接游戏步骤

(1)首先打开服务器和游戏
(2)通过API连接游戏

import mcpi.minecraft as minecraft#导入程序需要用到的模块#import为导入模块的关键字,mcpi.minecraft为需要引入的模块#as为模块创建别名的关键字,minecraft为模块的别名。#创建别名主要为了简化代码,比如中华人民共和国简称中国!mc = minecraft.Minecraft.create()#minecraft为我们导入的模块的别名,Minecraft.create()为连接游戏的方法#()结尾代表执行一个动作,在编程中一般叫做函数或方法。
  1. import mcpi.minecraft as minecraft
  2. #导入程序需要用到的模块
  3. #import为导入模块的关键字,mcpi.minecraft为需要引入的模块
  4. #as为模块创建别名的关键字,minecraft为模块的别名。
  5. #创建别名主要为了简化代码,比如中华人民共和国简称中国!
  6. mc = minecraft.Minecraft.create()
  7. #minecraft为我们导入的模块的别名,Minecraft.create()为连接游戏的方法
  8. #()结尾代表执行一个动作,在编程中一般叫做函数或方法。
复制代码

注意!#表示注释,用于解释程序,程序运行时不执行这些代码,我们可以不输入这些内容!

第二步:获取玩家的位置pos = mc.player.getTilePos()#网络课件中第6页pos = mc.player.getTilepos()有错误。#mc.player.getTilePos()为获取用户当前位置的方法#变量pos为mc.player.getTilepos()方法的返回值#返回值即方法执行后留给调用者的可用的值,不同方法、函数的返回可能不同。具体概念可在扩展中详细了解#pos变量代表的数据由x,y,z三部分组成,通过print语句可以输入这三部分内容print(pos.x)print(pos.y)print(pos.z)#注意!不是每个变量都可以用pos.x这样的形式表示某一部分数据
    1. pos = mc.player.getTilePos()
    2. #网络课件中第6页pos = mc.player.getTilepos()有错误。
    3. #mc.player.getTilePos()为获取用户当前位置的方法
    4. #变量pos为mc.player.getTilepos()方法的返回值
    5. #返回值即方法执行后留给调用者的可用的值,不同方法、函数的返回可能不同。具体概念可在扩展中详细了解
    6. #pos变量代表的数据由x,y,z三部分组成,通过print语句可以输入这三部分内容
    7. print(pos.x)
    8. print(pos.y)
    9. print(pos.z)
    10. #注意!不是每个变量都可以用pos.x这样的形式表示某一部分数据
    复制代码

3.第三步:改进玩家位置输出信息

pos变量用3个print语句太繁琐,而且程序设计者之外的人可能根本就不明白输出的3个值什么意思!
因此,我们改进程序将3个语句合并为1个语句。

print("x="+str(pos.x)+"y="+str(pos.y)+"z="+str(pos.z))# + 两端都为数字时表示两个数字相加,+ 两端都为字符串时表示拼接两个字符串# + 两端不能一边是数字,一边是字符串# + 在这里用作拼接2个字符串#pos.x,pos.y,pos.z的值均为整数,因此在与字符串拼接前需要转换为字符串
    1. print("x="+str(pos.x)+"y="+str(pos.y)+"z="+str(pos.z))
    2. # + 两端都为数字时表示两个数字相加,+ 两端都为字符串时表示拼接两个字符串
    3. # + 两端不能一边是数字,一边是字符串
    4. # + 在这里用作拼接2个字符串
    5. #pos.x,pos.y,pos.z的值均为整数,因此在与字符串拼接前需要转换为字符串
    复制代码

4.第四步:动态获取玩家位置

通过前两步我们已经可以获取玩家的所在位置,但是有一个缺点,每次运行程序,只能获取一个坐位置,再移动玩家,就获取不了位置,只能再次运行程序!如何动态获取玩家位置?

4.1 导入time模块

time是Python自带的关于时间的模块。

import time#通过import语句导入time模块time.sleep(1)#time.sleep()方法可以让程序暂停执行一定时间,单位为秒#演示代码为1,即暂停1秒,()内的值可以修改,要求为整数。
    1. import time
    2. #通过import语句导入time模块
    3. time.sleep(1)
    4. #time.sleep()方法可以让程序暂停执行一定时间,单位为秒
    5. #演示代码为1,即暂停1秒,()内的值可以修改,要求为整数。
    复制代码

4.2 while循环

格式:

while 条件:    子代码块条件为True时,执行子代码块
    1. while 条件:
    2.     子代码块
    3. 条件为True时,执行子代码块
    复制代码

注意:子代码块整体要缩进!

4.3 动态获取玩家位置

代码:

import timeimport mcpi.minecraft as minecraftmc = minecraft.Minecraft.create()while True:    time.sleep(1)    pos = mc.player.getTilePos()    mc.postToChat("x=" + str(pos.x) + "y=" + str(pos.y) + "z=" + str(pos.z))
    1. import time
    2. import mcpi.minecraft as minecraft

    3. mc = minecraft.Minecraft.create()
    4. while True:
    5.     time.sleep(1)
    6.     pos = mc.player.getTilePos()
    7.     mc.postToChat("x=" + str(pos.x) + "y=" + str(pos.y) + "z=" + str(pos.z))
    复制代码

代码解读:

#导入使用到的模块import time import mcpi.minecraft as minecraftmc = minecraft.Minecraft.create()#使用API连接游戏while True:    #死循环,监听游戏    time.sleep(1)    #每次循环暂停1秒钟,要不然一直后面输出太快,我们就不容易看到后面输出的结果    pos = mc.player.getTilePos()    #获取玩家当前位置    mc.postToChat("x=" + str(pos.x) + "y=" + str(pos.y) + "z=" + str(pos.z))    #利用postToChat()方法在游戏中输出玩家的位置
    1. #导入使用到的模块
    2. import time
    3. import mcpi.minecraft as minecraft

    4. mc = minecraft.Minecraft.create()
    5. #使用API连接游戏
    6. while True:
    7.     #死循环,监听游戏
    8.     time.sleep(1)
    9.     #每次循环暂停1秒钟,要不然一直后面输出太快,我们就不容易看到后面输出的结果
    10.     pos = mc.player.getTilePos()
    11.     #获取玩家当前位置
    12.     mc.postToChat("x=" + str(pos.x) + "y=" + str(pos.y) + "z=" + str(pos.z))
    13.     #利用postToChat()方法在游戏中输出玩家的位置
    复制代码

注意!因为while循环中条件一直为True,所以子代码块一直执行,而且子代码块未引入退出循环的机制,这样程序就无法正常退出,只能强制停止程序(在终端中同时按下ctrl键和c键)。
while True:这种形式的循环一般用于监听事件,等待用户执行某种操作,例如当代用户输入用户名、密码,用户输入完成之后退出循环,如果用户未完成输入,一直循环,等待用户完成输入。


                               
登录/注册后可看大图


信息中心 2020-12-20 22:49
游戏简介

我的世界(Minecraft)是一款沙盒建造游戏,于2009年5月17日发行,由瑞典游戏设计师马库斯·阿列克谢·泊松开创,现由Mojang Studios维护,2014年11月,微软(Microsoft)斥资25亿美元收购了Mojang Studios ,Mojang Studios 的业务也已经正式转移至了微软Xbox部门。2016年,微软、Mojang Studios 和网易联合宣布,Mojang Studios 将《我的世界》中国大陆地区的独家运营权正式授予网易公司。

游戏模式

Minecraft大部分游戏模式的主要游戏内容(Gameplay)是在一个随机生成的世界中放置和破坏各种方块。利用这些方块,玩家可以改造游戏世界,建造和破坏建筑结构。
Minecraft中的五大游戏模式为:生存模式、创造模式、冒险模式、极限模式和旁观模式。

  • 生存模式:在这种模式中,玩家必须收集资源以进行建造、合成及挣取经验值和活下去。玩家拥有生命、饥饿和盔甲条,物品栏和水下时的氧气槽。
  • 创造模式:在这个模式中,玩家可以无限使用几乎所有的方块和物品,并可以瞬间破坏。玩家是无敌的(除非使用/kill命令或掉入虚空‌‌[仅Java版]),不显示生命、饥饿、盔甲条和氧气槽,并可以飞行。
  • 冒险模式:玩家可以操作一些物品如拉杆和按钮,并可以与一些生物互动,但玩家只能使用带有CanDestroy的工具破坏方块,且只能在带有CanPlaceOn的方块上面放置方块。这个模式很适合用于探险类地图中。
  • 极限模式:这个模式大部分与生存模式相同,但游戏被锁定为“困难”,且玩家只有一条生命,在玩家死亡后,则会进入到旁观模式。
    从技术上讲,极限模式更像是一种游戏修改设定而不是一个独立的新模式。不过,除非作弊,否则玩家只能玩到“极限生存模式”。要玩到“极限创造模式”,玩家必须使用工具修改世界存档,不过,“极限创造模式”跟普通创造模式相比几乎没有任何区别,由于在创造模式中死亡只有使用游戏命令和掉进虚空这两种方法。在极限模式服务器中,如果一个玩家死亡,他就会被服务器屏蔽掉。如果服务器中所有人都死亡了,则服务器世界会被删除。
  • 旁观模式:旁观模式在Java版1.8被加入。当你在旁观模式时,你可以穿过方块,可以通过左键生物进入它们的视角,但是除了其他处于旁观模式的玩家之外,你对所有生物是都隐形的。你不能与任何方块、实体和物品栏里的物品互动,当你处于第三人称模式时,你看起来像一个浮空的透明头。不像在创造模式下的飞行,你可以使用滚轮调整你的飞行速度。
创造模式

创造模式(Creative Mode)是Minecraft中主要的游戏模式之一。创造模式移除了游戏中的生存内容,并且允许玩家方便自由地创造和破坏结构与机械。
在创造模式中,玩家拥有无限数量的方块用于创造,没有生命值和饥饿值来阻碍他们的建造。创造模式允许玩家在没有拿剑时瞬间破坏大多数的方块,包括像基岩和末地传送门这种正常情况下不能破坏的方块,除隐形基岩等。使用一次性的物品也不会使其被消耗。
创造模式给予玩家飞行的能力。玩家可通过快速按两下空格起飞,并通过按住空格上升高度,或通过Shift降低高度和着陆;使用WASD(默认值)可在同一高度下移动。另外,玩家在空中快速按两下空格可离开飞行状态并掉下来。在Java版中,飞行时碰到方块表面时(降落在方块上时),玩家会自动离开飞行状态;基岩版中则不会(但速度仍会降到行走的速度)。飞行时进入矿车和床后再离开后,玩家将仍然处于飞行状态。
玩家在创造模式中无法受到伤害。掉进虚空过深仍会导致玩家死亡‌‌,但是玩家只要不掉到y低于-64时就不会受到伤害,且玩家可以在虚空中飞行。这是在创造模式中除了通过/kill命令和外部修改器外唯一的死亡方法。与旁观模式类似,基岩版的玩家在创造模式下不会受到任何伤害。
在多人游戏中,管理员可以通过/gamemode命令单独切换每一位玩家的游戏模式。这意味着在一个生存模式的世界中(根据管理员的意愿)玩家也可以使用创造模式,反之亦然。新玩家的默认游戏模式也能通过/defaultgamemode命令来切换。

管理员命令

craftbukkit服务器启动后,可在控制台中输入命令。


                               
登录/注册后可看大图

输入op 用户名可将某用户指定为管理员,这样就拥有在服务器上执行命令的权限。

                               
登录/注册后可看大图


                               
登录/注册后可看大图

输入help,即可列出所有命令

                               
登录/注册后可看大图

查看命令的详细帮助,可以使用如下命令格式:help 命令

                               
登录/注册后可看大图

基本操作(默认)

用户进入游戏后界面下方是物品栏,默认9个空间。下方右侧即手中的方块。前方的立方体和准星即当前用户放置或摧毁方块的位置。


                               
登录/注册后可看大图

用户按E打开/关闭背包,打开背包后可将背包中不同种类的方块放置在快捷物品栏,以供用户快速放置。用户按Q键可丢弃手中的方块,按F键可切换手中方块。

                               
登录/注册后可看大图

用户可以使用鼠标左键摧毁方块,鼠标右键放置方块,鼠标中键或滚轮切换物品。
用户可以使用WASD 上左下右移动方位。
用户可以按一次空格进行跳跃。
用户快速按两次空格将进行飞行,在飞行过程中可以按空格提升高度,按shift下降高度。在飞行中快速按两次空格将快速落地。
用户按ESC键可以显示系统菜单。

                               
登录/注册后可看大图
其中菜单中比较重要的是选项>控制,在这里可以查看\修改默认快捷键。

                               
登录/注册后可看大图

坐标系

坐标(coordinates)在数字上反映了玩家在世界中的位置。
坐标基于一个由互相垂直且交于一点(即原点)的三条坐标轴形成的网格,即一个空间直角坐标系。坐标系的单位长度为一个方块长,基于测量方法,每一方块为1立方米。

  • x轴的正方向为东,其坐标反映了玩家距离原点在东(+)西(-)方向上的距离。
  • z轴的正方向为南,其坐标反映了玩家距离原点在南(+)北(-)方向上的距离。
  • y轴的正方向为上,其坐标反映了玩家位置的高低程度(从0至255,其中海平面为62),另见海拔高度。

                                   
    登录/注册后可看大图

    一个方块的坐标实际上是这个方块的西北下角那一点的坐标,即方块内的坐标向下取整得到的整数坐标。在游戏中,一个小数坐标通常需要通过向下取整转换成整数坐标,这个整数坐标称为原坐标的方块坐标。
    当用户向南方移动时z坐标会增加,向北方移动时z坐标会减少。类似地,向东方移动时x坐标会增加,向西方移动时x坐标会减少。而当用户上升时y坐标会增加,而当您下降时y坐标会下降。
    在显示调试信息时,调试信息包含坐标系信息,比如详细坐标、当前方向、坐标方位提示:蓝色正南,红色正东,绿色正上。

                                   
    登录/注册后可看大图

系统快捷键

F1隐藏用户图形界面
F2截图
F11全屏切换
F3显示调试信息


                               
登录/注册后可看大图

F3+Q显示F3帮助信息

                               
登录/注册后可看大图

设置永久白天

time set 0先设置当前时间为白天
gamerule doDaylightCycle false再关闭昼夜循环

>time set 0[INFO: Set the time to 0>gamerule doDaylightCycle false[INFO: Game rule doDaylightCycle has been updated to false>time set 0
    1. <li>><span style="color: rgb(0, 0, 0); font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-ligatures: common-ligatures; white-space: pre; background-color: rgb(250, 250, 250);">time </span><span class="token keyword" style="box-sizing: border-box; outline: 0px; word-wrap: normal; font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; color: rgb(0, 119, 170); word-break: break-all; white-space: pre; font-variant-numeric: normal !important; font-variant-east-asian: normal !important; font-stretch: normal !important; line-height: normal !important;">set</span><span style="color: rgb(0, 0, 0); font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-ligatures: common-ligatures; white-space: pre; background-color: rgb(250, 250, 250);"> 0
    2. </span><span class="token punctuation" style="box-sizing: border-box; outline: 0px; word-wrap: normal; font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; color: rgb(153, 153, 153); word-break: break-all; white-space: pre; font-variant-numeric: normal !important; font-variant-east-asian: normal !important; font-stretch: normal !important; line-height: normal !important;">[</span><span style="color: rgb(0, 0, 0); font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-ligatures: common-ligatures; white-space: pre; background-color: rgb(250, 250, 250);">INFO</span><span class="token punctuation" style="box-sizing: border-box; outline: 0px; word-wrap: normal; font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; color: rgb(153, 153, 153); word-break: break-all; white-space: pre; font-variant-numeric: normal !important; font-variant-east-asian: normal !important; font-stretch: normal !important; line-height: normal !important;">]</span><span style="color: rgb(0, 0, 0); font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-ligatures: common-ligatures; white-space: pre; background-color: rgb(250, 250, 250);">: Set the </span><span class="token function" style="box-sizing: border-box; outline: 0px; word-wrap: normal; font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; color: rgb(221, 74, 104); word-break: break-all; white-space: pre; font-variant-numeric: normal !important; font-variant-east-asian: normal !important; font-stretch: normal !important; line-height: normal !important;">time</span><span style="color: rgb(0, 0, 0); font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-ligatures: common-ligatures; white-space: pre; background-color: rgb(250, 250, 250);"> to 0
    3. </span><span class="token operator" style="box-sizing: border-box; outline: 0px; word-wrap: normal; font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; color: rgb(166, 127, 89); word-break: break-all; white-space: pre; font-variant-numeric: normal !important; font-variant-east-asian: normal !important; font-stretch: normal !important; line-height: normal !important;">></span><span style="color: rgb(0, 0, 0); font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-ligatures: common-ligatures; white-space: pre; background-color: rgb(250, 250, 250);">gamerule doDaylightCycle </span><span class="token boolean" style="box-sizing: border-box; outline: 0px; word-wrap: normal; font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; color: rgb(1, 132, 187); word-break: break-all; white-space: pre; font-variant-numeric: normal !important; font-variant-east-asian: normal !important; font-stretch: normal !important; line-height: normal !important;">false</span><span style="color: rgb(0, 0, 0); font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-ligatures: common-ligatures; white-space: pre; background-color: rgb(250, 250, 250);">
    4. </span><span class="token punctuation" style="box-sizing: border-box; outline: 0px; word-wrap: normal; font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; color: rgb(153, 153, 153); word-break: break-all; white-space: pre; font-variant-numeric: normal !important; font-variant-east-asian: normal !important; font-stretch: normal !important; line-height: normal !important;">[</span><span style="color: rgb(0, 0, 0); font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-ligatures: common-ligatures; white-space: pre; background-color: rgb(250, 250, 250);">INFO</span><span class="token punctuation" style="box-sizing: border-box; outline: 0px; word-wrap: normal; font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; color: rgb(153, 153, 153); word-break: break-all; white-space: pre; font-variant-numeric: normal !important; font-variant-east-asian: normal !important; font-stretch: normal !important; line-height: normal !important;">]</span><span style="color: rgb(0, 0, 0); font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-ligatures: common-ligatures; white-space: pre; background-color: rgb(250, 250, 250);">: Game rule doDaylightCycle has been updated to </span><span class="token boolean" style="box-sizing: border-box; outline: 0px; word-wrap: normal; font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; color: rgb(1, 132, 187); word-break: break-all; white-space: pre; font-variant-numeric: normal !important; font-variant-east-asian: normal !important; font-stretch: normal !important; line-height: normal !important;">false</span></li>
    复制代码

参考

Minecraft中文维基:https://minecraft-zh.gamepedia.com/Minecraft_Wiki

lubowen1906 2020-12-23 10:08
好硬核,甘拜下风

查看全部评论(7)

Loading...
展开
返回顶部