Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

Search the Community

Showing results for tags 'java'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • OpenComputers
    • Announcements
    • Feedback
    • IRC
  • Code Central
    • Support
    • Showcase
    • Tutorials
  • Addons & More
    • Addons Mods
    • Architectures
    • OpenEngineering Task Force
  • General
    • Lounge
    • Forum Games
    • Showcase
    • Servers
  • Archives
    • Public Archives

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Fediverse ID



Found 6 results

  1. Hi ! My project is te get my AE Inventory send to a SQL Database using a JAVA TCP server (because JAVA is the language I'm more familiar with). My issue is when I'm done sending my packet, my java program crash (I give you details below). I've tested with a JAVA TCP client and it work fine. My OC program is very basic. It's just to test my TCP server : local net = require("internet") local con = net.open("my ip",my port) if(con) then con:write("Hi ! I'm your OpenComputer ! \r\n") con:write("Test Sentence 2") con:close end This is my Class wich handle the input informations : import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketException; public class ClientProcessor implements Runnable{ private Socket sock; private BufferedInputStream reader = null; public ClientProcessor(Socket pSock){ sock = pSock; } public void run(){ System.err.println("Client Inbound"); boolean closeConnexion = false; while(!sock.isClosed()){ try { reader = new BufferedInputStream(sock.getInputStream()); String response = read(); InetSocketAddress remote = (InetSocketAddress)sock.getRemoteSocketAddress(); String debug = ""; debug = "Thread : " + Thread.currentThread().getName() + ". "; debug += "Demande de l'adresse : " + remote.getAddress().getHostAddress() +"."; debug += " Sur le port : " + remote.getPort() + ".\n"; debug += "\t -> Commande reçue : " + response + "\n"; System.err.println("\n" + debug); }catch(SocketException e){ System.err.println("LA CONNEXION A ETE INTERROMPUE ! "); break; } catch (IOException e) { e.printStackTrace(); } } } //Function to read the inbound data private String read() throws IOException{ String response = ""; int stream; byte[] b = new byte[4096]; stream = reader.read(b); response = new String(b, 0, stream); return response; } } So. I start my JAVA server, and then launch my OC test program. Here is the result : Thread : Thread-1. Demande de l'adresse : my ip. Sur le port : 60152. -> Commande reçue : Hi ! I'm your OpenComputer ! Test Sentence 2 Hi ! I'm your OpenComputer ! Test Sentence 2 Exception in thread "Thread-1" java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.checkBounds(String.java:381) at java.lang.String.<init>(String.java:545) at server.opencomputer.perso.ClientProcessor.read(ClientProcessor.java:71) at server.opencomputer.perso.ClientProcessor.run(ClientProcessor.java:36) at java.lang.Thread.run(Thread.java:748) I already started digging on the issue. For me, the "String index out of range: -1" is due to an "empty" packet while trying to build the answer in the "response" variable with "response = new String(b, 0, stream);". Since "stream" is equal to -1, it make it crash. But I don't know if it come from OpenComputer or my Java server since with a Java Client it work fine. I've also analyzed the inbound packets and I don't see empty or faulty one. I already have a program for listing my AE inventory, and a Class to input things into a SQL database (Mariadb server is ready too). Only a small thing before it's done Is there something I'm missing ? Thanks for your help The Frenchtopus.
  2. A while ago i made a JVM in Lua with the first goal of running Java on OC, just because i like Java and we all know it's a good programming language. So here's the JVM running a program that fills GPU: Oops, made a typo. Ok at first this might not seem impressive at all, but now you can interact with components using Java! That's an awesome thing for Java-ers like me! Race to first Java OS in OC? Anyone? Here's the (simple) code i used above import lukyt.oc.Component; public class ComponentTest { public static void main(String[] args) { String gpu = Component.getPrimary("gpu"); Component.invoke(gpu, "setBackground", new Object[] {0x2D2D2D}); Component.invoke(gpu, "fill", new Object[] {1, 1, 160, 50, " "}); System.out.println("Filled screen with RGB 0x2D2D2D"); } } Here's GitHub page (to download and use on your favourite OC computer): https://github.com/zenith391/lukyt
  3. I'm trying to implement OpenComputers support for a mod I'm making. The mod in question already supports ComputerCraft. I've managed to add OC support for everything else save for a radio transmitter block. The block / tile entity in question is designed to allow sending data over a channel, but is restricted to sending a certain amount of data within a timeframe. To be exact, you can send 2205 bytes over a channel 5 times a second (0.2 seconds per packet). To this end, the transmission method for ComputerCraft waits a certain amount of time if data has already been sent: if (PhotonicRadio.sendCache.containsKey(channel)) { PhotonicRadio.sendEventWhenSend(computer); context.pullEvent("photoniccraft_sendtimer"); } sendCache is whether data has already been sent to a certain channel, and sendEventWhenSend adds the computer into a queue, after which the thread responsible for running the radio (as well as sending packets to players; there's a pocket radio item to play the radio data as audio). The queue is cleared on every send by sending an event to all of the computers in the queue, and the pullEvent function will block until this event is sent - which makes the computer idle and wait until the packet currently in the queue is sent. For OpenComputers, I've failed to find such an alternative. I'm aware of Context#pause, but it requires a specific determined amount of time to pause for - and while the radio thread is supposed to be run every 200 ms as timed by the server scheduler, I cannot be certain that estimating the time would be correct - if it's too early, the whole thing may break apart, while if it's too late, it wastes processing time on the computer. I was thinking of using direct = true and simply using semaphores - adding the semaphore into the same radio queue, waiting it (acquire) and then signaling it (release) in the radio thread, but this actually causes the entire server to lag - if I add a print statement into the callback, 9 out of 10 calls still come directly from the server thread, so forcing it to sleep causes everything else to stop as well. I have noticed Machine#popSignal, but I'm not certain how to retrieve a Machine instance from a ManagedEnvironment, and it doesn't seem popSignal is blocking anyway ("return a signal or null if the queue was empty"). Is there any better way to achieve what I'm trying to do other than spinning (check if we've sent a packet, if not, Context#pause and check again), which feels wasteful? edit: It seems that using Context.pause and spinning causes all other computers to slow down (even if I try to predict the time beforehand and spin afterwards if it isn't sufficient), which makes a better solution (that could yield) even more urgent.
  4. I am working on a mod that adds drivers for Tinker's Construct, and everything works, except the component name. For some reason, the adapter always gives back, e.g. gui_smeltery_name for the smeltery, while I set the name to be 'smeltery' in the setComponent method. The code: https://github.com/BrisingrAerowing/TinkersOCDrivers/blob/master/src/main/java/tinkersoc/smeltery/EnvironmentSmeltery.java#L20 Anyone know why this happens and how to fix it?
  5. When I launch Minecraft with OpenComputers dev in eclipse OC spits alot of errors but does not crash, when I go into a world all items don't seem to work (can't put into computer). Some of the errors include: [18:39:50] [Client thread/INFO] [OpenComputers/OpenComputers]: Registering new assembler template 'Tablet (Creative)' from mod OpenComputers. [18:39:50] [Client thread/WARN] [OpenComputers/OpenComputers]: Failed registering assembler template. java.lang.ClassCastException: interface li.cil.oc.api.internal.Tablet Entire log: http://pastebin.com/YEteSicq I don't think it is my mods doing, since even if I comment out the 2 lines of code that run it will still break. If I build the mod it works fine with regular universal build. I didn't make an issue on github because I am not sure if this is just me messing up or if it's a problem with the dev build since I tried it on 3 versions.
  6. Hi there, I am currently implementing a JavaScript Architecture (based on J2V8) for OC and now I am stuck at implementing "component.methods(string)" because in Java I see Machine.methods(), which would give me what I want, but wants either a Value or an Environment object and I do not see a way of getting either of these by the component address. As I do not know Scala I am also not able to look up how it is done in the LUA implementation because I simply do not understand that code.
  • Create New...

Important Information

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