Solved Toggling redstone lamps

Discussion in 'Plugin Development' started by Chinwe, Sep 7, 2013.

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

    Chinwe

    Is it possible to toggle redstone lamps?
    Setting the material id from 123 (off) and 124 (on) makes it flash on for a sec, and changing it from on to off doesn't do anything at all :oops:

    EDIT: Immediately after posting this, I found a fancy method in LampControl that works fine:
    Code:
      public static void switchLamp(Block b, boolean lighting)
      {
        WorldServer ws = ((CraftWorld)b.getWorld()).getHandle();
     
        boolean mem = ws.isStatic;
        if (!mem) ws.isStatic = true;
     
        if (lighting)
          b.setTypeIdAndData(Material.REDSTONE_LAMP_ON.getId(), (byte)0, false);
        else {
          b.setTypeIdAndData(Material.REDSTONE_LAMP_OFF.getId(), (byte)0, false);
        }
     
        if (!mem) ws.isStatic = false;
      }
     
    tommycake50 likes this.
  2. Offline

    Lolmewn

    Chinwe Note that all methods using ID's are deprecated in newer versions of Bukkit/Craftbukkit.
     
Thread Status:
Not open for further replies.

Share This Page