Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MCP's decompile.sh script fails on mac due to narrator library natives #501

Closed
Pokechu22 opened this issue Sep 15, 2017 · 37 comments
Closed
Assignees
Labels

Comments

@Pokechu22
Copy link

This was reported by NarcolepticFrog elsewhere recently, though it was also mentioned in #mcp.

Running decompile.sh on mac with MC 1.12 causes this:

ERROR:root:FATAL ERROR
Traceback (most recent call last):
  File "./runtime/decompile.py", line 61, in decompile
    commands = Commands(conffile, verify=True, no_patch=no_patch, workdir=workdir, json=json)
  File "/Users/tdick/mcps/mcp-1.12-940/runtime/commands.py", line 178, in __init__
    normalStart = self.readconf(workdir, json)
  File "/Users/tdick/mcps/mcp-1.12-940/runtime/commands.py", line 568, in readconf
    self.mcLibraries = MinecraftDiscovery.getLibraries(mcDir, self.jsonFile, osKeyword)
  File "/Users/tdick/mcps/mcp-1.12-940/runtime/MinecraftDiscovery.py", line 158, in getLibraries
    libFilename = "%s-%s-%s.jar"%(libSubdir, libVersion, substitueString(library['natives'][osKeyword]))
KeyError: 'osx'

I personally do not use a mac, but I do know how version JSONs work. Here's the relevant data for the narrator library:

    {
      "name": "com.mojang:text2speech:1.10.3",
      "downloads": {
        "artifact": {
          "url": "https://libraries.minecraft.net/com/mojang/text2speech/1.10.3/text2speech-1.10.3.jar",
          "sha1": "48fd510879dff266c3815947de66e3d4809f8668",
          "size": 11055
        },
        "classifiers": {
          "natives-linux": {
            "url": "https://libraries.minecraft.net/com/mojang/text2speech/1.10.3/text2speech-1.10.3-natives-linux.jar",
            "sha1": "ab7896aec3b3dd272b06194357f2d98f832c0cfc",
            "size": 7833
          },
          "natives-windows": {
            "url": "https://libraries.minecraft.net/com/mojang/text2speech/1.10.3/text2speech-1.10.3-natives-windows.jar",
            "sha1": "84a4b856389cc4f485275b1f63497a95a857a443",
            "size": 81217
          }
        }
      }
    },
    {
      "name": "com.mojang:text2speech:1.10.3",
      "natives": {
        "linux": "natives-linux",
        "windows": "natives-windows"
      },
      "extract": {
        "exclude": [
          "META-INF/"
        ]
      },
      "downloads": {
        "artifact": {
          "url": "https://libraries.minecraft.net/com/mojang/text2speech/1.10.3/text2speech-1.10.3.jar",
          "sha1": "48fd510879dff266c3815947de66e3d4809f8668",
          "size": 11055
        },
        "classifiers": {
          "natives-linux": {
            "url": "https://libraries.minecraft.net/com/mojang/text2speech/1.10.3/text2speech-1.10.3-natives-linux.jar",
            "sha1": "ab7896aec3b3dd272b06194357f2d98f832c0cfc",
            "size": 7833
          },
          "natives-windows": {
            "url": "https://libraries.minecraft.net/com/mojang/text2speech/1.10.3/text2speech-1.10.3-natives-windows.jar",
            "sha1": "84a4b856389cc4f485275b1f63497a95a857a443",
            "size": 81217
          }
        }
      }
    },
    {
      "name": "ca.weblite:java-objc-bridge:1.0.0",
      "rules": [
        {
          "action": "allow",
          "os": {
            "name": "osx"
          }
        }
      ],
      "natives": {
        "osx": "natives-osx"
      },
      "extract": {
        "exclude": [
          "META-INF/"
        ]
      },
      "downloads": {
        "artifact": {
          "url": "https://libraries.minecraft.net/ca/weblite/java-objc-bridge/1.0.0/java-objc-bridge-1.0.0.jar",
          "sha1": "6ef160c3133a78de015830860197602ca1c855d3",
          "size": 40502
        },
        "classifiers": {
          "natives-osx": {
            "url": "https://libraries.minecraft.net/ca/weblite/java-objc-bridge/1.0.0/java-objc-bridge-1.0.0-natives-osx.jar",
            "sha1": "08befab4894d55875f33c3d300f4f71e6e828f64",
            "size": 5629
          }
        }
      }
    },
    {
      "name": "ca.weblite:java-objc-bridge:1.0.0",
      "rules": [
        {
          "action": "allow",
          "os": {
            "name": "osx"
          }
        }
      ],
      "downloads": {
        "artifact": {
          "url": "https://libraries.minecraft.net/ca/weblite/java-objc-bridge/1.0.0/java-objc-bridge-1.0.0.jar",
          "sha1": "6ef160c3133a78de015830860197602ca1c855d3",
          "size": 40502
        },
        "classifiers": {
          "natives-osx": {
            "url": "https://libraries.minecraft.net/ca/weblite/java-objc-bridge/1.0.0/java-objc-bridge-1.0.0-natives-osx.jar",
            "sha1": "08befab4894d55875f33c3d300f4f71e6e828f64",
            "size": 5629
          }
        }
      }
    }
  ],

