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

    Hell_Fire

    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: http://forums.bukkit.org/threads/34394/

    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.


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

    NOTE: IN 1.07 CREATING CONTROLLERBLOCKS CHANGED, YOU NEED TO PUT A REDSTONE TORCH OR WIRE ON TOP OF THE BLOCK BEFORE YOU LEFT CLICK ON THE BLOCK TO CREATE. (Yes, enough people have missed this change to warrant the large bold text :p)

    Source now also available up on GitHub! https://github.com/Hell-Fire/ControllerBlock

    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.

    Changelog:
    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.
    -- (YOU ONLY NEED TO DO THIS IF YOU USED THE BUGGED 1.08) --
    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).
    -- (YOU ONLY NEED TO DO THIS IF YOU USED THE BUGGED 1.08) --
    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

    kovarex

    I just wanted to say, that this is one of the best plugins I ever seen, very simple to use, simple mechanics, but adds LOT of potential to interactive minecraft.

    For example, now you can use it to show/disable red-torch, voila, long distance wireless transmiter.
    You can add it to show/hide normal torches to control lights of building.
    You can make this to create gate out of fances that opens when I trigger plates (even animated), or controllable bridge
    You can make water/lava controller, controlled pipe system, new type of funny drawning mob traps that works not only once.

    (We tried all of this and it works well)

    There is surely lot of cool things that we didn't find out so far that could be done, btw any ideas in this thread would be cool :)

    Thank you for the plugin.
     
  3. Offline

    NEO

    This plugin looks great, I do have a concern though.

    I would like to let users on my server use this plugin but I dont want them exploiting it to receive extra blocks of rarer value. If they where to break a block after the switch changes its type does the original block drop, or does the block that type that it has changed to drop?
     
  4. Offline

    Hell_Fire

    No blocks should drop from a controllerblock controlled block, if it does, let me know, it's a bug. The controller block specifically disables normal interactions to stop users from exploiting it like that. Eventually I'm going to add an option that if a user does something that causes something "unexpected" as far as the controller block goes, it either does as it does now (prevents the drop, but causes "odd" looks, like minecart tracks without blocks under them), or drops the block and removes it from the controller. And perhaps add an option that removes the checks all together so users can dupe as much as they like (up to the server admin that way).
     
  5. Offline

    kovarex

    I have one suggestion, the block should trigger not only when there is redstone on the block, but when the controller cube is powered (same behaviour as when the red torch is connected to the cube)

    It would be also fun to
    a) Add permission support
    b) Add iconomy support (Adding togglable block would cost something, maybe different prices for individual blocks)
     
  6. Offline

    NEO

    ok good to know. I haven't had time to play with the plugin yet so I figured I would ask. I initially assumed all blocks were taken from your inventory and would drop when broken. I agree with the above poster, permissions support would be great.

    Thanks for the response :)
     
  7. Offline

    MikeC2103

    I'm having loads of fun with this plugin.

    I do have a suggestion or two.

    1. It seems that every iron block can be punched to activate this.

    Would it be possible to make it so it only acts as a controller block if it has a redstone torch on top? With the redstone only needing to come up to and not cover the iron.

    Once the redstone torch is set on top of the iron, that activates the controller properties, Then you hit it normally with the block of your choice. etc.. But without that torch on top punching the iron blocks shows no messages.

    I've noticed it activating trying to hit door/minecart switches on iron walls.

    2. Would it be possible to keep the blocks from appearing if there is a player within the place the blocks are supposed to spawn. Then once they move out they spawn. Too easy to kill people by suffocation. or maybe a toggle option for this.
     
  8. Offline

    QQCucumber

    That's a really nice idea but it makes it a little too easy to destroy on accident. The preferred thing, I think, would be changing it so a controllerblock needs a sign on it that designates it as one, and for it to receive power through the sign.
     
    MikeC2103 likes this.
  9. Offline

    MikeC2103

    Yea, that would be perfect.

    Would it be possible to select 2 sets of blocks to toggle? Maybe an option if the sign thing happens? ;)

    After the first set of blocks was set and confirmed they would disappear. Then I would do the same with a second set of blocks. Once the second set was confirmed it would toggle between those two sets of blocks.

    I'm thinking glass windows that toggle to iron at night. or traps that wall in a hallway while opening holes in the roof for lava flows.
     
  10. Offline

    eRko16

    Doesn't work for me, Bukkit version 303
     
  11. Offline

    kovarex

    This message drives me crazy :"Removed block due to changed type while editing"
    Seems to act semi random, and I don't even get the reason of that, could it be solved?

    What is the reason that the block can edit just one type of blockid?
     
  12. Offline

    Hell_Fire

    If you invert the redstone on a second controller block, it'll do this just fine.
    --- merged: Feb 15, 2011 8:44 AM ---
    This happens spuriously with some blocks, particularly sand/gravel does it. It's part of the antidupe code, but the block type is getting changed that Bukkit is reporting to the event, hence the mod removes it from the block because it thinks you've managed to do something you shouldn't be doing (like digging out dirt underneath a minecart track). (It's a bug, but I haven't confirmed if it's a bug with bukkit or my mod yet).

    Blocks only edit one type because:
    It's possible to wire multiple controller blocks with different types up to the same redstone wire easy.
    I don't need to store a type for every block that you place down/save that value, also makes validation checks a heck of a lot easier/quicker.
    Scaffolds used during buildings you generally don't want to toggle on/off with the rest of your build while testing, and without adding commands to go in and out of edit mode (more complexity, and I hate having to use commands for everything, ESPECIALLY when editing something, commands = slow).

    As it is, it's a nice simple mechanic that fits in well with the Minecraft world, that is able to be extended into complex contraptions to make entire animated features. If you have a cool idea that you can't already implement in game with some thinking, I'd consider it. But as it is, you can already toggle between one, two, or as many types of blocks as you like with the system as it is now. Actually limiting it to 2 types would be going backwards in terms of features for this mod ;)
    --- merged: Feb 15, 2011 9:29 AM ---
    My last tested version was 312, which was the last build after a bunch of builds a few days ago, so perhaps try that one.
    --- merged: Feb 15, 2011 10:01 AM ---
    I like the idea of needing a redstone something (both wire or torch) on top of the block to activate it as a controllerblock. For the powering it like a normal block however, I need to see if bukkit added a proper working isBlockPowered check that I can use from the REDSTONE_CHANGE event. The problem is manually running the checks for each adjacent block, as well as verifying that it's properly directed into the block adds a huge amount of complexity to the check that gets thrown for every block of redstone you have out (one line of redstone wire 15 long adds up to 15 REDSTONE_CHANGE events in one frame, which already runs over every ControllerBlock object to see if the block underneath the wire is a ControllerBlock, I'm very mindful of adding checks to this code to keep lag down.)

    For it to do a properly wired redstone check, every REDSTONE_CHANGE event would have to check not just the block underneath the redstone, but every adjacent block (number of checks gone up from 1 to 5 just in that). Then if we have a controllerblock next to the wire, if we have a wire block on top, no extra, but if it's next to the block, we need to then check that the next block away from the controller block is a wire/torch as well, but none of the blocks to the side are wire/torch (since that would make it a 90 degree turn, and would no longer go into the controller block), these checks on the adjacent of the adjacent also need to be done one level up and one level down.

    Maybe I can add the code anyway and make it an option. I really need to work on the new configuration file processing stuff :p
    --- merged: Feb 15, 2011 11:39 AM ---
    I guess if I wanted it to fit in snuggly with how original redstone works, I'd be doing my checks once per controller block per frame, can actually do that now with the extra events added.
    --- merged: Feb 15, 2011 3:23 PM ---
    Good news! Since bukkit added the scheduler and I can run a check every tick for every ControllerBlock in the server with the .isBlockPowered() function like I would have done originally, I now have blocks you can wire to like normal blocks (in from the side, etc).

    Torches on top of the block take priority, so placing a torch on top of a block still inverts like used to, and wiring to the top of the block still works with the full check. And as a bonus, I've expanded my configuration file to allow more options easily, so you can still use the old quick REDSTONE_CHANGE event which is probably faster on the server if you want (still only checks the block above it), or you can have the full "normal" redstone checks.
    --- merged: Feb 15, 2011 3:24 PM ---
    Also changed that making a ControllerBlock needs to have either redstone wire or a redstone torch on top of it to turn it into a ControllerBlock, but once it's created, you don't need to leave the wire/torch there.
    --- merged: Feb 15, 2011 3:35 PM ---
    I just noticed I missed a whole heap of messages on the previous page! Sorry guys.

    I noticed the BlockBreakEvent, might have a look at it to replace the BlockDamageEvent BlockDamageLevel.BROKEN bit. Thanks!

    I'm gonna go through the thread and grab the links of the videos you guys have made and chuck them in the first post, hopefully they inspire some people :) I look forward to seeing what comes out of it :)
    --- merged: Feb 15, 2011 5:30 PM ---
    Changed to the BlockBreakEvent, messing about with BlockPhysicsEvent, trying to work out what's the best to not get duped items, but handle the crappyness that it does with the getChangedType() call on it >.< Ugh, is 3:30am, might upload what I've got and let you guys have at it, at least there's a couple of changes in there.
    --- merged: Feb 15, 2011 5:34 PM ---
    Uploaded, will need at least version 323.
     
  13. Offline

    QQCucumber

  14. Offline

    Hell_Fire

    Oh, just a note, QuickRedstoneCheck defaults to true in the config, so might want to set it to false for the new slow "proper" check.
    --- merged: Feb 15, 2011 5:52 PM ---
    Anyway, sleep time I think. Have fun all :)
     
  15. Offline

    eRko16

    Still doesn't work on bukkit 404 x(
     
  16. Offline

    QQCucumber

    I think you mean 304, and no, it requires 323+, you can see it in the topic.
     
  17. Offline

    eRko16

    I tested it right now on bukkit 328(newest) and still doesn't work. On bukkit 168 it work perfectly.
     
  18. Offline

    Hell_Fire

    Which version (mod and craftbukkit)? What messages is ControllerBlock outputting? Log files? All these things will help me help you :)
     
  19. Offline

    weirdbeard

    Lots of fun, this mod! Thanks very much for your effort!

    I'd like to make a request: Is it possible to allow a controller block to control already-placed blocks? Perhaps some sort of integration function to make the plugin cooperate with WorldEdit by @sk89q ? It would be great for editing areas or creating large effects. It would be convenient, for example to be able to select a cuboid region with WorldEdit and assign it to a controller block somehow. :)

    Related to this, I have noticed that if I destroy a controllerblock with WorldEdit's "Super Pick", the block is destroyed but the controller is not de-referenced. I am sure this has to do with WE producing a different block_destroy event or something like that. Not sure if anything can be done about this. (Noticed on v1.06. Have not tested 1.07.)

    Thanks!
    -WB
     
  20. Offline

    grinch843

    @Hell_Fire

    Hi, I just installed and works great except for one problem, can't use fences. I'am trying to add a "gate" to a fenced in area, but havn't been able to get the controller block to work with fences.

    I can set the block up, add the redstone then hit it with a fence I'll get the message saying "Now editing this block with FENCE (0 blocks)" but when I place a fence nothing happens, I can then go hit the block again and I'll get the message "Finished editing contollerblock" and activate the block and nothing happens to the fence....


    EDIT: Ok, found the problem, when used with fencestack it stops the controller block from working with fences, any way you can look at this and see if there is a fix....

    Thanks
    Grinch...
     
  21. Offline

    Hell_Fire

    WorldEdit doesn't generate any kind of event when it destroys blocks with the superpick. When it's enabled, worldedit just goes "you hit block here, turn it to air type". No real quick way to fix this :(. You can work around it by placing something easy to destroy in the spot of the controller, then break it normally.

    Integration with other mods is tricky, I haven't done enough Java to know how to reference other object types in a way that makes the mod not dependent on having those installed. I like the idea though :)
    --- merged: Feb 16, 2011 9:18 PM ---
    Thanks for finding the conflict :) Fencestack might be cancelling an event that I look at, I'll take a look at it :)
    --- merged: Feb 16, 2011 9:26 PM ---
    Ahh, fencestack is a bit of a hack around the minecraft logic, it goes if you right click and are holding a fence, and the block above the block you right clicked on is air, turn it to fence and subtract a fence from your hand. (with some other checks of course). There's no event to catch because it doesn't throw an event at all. I'll take a look at writing a patch for fencestack that makes it call a BlockPlaceEvent when it does it's work. :)
     
  22. Offline

    grinch843

    Thanks for the info.....
     
  23. Offline

    Hell_Fire

    Modifed patched FenceStack that throws a BLOCK_PLACED event that I can catch with ControllerBlock can be found here. This modified jar isn't supported by me or recanu (the author) so don't go looking for help with either one of us with it. That said, I left a post in their thread with the patch I made, so if it gets included into the main, all the better :)

    Edit: woops, helps if I select everything in the export, file is fixed.
    Edit 2: Fixed BlockPlaceEvent handling, canceled BlockPlaceEvents undo the FenceStack changes (FenceStack-1.02-hf2)
     
  24. Offline

    weirdbeard

    No worries. Thanks for looking into it, anyway. :)
     
  25. Offline

    grinch843

    Thanks for the quick fix -- I'll check it out sometime today.......
     
  26. Offline

    Vlyn91

    Hey, 2 little things :)

    1. Could you please make an option in the config if controller blocks (the blocks you control) are breakable or not? I host a pvp server and unbreakable blocks aren't cool :-/ So I just want to get those blocks removed from the script when they break.

    2. I had a little problem with getting rid of a controller block. I placed it, linked blocks to it, then destroyed the controller block. The linked blocks were still protected. When I erased them with worldedit and built something (I placed a ladder there) the ladder was suddenly a linked block to a non existant controller block. Only deleting the controller block data in the file on the server and a serverrestart helped :(
     
  27. Offline

    gustav9797

    The controllerblocks dont save ? you need any special save plugin for this?
     
  28. Offline

    Hell_Fire

    Always planned on making the breakable thing an option, will look at doing it for the next version :)

    As for the worldedit thing, Worldedit is literally made to be like an ingame map editor. I guess I can try and check if the block you hit is a controllerblock, and if it becomes an AIR block (since CB should get called after). Gets better. When you use the superpickaxe, it cancels the event. So I'd be checking for a cancelled event that's acting on the Controllerblock and turning it to air underneath us. Oh well, guess it's doable, isn't a particularly nice situation to deal with, but I've had enough complaints about it to need a fix.

    The workaround for now anyway is to place something easily destroyable like wool or dirt and dig it out "properly".
    --- merged: Feb 17, 2011 8:54 PM ---
    Nope, no special plugin, check your craftbukkit server has write access to the plugins/ControllerBlock folder
    --- merged: Feb 18, 2011 1:45 AM ---
    I made a "beta" version of the next release available here. Managed to get Worldedit superpick removing the controllerblock removing the associated info. New config option will be available once I get the parser sorted for it, it's not working at the moment, then I'll release a proper 1.08, anyway, RL work calls for now :)
     
  29. Offline

    captainbinary

    This is strange in CB 339 i am trying to add a controller block, yet when i hit it with any block it does not register or activate to start editing, i have then thought, oh maybe the whole plugin has gone a bit buggy so i went to a portcullis i made and it works fine.

    Is there a maximum amount of controller blocks you can have?
     
  30. Offline

    Hell_Fire

    Nope, no max, however a recent change for creating a controller block is you need to place a redstone torch or wire on top of the block before you hit it to set it as a controller block.

    Edit: It doesn't need to stay there if you're using the full redstone check, it's just for the creation.
     
  31. Offline

    Simn

    Downloaded, installed, worked. Built a shower, almost drowned, built a drain, had fun!

    Feature request: Allow signs attached to the iron block to configure behaviour, like
    Code:
    move
    3 U
    to make affected blocks move 3 tiles up instead of simply disappearing. This would allow nice floodgates.
     

Share This Page