Jump to content

LexManos

Forge Code God
  • Posts

    9264
  • Joined

  • Last visited

  • Days Won

    66

Posts posted by LexManos

  1. So what happens when I've created an entity server-side? What infos about it will be sent by the server to the client? And is there a standard way to send extra data?
    Look at MinecraftForge.registerEntity, and ISpawnHandler.

    I guess what I don't get is why the server would need that. When the player moves a stack from his inventory to a chest for example, how is the info sent back to the server? The GUI code will update the stack on the client I assume, by what mechanism is it synched back?

    Take a look at PlayerControllerMP.windowClick, it does all the normal things that clicking on a window does but it also sends to the server, that it clicked the window.

     

    Also, just to be sure, methods like Block.blockActivated or Entity.interact are called both client- and server-side, right? Looking at the vanilla code, EntityCow for instance, I find it strange that:

     

    par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, new ItemStack(Item.bucketMilk));

     

    is executed both client-side and server-side. Unless the client-side version is only to give immediate feedback to the player, and the server-side one is the only one that matters? So that if for some reason I changed the server-side one to give the player a lava bucket instead, the player would briefly get a milk bucket visible in his inventory due to the client code executing and a second later it would be replaced by a lava one as the server executes its own code and the player's client inventory is overwritten by the server one?

    Yup, in this particular case, it edits the inventory, which on the server signifies that it should send the new slot data to the client.

    Ever played on a server and gotten your damage values out of sync, had a item in your hand break, but then reappear? This is the exact reason why.

     

    However, there are some cases where the code should only be run on one side, and the event is fired on both.

    In such cases you should use world.isRemote, to determine if you are the authoritative side of the conversation or not.

    Droping items from blocks is an example, When a block drop is created, it checks world.isRemote, if that is true, it doesn't add it to the world.

    If it did, the client would see duplicate entities.

  2. There really sin't an equivalent for entites.

    But the reason the server sides uses Containers is because the bulk of Vanilla GUIs do exactly the same thing, they have a slot and you move item stacks around.

    All the container code is vanilla minecraft, nothing to do with forge. the openGUI is just a generic interface that deals with signaling the client that it should open a block related GUI, and signing the server that it should expect the client to have a block related GUI open.

     

    A couple of modders have hacked around with the openGui function to do some odd stuff, for example, the EnderStorage uses the X value to send the color code of the bag its opening, and ignores the Y/Z.

     

    The X/Y/Z are just ints that are transferred intact to the client without manipulation, so you can use them for whatever you want.

  3. Well your Container on the server can have as much information as you want, as you can make your own subclasses of Container.

     

    As for things with the text related field, the server doesn't need to know that it is a GUI at all, it just needs to know that the client has pressed button XYZ. Your best bet would be to setup a communication system between the server and client using the internal messaging system.

    You can look at Forge's internal handlers in it's code and this. Not the best in the world, but should be able to point you in the right direction.

     

     

     

  4. Well having a full blown file transfer system for your mod from the server isn't to bad of a idea, nor is it particularly difficult.

    Anyways,  All server side GUIs are containers, you will probably have to write something quite special for some of your GUI's.

    It's been to long since I've played your mod to determine which specific types of GUIs you're referring to. What is your GUI needing to do?

  5. Well you should be able to toss your resources in anywhere along the class path, as long as java knows where it is.

    Having it in a zip in the mods folder is the simplest method to make sure its in the same configuration as it would be when you do the release.

    However, you would try making a resources linked folder in eclipse, and make sure that that is treated as a source folder and the files are copied to the bin folder when you debug. There are a bunch of ways to do it, just none to simple or intuitive.

     

    Meh, with the way MCP is setup, and everything, doing the repo management from inside eclipse is a pain.

     

    As for your languages, there are a few issues, You'll have to have the client tell the server what language it is. And then the server would have to translate in a per-player bases.

     

    You may want to write a system where when a player connects, it asks the server for the latest version of the translation file for it's language. And if they are out of sync, the client downloads it from the server.

     

    That would allow your admins to write custom phrases and translations, and the client would download it on the fly.

     

    Personally, I think that the server should have no concept of language and translation. Except for system messages aimed twards the server admin in the log. If you are wanting something displayed to the client it should only be known to the server as a key.

  6. Toss your resources into a zip and toss them into the jars/mods folder, FML loads that into the class path so you should be able to access them just fine.

     

    As for the whole having to get linked folders and stuff into git or svn, just don't use the SVN stuff inside eclipse, Forge just uses a folder inside the MCP workspace as the git root.

    So you have MCP/Millénaire/{stuff in svn}

     

    For the languages, just send the client a key and have them translate it to the full string depending on there selected language. This has the added benefit of minimizing the length text sent to the client.

  7. In eclipse you can have linked source files, and debugging in eclipse will pull all source files that are linked and compile them.

    It only because a issue when you go to reobf, in which case you do exactly what you said,

    Make copy of MCP/src to MCP/src-bak

    Copy Mod/Client -> MCP/src/minecraft

    Copy Mod/Common -> MCP/src/minecraft

    Copy Mod/Server -> MCP/src/minecraft_server

    Copy Mod/Common -> MCP/src/minecraft_server

    Recompile, reobf

    Del MCP/src

    Move MCP/src-bak -> MCP/src

    Small batch file to do that makes it simple.

×
×
  • Create New...

Important Information

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