If so, how would I do that?
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Native Java Api Possible?
Started by distantcam, 20 October 2013 - 09:45 PMPosted 20 October 2013 - 11:45 PM
Is it possible to make a native API in Java and have it picked up in ComputerCraft?
If so, how would I do that?
If so, how would I do that?
Posted 21 October 2013 - 01:19 AM
You can write java code that is executed by computers using peripherals. Check out this link for the very plain basics. Beyond that, I'm in the process of writing up a peripheral tutorial which may or may not get posted sometime this month (between frequent MC/Forge updates and real life, I've had a lot of trouble getting anything done). Assuming you don't already have background modding experience, check out this to learn about actually making a mod.
As for making an actual API that has no physical block in the world, I'm afraid that's quite difficult. You can make blocks in the world into peripherals, as exampled by OpenPeripheral, but making an API without a peripheral is essentially impossible without deobfuscating/messing around with native CC code, which is not allowed.
As for making an actual API that has no physical block in the world, I'm afraid that's quite difficult. You can make blocks in the world into peripherals, as exampled by OpenPeripheral, but making an API without a peripheral is essentially impossible without deobfuscating/messing around with native CC code, which is not allowed.
Posted 21 October 2013 - 11:04 AM
I had thought about doing it as a peripheral, so I'm glad that'll work and was the right track.
Is it worth asking if future versions of ComputerCraft could support native APIs?
Those links were helpful, thanks! Now to relearn Java (it's been 11+ years).
Is it worth asking if future versions of ComputerCraft could support native APIs?
Those links were helpful, thanks! Now to relearn Java (it's been 11+ years).
Posted 21 October 2013 - 12:31 PM
Is it worth asking if future versions of ComputerCraft could support native APIs?
They already do; see "Peripherals". As for java code loaded solely from Lua code, that will never happen.
Posted 21 October 2013 - 07:34 PM
They already do; see "Peripherals". As for java code loaded solely from Lua code, that will never happen.
I meant without needing a peripheral.
I'm curious as to why loading java as an API without a peripheral would never happen. Is it a security problem? Technical problem?
Posted 21 October 2013 - 07:46 PM
Probably both, but a big concern would be that it would allow code to break out of the Lua sandbox.
Posted 21 October 2013 - 08:33 PM
Interesting.
Wait, does that mean that peripherals run outside the Lua sandbox? So peripherals are running in Minecraft outside of ComputerCraft?
That's a pretty neat way of dealing with plugins that might potentially crash and bring down Computercraft. Although really that's just shoving the problem back onto Minecraft. ;)/>
Wait, does that mean that peripherals run outside the Lua sandbox? So peripherals are running in Minecraft outside of ComputerCraft?
That's a pretty neat way of dealing with plugins that might potentially crash and bring down Computercraft. Although really that's just shoving the problem back onto Minecraft. ;)/>
Posted 21 October 2013 - 08:38 PM
Peripherals are a Minecraft mod that interfaces with ComputerCraft, so of course they run outside of the Lua sandbox.Wait, does that mean that peripherals run outside the Lua sandbox? So peripherals are running in Minecraft outside of ComputerCraft?
Posted 22 October 2013 - 03:27 PM
Posted 24 October 2013 - 12:08 AM
great tutorial btw,
but yes a peripheral will call back into its java programming so maybe just add a peripheral like a command block where a method can be called with some code as an argument and then it can be run somehow