Exemple #1
0
  public Location getExit(Location traveller) {
    Location loc = null;
    // Check if the gate has an exit block
    if (gate.getExit() != null) {
      Blox exit = getBlockAt(gate.getExit());
      int back = (isBackwards()) ? -1 : 1;
      loc =
          exit.modRelativeLoc(
              0D, 0D, 1D, traveller.getYaw(), traveller.getPitch(), modX * back, 1, modZ * back);
    } else {
      Stargate.log.log(
          Level.WARNING,
          "[Stargate] Missing destination point in .gate file " + gate.getFilename());
    }
    if (loc != null) {

      if (getWorld().getBlockTypeIdAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())
          == Material.STEP.getId()) {
        loc.setY(loc.getY() + 0.5);
      }

      loc.setPitch(traveller.getPitch());
      return loc;
    }
    return traveller;
  }
 public void triggerWorldHour(World world, int h) {
   h = h % 24;
   for (Gate gate : Gates.i.getAll()) {
     World gateWorld = gate.calcGateWorld();
     if (!world.equals(gateWorld)) continue;
     gate.trigger(TriggerHour.getInstance(h), null, null);
   }
 }
Exemple #3
0
  /** gate score = smallest noise margin (distance in log(REU) of input REU to margin REU) */
  public static void evaluateGateNoiseMargin(Gate g, Args options) {

    if (options.is_noise_margin() == false) {
      g.get_scores().set_noise_margin_contract(true);
      return;
    }

    if (g.Type == GateType.INPUT || g.Type == GateType.OUTPUT || g.Type == GateType.OUTPUT_OR) {
      return;
    }

    // "x" to value
    HashMap<String, Double> lowest_on_reu = GateUtil.getIncomingONlow(g);
    HashMap<String, Double> highest_off_reu = GateUtil.getIncomingOFFhigh(g);

    ArrayList<Double> all_margins = new ArrayList<Double>();

    for (String var : highest_off_reu.keySet()) {

      if (g.get_variable_thresholds().get(var) != null) {

        // IL is the input-low threshold
        Double IL = g.get_variable_thresholds().get(var)[0];

        // actual REU
        Double log_input_reu = Math.log10(highest_off_reu.get(var));

        // NML is the margin/width between the actual REU and the threshold REU
        Double NML = Math.log10(IL) - log_input_reu;

        all_margins.add(NML);
      }
    }

    for (String var : lowest_on_reu.keySet()) {

      if (g.get_variable_thresholds().get(var) != null) {
        Double IH = g.get_variable_thresholds().get(var)[1];
        Double NMH = Math.log10(lowest_on_reu.get(var)) - Math.log10(IH);
        all_margins.add(NMH);
      }
    }

    if (all_margins.isEmpty()) {
      g.get_scores().set_noise_margin(0.0);
      g.get_scores().set_noise_margin_contract(true);
    } else {
      Collections.sort(all_margins);

      g.get_scores().set_noise_margin(all_margins.get(0));

      if (all_margins.get(0) < 0) {
        g.get_scores().set_noise_margin_contract(false);
      } else {
        g.get_scores().set_noise_margin_contract(true);
      }
    }
  }
Exemple #4
0
  public boolean calculateValue() throws GateException {
    System.out.println(this.inputGates.size());
    if (this.inputGates.size() < 2) {
      throw new GateException("Error in: " + this.name + " - invalid number of input gates.");
    }

    for (Gate g : this.inputGates) {
      if (g.getOutputValue()) {
        return true;
      }
    }
    return false;
  }
Exemple #5
0
  /**
   * for all logic and output gates: set flag simulate_reu = true (indicates that REU needs to be
   * simulated) then call simulateREU() in Gate.java
   *
   * <p>Hill function evaluation
   */
  public static void simulateREU(LogicCircuit lc, GateLibrary gate_library, Args options) {
    ArrayList<Gate> logic_and_output_gates = new ArrayList<Gate>();
    logic_and_output_gates.addAll(lc.get_logic_gates());
    logic_and_output_gates.addAll(lc.get_output_gates());

    // input gate REU already set
    // make sure that all gates are re-simulated by setting simulate_reu to TRUE
    for (Gate gate : logic_and_output_gates) {
      gate.set_unvisited(true);
    }
    for (Gate gate : logic_and_output_gates) {
      simulateREU(gate, gate_library, options);
    }
  }
