Use attached block for r triggers on wall signs; resolves #792

This commit is contained in:
Daniel Saukel 2020-05-10 18:02:52 +02:00
parent 4de94822b2
commit 98f9f2c8de

View File

@ -16,6 +16,8 @@
*/
package de.erethon.dungeonsxl.trigger;
import de.erethon.caliburn.category.Category;
import de.erethon.commons.misc.BlockUtil;
import de.erethon.dungeonsxl.api.sign.Deactivatable;
import de.erethon.dungeonsxl.api.sign.DungeonSign;
import de.erethon.dungeonsxl.event.trigger.TriggerActionEvent;
@ -78,8 +80,15 @@ public class RedstoneTrigger extends Trigger {
/* Statics */
public static RedstoneTrigger getOrCreate(Sign sign, DGameWorld gameWorld) {
Block rtBlock = sign.getBlock();
if (rtBlock != null) {
Block rtBlock;
if (Category.WALL_SIGNS.containsBlock(sign.getBlock())) {
rtBlock = BlockUtil.getAttachedBlock(sign.getBlock());
} else {
rtBlock = sign.getBlock();
}
if (rtBlock == null) {
return null;
}
for (Trigger uncasted : gameWorld.getTriggers(TriggerTypeDefault.REDSTONE)) {
RedstoneTrigger trigger = (RedstoneTrigger) uncasted;
if (trigger.rtBlock.equals(rtBlock)) {
@ -88,8 +97,6 @@ public class RedstoneTrigger extends Trigger {
}
return new RedstoneTrigger(rtBlock);
}
return null;
}
public static void updateAll(DGameWorld gameWorld) {
for (Trigger trigger : gameWorld.getTriggers(TriggerTypeDefault.REDSTONE)) {