Redstone power generator?

Discussion in 'Archived: Plugin Requests' started by LRFLEW, Jan 27, 2011.

  1. Offline

    LRFLEW

    I got a request for a plugin from a server i frequent, but i'm not completely sure on how to approach it.

    I want to get it to work by allowing a block to power a redstone circuit if certain conditions are met. Can I get a block that is not a lever or a button to power a redstone circuit? How might I go about this?

    Thanks
    LRFLEW
     
  2. Offline

    Archelaus

    Please move this to the plugin requests forum.
     
  3. Offline

    LRFLEW

    But it's not a request. I want to make this myself and learn from it, I'm just don't know how to control redstone circuits. :p
     
  4. Offline

    Archelaus

    Sorry. I admit I got it wrong. It's late, I appear to have read "I request" and half of the second sentence all in one.

    Also, you can. Just find the area around the block(s) and find any red stone around it. If there is, change the redstones "isPowered" state to on.

    Sorry about the initial confusion.
     
  5. Offline

    nachotp

    lol sorry it was a really quick response,but check the signchips something like that that works just like craftbook sign chips
     
  6. Offline

    LRFLEW

    It's ok; I forgive you and sorry if I sounded harsh.

    isPowered is a checker, not a setter. Although looking at the javadocs, it shows isPowered as
    Code:
    public boolean isPowered() {
    return getData() > 0;
    }
    which would mean setData() could do the trick, just what do I set it to?

    Also, if I change all blocks immediately surrounding it, will the ones connected to them update as well?
     
  7. Offline

    mjmr89

    That code you posted is only for redstone wire (which, well, is probably the most of what you'll be turning on) but they all have different isPowered() functions. I think that all redstone instances use different bits for powering. I think redstone uses its rawdata to store its power/current level -- 0-15 (in binary). So setData(15). Though I don't know if you can just input an int for a byte value, so... yeah. So try 0xF I guess if that doesn't work.
     
  8. Offline

    LRFLEW

    thanks. I was thinking that, but I wanted to test to make sure. Now about the updating connected wire...
     
  9. Offline

    eisental

    In my experience its not possible to actively change current of redstone wire. That's why I use levers and set their data value on and off. If you try this you should be careful not to change the lever's attached face which is also part of the data byte. Another option that I used before was to switch the block type between redstone_wire and redstone_torch_on but It might be heavier on the server.

    It would be very nice if it IS possible...
     
  10. Offline

    Silentspy

    moved to appropriate forum.
     
  11. Offline

    LRFLEW

    No, this ISN'T the appropriate form! Read the post!

    It's asking for HELP MAKING a plugin!
     
  12. Offline

    Eris

    Best solution for now is probably to use a lever as part of your power source. Directly manipulating the data of redstone wires leaves you vulnerable to failures due to the powered state being recalculated outside of your control. Here are a couple of slightly naughty helper methods that should allow you to toggle or set a lever's powered state.

    Code:
    private void
    toggleLever(Lever lever)
    {
        // naughty - 0x8 is the powered bit for levers.
        lever.setData(lever.getData() ~ 0x8);
    }
    
    private void
    setLeverPowered(Lever lever, boolean powered)
    {
        if ( lever.isPowered() != powered )
            toggleLever(lever);
    }
    
    I suppose you could also use a redstone torch and set it on or off, but I think you'd run into the same recalculation problem in the opposite direction then. Handling the REDSTONE_CHANGE event could allow you to evade that problem, but I feel like that could get messy pretty quickly.
     
  13. Offline

    mjmr89

    I've been trying to make your code work, eris, but I don't think that you can use ~ as an operator between two numbers. In all the examples on it I've looked up, it seems like they only use it on somethin like "~0xF0", making it "0x0F". I think you meant ^, not ~. I'll test it in a minute.
     
  14. Offline

    LRFLEW

    I've figured out how lever status woks through experimentation. Data % 8 is what side it's on and what direction it's facing. Data / 8 (using C code's definition of integer division; I don't know what Java uses) is a boolean on or off.
     
  15. Offline

    mjmr89

    Data/8 shifts the data right three bits, which gives you 0x8 as 0x1. Tricky part seems to be toggling just that - I still haven't tested my correction but im pretty sure about that (^ is the xor operator, and xoring a bit with 1 will toggle it). Also, http://www.minecraftwiki.net/wiki/Data_values gives more information about the data values.

    Also, come on guys, move this back to plugin development! As hes stated several times, its a request for KNOWLEDGE, not a plugin!
     
  16. Offline

    LRFLEW

    Code:
    if (Lever.getData() < 8) {
         Lever.setData(Lever.getData() + 8);
    } else {
         Lever.setData(Lever.getData() - 8);
    }
    How about that?
     
  17. Offline

    mjmr89

    I meant to edit that part out. All you need to do is something like

    Code:
    lever.setData((byte) (lever.getData() ^ 0x8));
    Assuming lever is your lever object. The byte cast was insisted on by Eclipse.
     
  18. Offline

    LRFLEW

  19. Offline

    Eris

    @mjmr89 (several days later) Whoops, yeah, that was a typo on my part. That's what I get for not compiling my code before posting it. :F
     
  20. Offline

    anthonynoahan

    It is totally a different generator from Steam Engine. The RedStone engine is actually does not move at all, with or without the mining well. The Redstone power is a switch on a generator and switch flipped on generator turns on, and if the switch flipped off then the generator turns off and it requires fuel. It have enough power to sparkle, but don't move or move with very large gaps.




    circuit breaker tester
    micro ohm meter
     

Share This Page