No, this code was written by an actual person and it is not decompiled, the person who wrote this code learned Java by reading decompiled Minecraft code and had no previous programming experience, the local variables had names like var23 or i8 which lead him to believe that those were the only valid names for primitive types
Yeah this really sucks and probably one of the strongest things that stop me from rolling into this modding community. I feel like I can understand how to implement my ideas, but I don't understand the api.
Yeah, that's a big problem with getting into Forge modding. Minecraft, and thus Forge, make huge changes between each major version, so there isn't enough time to write proper documentation before the next major version releases. However, there's a Forge discord server where you can ask questions.
ALL of the variables names are like this in the decompiled Minecraft source. For now, the Minecraft Forge team are sticking to the pure Mojang-provided mappings, which include all class and class field names, but no parameter or local variable names. This switching to the Mojang mappings is a pretty recent change, hence why this is an issue at the moment. However, they are planning on incorporating these missing mappings via community efforts soon (don't know how soon, though). In the meantime, ParchmentMC is an unofficial community effort to map these previously unmapped symbols.
To everyone saying this is decompiled code: It's not! This was code was written by someone who learned Java by reading decompiled Minecraft code. The code snippet that I posted was written by an actual person who thought that "var2", "var34", etc. were the only valid primitive type names
You are right. A minecraft mod is written in a jvm language, usually java. In the jvm, local variables are stored inside frames, and don’t have names or types. However, decompilers can make use of the LocalVariableTable, which contains debugging information, including names of them. Decompilers usually opt to using “var + index of the local variable” when there is no debugging information for a certain local variable. Here, var0 is reserved because this is a virtual method (instance method), and is passed every time you call it, and can be accessed with the “this” keyword. So here, counting starts at 1.
Hi, long time Minecraft modder here. Decompiled code doesnt save local variables, this is extremely old minecraft code and im not even sure if this is legit mc. Either way its a bad decompile, I think that "while" would instantly freeze game. Also, im pretty sure it's illegal to post that on this subreddit or anywhere stating "decompiled code of closed source, ARR game"
86
u/nikstick22 Feb 04 '22
Could be a decompiler doing that if it's not the src files for the mod itself.
The decompiled minecraft code I work with has some pretty bad variable names in places when they're autogenerated.
26
u/xxkmatiasxx Feb 04 '22
This is decompiled code...
6
u/TemporaryAccount-tem Feb 04 '22 edited Feb 04 '22
To everyone saying this is decompiled code: It's not! This was code was written by someone who learned Java by reading decompiled Minecraft code. The code snippet that I posted was written by an actual person who thought that "var2", "var34", etc. were the only valid primitive type names
16
u/R3D3-1 Feb 04 '22
Modding: Learning to program "on the go", just enough to get something done, while working with APIs, that might not have any documentation at all.
Produces plenty of bad code, but rather I consider it impressive, that it produces working code.
39
u/CopperyMarrow15 Feb 04 '22
Variable Naming 100
109
u/dasbodmeister Feb 04 '22
Else while wtf
16
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Feb 03 '22
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
18
u/DumbAceDragon Feb 04 '22
I don't think I've ever seen an else while, but seems like it would be pretty useful in some circumstances
4
u/kaveish Feb 04 '22
Is var1 being updated in another thread?
I get that this is decompiled code, but still curious. Particularly since Minecraft is notoriously single threaded.
2
u/SirZok Feb 06 '22
Loops depending on keyboard input are a no-go in games. Everybody who starts learning Unity discovers that the hard way.
-2
u/LatvianModder Feb 04 '22
Hi, long time Minecraft modder here. Decompiled code doesnt save local variables, this is extremely old minecraft code and im not even sure if this is legit mc. Either way its a bad decompile, I think that "while" would instantly freeze game. Also, im pretty sure it's illegal to post that on this subreddit or anywhere stating "decompiled code of closed source, ARR game"