简体   繁体   中英

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. What I tried: First I set up a basic 1.8 forge mod which works completely. 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. (function's that dont exist for example). How could I update this mod to 1.8?
Arrow marker 1.7.10

example of strange decompiling:(it errors on the func_151468_f, or the mc.field things)

@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). 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. Since it decompiles and reformats the entire minecraft client, it has access to very specific names that the obfuscated methods/fields cannot find. This causes the Java IDE to throw errors, mainly unimplemented errors, where it cannot find the method/field specified. It is also important to note that 'methods' will always start with func , which means function. 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 . This file contains three csv files, named methods, fields, and params. What you are concerned with is methods and fields. Open these files in a text editor, or Excel if you own it. 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). Use the 'find' option to find the obfuscated name. Beside it, the official MC name should be listed. As an example, your obfuscated code, translated into normal MC code should look something like this:

@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. 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. Once that is confirmed to build and work correctly, download forge for 1.8 and copy paste src folder into the new forge directory. 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 ). What this means is that you take the obfuscated method/field, and search for it in the 1.8 csv files. This method usually doesn't work out too well, however does work in certain cases.

Conclusion

To sum it up (or 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)
  • 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.
  • The mod should update properly. Have fun playing with your updated 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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