There are 4 libraries specified there:

  • com.mojang:text2speech:1.10.3
  • com.mojang:text2speech:1.10.3 again, but with "natives" and "extract"
  • ca.weblite:java-objc-bridge:1.0.0
  • ca.weblite:java-objc-bridge:1.0.0 again, but with "natives" and "extract"

What's going on here (and you can see this pretty well if you take a look at the sources for text2speech) is that text2speech uses a library to interact with ObjectiveC code to communicate with whatever text2speech system is included with mac, while on windows and linux it directly access native code without needing a separate library. But this means that text2speech only has natives for windows and linux, while the objectivec bridge has natives for OSX only. However, the text2speech natives does not have a rule defined to limit it to windows and linux (perhaps this is a mistake with the version JSON).

This should be fixable by changing this (in MinecraftDiscovery.py):

        if 'natives' in library:
            libFilename = "%s-%s-%s.jar"%(libSubdir, libVersion, substitueString(library['natives'][osKeyword]))

to this:

        if 'natives' in library:
            if osKeyword not in library['natives']:
                continue
            libFilename = "%s-%s-%s.jar"%(libSubdir, libVersion, substitueString(library['natives'][osKeyword]))

Or Mojang should be able to fix this by adding

      "rules": [
        {
          "action": "allow"
        },
        {
          "action": "disallow",
          "os": {
            "name": "osx"
          }
        }
      ],

