Jump to content

Server content mods offering backward-compatible "hallucinations" to unmodded clients


jhogan42

Recommended Posts

Hi all,

 

I'm trying to figure out whether there's a way to create a server-side mod that offers new content to modded clients, but will still allow unmodded clients to connect and have a mostly-intact experience (without the new content, of course).  The motivation is to encourage server-side mod adoption by minimizing the impact to non-participating players.

 

The general idea is for the server to induce vanilla-based "hallucinations" in the unmodded client that are as close to the "reality" of the modded server as possible.  For example, consider a server-side mod that implemented a new ore block.  When an unmodded client encountered the ore block, it might appear to them as stone.  If they break it, the dropped ItemBlock might be invisible and un-gettable to them.

 

Because this assumes an unmodded client, this translation would have to happen server side.  For example, the server would need to tell the modded clients "block x,y,z is NewOre!" while telling the unmodded clients "block x/y/z is just stone."

 

I don't think there's any generalized solution to this problem -- the approach & implementation would need to be custom-tailored for each use case.  And it does have its limits.  Hallucinating stone instead of ore will not be terribly disconcerting for a player, but bouncing 100 feet in the air because the "grass" they walked on is actually a super-trampoline starts to get a little weird.  Nonetheless I think for many situations this approach would work fine.

 

So my questions are:

 

1)  Does the above approach seem theoretically possible?  Is there something I'm missing?

 

2)  If so, how difficult would it be in practice to implement the "stone for ore" example?  I'm sure it's not easy, and I figure it would probably require hooking directly into the core source, but I don't have much of an intuition beyond that.

 

I don't have much experience with Minecraft modding, but do have software dev experience more & a lot of time on my hands right now, so may actually decide to tackle this if it's feasible  :D

Link to comment
Share on other sites

Sounds like the requirement there would be to create two parallel data structures before the data is compressed -- one "real" and one with the "hallucinations".  Then in the loop which sends it to the clients, send the corresponding compressed data structure.  In the grand scheme of things that doesn't sound that bad.

Link to comment
Share on other sites

Well, I know any vanilla code modification would be an undertaking.  My hope is that the changes might be relatively small and self-contained -- minor in scope compared to projects like Forge/FML.

 

I don't think other mods would need to adapt to this -- all of the altered behavior could be contingent upon a mod explicitly opting in.  No change for current mods.

Link to comment
Share on other sites

Progress!

 

It looks like net.minecraft.network.play.server.S21PacketChunkData.func_179756_a() is where the server does the raw data assembly for sending chunks to the client.  Passing in an optional hash table of block-id translations (e.g. "newOre->stone") would make it a fairly straightforward code change to present "stone" to the player instead of "newOre".

 

There are a number of other circumstances under which a similar translation would need to be made (block placements, itemblock spawns, opening inventory / containers which might have the affected block inside) but it looks like net.minecraft.network.play.server has nicely compartmentalized points to address most of these -- maybe all.

 

One area I'm uncertain about is performance.  The loop in question (for sending chunks to players) obviously gets called a lot, and is quite optimized, down to bit manipulation.  Presumably this was done to minimize CPU load.  I don't know if Notch was just being prudent, or if this is loop is a crucial part of server load.  I'm hoping the former, since chunk loading isn't done *that* often (compared to, say, tick processing).

 

Of course I don't know anything about injecting Java code so now I need to go look into that and hope I don't run into any critical roadblocks.

 

Suggestions, or pointing out pitfalls I am missing, would be appreciated!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.