Skip to content

Commit 728b69f

Browse files
committed
Redstone lamp support (#114)
1 parent c0ac059 commit 728b69f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/main/java/ch/njol/skript/effects/EffToggle.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public boolean init(final Expression<?>[] vars, final int matchedPattern, final
6767

6868
// TODO !Update with every version [blocks]
6969
private final static byte[] bitFlags = new byte[Skript.MAXBLOCKID + 1];
70-
private final static boolean[] doors = new boolean[Skript.MAXBLOCKID + 1]; // Update also array length
70+
private final static boolean[] doors = new boolean[Skript.MAXBLOCKID + 1];
7171
static {
7272
bitFlags[Material.DETECTOR_RAIL.getId()] = 0x8;
7373
// Doors
@@ -107,6 +107,16 @@ public boolean init(final Expression<?>[] vars, final int matchedPattern, final
107107
protected void execute(final Event e) {
108108
for (Block b : blocks.getArray(e)) {
109109
int type = b.getTypeId();
110+
111+
// Redstone lamps have separate block ids for off/on.
112+
if (type == Material.REDSTONE_LAMP_OFF.getId()) {
113+
b.setType(Material.REDSTONE_LAMP_ON);
114+
continue;
115+
} else if (type == Material.REDSTONE_LAMP_ON.getId()) {
116+
b.setType(Material.REDSTONE_LAMP_OFF);
117+
continue;
118+
}
119+
110120
byte data = b.getData();
111121
if (doors[type] == true && (data & 0x8) == 0x8) {
112122
b = b.getRelative(BlockFace.DOWN);

0 commit comments

Comments
 (0)