Exemple #6
0
  /** Same as above, but converts input distr to output distr using a matrix transfer function */
  public static void simulateHistogramREU(LogicCircuit lc, GateLibrary gate_library, Args options) {

    ArrayList<Gate> logic_and_output_gates = new ArrayList<Gate>();
    logic_and_output_gates.addAll(lc.get_logic_gates());
    logic_and_output_gates.addAll(lc.get_output_gates());

    // input gate REU already set
    for (Gate gate : logic_and_output_gates) {
      gate.set_unvisited(true);
    }
    for (Gate gate : logic_and_output_gates) {
      simulateHistogramREU(gate, gate_library, options);
    }
  }
Exemple #7
0
 private static String getResetFunction(Gate gate) {
   String result = null;
   if (gate.isSequential()) {
     result = ExpressionUtils.extactResetExpression(gate.function.formula, gate.seq);
   }
   return result;
 }
Exemple #8
0
  public void close(boolean force) {
    if (!isOpen) return;
    // Call the StargateCloseEvent
    StargateCloseEvent event = new StargateCloseEvent(this, force);
    Stargate.server.getPluginManager().callEvent(event);
    if (event.isCancelled()) return;
    force = event.getForce();

    if (isAlwaysOn() && !force) return; // Only close always-open if forced

    // Close this gate, then the dest gate.
    for (Blox inside : getEntrances()) {
      inside.setType(gate.getPortalBlockClosed());
    }

    player = null;
    isOpen = false;
    Stargate.openList.remove(this);
    Stargate.activeList.remove(this);

    if (!isAlwaysOn()) {
      Portal end = getDestination();

      if (end != null && end.isOpen()) {
        end.deactivate(); // Clear it's destination first.
        end.close(false);
      }
    }

    deactivate();
  }
  public void run() {

    while (true) {
      // May print inconsistent value, as toString is not synchronized
      System.out.println(gate.toString());
    }
  }
Exemple #10
0
 @Override
 public void run() {
   System.out.println(myname + " BEGIN");
   while (true) {
     gate.pass(myname, myaddress);
   }
 }
Exemple #11
0
  public void writeToNBT(NBTTagCompound nbttagcompound) {
    transport.writeToNBT(nbttagcompound);
    logic.writeToNBT(nbttagcompound);

    // Save pulser if any
    if (gate != null) {
      NBTTagCompound nbttagcompoundC = new NBTTagCompound();
      gate.writeToNBT(nbttagcompoundC);
      nbttagcompound.setTag("Gate", nbttagcompoundC);
      // Wire states are stored for pipes with gates only
      for (int i = 0; i < 4; ++i)
        nbttagcompound.setBoolean("wireState[" + i + "]", broadcastSignal[i]);
      nbttagcompound.setBoolean("redstoneState", broadcastRedstone);
    }

    for (int i = 0; i < 4; ++i) nbttagcompound.setBoolean("wireSet[" + i + "]", wireSet[i]);

    for (int i = 0; i < 8; ++i) {
      nbttagcompound.setInteger(
          "action[" + i + "]", activatedActions[i] != null ? activatedActions[i].getId() : 0);
      nbttagcompound.setInteger(
          "trigger[" + i + "]", activatedTriggers[i] != null ? activatedTriggers[i].getId() : 0);
    }

    for (int i = 0; i < 8; ++i)
      if (triggerParameters[i] != null) {
        NBTTagCompound cpt = new NBTTagCompound();
        triggerParameters[i].writeToNBT(cpt);
        nbttagcompound.setTag("triggerParameters[" + i + "]", cpt);
      }
  }
Exemple #12
0
 protected void initLocalData() {
   docTableModel = new DocumentTableModel();
   try {
     documentsLoadedCount = Gate.getCreoleRegister().getAllInstances("gate.Document").size();
   } catch (GateException exception) {
     exception.printStackTrace();
   }
 }
  public int CalculateHandlingTime() {
    int minutes = 0;
    Gate arrivalGate = arrival.getLanding();
    Gate departureGate = destination.getTakeoff();

    if (arrivalGate.equals(departureGate)) {
      return 20; // assuming they have to unload all baggage and reload the baggage that doesnt
                 // transfer to
      // different planes
    }

    int ag = arrivalGate.getGateNumber(); // to extract the numbers from the gate string
    int dg = departureGate.getGateNumber();

    if (arrivalGate.getGateTerminal().equals(departureGate.getGateTerminal())) // if same terminal
    {
      if (ag < dg) {
        minutes = 20 + dg - ag;
      } else {
        minutes = 20 + ag - dg;
      }
    } else // not same terminal
    {
      minutes = 20 + ag + dg;
    }

    return minutes;
  }
