コード例 #1
0
  @Override
  public void updateEntity() {
    oldDishRotation = dishRotation;
    if (isSensorActive) {
      dishSpeed = Math.min(dishSpeed + 0.2F, 10);
    } else {
      dishSpeed = Math.max(dishSpeed - 0.2F, 0);
    }
    dishRotation += dishSpeed;

    if (worldObj.isRemote) {
      int sensorRange = getRange();
      if (oldSensorRange != sensorRange || oldSensorRange == 0) {
        oldSensorRange = sensorRange;
        if (!firstRun) rangeLineRenderer.resetRendering(sensorRange);
      }
      rangeLineRenderer.update();
    }
    super.updateEntity();

    if (!worldObj.isRemote) {
      ticksExisted++;
      ISensorSetting sensor = SensorHandler.instance().getSensorFromPath(sensorSetting);
      if (sensor != null
          && getPressure(ForgeDirection.UNKNOWN) > PneumaticValues.MIN_PRESSURE_UNIVERSAL_SENSOR) {
        isSensorActive = true;
        addAir(-PneumaticValues.USAGE_UNIVERSAL_SENSOR, ForgeDirection.UNKNOWN);
        if (sensor instanceof IPollSensorSetting) {
          if (ticksExisted % ((IPollSensorSetting) sensor).getPollFrequency() == 0) {
            int newRedstoneStrength =
                ((IPollSensorSetting) sensor)
                    .getRedstoneValue(worldObj, xCoord, yCoord, zCoord, getRange(), sensorGuiText);
            if (invertedRedstone) newRedstoneStrength = 15 - newRedstoneStrength;
            if (newRedstoneStrength != redstoneStrength) {
              redstoneStrength = newRedstoneStrength;
              if (requestPollPullEvent) {
                notifyComputers(redstoneStrength);
              }
              updateNeighbours();
            }
          }
          eventTimer = 0;
        } else {
          if (eventTimer > 0) {
            eventTimer--;
            if (eventTimer == 0 && redstoneStrength != (invertedRedstone ? 15 : 0)) {
              redstoneStrength = invertedRedstone ? 15 : 0;
              updateNeighbours();
            }
          }
        }
      } else {
        isSensorActive = false;
        if (redstoneStrength != (invertedRedstone ? 15 : 0)) {
          redstoneStrength = invertedRedstone ? 15 : 0;
          updateNeighbours();
        }
      }
    }
  }
コード例 #2
0
  @Override
  public void handleGUIButtonPress(int buttonID, EntityPlayer player) {
    if (buttonID >= 10 && buttonID % 10 == 0) {
      String[] directories = SensorHandler.instance().getDirectoriesAtLocation(getSensorSetting());
      if (buttonID / 10 <= directories.length) { // <= because of the redstone button being 0.
        if (getSensorSetting().equals("")) {
          setSensorSetting(directories[buttonID / 10 - 1]);
        } else {
          setSensorSetting(getSensorSetting() + "/" + directories[buttonID / 10 - 1]);
        }
      }
    } else if (buttonID == 1) { // the 'back' button

      String[] folders = getSensorSetting().split("/");
      String newPath = getSensorSetting().replace(folders[folders.length - 1], "");
      if (newPath.endsWith("/")) {
        newPath = newPath.substring(0, newPath.length() - 1);
      }
      setSensorSetting(newPath);
    } else if (buttonID == 0) {
      invertedRedstone = !invertedRedstone;
      redstoneStrength = 15 - redstoneStrength;
      updateNeighbours();
    }
  }
コード例 #3
0
 private boolean setSensorSetting(ISensorSetting sensor) {
   if (areGivenUpgradesInserted(
       SensorHandler.instance().getRequiredStacksFromText(sensor.getSensorPath()))) {
     setSensorSetting(sensor.getSensorPath());
     return true;
   } else {
     return false;
   }
 }
コード例 #4
0
 @Override
 public void setInventorySlotContents(int slot, ItemStack itemStack) {
   // super.setInventorySlotContents(slot, itemStack);
   inventory[slot] = itemStack;
   if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) {
     itemStack.stackSize = getInventoryStackLimit();
   }
   if (!worldObj.isRemote
       && !getSensorSetting().equals("")
       && !areGivenUpgradesInserted(
           SensorHandler.instance().getRequiredStacksFromText(getSensorSetting()))) {
     setSensorSetting("");
   }
 }
コード例 #5
0
 public void onEvent(Event event) {
   ISensorSetting sensor = SensorHandler.instance().getSensorFromPath(sensorSetting);
   if (sensor != null
       && sensor instanceof IEventSensorSetting
       && getPressure(ForgeDirection.UNKNOWN) > PneumaticValues.MIN_PRESSURE_UNIVERSAL_SENSOR) {
     int newRedstoneStrength =
         ((IEventSensorSetting) sensor)
             .emitRedstoneOnEvent(event, this, getRange(), sensorGuiText);
     if (newRedstoneStrength != 0)
       eventTimer = ((IEventSensorSetting) sensor).getRedstonePulseLength();
     if (invertedRedstone) newRedstoneStrength = 15 - newRedstoneStrength;
     if (eventTimer > 0 && ThirdPartyManager.computerCraftLoaded)
       notifyComputers(newRedstoneStrength);
     if (newRedstoneStrength != redstoneStrength) {
       redstoneStrength = newRedstoneStrength;
       updateNeighbours();
     }
   }
 }