Jump to content

geekles

Members
  • Posts

    37
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Location
    United States

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

geekles's Achievements

Tree Puncher

Tree Puncher (2/8)

1

Reputation

  1. How would I go about creating a connection on a separate thread but then calling a listener synchronous with the main thread with the result? Currently my last issue is synchronously starting my "ProxyResponseReader" class if the connection was successful. new SocketConnection("127.0.0.1", 8080).connect().onConnectionResult(new ConnectionResultEvent() { @Override public void onResult(boolean connected) { if(Thread.currentThread() == Main.t) { System.out.println("onResult: Same Thread!"); } else { System.out.println("onResult: Other Thread!"); //not on the main thread } if (connected) { reader = new ProxyResponseReader(socket); return; } [...] } } private static class SocketConnection { private Socket socket; private final String ip; private final int port; private ConnectionResultEvent event; public SocketConnection(String ip, int port) { this.ip = ip; this.port = port; } // make the connection with the socket private SocketConnection connect() { new Thread() { public void run() { try { SocketConnection.this.socket = new Socket(ip, port); SocketConnection.this.event.onResult(true); } catch (IOException e) { SocketConnection.this.event.onResult(false); } } }.start(); return this; } public void onConnectionResult(ConnectionResultEvent event) { this.event = event; } [...] }
  2. I see my problem. I'll try to rewrite my proxy response checker and subscribe to the client's tick instead of running the checks on a new thread.
  3. Thank you for the information. I looked into it, and yes, I forgot to consider that I am on a separate thread. This is because the listener I spoke about earlier is called from a separate thread. Is there a client supported asynchronous method that I can use to easily switch back to its main thread?
  4. Should I send over my entire project? ? CommandExecutor is an interface I implemented. CommandManager is a class that is responsible for registering these interfaces and setting up a listener for a class responsible for collecting outputs from a node.js proxy connection. Whenever a response is returned, the message is handled and then passed over to the listener that CommandManager uses. It then takes the string, converts it into an array of string command arguments and passes it to all the registered CommandExecutor. I know there's a more efficient method of going about doing this, e.g. associating aliases for each of these classes so that CommandManager can instead pass the parameter to only one of the classes instead of passing it to all of them blindly, however considering that this project is relatively small, and I have not created too many commands yet, but is something I intend to correct soon. But the information you're asking for now is quite redundant since now you're getting into how my entire project is functioning and not staying particularly focused on the subject of why the following line is throwing an error. mc.launchIntegratedServer(handler.getWorldDirectory().getAbsolutePath(), world, settings); I suppose first you can highlight what that error ("No context is current or a function that is not available in the current context was called") means since I'm quite unfamiliar with it and would like a general explanation of why the minecraft client throws it. Secondly, if you really need more information, please explain for what purpose, because at this point, I feel going back and forth like this is quite inefficient, and isn't getting us anywhere. If you have a question about the particular functionality of a class, then please ask and I'll explain.
  5. public class WorldCmd implements CommandExecutor { @Override public boolean onCommand(String[] args) { if(!args[0].equalsIgnoreCase("world")) return false; if(args.length == 2) NetworkUtil.joinWorld(args[1]); return true; } }
  6. I'm working on a mod (for a personal project of mine) that allows for the game to be controlled wirelessly through commands. It's a challenge for the game where the output from the game will be streamed to connected viewers. The audience may control the game's instance through commands. I currently have it so that the ingame character's movement may be controlled via commands as well as specifying which multiplayer server to join etc. however loading up a singleplayer world is ironically seemingly more tedious and I haven't been able to get far with that part. I would like to give the audience the opportunity to either choose to join a server and try controlling the game through commands only or choose to create or join a pre-existing singleplayer world. Naturally, checks will be made to ensure no one abuses this system and tries spamming servers with connection requests.
  7. I'm calling the Minecraft#launchIntegratedServer() function since the CreateWorldScreen class does the same when creating a world. I'm merely trying to replicate the actions used to create/load a new or existing world. CreateWorldScreen#createWorld()
  8. I am currently working on creating a method that lets me load a world from the world saves directory, however, after calling launchIntegratedServer to hopefully start loading up the world, I get some kind of *out of context* error that I'm not sure how to handle or resolve. This is my current setup: public static void joinWorld(String world) { Minecraft mc = Minecraft.getInstance(); SaveHandler handler = mc.getSaveLoader().getSaveLoader(world, mc.getIntegratedServer()); WorldInfo info = handler.loadWorldInfo(); if (info != null) { WorldSettings settings = new WorldSettings(info.getSeed(), info.getGameType(), info.isMapFeaturesEnabled(), info.isHardcore(), info.getGenerator()); mc.launchIntegratedServer(handler.getWorldDirectory().getAbsolutePath(), world, settings); LogManager.getLogger().info("World: " + info.getWorldName()); } } Stacktrace: FATAL ERROR in native method: Thread[Thread-15,5,main]: No context is current or a function that is not available in the current context was called. The JVM will abort execution. at org.lwjgl.opengl.GL11.glPushMatrix(Native Method) at com.mojang.blaze3d.platform.GlStateManager.pushMatrix(GlStateManager.java:572) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:916) at net.minecraft.client.Minecraft.func_213241_c(Minecraft.java:1710) at net.minecraft.client.Minecraft.func_213231_b(Minecraft.java:1683) at net.minecraft.client.Minecraft.func_213254_o(Minecraft.java:1667) at net.minecraft.client.Minecraft.launchIntegratedServer(Minecraft.java:1563)
  9. I did a bit more testing and found Optifine's Shaders does nothing to the actual gamma value in the gameSettings (which makes sense). However, the brightness is definitely being altered somehow and knowing how gamma is being used to determine how light darkness actually is would be a start. I'm thinking maybe LightTexture#updateLightmap(float) method may be in charge of this, but I'm not sure and I'm not sure yet how to override such a method for debugging purposes. It is also likely a waste of time to do so since it is very likely such a method is being replaced by Optifine's own way of handling lighting in the world. Optifine also uses a LightMap class which has methods that seem to replace the pre-existing vanilla lighting mechanics, but that could take time to properly debug/override as well. I suppose I could create my own, call it after optifine calls its own, but not knowing when this method is called could be an issue for now. Perhaps I'm overthinking all of this?
  10. *bump* Help with original issue.
  11. I suspect with reflection I can override some of the basic values, e.g. gamma and fog levels. However, I am still unclear on where these fields exist.
  12. I currently developed a mod that drops the gamma levels of the world and modifies the fog levels dynamically based off of several factors occurring in the world. I recently discovered however that when a shader is installed, the gamma levels and fog levels that my mod modifies are overridden by the shaderpacks. This is understandably so, however it would be nice to know if there's a way I could implement compatibility with shader packs instead of potentially having to disable the option completely. I suppose what I am asking, is there an event that Optifine passes when a shader loads so I can ensure the setting my mod plays with are not overridden, or do I need to create a schedular that constantly ensures the gamma levels are where they should be at (obviously a bit overkill but a possibility)?
  13. Thank you. I'll give it a try soon.
  14. Which one though. Should both handle an unmatched Protocol_Version?
  15. How would I listen for when this NetworkRegistry.ABSENT is passed? I assume perhaps there's an event I can cancel and handle it myself instead of having the client by default close the connection.
×
×
  • Create New...

Important Information

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