예제 #1
0
  private void handlePower(
      boolean doEffects,
      DimensionStorage dimensionStorage,
      Map.Entry<Integer, DimensionDescriptor> entry,
      Integer id,
      DimensionInformation information) {
    int cost = 0;
    if (DimletConfiguration.dimensionDifficulty != -1) {
      cost = information.getActualRfCost();
      if (cost == 0) {
        cost = entry.getValue().getRfMaintainCost();
      }
    }

    int power = dimensionStorage.getEnergyLevel(id);
    power -= cost * MAXTICKS;
    if (power < 0) {
      power = 0;
    }

    handleLowPower(id, power, doEffects);
    if (doEffects && power > 0) {
      handleEffectsForDimension(power, id, information);
    }

    dimensionStorage.setEnergyLevel(id, power);
  }
예제 #2
0
  private void serverTick(boolean doEffects) {
    World entityWorld = MinecraftServer.getServer().getEntityWorld();
    RfToolsDimensionManager dimensionManager =
        RfToolsDimensionManager.getDimensionManager(entityWorld);

    if (!dimensionManager.getDimensions().isEmpty()) {
      DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(entityWorld);

      for (Map.Entry<Integer, DimensionDescriptor> entry :
          dimensionManager.getDimensions().entrySet()) {
        Integer id = entry.getKey();
        // If there is an activity probe we only drain power if the dimension is loaded (a player is
        // there or a chunkloader)
        DimensionInformation information = dimensionManager.getDimensionInformation(id);
        WorldServer world = DimensionManager.getWorld(id);

        // Power handling.
        if (world != null || information.getProbeCounter() == 0) {
          handlePower(doEffects, dimensionStorage, entry, id, information);
        }

        // Special effect handling.
        if (world != null && !world.playerEntities.isEmpty()) {
          handleRandomEffects(world, information);
        }
      }

      dimensionStorage.save(entityWorld);
    }
  }