to the narrator natives library (but not the narrator library itself). MCP itself would handle this correctly, and I think that this would be the logically correct version JSON. (I haven't created an MCL issue for this, but I may later if it seems like a good idea)

@kashike kashike added the mcp label Sep 15, 2017
@bddvlpr
Copy link

bddvlpr commented Oct 11, 2017

Thank you so much for this solution!

@Funkey723
Copy link

Funkey723 commented Oct 14, 2017

Thank you so much, but another error showed up after I launched Eclipse.

Description Resource Path Location Type
The project was not built since its build path is incomplete. Cannot find the class file for java.util.function.Predicate. Fix the build path then try building this project Client Unknown Java Problem

Can you help me with this?

@Pokechu22
Copy link
Author

That's got nothing to do with this. But you need to be using Java 8 (both as the compiler and as a library in build path).

@Funkey723
Copy link

I installed Java SE 8 [1.8.0_144], but this error showed up, thank you sooo much for helping me!!!

Description Resource Path Location Type
Resource leak: '' is never closed FallbackResourceManager.java /Client/src/net/minecraft/client/resources line 72 Java Problem
The enum constant ADD needs a corresponding case label in this enum switch on SPacketUpdateBossInfo.Operation BossInfoClient.java /Client/src/net/minecraft/client/gui line 40 Java Problem
The enum constant BLEND_WEIGHT needs a corresponding case label in this enum switch on VertexFormatElement.EnumUsage WorldVertexBufferUploader.java /Client/src/net/minecraft/client/renderer line 27 Java Problem
The enum constant BLEND_WEIGHT needs a corresponding case label in this enum switch on VertexFormatElement.EnumUsage WorldVertexBufferUploader.java /Client/src/net/minecraft/client/renderer line 61 Java Problem
The enum constant IGNORE needs a corresponding case label in this enum switch on EnumPushReaction BlockPistonBase.java /Client/src/net/minecraft/block line 332 Java Problem
The enum constant MATRIX needs a corresponding case label in this enum switch on VertexFormatElement.EnumUsage WorldVertexBufferUploader.java /Client/src/net/minecraft/client/renderer line 27 Java Problem
The enum constant MATRIX needs a corresponding case label in this enum switch on VertexFormatElement.EnumUsage WorldVertexBufferUploader.java /Client/src/net/minecraft/client/renderer line 61 Java Problem
The enum constant NORMAL needs a corresponding case label in this enum switch on EnumPushReaction BlockPistonBase.java /Client/src/net/minecraft/block line 332 Java Problem
The enum constant PADDING needs a corresponding case label in this enum switch on VertexFormatElement.EnumUsage WorldVertexBufferUploader.java /Client/src/net/minecraft/client/renderer line 27 Java Problem
The enum constant PADDING needs a corresponding case label in this enum switch on VertexFormatElement.EnumUsage WorldVertexBufferUploader.java /Client/src/net/minecraft/client/renderer line 61 Java Problem
The enum constant REMOVE needs a corresponding case label in this enum switch on SPacketUpdateBossInfo.Operation BossInfoClient.java /Client/src/net/minecraft/client/gui line 40 Java Problem

@Pokechu22
Copy link
Author

Those are all warnings. If your IDE is configured to treat those as errors, change it to a warning (or disable it entirely). It is unfixable by nature of the same issues being present in the actual game code - decompilation won't get rid of it.

@MajickTek
Copy link

MajickTek commented Jan 20, 2018

python sucks with indentation errors. this won't actually work unlesslibFilename is lined up with continue. also watch out for spaces/tabs.

if 'natives' in library:
        	if osKeyword not in library['natives']:
        		continue
                        libFilename = "%s-%s-%s.jar"%(libSubdir, libVersion, substitueString(library['natives'] [osKeyword]))

EDIT: MD's formatting also sucks. but you get the idea.

@Pokechu22
Copy link
Author

I used all spaces; my indentation is correct. You do still need to make sure that you use all spaces, as that's how the rest of the file is formatted (and mixing spaces and tabs is not allowed in python).

@MajickTek
Copy link

here is a simple error I got that I have never gotten before while doing this:

== MCP 9.40 (data: 9.40, client: 1.12, server: 1.12) ==
# found ff, ff patches, srgs, name csvs, doc csvs, param csvs, astyle, astyle config, scalac, rg, ss
Looking in /Users/<username>/Library/Application Support/minecraft/versions for mc installs... OK
Copying assets... OK
Parsing JSON file... OK
Looking for minecraft main jar... OK
> Checking libraries...
	Copying library java-objc-bridge-natives-osx... Error copying library java-objc-bridge-natives-osx

any ideas?

I already reset the game.

@Eaglewolf13
Copy link

Thank you so much, you solved my problem! I am completely new to coding and I encountererd this problem and had NO IDEA how to fix it, so when the problem came, I just said to myself: Well, time to leave coding and try something else...
But you helped me so much, thanks!

@bspkrs bspkrs self-assigned this Feb 21, 2018
@FledgeXu
Copy link

Thank you so much,you solved the problem!

@Jmbaffo
Copy link

Jmbaffo commented Mar 28, 2018

@MajickTek Did you ever solve that issue? I'm having the same problem.

@MajickTek
Copy link

nope - still unsolved

@Jmbaffo
Copy link

Jmbaffo commented Mar 29, 2018

Gah! Literally all I want to do is study MC's damn code because I'm learning Java at my uni, but I can't seem to get this thing decompiled.

@MajickTek
Copy link

the code is complex, just saying ;)

@Jmbaffo
Copy link

Jmbaffo commented Mar 31, 2018

I figured it out I just chose to analyze mc 1.10 instead. The code is also fairly basic for what it is, just a fair amount of certain things that I haven't learned yet.

@bddvlpr
Copy link

bddvlpr commented Apr 1, 2018

If you really can’t figure it out, i have public downloads on my site: https://baddeveloper.xyz

@MajickTek
Copy link

@stijnsimons : thanks a lot. Will download and check out later.

@MajickTek
Copy link

@stijnsimons This actually works! thanks!

I will analyze the files and try to build a tutorial on how to do this.

@MajickTek
Copy link

is it against the rules to distribute modified versions of MCP, though?

correct me if I'm wrong here.

@Jmbaffo
Copy link

Jmbaffo commented Apr 2, 2018

I think so.

@bddvlpr
Copy link

bddvlpr commented Apr 8, 2018

No since it doesn’t have a license + as long as you don’t change the name and resell it, its fine i guess.

@MajickTek
Copy link

I guess that's true?

I mean, EPIK had their own version built for netbeans a while back so i guess it's fine

@Pokechu22
Copy link
Author

MCP does have a license (LICENSE.txt) and it's pretty explicit:

MCP - Mod Coder Pack
MCP is (c) Copyright by the MCP Team

