MinicraftPlus / minicraft-plus-revived

Minicraft+, an extension of Notch's original minicraft project, with tons more features.
GNU General Public License v3.0
474 stars 96 forks source link

Any chance you give access to the serial port, to communicate with an Arduino like bord? #31

Closed fredericplante closed 3 years ago

fredericplante commented 6 years ago

Yeap, It's all up there

chrisj42 commented 6 years ago

Could you explain further what you mean by that? I am not as familiar with the hardware aspects of computers and stuff as I am with software. What exactly are you asking? Are you referring to the TCP port that minicraft plus uses for multiplayer? That is the only "port" I know of that I explicitly decided on in the code...

fredericplante commented 6 years ago

Ok then here is the challenge, go to www.arduino.cc and check out what is there. Then check out these 2 words: "ESP8266" and "ESP32". The goal is to open a serial port to send data out to the mcu serially to check if a switch is on or off, or to send a byte that will for example set on or off an LED hook on the board.

When I say serial port, I mean those port with a trapezoid male shape behind your computer and also those that we commonly use to communicate with modern mcu.

https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTKCzC7F15E2PEN8A5FjTYMbUiGHOVpS_YKPXi0_1tuN6rpsy6R7w

There are plenty of java libraries that allow to connect and use computer serial ports.

https://en.wikibooks.org/wiki/Serial_Programming/Serial_Java

It could be interesting to have real world control from the game, and vice versa. Mojong has never reply to my request, so I'm looking else where. :)

chrisj42 commented 6 years ago

Oof.

Why are you looking to do this directly within java? Surely there are other ways to do... whatever it is your want to do.... what do you want to do, anyway? Like, once you can connect to an arduino, what are you going to do with it? Physical things, I guess? It does sound cool...

What sort of data would get sent across the serial port? Does it matter? This is waaayy out of my realm of experience, but I'd be willing to try if I knew how to start...

fredericplante commented 6 years ago

Yeah! this would require the creation of a few kind of blocks, like switches and commendable light and stuff we will need as we go along. I'm not really requiring that it being done in JAVA, but you seem to use a lot of JAVA already, so I was suggesting on the same path.

This 2d interface open the door to many systems, it's an interesting aspect.

As for the type of data, it's for you, or us, to decide. It could be a block address, id, kind and data( char or byte). It could also end up with a neat command line, ESP family can handles a lot, can even transform JPEG to RGB TFT data.

With a minimum of work, one could easily reproduce the concept of his house and have some monitoring and actioning control over it. I would just need an interface like your game.

Of coarse, with out using an serial port it could be done, It could also be interesting to simply open a tcp socket and send a command line to an ESP device, this would also allow the ESP to report and or repost some data to some monitoring station that runs the game.

Any ways, you get the idea.

chrisj42 commented 6 years ago

So... what you're suggesting is... use the game as an interface to do other things outside the game? That's cool... a bit of a strange choice of interface, but I guess that's the fun part. :P So, what does this require on my end..?

fredericplante commented 6 years ago

first of all, we need a switch block a light block. Those two are required to do the prime testing. The switch block has to be able to turn the light on, using conductor. In the original minicraft they would of call it red stone I guess.

Also, get your self an esp8266 to have to possibility to also test it and be amazed

Get :

If you don't have Iron and lead, get them. :D Time to learn how to solder.

Europe plug:

American plug:

welding lead:

make sure to have an nano usb cable, take to 200cm one, you will enjoy the freedom of movement

This should make you a <40$ starter kit. Get your self a prepaid card at the store, never buy online with you own credit card.

Then download the Arduino IDE at:

and the ESP8266 API

Once you are at the point where you hooked the WEMOS mini to the USB bus of some computing unit, Let me know. :)

fredericplante commented 6 years ago

Well it's a general suggestion. I plan to use those, at first, so if you want to see the progress on both side, and not just get Bravos for the game from the Arduino community you might has well get the BOM. ;)

I'm pretty sure that with in a year you will port the game to be played on an ESP32 and a TFT, or something, cause has you will find out, you already know how to program those WiFi computing unit.

chrisj42 commented 6 years ago

Ooooof... wow. I did not realize what I was getting into... I was kinda hoping that I would just need to, ya know, add some code to the game... Speaking of code, you're saying that I'd need to basically make electrical components on minicraft?

I mean, I guess what you wanted from minecraft was a backdoor sort of thing to receive events from the game about certain buttons being pushed, things turning on, etc., and also the ability to send data back. I imagine, had this been in minecraft, it would have been a type of block, similar to a command block.

Anyway, wow, yeah, so this is pretty complicated. I don't know if I want to go all the way with buying the stuff and such, but... at the very least, I think I understand your idea now. And while I see that it potentially has merit, I also see that this will be no easy task... I'll have to come up with a system for what to pass in and out of the serial port, and how to use the info in the main game. Which will require a couple new blocks, which may or may not be very difficult depending on how far I go to implement it well.

Not to mention one little thing: I've kinda ceased adding new features to minicraft+... I might try and do this, sure, but it's probably going to be a pain 'cause the code sucks...

fredericplante commented 6 years ago

Oh no problem, you can totally just add some code to the game. And I do the material part, that is totally ok. :) But you should still just get a Wemo mini and start to mess with it, just for fun.

I would also have some question about your stuff, I usually do my programming on non-classical computer, so depending on the thing I program and the environment, like windows or linux, I would use IDE like visual studio or the Arduino IDE or simply command line using AVRDude plus a few other program on a chain, to compile and upload my code, but I know nothing about the JAVA structure, I can read and under stand your code, I can say this wil do that, but I have no clue what to use to program and compile it. I can't even find the entry point of the code all together.

Spare a few moments to help me? :D I was hoping to share my experience in my field with yours basically :D

chrisj42 commented 6 years ago

Sure, I love sharing. :D That sounds like a good plan. And to answer your questions regarding the code, the IDE of choice (imo) would be IntelliJ IDEA. You could also use Eclipse I suppose, but I haven't used that before, so I don't know how it works and I wouldn't be able to help you with it. The entry point is minicraft.core.Game.

chrisj42 commented 6 years ago

Also, are you sure you want to continue this here? There's a discord server for the game that I'm on very frequently; we could also use a DM to chat as well. Or we could continue the discussion here, I suppose, if you really want to. I'd prefer discord if you want more real-time chat, but if you want to talk here that's fine too. Your choice.

fredericplante commented 6 years ago

public static void main(String[] args) {

Ok found it. Thanks

Ok I see you on discord, but I will post update here.

Thanx

chrisj42 commented 6 years ago

alright then, no problem