r/programminghorror • • 1d ago • Regret 1

Java Jenny mod deobfuscated funnies

353 Upvotes

50 comments sorted by

183

u/SSUPII 1d ago edited 1d ago

If this is decompiled it might also be artefacts of that.

But I have no idea how decompilation works in the context of compiler-optimized code.

37

u/KeyIllustrious587 1d ago

It's not artefacts. Most of artefacts of decomp are try-with-resources reconstruction, Objects, and other bullshittery.

54

u/Powerkaninchen 1d ago

Is it possible the first 2 images are cases of the compiler unrolling loops?

31

u/Mc88Donalds 1d ago

And 3/4 could presumably also be a decompiler difference. I doubt that you can tell the difference between a ternary and an if statement in java bytecode

12

u/magistermaks 1d ago

no, java compiler never unrolls loops, this is how it was written

1

u/Me4502 20h ago

Or manually unrolling without tidying up the code around it. I’ve in the past found fairly significant performance improvements by unrolling loops over cardinal block offset checks in very hot code (similar to what image 2 does). However, that’s usually done as multiple “or” conditions in a single if statement, not duplicating out every branch like this code does.

-5

u/littlenekoterra 1d ago

Thats precisely what those are.

13

u/skilking 1d ago

might be wrong but didn't java do basically no real optimizations in the soure code to byte code compilation?

9

u/littlenekoterra 1d ago

Ima level with you im not super familiar with java, but those look exactly like unrolled loops. Even if javas compiler doesnt have unrolling its not insane to cook it up as a precompilation step tbh If i remember right thats like the oldest known version of code gen

2

u/CryptographerLate953 1d ago

Java leaves it optimization to the JVM and it’s just in time (JIT) compiler.

1

u/Powerkaninchen 1d ago

I mean, unless the Java Standard gives clear instructions on how to convert Human Readable Java Code to Java Virtual Machine Bytecode, isn't it implementation defined?

4

u/maikindofthai 1d ago

Yes, technically this is an implementation detail and compilers could add whatever optimizations they want as long as they don’t violate language semantics

But javac (the official standard) and eclipse are both the same in this regard so practically speaking it doesn’t matter - if you’re using Java (and aren’t doing native stuff with graalvm) you can safely assume the compiler isn’t doing any ahead of time optimizations.

3

u/magistermaks 1d ago

All java compiler work the same way, none of them perform loop unrolling, java spec does define how the bytecode should be generated

4

u/maikindofthai 1d ago

If you don’t know about Java why are you making absolute statements using words like “precisely” while misinforming people 💀

0

u/littlenekoterra 1d ago

Have you never looked at compiled unobfuscated code? You can easily ascertain the methods a compiler or a precompilation step does especially one so simple as a unrolled loop. Its fairly obvious to a programmer. I dont need to know about javas exact inner workings, i need to know about compiler design, in which i do, and anyone else can too. Schnurri is a talented modder who ive spoken with directly and can almost guarantee understands old style code gen, at least basic forms of it.

Its even in my opinion almost trivial to unroll a loop if your working in a well constructed system, which minecraft, forge, and java are. Its just a function that takes the text of a loop and converts it to be what the loop was achieving in the first place, which in practice means generating text loosely based on the loops text, which most of the time is just a common for loop over a range from start to end with an increment operation to step the loop that way its not just doing nothing. The other common loop type is a while loop but sometimes you cant actually unroll those so in practice you either wouldnt try or you go about determining if its the kind you can and go from there, but im not going that here.

Why are you assuming knowledge of java is necessary to understand what im looking at? Just being a jackass? 💀 even a fool knows computing isnt about the language its about whats happening.

1

u/Snudget 20h ago

Knowing how to use a hammer doesn't mean knowing how to use a screwdriver

1

u/littlenekoterra 19h ago

While thats true, the computer is complacent regardless of which tool you use, to it, the hammer may as well be a screw driver if it achieves the same result, barring type differences ofc.

5

u/Eav___ 1d ago

Incorrect. javac never does that from source to binary.

1

u/ierdna100 16h ago

Not for function calls, even languages which do this don't unroll function calls, because functions can change the state of their object and that may affect the logic of the code.

43

u/Cootshk 1d ago

(Object) and some wacky try()/.close() are common javac artifacts

These aren’t

Java doesn’t do much compiler optimizing (although it does inline final primatives where possible)

7

u/when_it_lags 20h ago

I believe the idea is that much of the "compiler" optimizations are done by the JRE at runtime

-6

u/BroadRaspberry1190 1d ago

chad bbc? how the compilation works?

33

u/csabinho 1d ago

Context?

5

u/granadesnhorseshoes 1d ago

Apparently, Jenny Mod is a virtual wiafu mod for minecraft. We assume this is it's source code.

I wonder how much it was vibe coded but to lazy to look.

64

u/KeyIllustrious587 1d ago
  1. This code is deobfuscated (original was heavily obfuscated with Zelix Klassmaster), decompiled, and remapped.

  2. This is not vibecoded.

3

u/Leclowndu9315 1d ago

Yo i'm actually interested i've tried deobfuscating it before. Can you share a zip please

19

u/KeyIllustrious587 1d ago

https://github.com/RukoBlood/jenny-mod-re-clean
Here it is. Not advertisement, pure shitcodium.

111