Exemple #14
0
  public LinkedList<IAction> getActions() {
    LinkedList<IAction> result = new LinkedList<IAction>();

    if (hasGate()) {
      gate.addActions(result);
    }

    return result;
  }
Exemple #15
0
  /**
   * To evaluate the ON/OFF ratio for a circuit, calculate the ON/OFF ratio for each output gate,
   * and choose the worst score among the outputs (#outputs >= 1).
   */
  public static void evaluateCircuitONOFFRatio(LogicCircuit lc) {

    double worst_out = Double.MAX_VALUE;

    for (int out = 0;
        out < lc.get_output_gates().size();
        ++out) { // if multiple outputs, average _scores
      Gate output = lc.get_output_gates().get(out);
      evaluateGateONOFFRatio(output);

      // if multiple outputs, circuit score = score of worst output
      if (output.get_scores().get_onoff_ratio() < worst_out) {
        worst_out = output.get_scores().get_onoff_ratio();
      }
    }

    lc.get_scores().set_onoff_ratio(worst_out);
  }
Exemple #16
0
  /**
   * The function evaluateCircuit calls other evaluate functions based on the circuit_score chose by
   * user.
   *
   * <p>-circuit_score onoff_ratio score = log(ON/OFF), where ON is the lowest ON in the truthtable,
   * and OFF is the highest off in the truthtable
   *
   * <p>-circuit_score noise_margin noise margin is computed from input REU distance from low margin
   * (if low) or high margin (if high) score = average noise margin of all logic gates used for
   * NOR/NOT only, and cannot be used if there are input gates and no logic gates
   *
   * <p>-circuit_score histogram score = 1 - overlap penalty, where overlap is from the worst pair
   * among ONs and OFFs in the truthtable
   *
   * <p>Circuit is evaluated by evaluating each gate, so the same function calls appear but with a
   * Gate parameter instead of LogicCircuit parameter
   */
  public static void evaluateCircuit(LogicCircuit lc, GateLibrary gate_library, Args options) {

    refreshGateAttributes(lc, gate_library);

    // if sequential
    if (options.get_circuit_type() == DNACompiler.CircuitType.sequential) {

      SequentialHelper.setInitialREUs(lc, gate_library);

      HashMap<String, ArrayList<ArrayList<Double>>> track_reus = new HashMap<>();

      for (Gate g : lc.get_Gates()) {
        track_reus.put(g.Name, new ArrayList<ArrayList<Double>>());
        ArrayList<Double> copy_reus = new ArrayList<Double>(g.get_outreus());
        track_reus.get(g.Name).add(copy_reus);
        track_reus.get(g.Name).add(copy_reus);
      }

      boolean converges = SequentialHelper.convergeREUs(lc, gate_library, options, track_reus);

      if (!converges) {

        lc.get_scores().set_onoff_ratio(0.0);
        lc.get_scores().set_noise_margin_contract(false);

        return;
      }
    }

    // if combinational
    else if (options.get_circuit_type() == DNACompiler.CircuitType.combinational) {
      simulateREU(lc, gate_library, options);
    }

    evaluateCircuitONOFFRatio(lc);

    if (options.is_noise_margin()) {
      evaluateCircuitNoiseMargin(lc, options);
    }

    if (options.is_snr()) {
      evaluateCircuitSNR(lc, options);
    }
  }
Exemple #17
0
  /** noise_margin */
  public static void evaluateCircuitNoiseMargin(LogicCircuit lc, Args options) {

    // initialize to true. circuit will fail if any gate fails.
    lc.get_scores().set_noise_margin_contract(true);

    if (options.is_noise_margin() == false) {
      return;
    }

    double sum_noise_margin = 0.0;
    double min_noise_margin = 999.0;

    for (Gate g : lc.get_logic_gates()) {

      // 'options' are passed in to read the _noise_margin boolean
      evaluateGateNoiseMargin(g, options);

      if (g.get_scores().get_noise_margin() < min_noise_margin) {
        min_noise_margin = g.get_scores().get_noise_margin();
      }

      // g.get_noise_margin() returns the min of the NML and NMH values (noise margin low, noise
      // margin high)

      sum_noise_margin += g.get_scores().get_noise_margin();
      // sum_noise_margin += g.get_scores().get_noise_margin() * g.get_distance_to_input();

      /** if one gate fails, the whole circuit fails threshold analysis */
      if (g.get_scores().is_noise_margin_contract() == false) {
        lc.get_scores().set_noise_margin_contract(false);
        // lc.get_scores().set_noise_margin(0.0);
        lc.get_scores().set_noise_margin(min_noise_margin);
        break;
      }
    }

    // noise margin value is not being used.
    // noise margin is only used as a pass/fail filter, not a score term.
    if (lc.get_scores().is_noise_margin_contract() == true) {
      // lc.get_scores().set_noise_margin(sum_noise_margin / lc.get_logic_gates().size());
      lc.get_scores().set_noise_margin(sum_noise_margin);
    }
  }
