Jump to content

Endyl

Members
  • Posts

    12
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed

Endyl's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I didn't get much (if any) further with this problem. To find a possible solution/workaround I made the task a bit more abstract, so maybe you can give me more ideas, because I'm running out of them. When a player connects to a game (on a remote or the integrated server), I'd like to open (or at least get a path to) one or more files which should be unique to that server/sp world. Also, when the player disconnects (for whatever reason) I'd like to close these files (if any of them are open), or "forget" about their paths. The problems I have encountered: - during ClientConnectedToServerEvent, I cannot get a reference to the name of the current SP world - my ClientConnectedToServerEvent handler is not called when connecting to a default bukkit server running on the same machine, due to some error in FML/Forge (I did not test this with a vanilla server) I don't have the error log right now, but I can attach it later if necessary. - my ClientDisconnectionFromServerEvent handler never gets called, ever - while trying to work around these with WorldEvent.Load, I have found that that event is fired variable number of times (some of those I could make some sense of and for some I couldn't) Technically I could get a reference to the necessary files when things of interest happen, but that just seems like such a waste of computation power to "calculate" these things frequently when in theory I would only need to do it on connection. And with this method I still wouldn't know when to close/"forget about" these files. TL;DR - when joining a game, I would like to know the server IP (and possibly other data about it)[solved for remote servers, unsolved for local bukkit server] or the sp world name [unsolved] - I would like to be notified, when a disconnect happens for whatever reason [unsolved]
  2. IIRC for TickEvents you should register your eventhandler instances with FMLCommonHandler.instance().bus().register(). Check out the subclasses of TickEvent for specific types of ticks.
  3. I have managed to get the ServerData of a remote server by Minecraft::func_147104_D(), but now I don't know how could I get info about the singleplayer world during ClientConnectedToServerEvent: With a breakpoint in the else branch mc.theWorld, mc.thePlayer are null, but according to the console, I have already joined the game). And I still don't know how to get notified about disconnection.
  4. I have a class with these methods: An instance of this class is registered with FMLCommonHandler.instance().bus(). When I connect to a server "Connected to server" is printed to the console, but when I disconnect "Disconnected from server" is not (but it should, if I understand the javadoc correctly: "Fired at the client when the client is disconnected from the server."). My question is, how do I get notified of being disconnected from a server (both by the client, by the server or by any sort of error)? And once a connection is made to a server, can I still get info about the server (ip, name, whatever; I assume yes)? From where do I get that info, because I have been browsing through the javadoc for a long time, and I just cannot find the way to get some sort of reference to the currently connected server? Thanks!
  5. Thank you for your help! Calling loadOptions() after registering KeyBindings is a viable workaround for now, and I started a topic in support.
  6. During FMLPreInitializationEvent I add a custom KeyBinding by registering it with ClientRegistry.registerKeyBinding(). The KeyBinding works as expected except for it not being loaded at startup by GameSettings::loadOptions. The KeyBinding is saved to options.txt and the respective line is processed in GameSettings::loadOptions but GameSettings::keyBindings does not contain any KeyBindings registered with ClientRegistry at this point, so the saved value is not loaded and the default key is used after every client restart. Can be solved by calling GameSettings::loadOptions after registering KeyBindings from mod code as a workaround.
  7. You are still directly casting doubles to int... that has been pointed out earlier to be the major culprit of your problem (most probably). Try something like this: int x = (int) Math.floor(player.posX); // etc.
  8. By stepping through saveOptions() and loadOptions() I have found the following: In saveOptions() my KeyBinding is present with proper keyDescription and a keyCode different from the default one. In loadOptions() the String representing my KeyBinding's setting in file is also present with the appropriate keyDescription and the nondefault keyCode value, however, akeybinding[] does not contain my KeyBinding instance, thus fails to load the saved value. I have just double checked that the code creating the KeyBinding instance runs during FMLPreInitializationEvent. And as I have said it works perfectly except for, as it seems not the saving but the loading of the custom value. What am I missing here? Or is it a bug in Forge 1024?
  9. From my ClientProxy I call the following during FMLPreInitializationEvent: This code is in a static method of KeyBindingHandler. if(KeyBindingHandler.toggleInfoScreenKey.isPressed()) { //Render stuffs } This doesn't work, as once it consumes all the keypresses it returns false every time. For this to work I would have to press the key for every RenderGameOverlayEvent.
  10. I have a KeyBinding registered with ClientRegistry, and it correctly shows up in the Controls menu and I can change it, and I can also use it in-game. The only thing missing is that when I restart the client, the KeyBinding is reset to the original key (other mc defined keys are saved). How can I get my KeyBinding to persist its customized key association across client restarts? Any pointers to documentation or examples are welcome! Thanks! ps.: A side question: I use this key during RenderGameOverlayEvent to see whether I should render my custom HUD or not by using something similar: Is it a right approach to implement a toggle key, or should I do it differently?
  11. I've searched far and wide to find a way to draw text to the screen and I have found the following so far, that is unfortunately not working correctly: I have a TickEventHandler.java, that is registered through FMLCommonHandler.instance().bus(). My event handler gets called (if I write to the console from there, the console gets flooded), but the text is nowhere to be seen. My question is: how can I draw text to the screen, preferably showing only when in a game (not in menu screens) like the data shown when F3 is pressed? Thanks!
×
×
  • Create New...

Important Information

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