如何从Minecraft编辑.mca文件? [英] How do I edit .mca files from Minecraft?

查看:1036
本文介绍了如何从Minecraft编辑.mca文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简介

我想将自己的Minecraft世界组合成一个世界,这似乎是一个相对容易的壮举,但是随着我的研究,它逐渐演变为制作自定义程序的需求.

挣扎

我首先移动区域文件并将它们组合到一个区域文件夹中,这似乎是显而易见的解决方案,并且几乎可以正常工作. 注意:我已经打开了文件,似乎整个扇区都存储了它们的坐标,而不是实体,因此地形本身在空间上与区域文件名不匹配.

当我打开客户端并且区域无法渲染时,这导致了相当大的滞后.我阅读了Anvil文件格式,并设想了一种读取NBT文件的方案.我以为我可以手动读出字节并进行编辑,但是在我的继续研究中,关于区域文件是否被压缩,我得到了矛盾的答案.

我完成了足够的代码来读取一些原始字节,但是字节值没有按我预期的那样输出.

根据我在NBT文件上获得的信息,它们都以CompoundTag开头,而CompoundTag以值为10或x0A的单个字节开头. 这是我获取格式信息的地方: https://minecraft.gamepedia.com/NBT_format

以下是实际结果的屏幕截图:

注意:屏幕截图中的类描述不正确.我只是迅速地填写了足够的内容以读取字节,而不是充实UI功能.

我认为这些字节以无意义的方式出现,表明文件已被压缩.我发现这是gzip问题的开始: http://gnuwin32.sourceforge.net/packages/gzip.htm

我想如果可以安装此程序,它将解压缩该.mca文件,并且可以按预期读取字节,但是我不理解安装说明.它说使用​​ Shell命令,'configure','make'和'make install'".对我来说,这听起来像Unix,但是我下载的文件是否适用于Windows?没有任何exe文件,但是有很多C文件.我没有C编译器. .

注意:我仍然没有使用gzip软件.

发布脚本

我在这里看到过类似的问题,但是它们要么都是旧的(2016年问世),而且以前使用的软件链接无效,要么是最新的且未得到解答.我找到了五个月前问到的该问题的一份具体副本,但是我不得不建立一个帐户才能发表评论.这是链接:解决方案

我找到了编辑器!

现在我可以编辑,但是我不知道编辑方式.我没有学到的任何东西,但是我终于找到了别人的编辑器.并不是我想要的,因为我想自己知道如何做到这一点.

更新:要使用此软件修复区域,我必须手动编辑2个字段(最多32x32块),并且需要修复 118个区域 . **这是241,664个潜在的手动编辑!此解决方案在合理的时间范围内不可行,但这是我到目前为止所拥有的最好的解决方案:

我找到了此页面: https://fileinfo.com/extension/mca

链接到此页面的页面: https://fileinfo.com/software/nbtexplorer/nbtexplorer

链接到此页面的页面: https://github.com/jaquadro/NBTExplorer/releases

我安装了该软件,它自动链接到.minecraft文件夹,这是GUI的屏幕截图:

从好的方面来说,该应用程序下载页面上也有该源代码的下载链接,因此,我打算读一下!到目前为止,我已经打开了两个文件,以一目了然,并且它们都没有被评论.它们也是用C#编写的,这是我以前从未见过的,但是我听说它与Java非常相似,所以也许我也会学习该语言.

Introduction

I want to combine my separate Minecraft worlds into a single world and it seemed like a relatively easy feat, but as I did research it evolved into the need to make a custom program.

The Struggle

I started by shifting the region files and combining them in one region folder, which seemed like the obvious solution and it almost worked. Note: I've opened the files and it seems entire sectors have their coordinates stored, not entities, hence the terrain itself is spatially mismatched with the region file name.

That led to quite a bit of lag when I opened the client and the regions failed to render. I read up on the Anvil file format and imagined a scheme for reading NBT files. I figured I could manually read out the bytes and edit them, but in my continued research I got conflicting answers as to whether region files are gzipped.

I finished enough code to read some raw bytes, but the byte values didn't come out as I expected.

According to the info I have on NBT files, they all start with a CompoundTag and a CompoundTag starts as a single byte valued as 10, or x0A. This is where I got my format information: https://minecraft.gamepedia.com/NBT_format

Here's a screenshot of what actually came out:

Note: The class description in the screenshot is not accurate. I just quickly filled in enough to read the bytes, not flesh out the UI function.

I assume these bytes coming out as non-sense is a sign that the file is compressed. I found this as a start to the gzip problem: http://gnuwin32.sourceforge.net/packages/gzip.htm

I imagine if I could get this installed it would unzip this .mca file and I could read the bytes as expected, but I don't understand the installation instructions. It says use the "Shell Commands, 'configure', 'make' and 'make install'". To me that sounds like Unix, but the file I downloaded is for Windows? There aren't any exe's, but there are quite a few C files. I don't have a C-compiler. . .

Note: I still have not got the gzip software to work.

Post Script

I've seen similar questions asked here, but all of them were either old (2016ish) with dead links to software that used to work, or they were recent and unanswered. I found one specific copy of this question asked 5 months ago, but I had to make an account to comment. Here's the link: How can read Minecraft .mca files so that in python I can extract individual blocks? His question is with regard to a Python implementation. He said he found an NBT library for Python, but it was rejecting his MCA files for being not-gzipped.

I've got a lead on understanding the problem because I have the NBTExplorer source code (see the answer I posted), but I'll have to update on how that pans out. As far as getting my world fixed, I think I have a viable solution now.

If anyone could point me to a finished Java library, with source code, that opens .mca's or a discussion board related to this topic that'd be cool. I'm still also interested in how file compression works, but that's probably outside this question's scope. I realize this isn't directly bug or error related; it's it was moreso that I didn't know what further steps to take to make a code that accomplishes this task.

Update

I found someone else's program to do this and posted it as an answer, but I'd still like to know how the file is converted from bytes to useable info. Using the manual edit method of the answer I posted, I will need at most 241,664 manual edits, so I still need a better solution.

解决方案

I found an editor!

Now I can edit, but I don't know how the editing works. I haven't learned anything, but I did finally find someone else's editor. Not quite what I wanted because I wanted to know how to do this myself.

Update: To fix a region using this software I have to manually edit 2 fields, for up to 32x32 chunks, and I have 118 regions that I need to fix. **That's 241,664 potential manual edits! This solution is not viable on a reasonable timescale, but it's the best I have so far:

I found this page: https://fileinfo.com/extension/mca

Which linked to this page: https://fileinfo.com/software/nbtexplorer/nbtexplorer

Which linked to this page: https://github.com/jaquadro/NBTExplorer/releases

I installed the software and it automatically linked to the .minecraft folder, here's a screenshot of the GUI:

On the bright side, the application download page also has a download link for the source, so I intend to read that! I've opened two files so far to take a glance and they were not commented at all. They're also written in C# which I have never seen before, but I've heard it's very similar to Java, so maybe I'll learn that language too.

这篇关于如何从Minecraft编辑.mca文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