Inactive [MECH] ControllerBlock v1.18 - Toggle blocks on/off with redstone [740]

Discussion in 'Inactive/Unsupported Plugins' started by Hell_Fire, Jan 24, 2011.

  1. Offline


    ControllerBlock - Toggle blocks on and off with redstone

    I've stopped work on this plugin due to other work, please see Zero9195s continuation of this plugin here:

    Pretty simple, there was a version of this for hmod, so the inspiration comes from that.

    Iron blocks can be turned into controller blocks. Drop the block down, drop a redstone wire or torch on top, switch to the type of block you want to toggle and smack the iron block with it. (Can remove redstone on top after it's been set as a ControllerBlock).

    Place those blocks down where you want them to be, you can work from multiple piles of it, where it is in the inventory doesn't matter, as long as you place the block of that type.

    Once you're done placing blocks, wack the iron block again and it'll save the block locations and ready to go. Power the block they'll appear, remove the power and they'll disappear again. Invert the control with a redstone torch on top of the block. To remove the binding, just remove the block.

    Source is included in the .jar file in case I disappear. Tested on my local server but other than that, not much else. Sure you guys will find me bugs :)

    A smallish howto of how to make blocks, and change between types.

    • Redstone toggleable blocks
    Download ControllerBlock (recommend using the recommended build of craftbukkit here, previous version available below in the changelog, tested up to 733).


    Source now also available up on GitHub!

    Some builds done with ControllerBlock:
    Treasure Quest 3 (dungeon game inside MineCraft) (by neoguy21)
    Xtreme HowTo controller blocks (by mrgreaper)
    :getout: frog animation (by Gorbachev, sup goons :V)
    gravity mob trap (by Arolathe)
    hidden staircase/entrance (by narrowtux)

    And a couple by me:
    Real simple on/off example/howto
    Item elevator
    Portcullis/castle gate build/howto (long >.<)

    Known Issues:
    - Placing a block in snow/flowing water/lava doesn't register.
    - Occasionally block hits/places/destroys don't register.
    - Liquids being directly controlled don't work properly.

    Version 1.18
    - Updated for craftbukkit #733
    Version 1.17
    - Fixed config loading of BlockFlowProtectMode and BlockPhysicsProtectMode
    Version 1.16
    - Fixed for changes to bukkit/craftbukkit #602
    - Changed some messages, added some config options, haven't slept much, so forgotten a bit of what's changed, find bugs! :)
    Version 1.15
    - Fixed up multiworld, also loads the data file after all the other plugins have loaded.
    Version 1.14
    - Changed world to use name instead of the ID in data file, should fix multiworld stuff when ControllerBlock loads before other multiworld initializing plugins.
    - Not much else that I recall, will be another version soon
    Version 1.13
    - New config patcher, new options get added into the ControllerBlock.ini automatically.
    - Added a whole lot of currently disabled debug lines (They're spammy... really spammy).
    - Added option to disable the edit dupe check all together.
    - Added protection against water/lava flows (and dupe checks, that are disable-able with the above new option).
    - Added ability to disable the checks against Permissions (and clones) completely, if you want to just use my inbuilt controls only (not mandatory to set if you don't have Permissions, this is in addition to, if Permissions isn't installed, it won't use it anyway).
    - Fixed Grass/Dirt and Redstone Torch On/Off in the edit dupe checks. No other blocks are coming to mind that change automatically.
    - Added a bunch of error checking on the loading of the ControllerBlock.dat, hopefully will give me some clues as to what's going on there.
    Version 1.12
    - Removed plugin constructor for craftbukkit-419+ (wasn't needed anyway)
    - Fixed Permissions mod checking stuff (haven't tested it actually works with permissions, but doesn't seem to throw any errors on loading anymore)
    Version 1.11
    - Fixed a bug that mostly affected Windows users with .dat handling (wasn't closing the file on reading, so it couldn't overwrite it when saving).
    - Added some sanity checking to reading the .dat file (empty lines ignored rather than creating null controllerblocks that make the mod unable to save).
    - Destroying a block in edit mode that has more than one controllerblock controlling it will replace the block with the type from the enabled controllerblock.
    - Destroying a controllerblock now destroys all the controlled blocks and refunds them all at the controller block itself.
    Version 1.10
    - New antidupe code, a lot more reliable!
    - Fixed permissions check (uninitialized objects are a pain :p)
    Version 1.09
    - Fixed a rather critical bug that was saving the new data format with the old identifier.
    If affected by this (getting NumberFormatException on loading), edit ControllerBlock.dat with a text editor and change the first line from "# v2" to "# v3" (That's <hash><space>v3).
    Version 1.08 - critically bugged, don't use, use 1.09 instead
    - Added a builtin permissions support, also supports Nijikokuns Permissions on top of it
    - Removing the controller block with WorldEdits superpick, and possibly any of the "stick" plugins that cancel/set to air on hit will now remove the controller block.
    - Added configurable limits on number of blocks and block distance from controllerblock (is a "sphere" around the controllerblock, rather than a cube, might add another option to change it later).
    - Probably some more random little bugfixes/refactoring, but I can't remember >.<
    Version 1.07
    - Updated for API changes (bukkit-144/145 and craftbukkit-323, tested with 326)
    - Config file format change, old config files will convert automatically
    - ControllerBlocks need a redstone "thing" (wire/torch) on top to create a ControllerBlock
    - Added per-tick, per-controllerblock .isBlockPowered() check for more natural redstone integration (power feeds into the block rather than needing wire on top), more CPU hungry, toggleable with old quick REDSTONE_CHANGE event method in config (quickRedstoneCheck=true for fast version that needs wire on top of block)
    Version 1.06
    - Updated for API change (bukkit-128/craftbukkit-281, only tested with 289)
    - Added counts on block add/remove messages
    - Added notice if a block gets removed by the anti-dupe code while editing
    Version 1.05
    - Updated for API change (bukkit 122/craftbukkit-265)
    - If you're running a version prior to this, you can still find 1.04 at here. I won't be supporting it anymore though, so any bug fixes, etc, won't find there way backported there.
    Version 1.04
    - Moved config/data to plugins/ControllerBlock (or whatever getDataFolder() is). Should make it multi-server usable as long as each server has a different plugins dir.
    - Sorted out minecart track metadata storing, this should make dynamic minecart tracks actually stay how you put them out now.
    - Stacked fences should work again now.
    - Probably some other small bugfixes that I've lost track of.
    Version 1.03
    - More refactoring
    - Inverted blocks again, blocks on when redstone wire off, reads from torches now, blocks on when redstone torch on.
    - Added some error handling in the config file loading
    - Fixed a metadata handling bug when a block has more than one controller.
    - Listen to event cancellations, no longer processes canceled events.
    - Changed a bunch of the edit mode handling, still similar to how it was, just with some nice changes (no longer need to exit editing one block to edit another, will save/finish the previous block for you).
    - Can now edit/modify ControllerBlocks that were made with a different Material before a configuration change took place, Material only matters for creation of new blocks.
    Version 1.02
    - Whole lot of code refactoring
    - Blocks on when redstone on (can still use torches)
    - Block protection for controlled blocks (Physics events can't modify controlled blocks anymore, fixes duping issues, but allows some odd builds, might implement a "break" feature like the original had, where block changes cause the controllerblock to disable)
    - Added configuration file (creates on first load, in main folder, ControllerBlock.ini). First line is ControllerBlock material type, other lines are disallowed materials.
    - Saves block metadata, allows toggling of minecart tracks.
    - Probably some other stuff I'm forgetting.
    Version 1.01
    - Added controlled block checks, need to edit block before removing controlled blocks
    Version 1.0
    - Release
  2. Offline


    Yes yes, and as I've argued many.. MANY times before, while it takes two controller blocks to toggle between two different kinds of blocks, YOU AREN'T LIMITED TO JUST TWO TYPES. With my method you can wire up a single location to toggle between any number of materials, not just between two. This allows complex animations and behaviors to be built in redstone.

    Changing the default now isn't workable, too many peoples builds will break as they expect a particular behavior (This goes back half a year or so, someone wanted it changed, I changed it, people argued the way it now is is better, I took both sides of the argument and decided how it currently is is the better way, if you wish to bring up this discussion again, fine, but I'm not going to participate, feel free to try and get all the other users of ControllerBlock to bend to your thinking)

    To be quite honest, you're rather ignorant if you've just seen this thread, ignored the 20+ pages of discussions and posted your will as "the better way".

    I had originally looked at the idea back a while ago but with many of the changes going on in those mods, keeping up with them at the time wasn't realistic (as well as keeping up with all the changes in the bukkit API itself).

    If MoveBlock/other plugins have standardized some kind of block moving custom event, then I might take another look at it, adding support for one mod isn't too much problems if they've already done the work to fire off the correct events, but usually it's more that I end up having to work on two mods instead of maintaining this one to get interoperability working.

    If there's a favorite and there's enough support for one of these other mods to plug support into ControllerBlock, I might give it a shot :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 7, 2016
  3. Offline


    ya i know I'm quite lazy. i didn't realize you were the actual designer of the mod because the one i used was a modified version from back in 1.1_02. I used it in my adventure map and it was prity f'n awesome so thanks.

  4. Offline


    The original that was done under Hey0s server saved data in a binary format, one that wasn't trivial to work out the ins and outs of, so even if I made the behavior the same, it wouldn't be able to load your data. While it takes two controllers to toggle between two blocks, it does register redstone torches on top to invert the input (they take priority over how the block is powered). Give it a shot :) Can make some very interesting things with it.
  5. Offline


    Technically, the hmod version could have been used in the same fashion as this one is designed. It just would have required more redstone and been far more likely to break if it was wired wrong.

    The biggest problem with this particular approach is simply that it breaks *every* old map. But you sorted out how the data was being saved anyway, so the new version would have broken old maps anyway. And at this point, the argument is pretty much irrelevant given that most servers have probably switched over.

    I didn't really find it that complex when I went through it after sunrise disappeared. It was certainly the hardest part of sorting through his code, and I didn't really care for his method (despite the fact that I continued to use it), but it wasn't terribly difficult. And I thought I had made the source available anyway?

    EDIT: Actually, now that I think about it, I don't believe I did release the source, since sunrise hadn't released the source when he was working on it, and I was using much of his code still.
  6. Offline


    no i know, sorry if i insulted you. your mod is still one of the best espeshely for transferring redstone signals across areas.
  7. Offline


    Yeah, I couldn't find any code readily available when I started this one. and peaking at a simple save file with a hex editor wasn't revealing too much on its format (MC uses too many different varying sized data types :p), on the plus side, it's 100% from scratch and uses the pure bukkit API so is "clean room" as far as licensing goes.

    I've pushed a merged version of your patch up, streamlined some code, added config options to the config patcher and made the save file format compatible with older versions (pretty much changed it to assume the block is protected unless that field is specified as semi-protected or unprotected). This will break your current usage, but if you sed 's/,protected//' your .dat file, it should be enough to make it compatible.

    Edit: Actually, I'ma change the loading code to recognize your format anyways, doesn't matter either way :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 7, 2016
  8. Offline


    Just out of curiosity, what have you changed about it? My version loaded as protected by default if it was saved in the old format!

    Oh I see - if it is protected it does not save as anything. I don't know whether it is better to have protected in there or not, but it doesn't matter. I see you've also reduced the number of lines - mine was a quick edit to add much-needed functionality :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 7, 2016
  9. Offline


    Well, nothing now, except when it saves, it doesn't flag it in particular if it's protected, gives some extra flexibility if people want to downgrade back one version, it won't be able to load unprotected or semiprotected blocks, but then the downgraded version wouldn't have that functionality either.
  10. Offline


    Ah true :)
  11. Offline


    It was an awesome plugin.. but the owner of this plugin don't update it..
  12. Offline


    It hasn't needed any updates to keep compatibility with bukkit... I'll release an update when I've got a decent fix for the block protection not working on ladders, etc.
  13. Offline


    So, I have a story to tell. First let me get to the point. If you set a controller block to use air blocks instead of, you know, real blocks, and destroy it, the server will crash--after you are placed in limbo. And I couldn't join again until I deleted my .dat

    Here's how it happened. I have a long 1x1 tunnel to bedrock where I have an admin lounge. I wanted to be able to fall down the shaft without dying or having to give myself 30,000 health. So I was going to use the 3 deep water method. But I didn't want the water to break all the breakables in the lounge. I thought "Wow, since I can set controller blocks to not be destroyed by physics, I'll just set an air block at the bottom of the tunnel!" But I didn't know how to set air blocks with the controllers. In my infinate wisdom, I put some cobblestone where I wanted the air, then shut down the server, open the CB.dat, and changed the cobblestone to air!!

    Which didn't work. So I just destroyed the CB. And that's when all hell broke loose.

    You probably don't have to worry about it. I doubt it's a common issue. :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 7, 2016
  14. Offline


    Haha, I never thought about what would happen if you forced a block to AIR, think I might have to set up another test world just to try it out, Thanks! :D
  15. Offline


    Haha, it seemed like a good idea at the time ^^
  16. Offline


    Is there any chance you could add Signs to the Controllerblocks? It would be awesome for dungeons if I could write a text on the sign and with a two-controllerblocks-combo I could change the text on the same (pseudo same) sign!
  17. Offline


    Man, this seriously is my favorite plugin by far. Any chance of having in game reloading of the config settings?
  18. Offline


    Shouldn't be hard to add now that the player and server command stuff has stabilized. I'll look at adding it for the next version :)
  19. Offline


    Thanks man. The possibilities of this plugin are endless. You should see how pissed people get in mazes that constantly change on them =P Now to figure out how to make a lava wall with this...
  20. Offline


    Just out of curiosity, why do you use the .isBlock test?
  21. Offline


    From what I remember of when I wrote that code, BLOCK_PLACED events are thrown with the item ID (or at least were), and several blocks have a item and block that are effectively the same thing, but while you can set a block to REDSTONE_WIRE, you can't set it to REDSTONE. At the time of writing, it saved time to just check .isBlock() rather than add a translation table of every item to their actual blocks. That may have changed since writing it though.
  22. Offline


    Thinking of changing the save format again to use the Type ID instead of the Material type, will make it less readable, but mods that add extra block types should work I think...
  23. Offline



    I'm not sure if its possible, but could you make it so a controlled block can have its state changed? For example, if you had a redstone torch controlled by a CB, and applied a current to it, it'd turn off.

    Its always something I thought would be useful, but now we have pistons its almost needed. Right now i'm trying to make a 4x4 smooth motion opening in the ground using pistons and CBs, and I need to turn a standard piston into a sticky one half way through. If I use a controllerblock for the piston, the piston wont open :(
  24. Offline


    Sounds like it acts like TNT. It can't be activated when it's toggled by a ControllerBlock.
  25. Offline


    Flenix, you could use something like Pailstone for "wireless" redstone.
  26. Offline


    Yeah, thats the same thing, you cant change the state of an object thats controllled

    That wouldn't help at all... the redstone torch was just an example, the pistons are another example and also TNT from t2wave just then... pailstone would only help with the redstone torch.
  27. Offline


    Much love for your great plugin, very popular on my server :)
    On my server we use WorldEdit. When changing a controller block to air with superpickaxe it remains in the database. Could you please on plugin startup check all locations of controller blocks, and if they are air, remove from database? Or even a command that does this? It would save me alot of time messing around teleporting to the co-ordinates, replacing the block to remove it. Please :)
    Also, bug:
    If used in a time delay circuit, i.e. 1 redstone torch combined with redstone repeaters to toggle state of controller blocks then eventually the redstone will stop updating. I have only ever seen this with circuits that use controller blocks. For example I used this to create moving stepping stones over lava as part of a dungeon. Please look into this :)
  28. Offline


    I like the SuperPick not removing the block from the database. It allows me to hide ControllerBlocks easily (I placed wood where the block used to be and have to place a torch on top to open the pathway).
  29. Offline


    I'd actually already previously added some code to try and handle WorldEdits superpickaxe removing the block, maybe something has changed and broken that code (ugh..). The problem with checking it at startup is that the whole world at startup isn't actually loaded, so there's nothing to check really. I'll take a look at maybe doing some chunk loaded hook to scan over chunks as they're loaded into memory.

    Any errors on console when this happens?

    Will keep it in mind, will make it an option :)
  30. Offline


    Yeah, blocks can be duplicated with WE's superpick. It hasn't been that much trouble for our server since its only donators and admins with superpick.

    It would be nice if the ability to break controlled blocks with the superpick was deturmined by permissions.
  31. Offline


    Only admins have access to worldedit, but this is also a problem when we set a large area (i.e. unwanted buildings) to air using //set or a similar command.
    Yeah, it's been like that since about ~1.5 MC associated bukkit build or earlier, whatever that may be.

    Will recreate this week when I have a chance and observe the console.

Share This Page