Exemple #18
0
  /**
   * histogram
   *
   * <p>Histogram overlap score worst-case = 0.0 and best-case = 1.0
   */
  public static void evaluateCircuitHistogramOverlap(
      LogicCircuit lc, GateLibrary gate_library, Args options) { // output gate _score (average)

    refreshGateAttributes(lc, gate_library);

    // if sequential
    if (options.get_circuit_type() == DNACompiler.CircuitType.sequential) {

      // set initial
      SequentialHelper.setInitialHistogramREUs(lc, gate_library);

      // track
      HashMap<String, ArrayList<ArrayList<double[]>>> track_reus = new HashMap<>();
      for (Gate g : lc.get_Gates()) {
        track_reus.put(g.Name, new ArrayList<ArrayList<double[]>>());
        ArrayList<double[]> copy_hist_reus = new ArrayList<double[]>(g.get_histogram_reus());
        track_reus.get(g.Name).add(copy_hist_reus);
        track_reus.get(g.Name).add(copy_hist_reus); // looks for i-1
      }

      // converge
      SequentialHelper.convergeHistogramREUs(lc, gate_library, options, track_reus);
    }

    // if combinational
    else if (options.get_circuit_type() == DNACompiler.CircuitType.combinational) {
      Evaluate.simulateHistogramREU(lc, gate_library, options);
    }

    double worst_out = Double.MAX_VALUE;

    for (int out = 0; out < lc.get_output_gates().size(); ++out) {
      Gate output = lc.get_output_gates().get(out);
      evaluateGateHistogramOverlap(output);

      if (output.get_scores().get_conv_overlap() < worst_out) {
        worst_out = output.get_scores().get_conv_overlap();
      }
    }

    lc.get_scores().set_conv_overlap(worst_out);
  }
Exemple #19
0
  public boolean isPowered() {
    RelativeBlockVector[] controls = gate.getControls();

    for (RelativeBlockVector vector : controls) {
      MaterialData mat = getBlockAt(vector).getBlock().getState().getData();

      if (mat instanceof Button && ((Button) mat).isPowered()) return true;
    }

    return false;
  }
  /**
   * Initialise the ANNIE system. This creates a "corpus pipeline" application that can be used to
   * run sets of documents through the extraction system.
   */
  public void initAnnie() throws GateException, IOException {
    Out.prln("Initialising ANNIE...");

    // load the ANNIE application from the saved state in plugins/ANNIE
    File pluginsHome = Gate.getPluginsHome();
    File anniePlugin = new File(pluginsHome, "ANNIE");
    File annieGapp = new File(anniePlugin, "ANNIE_with_defaults.gapp");
    annieController = (CorpusController) PersistenceManager.loadObjectFromFile(annieGapp);

    Out.prln("...ANNIE loaded");
  } // initAnnie()
Exemple #21
0
  public void readFromNBT(NBTTagCompound nbttagcompound) {
    transport.readFromNBT(nbttagcompound);
    logic.readFromNBT(nbttagcompound);

    // Load pulser if any
    if (nbttagcompound.hasKey("Gate")) {
      NBTTagCompound nbttagcompoundP = nbttagcompound.getCompoundTag("Gate");
      gate = new GateVanilla(this);
      gate.readFromNBT(nbttagcompoundP);
    } else if (nbttagcompound.hasKey("gateKind")) {
      // Legacy implementation
      Gate.GateKind kind = Gate.GateKind.values()[nbttagcompound.getInteger("gateKind")];
      if (kind != Gate.GateKind.None) {
        gate = new GateVanilla(this);
        gate.kind = kind;
      }
    }
    // Wire states are restored for pipes with gates
    if (gate != null) {
      for (int i = 0; i < 4; ++i)
        broadcastSignal[i] = nbttagcompound.getBoolean("wireState[" + i + "]");
      broadcastRedstone = nbttagcompound.getBoolean("redstoneState");
    }

    for (int i = 0; i < 4; ++i) wireSet[i] = nbttagcompound.getBoolean("wireSet[" + i + "]");

    for (int i = 0; i < 8; ++i) {
      activatedActions[i] = ActionManager.actions[nbttagcompound.getInteger("action[" + i + "]")];
      activatedTriggers[i] =
          ActionManager.triggers[nbttagcompound.getInteger("trigger[" + i + "]")];
    }

    // Force any triggers to be resolved
    fixTriggers();
    for (int i = 0; i < 8; ++i)
      if (nbttagcompound.hasKey("triggerParameters[" + i + "]")) {
        triggerParameters[i] = new TriggerParameter();
        triggerParameters[i].readFromNBT(
            nbttagcompound.getCompoundTag("triggerParameters[" + i + "]"));
      }
  }
