Thoughts on a flexable client side mod

Discussion in 'Plugin Development' started by Myers Carpenter, Mar 10, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Myers Carpenter

    I want to create a client side mod that can work with server side mods that would give SMP some of the same abilities as SSP mods. Oh, and I'm tired of waiting for Notch to do this, even though it seems that is his long term plans.

    Limitations I can live with
    • The client must have the mod to connect to the server, but should be gently disconnected (e.g. kick with this message "You need a mod to connect to this server: http://example.com/mod")
    • The same mod should be usable on multiple servers
    • The mod should focus at first on adding new entities to the server
    • The mod should allow sandboxed java code, downloaded from the server to be run on the client.
    Client identifies itself to the server

    The client will connect to the server and claim to be using protocol version 100 + client mod version + current vanilla minecraft protocol version. If the server doesn't see this version it can disconnect with the message above. If the server is does not support this version it will disconnect with the message "out of date server". The client mod will then disable itself and attempt to reconnect.

    Custom Packets

    The packets in minecraft have their own ID numbers. Since we know the client side mod is present we can seen new packet types without causing errors. There will be a few new packet types. Another problem is that these packets types all have a size (or is it a max size?) hard coded on them.

    Telling the client what extra files it needs

    On the server side we'll have jar files with Model classes, sounds, and skins. Right after the client connects, but before sending terrain, the server will send a new packet type FetchAsset that says "get jar with SHA2-256 hash X, and size Y which can be found at url Z". A progress bar should be shown telling the user how long until all the jars have been downloaded. The hash can be used when the user reconnects to check that it has up to date files and avoid redownloading.

    Sandboxing

    The jars will be loaded with a new ClassLoader and make use of a SecurityManager to sandbox the code downloaded from the client. The code loaded this way would be in the same restrictions as a Java Applet in a web browsers. It will have no direct access to the screen either. For this first iteration we just need to define models the same way the other models work this should be fine.

    EntityMap Packet

    The server will also send a EntityMap packet, mapping Entity ID's to model classes.

    Spawning

    The server can tell the client to spawn entity ID just like it does for current mobs.
     
  2. Offline

    Archelaus

    I've been thinking about this. I quite like the idea. A "bukkit" like client mod that expands the functionality of the server mod.
     
  3. Offline

    maxx001

    That would be great to have such a system. Reminds me a lot of the successful MTA mod for GTA: San Andreas.

    Then it would finally be possible to make a coin item so that one could make a real economy for bukkit servers.
     
  4. Offline

    Raphfrk

    Interesting.

    Have you seen this page.

    It has all the packets. They aren't all standard sizes.

    It might also be worth having a packet that will load resources during run-time. For example, if a new server plugin was loaded, then it could order all connected clients to load its corresponding resources.

    Btw, when you say entities, do you just mean new mobs or also things like new blocks (and I guess corresponding dropped versions)?
    [MERGETIME="1299844819"][/MERGETIME]
    I would also suggest using a different protocol version

    Maybe

    1000000 + (client mod version)*1000 + standard version
     
  5. Offline

    Myers Carpenter

    I'm only thinking new mobs at first. Once that was done new items, new recipes would be easy to build on the framework you already had.
     
  6. Offline

    Raphfrk

    I would have thought new mobs would be harder than new blocks?
     
  7. Offline

    Myers Carpenter

    The jar downloading framework and sandbox worry me more what it actually does when it's working. :)
     
  8. Offline

    matejdro

    What about having this do only the downloading and running mods and then have separate plugins to do custom mobs/blocks?
     
  9. Offline

    Raphfrk

    That's true. It is probably best to do as much as possible on the server anyway. This eliminates the need for a sand box and gives better security.
     
  10. Offline

    Joshua Neicho

    if this happens would it be possible for single player mods to be converted into Server mods?
     
  11. Offline

    Myers Carpenter

    The sandbox is needed so that some bad person doesn't create a client side mod that installs a virus, then adds it to his server. It allows you to download untrusted code and make sure it can't do anything but change your minecraft display.
     
  12. Offline

    Raphfrk

    Right. However, if most of the logic that is added to the client mod is just for graphics updates, then it wouldn't require new custom code being run on the client. That reduces the flexibility of the client mod ofc.
     
  13. Offline

    RyanTheLeach

    well, minecraft itself if programmed properly *should* be reasonably sandboxed by the Operating System shouldn't it? It shouldn't be running as root, or administrator so shouldn't be able to make a mess of anything that the user couldn't without confirming...

    A warning that the server will be downloading custom code/mods should be enough, with some way to acknowledge, and have details on where to find the source/information/trust-stuff on the internet should be made apparent.
     
  14. Offline

    Myers Carpenter

    Code is code. Graphics code could be code that downloads a virus and executes it. The way to deal with this is limiting what the code can do. The way to do that in Java is a sandbox.
    [MERGETIME="1299994404"][/MERGETIME]
    check this out:

    http://www.minecraftforum.net/viewt...5db39ae58dc409c50df1266ff73&start=60#p3183157
     
  15. Offline

    Raphfrk

    Well, I guess I was thinking that the mod would include the code and it would be designed so that it supports creating entities and blocks with any look (or at least flexible).

    The actual logic for the entities behavior would be handled by the server side of the mod, so players wouldn't have to worry about downloading a virus.
     
  16. Offline

    Malkierian

    I don't think a client-side mod is really necessary if you make the server code right. Just include any additional required images in the plugin.jar and insert code to download said images to the .minecraft folder in a separate directory and instruct the client to load the images from there, just like a SSP mod.

    Am I just too noobish to understand why it needs to be more complicated than that?

    By the way, I am totally for an idea of this kind, because I'd love to get obsidian tools and the paxel in SMP.
     
  17. Offline

    Raphfrk

    The idea is to make it so that all players automatically get the data when the connect to a server, rather than having to manually do it.

    This would mean that you install the mod for your client once, and then you can connect to all modified servers.
     
  18. Offline

    Malkierian

    Oh, I see, instead of having an individual mod for each plugin, each plugin uses a basic mod's control interface, which provides for that downloading. Wouldn't it then need to be able to dynamically remove those plugin files as well, in case you connect to a server that doesn't have some?

    Let's get moving on this, quick! LOL.
     
  19. Offline

    Samkio

    This sounds a great idea! Good luck to you. :)
    I guess this is a question on trust. With COD4 mods it just downloads them without confirmation but however has it's own file system "and stuff" to stop the transfer of viruses. Maybe this could be implemented into the Bukkit Client? Also a confirmation of when the client is downloading a mod, listing all the files in the client mod, (so the user can see what they are downloading).

    Alternativley you could have a server listing all the confirmed BC(BukkitClient) mods. Which it checks whenever a mod is downloaded.

    It's just ideas i am throwing out there.
    Best of luck on this endavour. :)
    Regards
    Samkio <3
     
  20. Offline

    Raphfrk

    Presumably, they would be downloaded to a separate directory.

    Also, the OP's plan is that they wouldn't just be simple mods that over-write image files or something. His plan is for full plugins that can be executed by the client.

    These plugins would read from their own directory.

    @Myers Carpenter

    Is there a basic version of this mod?

    One issue is that Notch has said that he doesn't like client mods relative to server mods, so an extensive plugin system would be more difficult.
     
  21. Offline

    Myers Carpenter

    I wish. I wanted to work on this last weekend, but work interfered.

    From what he's said about his plans I think this is what Notch wants to do in the long term.
    [MERGETIME="1300166658"][/MERGETIME]
    I spent a few hours this evening banging my head on Java Security stuff setting up the sandbox. I eventually got something to work were I load a class from a JAR and have it restricted from doing anything, but not also have that effect the rest of the code.

    I guess the next thing I might work on is using MCP to add support for some extra packet types.
     
  22. Offline

    NathanWolf

    I really like this idea..... like, a lot.

    I'd love some client-side GUI support. I mean, really love it.

    People seem to hate Wand, but I think if it had a real gui instead of taking over their inventories for that, it'd be a whole different story.
     
  23. Offline

    Myers Carpenter

    an update:
    I have a server that lists all it's client side mods, and looks for clients with a non standard protocol version. When a client connects with the right version it will send a Packet200ModsNeeded with a list of the mods (url to jar, size and sha2-256 hash). It runs it's own http server for the client side jar files. It uses reflection to add stuff to the packet list. Aside from the protocol verison hacks it's like a normal plugin that's linked to Craftbukkit
    On the client side I am using MCP. I've added support for sending the right protocol version and handling the Packet200ModsNeeded. It downloads the jars. Next up will be adding the sandbox code I developed in a test project into MCP and loading the client side mod. The client side mod does not do anything but print something. I think if the permissions are setup right it won't even be able to do that. :)
    Looking forward to adding a simple mob after that.
     
  24. Offline

    NathanWolf

    That really sounds promising!

    Myers, have you discussed this with EvilSeph, Dinnerbone, Tahg, or any of the other Bukkit devs? Maybe jump in IRC and ping them one day if not- see if they have time to chat.

    This is really very cool- but of course will only truly catch on if Bukkit embraces it- we need an official client as well as server! Definitely watching this one.
     
  25. Offline

    Phat_Rat

    This I like. If you can make it use the planes mod and fairies mod, I'll be a happy man.
     
  26. Offline

    Myers Carpenter

    Progress Report:
    We can download a mod that's trying to do something bad (read /etc/passwd on my mac) and it gets stopped by the sandbox.
    Next step: Register the new mob on the server and then have the server tell the client what class to use with what entity id
     
  27. Offline

    Malkierian

    Dude, this is so freaking awesome, more so by the day! This would solve all my problems as far as additional content goes in servers. It would be even more awesome if you could make it easily interfaceable by plugins! Would be perfect!
     
  28. Offline

    CuZnDragon

    Did Finnithnel ever reply to your message about working together?
     
  29. Offline

    PopeUrban

    Quite excellent. I'm watching this with much anticipation. Structure wise I see this working as an optional include for the bukkit framework, which allows plugins access to specific entity types as a variable declaration.

    So in your plugin code, you'd flip a bit ClientsideRequired = true;
    That bit flipped in the plugin's enable would flag the plugin itself as requiring a clientside mod, and would handle alerting the end user/soft disconnecting, etc.

    In this manner, it would then be fairly straightforward to add some of the simpler functionality to a given plugin, while still allowing plugin developers to develop serverside only modules.

    The bukkit server would get a subdir in the plugins directory, with a subdir for each loaded plugin. So if your plugin "awesomecraft.jar" sits in /plugins, and you need clientside resources, and a config.yml, then you'd have /plugins/awesomecraft/clientside. Your serverside files would nest in the same place they do now, but your resources to stream to the client would simply sit in /clientside.

    Thus, admins would get the same ease of use for installing plugins as they do now, in addition to knowing where to look if they want to tweak the clientside assets.

    Once that bit is set up your developers can easily work in their assets and client scripts by some declarations, only these declarations would be owned by the plugin rather than bukkit itself.

    plugin.textureAtlas(name)
    For loading a basic sliced texture atlas, using the default minecraft item and icon atlases as a reference. This is different than a standard texture load for an entity as this atlas may be referenced by multiple objects.

    plugin.csEntity(model,texture,sounds,script,name)
    For loading mobile entities, or anything else. Maybe allow the script to be filled with an existing script from the default list in addition to a given *.jar (so you could load an entity that simply runs the zombie scripting if you just wanted a new zombie)


    plugin.csItem(textureAtlas,atlasx,atlasy,ID,displayName)
    For loading non block items, references a texture file, determines the used atlas and slice, the new Item's ID, and the item's display name (for mouseovers, possibly auto-append to item databases, etc.

    plugin.csBlock(textureAtlas,atlasx,atlasy,ID,displayName)
    For blocks with one texture (e.g. dirt, cobble, etc.)

    plugin.csBlockComplex(texture,ID,displayName)
    for defining complex blocks (e.g. dispensers, chests, and other lovely things of that nature. This uses a specific texture format for the unwrapped block faces (so each complex block would have its own .png)

    plugin.csAbstract(texture,model,sound,script)
    for defining any other clientside functionality. This is essentially a wrapper that retains ownership of any assets. Thus your server plugin could address "myGUI.method" to call your client function, and any assets used by your abstract would register as belonging to said abstract.
     
  30. Offline

    Myers Carpenter

    No :(.

    Awesome well though out stuff. Go fork it on github :). Wait... did I say github?

    I've have a pre-release of this now. Read more

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 11, 2016
Thread Status:
Not open for further replies.

Share This Page