Forums - Open Redstone Engineers
MCsim (pre-alpha release) - Printable Version

+- Forums - Open Redstone Engineers (https://forum.openredstone.org)
+-- Forum: Off-Topic (https://forum.openredstone.org/forum-4.html)
+--- Forum: Programming (https://forum.openredstone.org/forum-8.html)
+--- Thread: MCsim (pre-alpha release) (/thread-1606.html)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20


MCsim (pre-alpha release) - CX gamer - 12-16-2013

OPEN SOURCE: https://github.com/CXgamer/MCsim

Hey guys! This turned a bit into a ramble. If anything, please look at the screenshot. Smile

Back in the old days there was Baezon's redstone simulator, then there was Mordritch's JavaScript Redstone Simulator. (EDIT: There's also Rek's Circiut Simulator.) But the major problem with simulators is that they're never 100% accurate, or fail to stay updated with the game.

So back in 2011, I started working on my own. I've only been working on it off and off, coïncidently, only in the months december and january (and once in february in 2012). But this last time I feel like I've made some good progress (and also removed large portions of bad code that dumb old me made years ago).

Here's a screenshot:
[Image: AJIxM9w.png]

Notice you're able to open more than one perspective, and you've got 3 perspectives in total. Visually this is pretty much the same as what I had years ago, but I've made major leaps in performance (I learned not to re-instantiate hundreds of objects every layer switch). Also note not all blocks are drawn yet, just air, wires, torches, repeaters and wooden and stone buttons.

But the difference with this simulator is that it uses Reflection to run actual parts of the original game. Of course minecraft.jar is obfuscated, so I'm also requiring some files out of MCP's /conf folder, parsing its deobfuscated names and then just grabbing the correct classes out of the .jar. The same applies to anything I want to do inside those classes. Had some minor trouble with duplicate entries but that's all sorted out.

With that, I'm down to doing the actual implementation (but all parsing and loading is already done). I heard there were major changes in the code since 1.7, so I'm kinda waiting on MCP's 1.7 update. But there's plenty of stuff I can work on in the meantime, of course.

If you have not already figured out, this whole reflection thing means I'll be using Java. My apologies to anyone who is disappointed in hearing this.

Rambling starts here...

Oh what also might be interesting is that I'm drawing each tile exactly once, and then use every tile's unique identifiers to generate a hash which is then used to store a BufferedImage into a HashMap. This achieved a great speedup in rendering. But it also limits the number of unique blocks to 64.

The reason being is that a hash is made out of 16 bit integers, and these are the unique identifiers that make up a piece of redstone wire:
  • 4 bits for all connections
  • 2 bits to indicate from which side you're looking (and thus how it should be rendered)
  • 4 bit power level
And that leaves me with 6 bits to use to indicate that it's actually a redstone wire. But that's not ever a problem, and there's plenty of ways around this.

But apart from that, the plan is to incorporate lots of tools for redstone engineering in this. Like automated testing, block update plotter, useful logic tooltips, ... But since we're using the original minecraft code anyway, we should be able to pretty much build anything that's possible in minecraft. I'm aware this is not the place for survival minecraft, but I'm thinking item entities, mobs, hoppers, ...

If I decide to do it by sending packets to the internal server, I might as well be able to connect to an existing creative server. But that's probably not for now. Anyway I hope some of you share my enthusiasm, and I hope that I'll get past february next year, then it might actually be something release-worthy.

Thanks for the read guys! Smile

EDIT: I noticed a small bug in the screenshot causing the off-torches to float on a grey block (which means it isn't drawn yet). It's probably got to do with the fact that block ID's are unsigned bytes and java's bytes are signed, and that block happens to be newly coloured quartz, so it's > 127. At some point, I had fixed it, but seems like I undid too much or broke it again in another way. Cheers!


RE: Redstone simulator anyone? - Somepotato - 12-16-2013

Cool but the main issue with all these redstone simulators is that it's hard to get a grasp on the layout. Very good job though


RE: Redstone simulator anyone? - CX gamer - 12-16-2013

I agree it may take some time before it becomes intuitive. However the advantage is that you always maintain your overview and don't have to fly around to build stuff.

EDIT: So sexy...
[Image: F7KBOWY.png]

EDIT2: Now supporting scaling once again!
[Image: 5PKBL5l.png]


RE: Redstone simulator anyone? - Frontrider - 12-19-2013

Make it to run on android, and everyone is happy.


RE: Redstone simulator anyone? - EDevil - 12-19-2013

(12-19-2013, 11:34 AM)Frontrider Wrote: Make it to run on android, and everyone is happy.

I approve this awesome feedback.


RE: Redstone simulator anyone? - CX gamer - 12-19-2013

(12-19-2013, 11:34 AM)Frontrider Wrote: Make it to run on android, and everyone is happy.

Hmm that would be quite hard. I certainly wouldn't be able to fit the features in it that I'm having planned now. It'd have some major performance issues, besides it requires the minecraft.jar, and I don't think it's got the memory available to run on Android, specially in the unoptimized parts of Reflection.

I am working on a chat client for Android for school. It will use encryption and has the possibility to send one GPS data if proper permission is given. But it's for school so that will probably be half-assed.

Anyway, here's another screenshot of more blocks being drawn. Also cleaned up more of the 2 year old code.

[Image: 6n13e6L.png]


RE: Redstone simulator anyone? - EDevil - 12-19-2013

The android thingy was kind of a joke Tongue You've been working so hard at this, and then we demand you to code it for android?!? Naah, just continue with this epic project on PC Big Grin


RE: Redstone simulator anyone? - redstonewarrior - 12-19-2013

In theory, if you get really into it, you could spend an evening stripping away at the block classes (and remove most others), until you arrive at a relatively small thing that could be put on android. Have fuuuuun.


RE: Redstone simulator anyone? - CX gamer - 12-19-2013

Haha alright both of you got me. xD


RE: Redstone simulator anyone? - Neogreenyew - 12-19-2013

Why wouldn't you just build the device in minecraft..? It would be easier and faster imo.