Minecraft地图读写器

minecraftmap的Python项目详细描述


简单的Python3编辑器,用于NBT格式的Minecraft地图(项目)。允许使用python图像库编辑地图图像,或通过以颜色本机格式编辑字节来编辑地图图像。

用法:

import minecraftmap
filepath = "/Users/spookymushroom/AppData/Roaming/.minecraft/saves/Test World/data/map_0.dat"

# The False eco value indicates that __init__ should run genimage to update im (the PIL image)
m = minecraftmap.Map(filepath,eco=False)

# The '8' byte in Minecraft's color format is equivalent to (174, 164, 115)
print(m.allcolors[8])

# The allcolorsinversemap dictionary will return the byte value of a color
# when any native Minecraft map color is passed into it
print(m.allcolorsinversemap[(174, 164, 115)])

if m.getbyte(6747) != 8:
   m.setbyte(6747,8)

# Equivalent to getbyte(6747) for a 128x128 map
if m.getpoint((91,52)) != 8:
   m.setpoint((91,52),8)

# Updates Map.im (PIL) to match Map.file (NBT)
m.genimage()

# PIL methods, m.font defaults to Andrew Tyler's Minecraftia
m.draw.rectangle((0,0,30,30),fill=(56,58,89))
m.draw.text((40,40),"testing",font=m.font)

# Save Map.im (The PIL.Image object) to a file
m.saveimagepng("map_0.png") #front-end for m.im.save
m.saveimagejpg("map_0.jpg") #front-end for m.im.save

# PIL.Image.save method
m.im.save("map_0_customqual.jpg","JPEG",quality=80)

# Updates Map.file (NBT data) to match Map.im (PIL image)
# Versions before 0.2 require that the image contains only native colors
m.imagetonbt()

# Saves Map.file to an NBT file
# If filename argument is left blank, it saves data to
# the original file as identified by m.file.filename
print(m.file.filename)
m.savenbt()
Requires:Thomas Woolford’s NBT library
Requires:Python Image Library (Pillow)
Includes:Andrew Tyler’s Minecraftia font

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何使用Ibatis在插入时返回ID(使用返回关键字)   java(org.hibernate.TransactionException)org。冬眠TransactionException:事务未成功启动   java小程序jwindow始终位于JNLP顶部   在Java中重新解析JSON对象?   java单击后将ListView数据移动到新屏幕   Mule ESB中的java WSA寻址特性   Java,对象编程:获取返回0值的方法   hibernate的Java通用问题,如何处理T get(K id)   java在使用超级CSV读取CSV时忽略引用   ssh使用Java远程运行命令   java如何向具体用户发送websocket消息?   在JAVA中,我可以在不指定的情况下使用条件运算符吗?