PDA

View Full Version : MC: Decompiling and deobfuscating Minecraft Server beta 1.8.1


Brad
2011-09-19, 22:57
I just spent my evening manually de-obfuscating the big wad of decompiled Minecraft server code. There are over 500 classes in the server itself. Many classes I've found already annotated by Craftbukkit, but even those are mostly populated with "useless" method and variable names. So, I've been using an IDE to refactor the whole code base whenever I can figure out what some method does or some variable means.

I've been looking for a few specific things that have been bothering me, and sure enough, I'm finding some answers...

edit: Oh, and if it's not obvious: SPOILER ALERT.


Q: What's up with animal spawning? Why do some of my old maps generate *no* animals at all?

A: So many factors are working against spawns! :grumble: First, we have biome-specific spawn settings. There are effectively: BigHills, Desert, Forest, Hell, Ocean, Plains, River, Sky, Swamp, and Taiga. Ocean, Desert, and Hell are set to spawn *no* animals. Ever! This means Sedona and South of the Border can't have animal farms. Animals only get the chance to spawn once every 400 ticks (40 seconds!) within 8 chunks in each direction of each player but not within 24 blocks of any player. Generally, Pig and Chicken have equal chance to spawn, Sheep has slightly higher chance, and Cow has slightly lower chance. Wolf only spawns in Forest with less chance than the other four types. A maximum of 4 of any type will spawn at a given time, giving an absolute maximum of 20 animals across the whole world every 40 seconds in the absolute best circumstances.

The answer to my second question there is that some of my maps (like the Survival Island map I kept bitching about) now have their biome data rearranged so that now I'm in the middle of an Ocean biome. Thus, no new animals.

Craftbukkit has no hooks in any of those options, by the way. I'd be tempted to contribute a patch, but I'm still far from that stage of development here...


Q: Why does the creeper seem to have a wider sensitivity radius in SMP than SSP? Why do enemy hitboxes generally seem smaller in SMP than SSP while their reach is farther?

A: Not sure yet, but I'm finding pieces of the puzzle. The creeper fuse lasts 30 ticks (3 seconds). Monsters in general will attack once every 20 ticks. Monsters will seek out players within 16 blocks (except for Endermen at 64 blocks). I've found how attack damage is applied to entities, but I've not quite pinned down how the intersection of the mob and a player's weapon is determined.


Anyone else have some pet peeves with the current version of Minecraft SMP that you're dying to figure out? I'm pretty exhausted from this code spelunking session, but I might have another go at it later this week if you have questions.

drewprops
2011-09-19, 23:26
If you go into our desert town and create a patch of rich green grass (whatever that biome is) will it operate as THAT biome or does it still in truth belong to the desert biome? I suspect the answer is that it still belongs to the desert biome.


...

billybobsky
2011-09-19, 23:34
I have seen 1 duck spawn in our desert, but it might be because it was *near* a river biome.

A couple comments: it seems that animals are biome specific (not absolutely, but pretty much) -- ie you find a lot of herd animals on planes, ducks in jungles, etc. I have also certainly run into a plain absolutely filled with cows (and others filled with sheep) -- more than 20, to be sure, more like 40. Now it is possible that the persistence thing worked, and they spawned before, remained around, and more spawned later, but it is clear that you can encounter herds of creatures unlike pre1.8. Is this coded somewhere?

I asked about where towns spawn in game tonight -- all of ours are in desert biomes, is this a necessity?

drewprops
2011-09-19, 23:51
When do we finally get horses???

...

ThunderPoit
2011-09-20, 05:59
Wait, we found the third town?

Robo
2011-09-20, 06:36
I just spent my evening manually de-obfuscating the big wad of decompiled Minecraft server code. There are over 500 classes in the server itself. Many classes I've found already annotated by Craftbukkit, but even those are mostly populated with "useless" method and variable names. So, I've been using an IDE to refactor the whole code base whenever I can figure out what some method does or some variable means...

http://4.bp.blogspot.com/_D_Z-D2tzi14/TAWLgUOLGpI/AAAAAAAADBE/7jOYpB5nrPg/s1600/texas14.png

...if you have questions.

I'm never going to learn how to computer, am I :(

billybobsky
2011-09-20, 07:46
Wait, we found the third town?
And forth evidently.

drewprops
2011-09-20, 08:13
Yes, I found a town and named it "Piggsburgh". The coords are in the other 1.8 thread. It's a pretty big town and it's in a much nicer clime with lots of critters. SHOULD there have even been a fourth town?

Question for Brad:
So is it likely that there's a stronghold near my town?
Is that the way it works?



...

Brad
2011-09-20, 08:13
I have seen 1 duck spawn in our desert, but it might be because it was *near* a river biome.
It probably wandered in from the River biome.

more than 20, to be sure, more like 40. [...]
The "20" number I mentioned as a maximum is the number that are able to spawn at a given spawn opportunity. Since spawning can happen once every 40 seconds and mobs persist (for a while at least), you definitely can run into more than 4 of a given animal type at a time. Plus, I think there's a separate algorithm that kicks in upon creation of a brand new chunk, but I haven't pinned down its workings yet.

I asked about where towns spawn in game tonight -- all of ours are in desert biomes, is this a necessity?
I've definitely hit a town outside of a desert in another SSP world (in a Plains biome), but this sounds like a neat one to investigate in the source code. I'll try finding this algorithm tonight too...

Bonn89
2011-09-20, 09:20
I think (but I'm not 100% sure) that Notch and Jeb changed the town spawning requirements to require relatively flat land, after people who where playing the pre-pre-release (o_O) found towns in the middle of oceans and whatnot.

The issue with requiring flat land is that the only two biomes where largish expanses of flat land occur are deserts and plains, and deserts seem to be much more common than plains.

drewprops
2011-09-20, 09:39
One of the doors of a building in my town was blocked by granite, the roof nearly digging into a hill. But it's a nice spot with relatively gentle terrain.

Brad
2011-09-20, 11:27
If you go into our desert town and create a patch of rich green grass (whatever that biome is) will it operate as THAT biome or does it still in truth belong to the desert biome? I suspect the answer is that it still belongs to the desert biome.


...
Biome data is calculated independently before blocks are set down. So, if the area was a desert biome before, it will still be a desert biome after you set down grass or any other block.