简体   繁体   English

将下载的minecraft mod更新为1.8

[英]Update a downloaded minecraft mod to 1.8

I have downloaded a forge mod (ArrowMarker 1.7.10 version) and I would like to update it so it works on 1.8 forge Minecraft. 我已经下载了一个forge mod(ArrowMarker 1.7.10版本),我想更新它,所以它适用于1.8 forge Minecraft。 What I tried: First I set up a basic 1.8 forge mod which works completely. 我尝试过的:首先我设置了一个基本的1.8锻造mod,它完全有效。 Then I tried multiple decompilers to decompile the .jar archive, however I keep getting a lot of errors when I paste in the code of these files. 然后我尝试了多个反编译器来反编译.jar存档,但是当我粘贴这些文件的代码时,我会遇到很多错误。 (function's that dont exist for example). (例如,不存在的功能)。 How could I update this mod to 1.8? 我怎么能将这个mod更新为1.8?
Arrow marker 1.7.10 箭头标记1.7.10

example of strange decompiling:(it errors on the func_151468_f, or the mc.field things) 奇怪的反编译的例子:(它在func_151468_f或mc.field事情上的错误)

@SubscribeEvent
      public void RenderVillageCheckerFromEvent(InputEvent.KeyInputEvent event)
      {

        if (key_enable.func_151468_f())
        {
            ArrowMarker.arrowMarker.mode += 1;
          if (ArrowMarker.arrowMarker.mode == 4) {
              ArrowMarker.arrowMarker.mode = 0;
          }
        }
        if (key_h.func_151468_f()) {
          ArrowMarker.arrowMarker.Hactive = (ArrowMarker.arrowMarker.Hactive);
        }
        if (sen == -1.0F) {
          sen = mc.field_71474_y.field_74341_c;
        }
        if (key_slow.func_151470_d()) {
          mc.field_71474_y.field_74341_c = (sen / 10.0F);
        } else {
          mc.field_71474_y.field_74341_c = sen;
        }
        if ((mc.field_71462_r != null) && (ArrowMarker.arrowMarker.mode > 2)) {
            ArrowMarker.arrowMarker.mode = 1;
        }
      }

I understand this post is old, however it helps to give a clear concise answer. 我知道这篇文章很老了,但是给出一个清晰简洁的答案是有帮助的。 This can help new developers understand what is going on. 这可以帮助新开发人员了解正在发生的事情。

Information 信息

What you are seeing are the obfuscated method/field names (known as searge names). 您所看到的是混淆的方法/字段名称(称为searge名称)。 This is due to a code protection system known as obfuscation . 这是由于代码保护系统称为混淆 It prevents people from being able to copy your code, and take credit for it. 它可以防止人们复制您的代码,并为此获得赞誉。 Usually, this doesn't pose too many problems, since it only creates illegible but otherwise working code. 通常,这不会造成太多问题,因为它只会创建难以辨认但其他工作代码。

Problem 问题

Minecraft Forge, however, operates a bit differently. 然而,Minecraft Forge的运作方式略有不同。 Since it decompiles and reformats the entire minecraft client, it has access to very specific names that the obfuscated methods/fields cannot find. 由于它反编译并重新格式化整个minecraft客户端,因此它可以访问模糊方法/字段无法找到的非常具体的名称。 This causes the Java IDE to throw errors, mainly unimplemented errors, where it cannot find the method/field specified. 这会导致Java IDE抛出错误,主要是未实现的错误,它无法找到指定的方法/字段。 It is also important to note that 'methods' will always start with func , which means function. 同样重要的是要注意'方法'总是以func开头,这意味着函数。 Similarly, fields will start with field , and parameters will start with p . 同样,字段将与现场开始,参数将与开始。

Solution

Since you say that this mod was written in 1.7.10, it uses 1.7.10 obfuscation, which means you should download this file . 既然你说这个mod是在1.7.10中编写的,它使用1.7.10混淆,这意味着你应该下载这个文件 This file contains three csv files, named methods, fields, and params. 此文件包含三个csv文件,名为methods,fields和params。 What you are concerned with is methods and fields. 你关心的是方法和领域。 Open these files in a text editor, or Excel if you own it. 如果您拥有它,请在文本编辑器或Excel中打开这些文件。 Now, copy either an obfuscated method name or field name onto your clipboard. 现在,将模糊的方法名称或字段名称复制到剪贴板上。 Once you have done that, open the corresponding file (if you copied a "func_", open methods.csv, etc). 完成后,打开相应的文件(如果您复制了“func_”,打开methods.csv等)。 Use the 'find' option to find the obfuscated name. 使用“查找”选项查找模糊名称。 Beside it, the official MC name should be listed. 除此之外,应列出官方MC名称。 As an example, your obfuscated code, translated into normal MC code should look something like this: 例如,您的混淆代码,翻译成正常的MC代码应该如下所示:

@SubscribeEvent
public void RenderVillageCheckerFromEvent(InputEvent.KeyInputEvent event)
{
    if (key_enable.isPressed())
    {
        ArrowMarker.arrowMarker.mode += 1;
        if (ArrowMarker.arrowMarker.mode == 4) {
            ArrowMarker.arrowMarker.mode = 0;
        }
    }
    if (key_h.isPressed()) {
        ArrowMarker.arrowMarker.Hactive = (ArrowMarker.arrowMarker.Hactive);
    }
    if (sen == -1.0F) {
        sen = mc.gameSettings.mouseSensitivity;
    }
    if (key_slow.getIsKeyPressed()) {
        mc.gameSettings.mouseSensitivity = (sen / 10.0F);
    } else {
        mc.gameSettings.mouseSensitivity = sen;
    }
    if ((mc.currentScreen != null) && (ArrowMarker.arrowMarker.mode > 2)) {
        ArrowMarker.arrowMarker.mode = 1;
    }
}

Now the above only addresses the errors for the 1.7.10 client. 现在上面只解决了1.7.10客户端的错误。 Most method names/fields change every release, and majority of the code will be broken. 大多数方法名称/字段都会更改每个版本,并且大部分代码都会被破坏。 My advice is to first perform the above solution and build on a 1.7.10 forge download. 我的建议是首先执行上述解决方案并构建1.7.10 forge下载。 Once that is confirmed to build and work correctly, download forge for 1.8 and copy paste src folder into the new forge directory. 一旦确认构建并正常工作,请下载forge for 1.8并将paste src文件夹复制到新的forge目录中。 Multiple errors will popup, your best chance is to look through them, and try and find what errors occur. 将弹出多个错误,您最好的机会是查看它们,并尝试查找发生的错误。 The forge forums are perfect, since the users there have an extensive amount of knowledge in terms of obfuscation and the new methods/fields that exist. 伪造论坛是完美的,因为那里的用户在混淆和存在的新方法/领域方面有广泛的知识。 Another way to do this, is to cross reference the 1.7.10 obfuscation with the 1.8 obfuscation (whose csv files can be found here ). 另一种方法是交叉引用1.7.10混淆与1.8混淆(其csv文件可以在这里找到)。 What this means is that you take the obfuscated method/field, and search for it in the 1.8 csv files. 这意味着你采用混淆的方法/字段,并在1.8 csv文件中搜索它。 This method usually doesn't work out too well, however does work in certain cases. 这种方法通常效果不好,但在某些情况下确实有效。

Conclusion 结论

To sum it up (or tl;dr) 总结(或tl; dr)

  • Download obfuscated name reference list from here . 这里下载混淆的名称参考列表。
  • Find the obfuscated name reference, and find the official documented name (is the second value from the obfuscated name ie func_123456_a, methodName, 0, description) 找到混淆的名称引用,并找到官方记录的名称(是混淆名称中的第二个值,即func_123456_a,methodName,0,description)
  • Compile and run for 1.7.10, then copy-paste into 1.8 directory, solve errors by cross referencing from 1.7.10 -> 1.8. 编译并运行1.7.10,然后复制粘贴到1.8目录,通过交叉引用从1.7.10 - > 1.8解决错误。
  • The mod should update properly. mod应该正确更新。 Have fun playing with your updated mod! 玩最新的mod玩得开心!

Important Notice 重要的提醒

Do not attempt to redistribute the software as your own. 不要尝试将软件重新分发为您自己的软件。 This will get you into lots of trouble, legal or not. 这会给你带来很多麻烦,合法与否。 It isn't worth stealing code and claiming it as your own. 不值得窃取代码并声称它是您自己的代码。 If you plan to release the updated version, make sure you credit the original author of the mod. 如果您打算发布更新版本,请确保您相信该mod的原始作者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM