Esempio n. 1
0
  /** Turns the factory on */
  public void powerOn() {
    // put active to true
    active = true;

    // Set attached lever
    if (FactoryModPlugin.LEVER_OUTPUT_ENABLED) {
      setActivationLever(true);
    }

    // lots of code to make the furnace light up, without loosing contents.
    Furnace furnace = (Furnace) factoryPowerSourceLocation.getBlock().getState();
    byte data = furnace.getData().getData();
    ItemStack[] oldContents = furnace.getInventory().getContents();
    furnace.getInventory().clear();
    factoryPowerSourceLocation.getBlock().setType(Material.BURNING_FURNACE);
    furnace = (Furnace) factoryPowerSourceLocation.getBlock().getState();
    furnace.setRawData(data);
    furnace.update();
    furnace.getInventory().setContents(oldContents);
    // reset the production timer
    currentProductionTimer = 0;
  }
Esempio n. 2
0
  /** Turns the factory off. */
  public void powerOff() {
    if (active) {
      if (FactoryModPlugin.LEVER_OUTPUT_ENABLED) {
        setActivationLever(false);
      }

      // lots of code to make the furnace turn off, without loosing contents.
      Furnace furnace = (Furnace) factoryPowerSourceLocation.getBlock().getState();
      byte data = furnace.getData().getData();
      ItemStack[] oldContents = furnace.getInventory().getContents();
      furnace.getInventory().clear();
      factoryPowerSourceLocation.getBlock().setType(Material.FURNACE);
      furnace = (Furnace) factoryPowerSourceLocation.getBlock().getState();
      furnace.setRawData(data);
      furnace.update();
      furnace.getInventory().setContents(oldContents);

      // put active to false
      active = false;
      // reset the production timer
      currentProductionTimer = 0;
    }
  }