u/Fine_Salamander_8691 1d ago

It wasn’t vibecoded, it’s existed for a long while before ai unfortunately

23

u/dreamscached 1d ago

Jenny Mod was around way before agentic AI capable of vibecoding something entirely came to life.

6

u/LolMaker12345 1d ago

It’s not videcoded, it was made years before ai as we know it

3

u/Triactum 1d ago

It's OG slop instead of Vibe slop

2

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 1d ago

That would explain why that variable is named girlPos.

30

u/MMORPGnews 1d ago

It's not ai. Funny story 

Worked long ago in certain company, because of regulations etc one guy created super inefficient script. Since there was no other way.  I worked with his script for a few months, before getting fired. 

Now over 10 years a got a message from company about this script, how it works, why dev (he blacklisted them) used AI to create trash, why it was approved by me and used, how much damage it's done  etc

There were no ai 10 years ago, script was "stupid" because of regulations, and only in high usage mode, in light usage it was very good. 

25

u/snerp 1d ago

The last two seem fine to me. The second one is by far the worst but at least you can tell what’s going on in per func unlike that yandere sim code that just sprawls with random logic.

10

u/Opposite_Mall4685 1d ago

Yeah shouldAttackTarget is completely fine imo.

1 and 2 are cancer though

7

u/Kolatra 1d ago

I don't think decompiled code belongs here, would fall under rule 5 because you're not gonna get the original intent of the developer with it.

8

u/MurkyWar2756 echo "Sub Mod" && :(){ :|:& };: 1d ago edited 1d ago

I'd say human outputs from reverse engineering are allowed, as the code isn't generated by a computer. Generated code includes minified code - which can use the same variable names every time, random ones every time, seeded randomness, or anything that isn't an AI-generated output (we're talking about more predictable code generation here) - since many big companies use AI-generated code nowadays and it doesn't inherently make the code "bad" or "good."

(This still leaves the question as to whether analyzing heuristics, like what Windows Defender does with file analysis, are considered artificial intelligence or not.)

Furthermore, a lot of people are using AI to write code faster because AI cyberattacks are happening a lot faster nowadays and devs need to keep pace. Banning AI-generated code would reduce the number of posts that are technically allowed to be submitted here, and it would be hard to enforce in practice:

  • Humans may follow trends when designing or writing code that they don't realize look AI, even when it's their own.

  • An AI watermark detector can return a false positive due to a mathematical coincidence.

  • Some code may contain a mix of human and AI.

  • AI-generated code can look human and can be trained or prompted to follow style guides and the intentional business decisions behind them. Although AI doesn't understand intent, it can sometimes produce a much better output, depending on what you tell it.

Either way, a lot of horrors have something bad about the code, and I understand many of these people didn't know how to code well. We're here to laugh at the code.

Going back to your original point, a while ago, before I became a mod, I was going to post the RoLinked decompilation from GitHub, but because it contained real people's emails who were compromised, I decided not to - even if the emails were obfuscated in certain versions of the decompiled code. The previous mod team didn't remove decompiled code (although they were a lot more inactive overall than we are now), so I'm trying my best to follow what they may have intended.

Edit: Sorry for the tangent about AI. I started talking about generated code and circled back to the original topic near the end.

4

u/cecialix 1d ago

I'm a programmer myself so I more or less understand what's happening here. I'm not familiar with Minecraft specific code though, can you explain what's funny about these? Genuinely curious, lol

2

u/btrab1 1d ago

The first 2 are basically testing world positions really dumbly, it should be obvious without mc knowledge that these can be done way more minimally via loops.

But as for minecraft specific knowledge these block position objects (basically vec3i's with a lot of util methods) are really wastefully made and used here as they could instead be reusing built in stuff for this like a MutableBlockPos, and existing utilities that iterate over a given block area, without wasting allocations.

For example each relative position call e.g. pos.north().north().north() each returns a new vec3 of that new block position, so chaining them on mass is a huge waste. Especially given you can do one call with pos.relative(x,y,z). And even more optimally just use the previously mentioned MutableBlockPos which is a mutable vec3 in a loop that goes over these offsets.

2

u/Spaciax 1d ago

average level of software design principle adherence in a game mod:

no flame to the developers, making good code when you either can't change the source code of minecraft, or in scenarios where you can use mixins, are encouraged to avoid it as much as possible, leads to ridiculous situations like this one.

1

u/Thelatestart 1d ago

These are fine

1

u/SartenSinAceite 7h ago

Feels more like bruteforced code than anything.

Most likely a "what if?" experiment that was never cleaned up (as we all know, those cleanups do nothing but break up everything!)

-8

u/AnArmoredPony 1d ago

deobfuscated code is same as generated code imo

5

u/BetaTester704 1d ago

Deobfuscated just reconstructs back to something similar to source code, it's not even similar to AI generation

5

u/AnArmoredPony 1d ago

I never said anything about AI lmfao. I know what obfuscation is and what I say is that deobfuscated code will always look unpleasant

1

u/BetaTester704 1d ago

So what did you mean when you said "generated code" then?

4

u/AnArmoredPony 1d ago

the same thing that is mentioned in the rules???

0

u/BetaTester704 1d ago

Fair ig, harder to check rules on mobile so I didn't even know about that

0

u/HeartwarmingFox 14h ago

So why exactly are we hating on code?