This is a simulator capable of imitating the redstone and piston mechanics from Minecraft! It is a fork of Simnik's simulator (which can be found here), as he was kind enough to make his project open-source. In keeping with the free spirit, I have also packaged my eclipse project, git repository, and full source into the download below (as well as a runnable JAR file). I'm hoping that my changes will be merged in with Simnik's original codebase so that we may combine our efforts.
Screenshot of the program, showing a complex circuit with an XOR-based piston!
Todo
* Conducting pistons mod (power through the paddle)
Bugs
* Piston delay is slightly innaccurate (see Simnik's post)
* Piston powering logic may be flawed
Changelog
v0.81-rek5:
+ Saving/Loading added (might not work great with loading into other programs)
+ Pistons that are facing up/down now are visibly different
+ Added new block types: Obsidian, Pink Wool, Blue Wool. (Middle click to change block type)
+ Ability to delete and rotate active pistons
+ Changed palette to fit everything (uses two columns now)
- Unextended powered pistons weren't pullable
- Would-be floating torches etc get deleted when deleting the block underneath
v0.81-rek4:
+ Extra sticky piston mode (for fun)
+ Set max number of blocks a piston can push to 12
- Sticky pistons pull paddle off of other pistons
- Piston icons flip when going between layers
v0.81-rek3:
+ Improved piston powering logic
v0.81-rek2:
- Pistons can't be rotated in 2-layer mode
v0.81-rek: My first release!
+ Made it so would-be floating torches etc get deleted when deleting the block underneath
+ Added pistons
+ Made the codebase use a BlockType enum rather than unspecified int values
+ Cleaned up various parts of the code
Fixed the rotation bug. Looks like getting the power working properly is going to be pretty involved and probably won't be happening tonight. Vertical pistons are pretty untested atm.
Hopefully you guys can have fun with them anyways!
If they're not working as expected, just make sure you are supplying power to the back of the piston.
Last update for tonight. Improved the piston powering logic. It's probably not perfectly accurate to MC, but at least it let me test out my double retracting sticky piston schematic!
v0.81-rek4:
+ Extra sticky piston mode
+ Set max number of blocks a piston can push to 12
- Sticky pistons pull paddle off of other pistons
- Piston icons flip when going between layers
I added "Extra sticky" pistons. These are sticky pistons which, when they retract if it is pulling another closed piston, it will pull whatever that one has stuck to it as well (and so on up until the max # of pushable blocks).
They let you do things like this...
and...
:smile.gif:
Note: this is just an option. Normal sticky piston behavior is still available (and is on by default).
For lots of other piston circuits, check out Grizdale's Piston Logic Compendium.
I will be working on making this sim support all the circuits that are posted in there. :smile.gif:
In your dirModifier in Block, you have set up to 0 and down to 5 (array index). In all of my coding I did it the other way around (down 0 and up 5). Such modifier might prove to be very powerful and being able to reduce redundancy greatly.
Ah, good catch. This is one of the problems with using "magic numbers", it's very easy for other people coming in to get confused by them!
You have placed all of the piston logic in Block, which I am wondering why.
Giving blocks their own coordinates might seems like a good idea.
It was more object-oriented and more encapsulated that way. It's easier to add new functionality when the logic doesn't need to be stuck in the middle of a giant function. Also for the pulling/pushing of blocks I am using a recursive algorithm, so it made more sense to me to do it that way. This is also why I put the coordinates in the block itself, even though this data is redundant.
What is the point about having an options to simulate extra sticky pistons? It is to support the old mod?
Just for fun. I was looking into making a mod with this behavior but the coding lib hadn't been updated to 1.7 at that time so instead I started working on this instead. Once I got it to a workable state I just threw it in to prototype it and see if it had any merit.
With the how the piston logic is working, the most important from my perspective, then ... this is enough for now.
Hmm. I'll have to consider how to handle that. Do you happen to know by what logic pistons are powered? How did you find out all the rules for redstone wires/torches/blocks?
How did you handle the 1.5 redstone ticks for pistons?
Answer: I didn't. I didn't know how much of a delay pistons actually take so right now the delay is the same as a redstone repeater. This hasn't impacted the simulation greatly in the circuits that I've tested... and I've tested some real doozies:
Do you know if there are any mod making sticky pistons act like I activated Extrasticky Pistons?
Don't know, I'm not working on it right now but it seemed like something that would be worthwhile to add. I did see one mod that lets you push/pull activated pistons.
Big changes here: added distinct block types, fixed various bugs, made vertical pistons work better, and now you can delete/edit stuff even when pistons are active. Full changelog below
(extract the zip-file, and run the jar-file with java) v0.81-rek5:
+ Saving/Loading added (might not work great with loading into other programs)
+ Pistons that are facing up/down now are visibly different
+ Added new block types: Obsidian, Pink Wool, Blue Wool. (Middle click to change block type)
+ Ability to delete and rotate active pistons
+ Changed palette to fit everything (uses two columns now)
- Unextended powered pistons weren't pullable
- Would-be floating torches etc get deleted when deleting the block underneath
Hi Rek, made a wiki entry for you'r sim. also, how about putting in transparent blocks? they don't conduct electricity and thus are very useful for memory and many other piston stuff.
Rollback Post to RevisionRollBack
Quote from Matraz »
That's not a circle... it's a triacontakaihexagon. (36 sided shape)
Hi!
I like this program, but... it can be better:
1. You forget even doors, other things like rails, water, lava, glass, sand, note would be handy for new logic;
2. N,W,S,E,T,B arrows and rotation with side view would be so useful especially for 1 block wide schemes;
3. Can you change control (left click selection change orientation, left click cell control switches/repeaters) and icons (brown/green pistons, not cylinder), please.
Rek, I made a small patch that enables you to shift-click instead of having to use the middle mouse button. It's fairly simple - here's the diff for GUI.java, which is the only file changed.
458c458
< workingAreaEvent(lastPressed, false);
---
> workingAreaEvent(event, false);
475,476c475
< lastPressed = event.getButton();
< workingAreaEvent(event.getButton(), true);
---
> workingAreaEvent(event, true);
499c498,499
< public static void workingAreaEvent(int operation, boolean trueClick) {
---
> public static void workingAreaEvent(MouseEvent event, boolean trueClick) {
> int operation = event.getButton();
507c507
< if (operation == 1) { // main click ( left button )
---
> if (operation == 1 && !event.isShiftDown()) { // main click ( left button )
546c546
< } else if (operation == 2 && trueClick) { //mousewheel pressed
---
> } else if (operation == 2 && trueClick || (operation == 1 && event.isShiftDown())) { //mousewheel pressed
I warn you however, this is literally my first time working with java (I use C++ and Python), so no guarantees, but it works on my machine at least.
You should add glass for the pistons. To simulate a block that cannot carry a current through it, like a solid block with a repeater. It would be very handy for some redstone implementations.
I took advantage of the open source code to take a look at Java and see if it was something that I wanted to try to learn. I wound up adding glass, wooden pressure plates, doors, trapdoors, and all three types of rails—though I'm not sure if the power logic is 100% correct and I didn't even try to add the carts. I don't want to have to maintain a version of the program myself (and you're doing a wonderful job with it, anyway), so I was wondering if you wanted to take a look at what I've done and see if it is something you would be able to add to the main download. I do have git, but I wasn't sure where the best place to push my revisions would be, or if you just wanted me to upload the files somewhere. If you'd rather talk privately, private messages are easy and I have a gmail account at this username. Thanks!
@jkat718: The wiki has twopages that might be what you're looking for. Keep in mind, though, that this program uses slightly different tiles—the levers and repeaters are some of the most obvious differences, but there are a few other blocks that aren't quite the same. Just imagine that you are looking straight down on the block and you should be able to guess most of them.
Current version: 0.81-rek5
This is a simulator capable of imitating the redstone and piston mechanics from Minecraft! It is a fork of Simnik's simulator (which can be found here), as he was kind enough to make his project open-source. In keeping with the free spirit, I have also packaged my eclipse project, git repository, and full source into the download below (as well as a runnable JAR file). I'm hoping that my changes will be merged in with Simnik's original codebase so that we may combine our efforts.
Download: CircuitSimulator_v0.81-rek5.zip
(extract the zip-file, and run the jar-file with java)
Screenshot of the program, showing a complex circuit with an XOR-based piston!
Todo
* Conducting pistons mod (power through the paddle)
Bugs
* Piston delay is slightly innaccurate (see Simnik's post)
* Piston powering logic may be flawed
Changelog
v0.81-rek5:
+ Saving/Loading added (might not work great with loading into other programs)
+ Pistons that are facing up/down now are visibly different
+ Added new block types: Obsidian, Pink Wool, Blue Wool. (Middle click to change block type)
+ Ability to delete and rotate active pistons
+ Changed palette to fit everything (uses two columns now)
- Unextended powered pistons weren't pullable
- Would-be floating torches etc get deleted when deleting the block underneath
v0.81-rek4:
+ Extra sticky piston mode (for fun)
+ Set max number of blocks a piston can push to 12
- Sticky pistons pull paddle off of other pistons
- Piston icons flip when going between layers
v0.81-rek3:
+ Improved piston powering logic
v0.81-rek2:
- Pistons can't be rotated in 2-layer mode
v0.81-rek: My first release!
+ Made it so would-be floating torches etc get deleted when deleting the block underneath
+ Added pistons
+ Made the codebase use a BlockType enum rather than unspecified int values
+ Cleaned up various parts of the code
Hopefully you guys can have fun with them anyways!
If they're not working as expected, just make sure you are supplying power to the back of the piston.
It worked. :smile.gif:
v0.81-rek4:
+ Extra sticky piston mode
+ Set max number of blocks a piston can push to 12
- Sticky pistons pull paddle off of other pistons
- Piston icons flip when going between layers
I added "Extra sticky" pistons. These are sticky pistons which, when they retract if it is pulling another closed piston, it will pull whatever that one has stuck to it as well (and so on up until the max # of pushable blocks).
They let you do things like this...
and...
:smile.gif:
Note: this is just an option. Normal sticky piston behavior is still available (and is on by default).
I will be working on making this sim support all the circuits that are posted in there. :smile.gif:
Ah, good catch. This is one of the problems with using "magic numbers", it's very easy for other people coming in to get confused by them!
It was more object-oriented and more encapsulated that way. It's easier to add new functionality when the logic doesn't need to be stuck in the middle of a giant function. Also for the pulling/pushing of blocks I am using a recursive algorithm, so it made more sense to me to do it that way. This is also why I put the coordinates in the block itself, even though this data is redundant.
Just for fun. I was looking into making a mod with this behavior but the coding lib hadn't been updated to 1.7 at that time so instead I started working on this instead. Once I got it to a workable state I just threw it in to prototype it and see if it had any merit.
Hmm. I'll have to consider how to handle that. Do you happen to know by what logic pistons are powered? How did you find out all the rules for redstone wires/torches/blocks?
Answer: I didn't. I didn't know how much of a delay pistons actually take so right now the delay is the same as a redstone repeater. This hasn't impacted the simulation greatly in the circuits that I've tested... and I've tested some real doozies:
Don't know, I'm not working on it right now but it seemed like something that would be worthwhile to add. I did see one mod that lets you push/pull activated pistons.
Haha... Not going to happen, at least not by me. If you've got the skills, the source is in the download!
It's blazing hot here today, but I think I might get an update out to you guys anyways...
Download: CircuitSimulator_v0.81-rek5.zip
Big changes here: added distinct block types, fixed various bugs, made vertical pistons work better, and now you can delete/edit stuff even when pistons are active. Full changelog below
(extract the zip-file, and run the jar-file with java)
v0.81-rek5:
+ Saving/Loading added (might not work great with loading into other programs)
+ Pistons that are facing up/down now are visibly different
+ Added new block types: Obsidian, Pink Wool, Blue Wool. (Middle click to change block type)
+ Ability to delete and rotate active pistons
+ Changed palette to fit everything (uses two columns now)
- Unextended powered pistons weren't pullable
- Would-be floating torches etc get deleted when deleting the block underneath
A wise man said: "My programs never have any bugs in them... They just develop random features..."
http://desmond.imageshack.us/Himg834/scaled.php?server=834&filename=bugyu.png&res=medium (sorry for link, no permission for tag)
I like this program, but... it can be better:
1. You forget even doors, other things like rails, water, lava, glass, sand, note would be handy for new logic;
2. N,W,S,E,T,B arrows and rotation with side view would be so useful especially for 1 block wide schemes;
3. Can you change control (left click selection change orientation, left click cell control switches/repeaters) and icons (brown/green pistons, not cylinder), please.
Immovable blocks (i.e. Bedrock/Obsidian)EDIT: I can't seeThe only bug I've found is the one that LordXaosa reported, namely that piston views sometimes mess up when resizing.
I warn you however, this is literally my first time working with java (I use C++ and Python), so no guarantees, but it works on my machine at least.
(And I'm also working on adding glass)
Thank you :smile.gif:
--douglasg14b
@jkat718: The wiki has two pages that might be what you're looking for. Keep in mind, though, that this program uses slightly different tiles—the levers and repeaters are some of the most obvious differences, but there are a few other blocks that aren't quite the same. Just imagine that you are looking straight down on the block and you should be able to guess most of them.