Exemple #22
0
  public Blox[] getEntrances() {
    if (entrances == null) {
      RelativeBlockVector[] space = gate.getEntrances();
      entrances = new Blox[space.length];
      int i = 0;

      for (RelativeBlockVector vector : space) {
        entrances[i++] = getBlockAt(vector);
      }
    }
    return entrances;
  }
Exemple #23
0
  public Blox[] getFrame() {
    if (frame == null) {
      RelativeBlockVector[] border = gate.getBorder();
      frame = new Blox[border.length];
      int i = 0;

      for (RelativeBlockVector vector : border) {
        frame[i++] = getBlockAt(vector);
      }
    }

    return frame;
  }
Exemple #24
0
  /** find ON_lowest and OFF_highest as worst-case scenario */
  public static void evaluateGateONOFFRatio(Gate g) {

    double lowest_on_reu = Double.MAX_VALUE;
    double highest_off_reu = Double.MIN_VALUE;

    for (int i = 0; i < g.get_logics().size(); ++i) { // for each row in the truth table...
      // if (!Args.dontcare_rows.contains(i)) { //don't score dontcare rows
      Double reu = g.get_outreus().get(i);

      if (g.get_logics().get(i) == 1) {
        if (lowest_on_reu > reu) {
          lowest_on_reu = reu;
        }
      } else if (g.get_logics().get(i) == 0) {
        if (highest_off_reu < reu) {
          highest_off_reu = reu;
        }
      }
      // }
    }
    // g.get_scores().set_onoff_ratio( Math.log10(lowest_on_reu/highest_off_reu) );
    g.get_scores().set_onoff_ratio(lowest_on_reu / highest_off_reu);
  }
  public static void computeShortestPath(Gate sourceGate) {
    sourceGate.shortestTime = 0.;
    PriorityQueue<Gate> gateQueue = new PriorityQueue<Gate>();
    gateQueue.add(sourceGate);

    while (!gateQueue.isEmpty()) {
      Gate u = gateQueue.poll();

      // Visit each edge exiting u
      for (Edge e : u.adjacencies) {
        Gate v = e.destGate;
        double travelTime = e.travelTime;
        double timeThroughU = u.shortestTime + travelTime;
        if (timeThroughU < v.shortestTime) {
          gateQueue.remove(v);

          v.shortestTime = timeThroughU;
          v.previous = u;
          gateQueue.add(v);
        }
      }
    }
  }
Exemple #26
0
  /**
   * A gate with two transcriptional units (e.g. AND) can have two different wirings. Doesn't matter
   * for a gate with one txn unit.
   *
   * @param g
   * @param gate_library
   * @param options
   */
  public static void setBestVariableMapping(Gate g, GateLibrary gate_library, Args options) {

    ArrayList<ArrayList<String>> variable_name_orders =
        Permute.getVariableNamePermutation(g.get_variable_names());
    Integer best_variable_name_order_index = 0;
    Double best_score = 0.0;

    int v = 0;
    for (ArrayList<String> variable_name_order : variable_name_orders) {

      g.get_outreus().clear();

      for (int i = 0; i < g.get_logics().size(); ++i) { // rows in truth table

        /*if (Args.dontcare_rows.contains(i)) {
            g.get_outreus().add(0.0);
            continue;
        }*/

        GateUtil.mapWiresToVariables(g, variable_name_order);

        double output_reu =
            ResponseFunction.computeOutput(
                GateUtil.getVariableValues(g, i, gate_library, options),
                g.get_params(),
                g.get_equation());

        g.get_outreus().add(output_reu);
      }

      evaluateGate(g, options);

      if (g.get_scores().get_score() > best_score) {
        best_score = g.get_scores().get_score();
        best_variable_name_order_index = v;
      }
      v++;
    }

    // this is the critical part, it's ordering the variable names in the list
    g.set_variable_names(variable_name_orders.get(best_variable_name_order_index));
  }
