コード例 #1
0
 /**
  * Ignores signs of current-tick redstone changes caused by the lever
  *
  * @param lever to ignore
  */
 public void ignoreOutputLever(Block lever) {
   // Ignore signs that are attached to the block the lever is attached to
   Block att = BlockUtil.getAttachedBlock(lever);
   for (BlockFace face : FaceUtil.ATTACHEDFACES) {
     Block signblock = att.getRelative(face);
     if (MaterialUtil.ISSIGN.get(signblock)
         && BlockUtil.getAttachedFace(signblock) == face.getOppositeFace()) {
       if (ignoredSigns.isEmpty()) {
         // clear this the next tick
         CommonUtil.nextTick(
             new Runnable() {
               public void run() {
                 ignoredSigns.clear();
               }
             });
       }
       ignoredSigns.add(signblock);
     }
   }
 }
コード例 #2
0
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onBlockRedstoneChange(BlockRedstoneEvent event) {
   if (TrainCarts.isWorldDisabled(event)) {
     return;
   }
   Material type = event.getBlock().getType();
   if (BlockUtil.isType(type, Material.LEVER)) {
     Block up = event.getBlock().getRelative(BlockFace.UP);
     Block down = event.getBlock().getRelative(BlockFace.DOWN);
     if (MaterialUtil.ISSIGN.get(up)) {
       updateRedstonePower(up, event.getNewCurrent() > 0);
     }
     if (MaterialUtil.ISSIGN.get(down)) {
       updateRedstonePower(down, event.getNewCurrent() > 0);
     }
     ignoreOutputLever(event.getBlock());
   } else if (MaterialUtil.ISSIGN.get(type)) {
     updateRedstonePower(event.getBlock(), event.getNewCurrent() > 0);
   }
 }