[UnSolved] How to keep a redstone lamp lit

Discussion in 'Plugin Development' started by Jogy34, Oct 3, 2012.

Thread Status:
Not open for further replies.
  1. Offline


    For part of a plugin I'm making I want to be able to turn on a redstone lamp by right clicking it with a certain item. The problem is that when I try to set the block to its on state it updates then turns off right after. Does anyone know how to do this.

    EDIT: I also need to know how to open/close iron doors. I've tried door.setOpen(true) but it doesn't seem to work. Anyone know how to do this?
  2. Offline


    If I had to take a guess, might need to keep the state turned on every tick. Sounds like your code is working, but when the next redstone update comes through it realizes it has no power and turns itself off. You'll have to keep track of which blocks should be powered and keep them powered using an event or something.
  3. Offline


    Bump. Also Netizen I don't really want to do that because if there are a lot of lamps that are turned on without redstone then it could end up slowing down a server a lot. I'll keep that in mind as a backup though
  4. Offline


    You need to hook the Physics event, and check if its a door/lamp which should be kept open/on, if so, cancel the event.
  5. Offline


    What I would probably do is set the data of the lamp to the on lamp (124) and when the block physics event is called, see if it's a block that should be staying on. As for doors, were you updating the state after door.setOpen(true) ?
  6. Offline


    How would I go about updating the state?

    EDIT: The physics thing is messed-up. I have to location of the lamps that were turned manually on. Then in the BlockPhysicsEvent I tried seeing if the location that the physics occured at was in the list. It didn't work. I then tried printing out the locations in the list and comparing them with the location of the block update. They were identical but still didn't return true when I wanted to see if the list contained the location. I then iterated through the list and crosschecked every variable in each location in the list and from the physics change location along with printing them out. They were all identical but still wouldn't return true. I then tried just canceling the event just if it was a redstone lamp going to the off state no matter what. It still didn't work.
    I was using debug statements to see if it got past the if statements.

    Any help?
  7. Offline


    Did you try setting the actual data value?
  8. Offline


    I had tried that before and I couldn't get it to work so I tried it again and I got it to work. The first time I was setting the data value of a Door object but this time I set the data of the actual Block object and set the use physics variable to false.

    I still can't get the Lamps to work though.
  9. Offline


    This is what i use:
    Save blocks in a list and check in the that i provided that the e.getBlock() equal to one of the block in the list.
        public void Redstone(BlockRedstoneEvent e) {
  10. Offline


    I'm not actually using any redstone so would that still work?
  11. Offline


    Yes,just check like this:
        public void Redstone(BlockRedstoneEvent e) {
            if (e.getBlock().getType() == Material.REDSTONE_LAMP_OFF || e.getBlock().getType() == Material.REDSTONE_LAMP_ON) e.setNewCurrent(5);
  12. Offline


    Still not working

    Never mind I just misspelled something
    Thank you it works now.

    Is there something similar I can do to redstone? I tried setting the data of a redstone wire so that it's on then in a BlockRedstoneEvent setting the current to the same but when I right click a wire with what I want to turn it on with it acts weird. If the wire is already in the list it takes 2 times to turn it on. Then if it isn't I have to right click 2 - 3 wires that are right next to each other. It works if the wire is by itself though.
  13. Offline


    Hmm... The part about the 2 clicks to turn it on, I can't tell you about that. As for the 2-3 wires that are next to it, try getting any redstone blocks around the one you're clicking on (in coding). Just an idea. I usually don't dabble in this stuff.
  14. Offline


    you need the "lampcontrol" plugin
  15. Offline


    Please don't thread necro.
  16. Offline


    Dude? Seriously? This thread is almost 2 years old.
  17. Offline


    @mythbusterma Nice necro posting.

    yes I know I'm necro posting too.
  18. Offline


    I want to necro too! But in all seriousness, you can now use NMS to do this if you really wanted to.
  19. Offline


  20. Offline


    yeah sorry .. i searched in the forum and didn't see the post date !

    .. anyway my comment dos not apply to that old cb version .. please forget
  21. Offline


    The thing I did is I turn on the lamp and typed /stoplag and removed the thing that turn the light on. After that type /stoplag -c and you know have a redstone lamp light
Thread Status:
Not open for further replies.

Share This Page