License and terms of use.

No warranties. If MCP does not work for you, or causes any damage, it's your problem. Use it at own risk.

You are allowed to:

  • Use MCP to decompile the Minecraft client and server jar files.
  • Use the decompiled source code to create mods for Minecraft.
  • Recompile modified versions of Minecraft.
  • Reobfuscate the classes of your mod for Minecraft.

You are NOT allowed to:

  • Use MCP to do anything that violated Mojangs terms of use for Minecraft.
  • Release Minecraft versions or modifications that allow you to play without having bought Minecraft from Mojang.
  • Release modified or unmodified versions of MCP anywhere.
  • Use any of MCPs scripts, tools or data files without explicit written permission.
  • Make money with anything based on MCP (excluding Minecraft mods created by using MCP).
  • Use MCP to create clients that are used for griefing or exploiting server bugs.
  • Release the decompiled source code of Minecraft in any way.

The license in turn references the Minecraft EULA, which you should have already read.

@bddvlpr
Copy link

bddvlpr commented Apr 8, 2018

What an useless license since they’re too lazy to patch this small bug.
Anyways, its taken offline.

@MajickTek
Copy link

the files are still in your GitHub repo

@bddvlpr
Copy link

bddvlpr commented Apr 8, 2018

I don’t own the repo.

@MajickTek
Copy link

nvm thought you were Strezzed

lol

@bddvlpr
Copy link

bddvlpr commented Apr 8, 2018

Also, mavenMCP isn’t agains the license since it downloads mcp from the official site

@LexManos
Copy link
Member

LexManos commented Apr 9, 2018

First off, blame someone for not telling me. I've fixed this for the next release. I don't have a Mac system so I don't typically fully test all of this. Tho with the launcher json not officially documented anywhere that I know of it was pretty much bests guessed when Prof wrote it.
Secondly, you people have a massive misunderstanding of how python works. It's a simple change: if 'natives' in library and osKeyword in library['natives']:
Thirdly, Learning java from MC, and decompiled code is a HORRIBLE idea. Don't do it.
And finally, probably worth useing ForgeGradle for anything you need here. But that's a fight we won't have.

@LexManos LexManos closed this as completed Apr 9, 2018
@MajickTek
Copy link

Now we wait for release. The only latest build is MCP940, which is 1.12. We need an official MCP941 and 942 (1.12.1, 1.12.2, respectively.)

@Jmbaffo
Copy link

Jmbaffo commented Apr 9, 2018

@LexManos That was a bit of a backhanded comment. I don't think anyone blamed you, and I wanted to see the game's code because I was curious about how the game was structured. Also, I was curious to see how it renders the game, I'm fairly new to programming Java as I'm only a freshman at my uni and I wanted to see a professional implementation of the language to try and obtain a deeper understanding of it.

@williewillus
Copy link
Contributor

williewillus commented Apr 9, 2018

the problem is this is not a "professional implementation", this is reverse engineered and decompiled code which is full of hacks, from both Mojang and otherwise. The class/field/method names you see? They're not even the real names Mojang uses, they're guesses the community has made. And some of them are terribly wrong (just see other issues on this repo for examples)

It's not a place to learn as you'll pick up bad habits.

@MajickTek
Copy link

MajickTek commented Mar 18, 2020

@Pichuminer there is multiple ways to do it, either the mac patches mentioned above, or use something like https://github.com/hypercubemc-github/Modern-Minecraft-Decompiler which uses ForgeGradle to extract the MCP code of modern minecraft versions into an eclipse/idea project.

I'm on a Windows PC now no this issue isn't relevant to me anymore.

Edit: the fixes above may not work anymore so go to https://github.com/ThisTestUser/MCPFixer and use that, it might work. It's essentially the same idea as Modern Minecraft Decompiler but you do the patching yourself without gradle.

@FinnT730
Copy link

Bloody hell, another 2 projects that are taking the MCP name, and are using that.....
Update, since MCP will not be used anymore... It is dead for Christ out laud

@MajickTek
Copy link

MajickTek commented Mar 20, 2020

@FinnT730 Those aren't 2 projects.....

Modern Minecraft Decompiler is literally MCP, using the forge version.

The MCPFixer repo is a script to patch the 1.12 version of MCP to work for 1.13 and up.

@LexManos
Copy link
Member

MCP is dead, just let it rest in peace.
And stop using it's name for other projects!

@ModCoderPack ModCoderPack locked as resolved and limited conversation to collaborators Mar 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

13 participants