Exemple #27
0
 public void actionPerformed(ActionEvent e) {
   List<Resource> loadedDocuments;
   try {
     // get all the documents loaded in the system
     loadedDocuments = Gate.getCreoleRegister().getAllInstances("gate.Document");
   } catch (GateException ge) {
     // gate.Document is not registered in creole.xml....what is!?
     throw new GateRuntimeException(
         "gate.Document is not registered in the creole register!\n"
             + "Something must be terribly wrong...take a vacation!");
   }
   Vector<String> docNames = new Vector<String>();
   for (Resource loadedDocument : new ArrayList<Resource>(loadedDocuments)) {
     if (corpus.contains(loadedDocument)) {
       loadedDocuments.remove(loadedDocument);
     } else {
       docNames.add(loadedDocument.getName());
     }
   }
   JList docList = new JList(docNames);
   docList.getSelectionModel().setSelectionInterval(0, docNames.size() - 1);
   docList.setCellRenderer(renderer);
   final JOptionPane optionPane =
       new JOptionPane(
           new JScrollPane(docList), JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
   final JDialog dialog =
       optionPane.createDialog(CorpusEditor.this, "Add document(s) to this corpus");
   docList.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getClickCount() == 2) {
             optionPane.setValue(JOptionPane.OK_OPTION);
             dialog.dispose();
           }
         }
       });
   dialog.setVisible(true);
   if (optionPane.getValue().equals(JOptionPane.OK_OPTION)) {
     int[] selectedIndices = docList.getSelectedIndices();
     for (int selectedIndice : selectedIndices) {
       corpus.add((Document) loadedDocuments.get(selectedIndice));
     }
   }
   changeMessage();
 }
Exemple #28
0
  public void updateEntity() {

    transport.updateEntity();
    logic.updateEntity();

    if (internalUpdateScheduled) {
      internalUpdate();
      internalUpdateScheduled = false;
    }

    // Do not try to update gates client side.
    if (worldObj.isRemote) return;

    if (actionTracker.markTimeIfDelay(worldObj, 10)) {
      resolveActions();
    }

    // Update the gate if we have any
    if (gate != null) {
      gate.update();
    }
  }
Exemple #29
0
  /**
   * *********************************************************************
   *
   * <p>Synopsis [ ]
   *
   * <p>keep tracing back to child until find one with logics defined assume it has either 1 or 2
   * children this method is recursive Note: Recursion is not necessary and does not occur if we
   * sort the gates by distance to input, then simulate logic in that order.
   *
   * <p>logic is computed according to Gate type and input logics
   *
   * <p>*********************************************************************
   */
  public static void simulateLogic(Gate g) {

    if (g.is_unvisited()) {

      ArrayList<Gate> children = g.getChildren();

      for (Gate child : children) {
        if (child.is_unvisited()) {
          simulateLogic(child); // recursive
        }
      }

      // if all children have been visited, visit the current gate 'g'
      g.set_unvisited(false);
      g.set_logics(GateUtil.computeGateLogics(g));
    }
  }
Exemple #30
0
  public void onBlockRemoval() {
    if (wireSet[IPipe.WireColor.Red.ordinal()]) {
      Utils.dropItems(
          worldObj, new ItemStack(BuildCraftTransport.redPipeWire), xCoord, yCoord, zCoord);
    }

    if (wireSet[IPipe.WireColor.Blue.ordinal()]) {
      Utils.dropItems(
          worldObj, new ItemStack(BuildCraftTransport.bluePipeWire), xCoord, yCoord, zCoord);
    }

    if (wireSet[IPipe.WireColor.Green.ordinal()]) {
      Utils.dropItems(
          worldObj, new ItemStack(BuildCraftTransport.greenPipeWire), xCoord, yCoord, zCoord);
    }

    if (wireSet[IPipe.WireColor.Yellow.ordinal()]) {
      Utils.dropItems(
          worldObj, new ItemStack(BuildCraftTransport.yellowPipeWire), xCoord, yCoord, zCoord);
    }

    if (hasGate()) {
      gate.dropGate(worldObj, xCoord, yCoord, zCoord);
    }

    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
      if (container.hasFacade(direction)) {
        container.dropFacade(direction);
      }
      if (container.hasPlug(direction)) {
        container.removeAndDropPlug(direction);
      }
    }

    if (broadcastRedstone) {
      updateNeighbors(false); // self will update due to block id changing
    }
  }