OPEN SOURCE: https://github.com/CXgamer/MCsim
Hey guys! This turned a bit into a ramble. If anything, please look at the screenshot.
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:
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:
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!
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!
Hey guys! This turned a bit into a ramble. If anything, please look at the screenshot.
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:
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
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!
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!