private EntityRef createResultItem(String itemResult) {
    String resultText = itemResult;
    int count = 1;
    int starIndex = resultText.indexOf("*");
    if (starIndex > -1) {
      count = Integer.parseInt(resultText.substring(0, starIndex));
      resultText = resultText.substring(starIndex + 1);
    }

    EntityManager entityManager = CoreRegistry.get(EntityManager.class);
    BlockManager blockManager = CoreRegistry.get(BlockManager.class);
    PrefabManager prefabManager = CoreRegistry.get(PrefabManager.class);
    Prefab prefab = prefabManager.getPrefab(resultText);

    EntityRef result;
    if (prefab != null) {
      result = entityManager.create(prefab);
      ItemComponent item = result.getComponent(ItemComponent.class);
      item.stackCount = (byte) count;
      result.saveComponent(item);
    } else {
      BlockItemFactory blockItemFactory = new BlockItemFactory(entityManager);
      BlockFamily blockFamily = blockManager.getBlockFamily(resultText);
      result = blockItemFactory.newInstance(blockFamily, count);
    }
    return result;
  }
Esempio n. 2
0
  @Override
  public void init(GameEngine engine) {
    EngineTime time = (EngineTime) CoreRegistry.get(Time.class);
    time.setPaused(true);
    time.setGameTime(0);

    CoreRegistry.get(Game.class).load(gameManifest);
    switch (netMode) {
      case CLIENT:
        initClient();
        break;
      default:
        initHost();
        break;
    }

    progress = 0;
    maxProgress = 0;
    for (LoadProcess process : loadProcesses) {
      maxProgress += process.getExpectedCost();
    }

    popStep();
    loadingScreen = nuiManager.setScreen("engine:loadingScreen", LoadingScreen.class);
    loadingScreen.updateStatus(current.getMessage(), current.getProgress());
  }
 @Override
 protected void setupNetwork() {
   EngineTime mockTime = mock(EngineTime.class);
   CoreRegistry.put(Time.class, mockTime);
   NetworkSystem networkSystem = new NetworkSystemImpl(mockTime);
   CoreRegistry.put(NetworkSystem.class, networkSystem);
 }
  @Override
  protected void setupStorageManager() {
    ModuleManager moduleManager = CoreRegistry.get(ModuleManager.class);
    EngineEntityManager engineEntityManager = CoreRegistry.get(EngineEntityManager.class);

    CoreRegistry.put(
        StorageManager.class, new StorageManagerInternal(moduleManager, engineEntityManager));
  }
Esempio n. 5
0
  // TODO: verify if this can be achieved entirely in the GPU, during tone mapping perhaps?
  public void downsampleSceneAndUpdateExposure() {
    if (renderingConfig.isEyeAdaptation()) {
      PerformanceMonitor.startActivity("Updating exposure");

      downsampleSceneInto1x1pixelsBuffer();

      renderingProcess
          .getCurrentReadbackPBO()
          .copyFromFBO(
              buffers.downSampledScene[0].fboId, 1, 1, GL12.GL_BGRA, GL11.GL_UNSIGNED_BYTE);

      renderingProcess.swapReadbackPBOs();

      ByteBuffer pixels = renderingProcess.getCurrentReadbackPBO().readBackPixels();

      if (pixels.limit() < 3) {
        logger.error("Failed to auto-update the exposure value.");
        return;
      }

      // TODO: make this line more readable by breaking it in smaller pieces
      currentSceneLuminance =
          0.2126f * (pixels.get(2) & 0xFF) / 255.f
              + 0.7152f * (pixels.get(1) & 0xFF) / 255.f
              + 0.0722f * (pixels.get(0) & 0xFF) / 255.f;

      float targetExposure = hdrMaxExposure;

      if (currentSceneLuminance > 0) {
        targetExposure = hdrTargetLuminance / currentSceneLuminance;
      }

      float maxExposure = hdrMaxExposure;

      if (CoreRegistry.get(BackdropProvider.class).getDaylight()
          == 0.0) { // TODO: fetch the backdropProvider earlier and only once
        maxExposure = hdrMaxExposureNight;
      }

      if (targetExposure > maxExposure) {
        targetExposure = maxExposure;
      } else if (targetExposure < hdrMinExposure) {
        targetExposure = hdrMinExposure;
      }

      currentExposure = TeraMath.lerp(currentExposure, targetExposure, hdrExposureAdjustmentSpeed);

    } else {
      if (CoreRegistry.get(BackdropProvider.class).getDaylight() == 0.0) {
        currentExposure = hdrMaxExposureNight;
      } else {
        currentExposure = hdrExposureDefault;
      }
    }
    PerformanceMonitor.endActivity();
  }
  @Override
  protected void setupAssetManager() {
    setupEmptyAssetManager();

    AssetManager assetManager = CoreRegistry.get(AssetManager.class);
    AudioManager audioManager = CoreRegistry.get(AudioManager.class);
    AssetType.registerAssetTypes(assetManager);

    CodeSource tsCodeSource = TerasologyEngine.class.getProtectionDomain().getCodeSource();
    assetManager.addAssetSource(
        new ClasspathSource(
            TerasologyConstants.ENGINE_MODULE,
            tsCodeSource,
            TerasologyConstants.ASSETS_SUBDIRECTORY,
            TerasologyConstants.OVERRIDES_SUBDIRECTORY));

    CodeSource thisCodeSource = HeadlessEnvironment.class.getProtectionDomain().getCodeSource();
    assetManager.addAssetSource(
        new ClasspathSource(
            "unittest",
            thisCodeSource,
            TerasologyConstants.ASSETS_SUBDIRECTORY,
            TerasologyConstants.OVERRIDES_SUBDIRECTORY));

    assetManager.setAssetFactory(
        AssetType.PREFAB,
        new AssetFactory<PrefabData, Prefab>() {

          @Override
          public Prefab buildAsset(AssetUri uri, PrefabData data) {
            return new PojoPrefab(uri, data);
          }
        });
    assetManager.setAssetFactory(
        AssetType.SHAPE,
        new AssetFactory<BlockShapeData, BlockShape>() {

          @Override
          public BlockShape buildAsset(AssetUri uri, BlockShapeData data) {
            return new BlockShapeImpl(uri, data);
          }
        });

    assetManager.setAssetFactory(
        AssetType.UI_SKIN,
        new AssetFactory<UISkinData, UISkin>() {
          @Override
          public UISkin buildAsset(AssetUri uri, UISkinData data) {
            return new UISkin(uri, data);
          }
        });

    assetManager.setAssetFactory(AssetType.SOUND, audioManager.getStaticSoundFactory());
    assetManager.setAssetFactory(AssetType.MUSIC, audioManager.getStreamingSoundFactory());
  }
 @ReceiveEvent(components = ClientComponent.class)
 public void onKeyDown(KeyDownEvent event, EntityRef entity) {
   switch (event.getKey().getId()) {
     case Keyboard.KeyId.F12:
       CoreRegistry.get(LwjglRenderingProcess.class).takeScreenshot();
       CoreRegistry.get(AudioManager.class).playSound(Assets.getSound("engine:camera").get());
       break;
     default:
       break;
   }
 }
  @Override
  protected void setupEntitySystem() {
    ModuleManager moduleManager = CoreRegistry.get(ModuleManager.class);
    NetworkSystem networkSystem = CoreRegistry.get(NetworkSystem.class);

    EntitySystemBuilder builder = new EntitySystemBuilder();
    EngineEntityManager engineEntityManager =
        builder.build(moduleManager, networkSystem, new ReflectionReflectFactory());

    CoreRegistry.put(EngineEntityManager.class, engineEntityManager);
  }
Esempio n. 9
0
 void connectToEntitySystem(
     EngineEntityManager newEntityManager,
     NetworkEntitySerializer newEntitySerializer,
     EventSerializer newEventSerializer,
     BlockEntityRegistry newBlockEntityRegistry) {
   this.entityManager = newEntityManager;
   this.eventSerializer = newEventSerializer;
   this.entitySerializer = newEntitySerializer;
   this.blockEntityRegistry = newBlockEntityRegistry;
   blockManager = (BlockManagerImpl) CoreRegistry.get(BlockManager.class);
   biomeManager = CoreRegistry.get(BiomeManager.class);
 }
Esempio n. 10
0
  public BlockManagerImpl(
      WorldAtlas atlas,
      List<String> registeredBlockFamilies,
      Map<String, Short> knownBlockMappings,
      boolean generateNewIds,
      BlockFamilyFactoryRegistry blockFamilyFactoryRegistry) {
    this.generateNewIds = generateNewIds;
    this.moduleManager = CoreRegistry.get(ModuleManager.class);
    blockLoader =
        new BlockLoader(CoreRegistry.get(AssetManager.class), blockFamilyFactoryRegistry, atlas);
    BlockLoader.LoadBlockDefinitionResults blockDefinitions = blockLoader.loadBlockDefinitions();
    addBlockFamily(getAirFamily(), true);
    for (BlockFamily family : blockDefinitions.families) {
      addBlockFamily(family, false);
    }
    for (FreeformFamily freeformFamily : blockDefinitions.shapelessDefinitions) {
      addFreeformBlockFamily(freeformFamily.uri, freeformFamily.categories);
    }
    if (knownBlockMappings.size() >= MAX_ID) {
      nextId = UNKNOWN_ID;
    } else if (knownBlockMappings.size() > 0) {
      nextId = (short) knownBlockMappings.size();
    }

    for (String rawFamilyUri : registeredBlockFamilies) {
      BlockUri familyUri = new BlockUri(rawFamilyUri);
      BlockFamily family;
      if (isFreeformFamily(familyUri)) {
        family = blockLoader.loadWithShape(familyUri);
      } else {
        family = getAvailableBlockFamily(familyUri);
      }
      if (family != null) {
        for (Block block : family.getBlocks()) {
          Short id = knownBlockMappings.get(block.getURI().toString());
          if (id != null) {
            block.setId(id);
          } else {
            logger.error(
                "Missing id for block {} in provided family {}", block.getURI(), family.getURI());
            if (generateNewIds) {
              block.setId(getNextId());
            } else {
              block.setId(UNKNOWN_ID);
            }
          }
        }
        registerFamily(family);
      } else {
        logger.error("Family not available: {}", rawFamilyUri);
      }
    }
  }
Esempio n. 11
0
  @Override
  protected void setupEmptyAssetManager() {
    ModuleManager moduleManager = CoreRegistry.get(ModuleManager.class);
    AssetManager assetManager = new AssetManager(moduleManager);

    // mock an empy asset factory for all asset types
    for (AssetType type : AssetType.values()) {
      assetManager.setAssetFactory(type, mock(AssetFactory.class));
    }

    CoreRegistry.put(AssetManager.class, assetManager);
  }
Esempio n. 12
0
  /**
   * Activate all modules. Note: this requires that the {@link ModuleSecurityManager} gives
   * permission to do that
   */
  public void activateAllModules() {
    ModuleManager moduleManager = CoreRegistry.get(ModuleManager.class);
    AssetManager assetManager = CoreRegistry.get(AssetManager.class);

    // activate all modules
    for (Module m : moduleManager.getModules()) {
      moduleManager.enableModule(m);
    }

    moduleManager.applyActiveModules();
    assetManager.clear();
    assetManager.applyOverrides();
  }
Esempio n. 13
0
  /**
   * Renders this AABB.
   *
   * <p>
   *
   * @param lineThickness The thickness of the line
   */
  public void render(float lineThickness) {
    CoreRegistry.get(ShaderManager.class).enableDefault();

    glPushMatrix();
    Vector3f cameraPosition = CoreRegistry.get(WorldRenderer.class).getActiveCamera().getPosition();
    glTranslated(
        aabb.getCenter().x - cameraPosition.x,
        -cameraPosition.y,
        aabb.getCenter().z - cameraPosition.z);

    renderLocally(lineThickness);

    glPopMatrix();
  }
Esempio n. 14
0
  /** Init. the HUD. */
  public UIScreenHUD() {
    setId("hud");
    maximize();
    time = CoreRegistry.get(Time.class);

    // Create hearts
    hearts = new UIImage[NUM_HEART_ICONS];
    for (int i = 0; i < NUM_HEART_ICONS; i++) {
      hearts[i] = new UIImage(Assets.getTexture("engine:icons"));
      hearts[i].setVisible(true);
      hearts[i].setTextureSize(new Vector2f(9f, 9f));
      hearts[i].setTextureOrigin(new Vector2f(52f, 0.0f)); // 106f for poison
      hearts[i].setSize(new Vector2f(18f, 18f));
      hearts[i].setVerticalAlign(EVerticalAlign.BOTTOM);
      hearts[i].setHorizontalAlign(EHorizontalAlign.CENTER);
      hearts[i].setPosition(new Vector2f(18f * i - 212f, -52f));

      addDisplayElement(hearts[i]);
    }

    breathBubbles = new UIImage[NUM_BUBBLE_ICONS];
    for (int i = 0; i < NUM_BUBBLE_ICONS; ++i) {
      breathBubbles[i] = new UIImage(Assets.getTexture("engine:icons"));
      breathBubbles[i].setVisible(true);
      breathBubbles[i].setTextureSize(new Vector2f(9f, 9f));
      breathBubbles[i].setTextureOrigin(new Vector2f(16f, 18f));
      breathBubbles[i].setSize(new Vector2f(18f, 18f));
      breathBubbles[i].setVerticalAlign(EVerticalAlign.BOTTOM);
      breathBubbles[i].setHorizontalAlign(EHorizontalAlign.CENTER);
      breathBubbles[i].setPosition(new Vector2f(-18f * i + 210f, -52f));

      addDisplayElement(breathBubbles[i]);
    }

    crosshair = new UIImage(Assets.getTexture("engine:gui"));
    crosshair.setId("crosshair");
    crosshair.setTextureSize(new Vector2f(20f, 20f));
    crosshair.setTextureOrigin(new Vector2f(24f, 24f));
    crosshair.setSize(new Vector2f(40f, 40f));
    crosshair.setHorizontalAlign(EHorizontalAlign.CENTER);
    crosshair.setVerticalAlign(EVerticalAlign.CENTER);
    crosshair.setVisible(true);

    addDisplayElement(crosshair);

    localPlayer = CoreRegistry.get(LocalPlayer.class);

    update();
    layout();
  }
Esempio n. 15
0
  @Override
  public void close() throws Exception {
    // it would be nice, if elements in the CoreRegistry implemented (Auto)Closeable

    // The StorageManager creates a thread pool (through TaskMaster)
    // which isn't closed automatically
    StorageManager storageManager = CoreRegistry.get(StorageManager.class);
    if (storageManager != null) {
      storageManager.shutdown();
    }

    CoreRegistry.clear();

    super.close();
  }
Esempio n. 16
0
 public void setFullscreen(boolean state) {
   if (renderingConfig.isFullscreen() != state) {
     renderingConfig.setFullscreen(state);
     DisplayDevice display = CoreRegistry.get(DisplayDevice.class);
     display.setFullscreen(state);
   }
 }
Esempio n. 17
0
  /**
   * Constructor for server or single player games
   *
   * @param gameManifest
   * @param netMode
   */
  public StateLoading(GameManifest gameManifest, NetworkMode netMode) {
    Preconditions.checkArgument(netMode != NetworkMode.CLIENT);

    this.gameManifest = gameManifest;
    this.nuiManager = CoreRegistry.get(NUIManager.class);
    this.netMode = netMode;
  }
  public ReadWriteStorageManager(
      Path savePath,
      ModuleEnvironment environment,
      EngineEntityManager entityManager,
      BlockManager blockManager,
      BiomeManager biomeManager,
      boolean storeChunksInZips)
      throws IOException {
    super(savePath, environment, entityManager, blockManager, biomeManager, storeChunksInZips);

    entityManager.subscribeForDestruction(this);
    entityManager.subscribeForChanges(this);
    // TODO Ensure that the component library and the type serializer library are thread save (e.g.
    // immutable)
    this.privateEntityManager = createPrivateEntityManager(entityManager.getComponentLibrary());
    Files.createDirectories(getStoragePathProvider().getStoragePathDirectory());
    this.saveTransactionHelper = new SaveTransactionHelper(getStoragePathProvider());
    this.saveThreadManager = TaskMaster.createFIFOTaskMaster("Saving", 1);
    this.config = CoreRegistry.get(Config.class);
    this.entityRefReplacingComponentLibrary =
        privateEntityManager
            .getComponentLibrary()
            .createCopyUsingCopyStrategy(EntityRef.class, new DelayedEntityRefCopyStrategy(this));
    this.entitySetDeltaRecorder =
        new EntitySetDeltaRecorder(this.entityRefReplacingComponentLibrary);
  }
Esempio n. 19
0
  private void initConfig() {
    if (Files.isRegularFile(Config.getConfigFile())) {
      try {
        config = Config.load(Config.getConfigFile());
      } catch (IOException e) {
        logger.error("Failed to load config", e);
        config = new Config();
      }
    } else {
      config = new Config();
    }
    if (!config.getDefaultModSelection().hasModule(TerasologyConstants.CORE_GAMEPLAY_MODULE)) {
      config.getDefaultModSelection().addModule(TerasologyConstants.CORE_GAMEPLAY_MODULE);
    }

    if (!validateServerIdentity()) {
      CertificateGenerator generator = new CertificateGenerator();
      CertificatePair serverIdentity = generator.generateSelfSigned();
      config
          .getSecurity()
          .setServerCredentials(serverIdentity.getPublicCert(), serverIdentity.getPrivateCert());
      config.save();
    }

    renderingConfig = config.getRendering();
    logger.info("Video Settings: " + renderingConfig.toString());
    CoreRegistry.putPermanently(Config.class, config);
  }
Esempio n. 20
0
  /**
   * Runs the engine, including its main loop. This method is called only once per application
   * startup, which is the reason the GameState provided is the -initial- state rather than a
   * generic game state.
   *
   * @param initialState In at least one context (the PC facade) the GameState implementation
   *     provided as input may vary, depending if the application has or hasn't been started
   *     headless.
   */
  @Override
  public void run(GameState initialState) {
    try {
      CoreRegistry.putPermanently(GameEngine.class, this);
      changeState(initialState);
      engineState = EngineState.RUNNING;
      Thread.currentThread().setPriority(Thread.MAX_PRIORITY);

      mainLoop(); // -THE- MAIN LOOP. Most of the application time and resources are spent here.
      cleanup();

    } catch (RuntimeException e) {
      logger.error("Uncaught exception, attempting clean game shutdown", e);
      try {
        cleanup();
      } catch (Throwable t) {
        logger.error("Clean game shutdown after an uncaught exception failed", t);
        logger.error("Rethrowing original exception");
      }
      throw e;
    } catch (Throwable t) {
      logger.error("Uncaught throwable", t);
      throw t;
    }
  }
  @Override
  public void initialise() {
    ingredientsInventory = find("ingredientsInventory", InventoryGrid.class);
    toolsInventory = find("toolsInventory", InventoryGrid.class);

    fluidContainerInput = find("fluidContainerInput", InventoryGrid.class);
    fluidContainer = find("fluidContainer", FluidContainerWidget.class);
    fluidContainerOutput = find("fluidContainerOutput", InventoryGrid.class);

    temperature = find("temperature", ThermometerWidget.class);

    burn = find("burn", VerticalTextureProgressWidget.class);
    burn.setMinY(76);
    burn.setMaxY(4);

    fuelInput = find("fuelInput", InventoryGrid.class);

    availableRecipes = find("availableRecipes", StationAvailableRecipesWidget.class);

    craftingProgress = find("craftingProgress", UILoadBar.class);

    resultInventory = find("resultInventory", InventoryGrid.class);

    InventoryGrid playerInventory = find("playerInventory", InventoryGrid.class);

    playerInventory.setTargetEntity(CoreRegistry.get(LocalPlayer.class).getCharacterEntity());
    playerInventory.setCellOffset(10);
    playerInventory.setMaxCellCount(30);
  }
  @Override
  public boolean validateBeforeStart(
      EntityRef instigator, EntityRef workstation, EntityRef processEntity) {
    if (!workstation.hasComponent(WorkstationInventoryComponent.class)) {
      return false;
    }

    // Defer the heat calculation until it is actually needed
    Float heat = null;

    for (int slot : WorkstationInventoryUtils.getAssignedSlots(workstation, "INPUT")) {
      HeatProcessedComponent processed =
          InventoryUtils.getItemAt(workstation, slot).getComponent(HeatProcessedComponent.class);
      if (processed != null) {
        float heatRequired = processed.heatRequired;
        if (heat == null) {
          heat =
              HeatUtils.calculateHeatForEntity(
                  workstation, CoreRegistry.get(BlockEntityRegistry.class));
        }
        if (heatRequired <= heat) {
          final String result =
              processed.blockResult != null ? processed.blockResult : processed.itemResult;
          if (canOutputResult(workstation, result)) {
            processEntity.addComponent(new SpecificInputSlotComponent(slot));
            processEntity.addComponent(new OutputTypeComponent(result));
            return true;
          }
        }
      }
    }

    return false;
  }
Esempio n. 23
0
  /**
   * This constructor initializes the engine by initializing its systems, subsystems and managers.
   * It also verifies that some required systems are up and running after they have been
   * initialized.
   *
   * @param subsystems Typical subsystems lists contain graphics, timer, audio and input subsystems.
   */
  public TerasologyEngine(TimeSubsystem timeSubsystem, Collection<EngineSubsystem> subsystems) {

    this.rootContext = new ContextImpl();
    this.timeSubsystem = timeSubsystem;
    /*
     * We can't load the engine without core registry yet.
     * e.g. the statically created MaterialLoader needs the CoreRegistry to get the AssetManager.
     * And the engine loads assets while it gets created.
     */
    // TODO: Remove
    CoreRegistry.setContext(rootContext);

    this.allSubsystems = Queues.newArrayDeque();
    this.allSubsystems.add(new ConfigurationSubsystem());
    this.allSubsystems.add(timeSubsystem);
    this.allSubsystems.addAll(subsystems);
    this.allSubsystems.add(new ThreadManagerSubsystem());
    this.allSubsystems.add(new MonitoringSubsystem());
    this.allSubsystems.add(new PhysicsSubsystem());
    this.allSubsystems.add(new CommandSubsystem());
    this.allSubsystems.add(new NetworkSubsystem());
    this.allSubsystems.add(new WorldGenerationSubsystem());
    this.allSubsystems.add(new GameSubsystem());
    this.allSubsystems.add(new I18nSubsystem());
  }
Esempio n. 24
0
  public void renderTransformed() {
    CoreRegistry.get(ShaderManager.class).enableDefault();

    if (isVisible()) {

      for (Animation animation : animations) {
        if (animation.isStarted()) {
          animation.renderBegin();
        }
      }

      if (positionType == EPositionType.RELATIVE) {
        glPushMatrix();
        glTranslatef(getPosition().x, getPosition().y, 0);
        render();
        glPopMatrix();
      } else if (positionType == EPositionType.ABSOLUTE) {
        glPushMatrix();
        glLoadIdentity();
        glTranslatef(getPosition().x, getPosition().y, 0);
        render();
        glPopMatrix();
      }

      for (Animation animation : animations) {
        if (animation.isStarted()) {
          animation.renderEnd();
        }
      }
    }
  }
Esempio n. 25
0
  public List<Property<?, ?>> createProperties(Object target) {
    List<Property<?, ?>> properties = Lists.newArrayList();
    try {
      Class<?> type = target.getClass();

      ReflectFactory reflectFactory = CoreRegistry.get(ReflectFactory.class);
      CopyStrategyLibrary copyStrategies = new CopyStrategyLibrary(reflectFactory);
      ClassMetadata<?, ?> classMetadata =
          new DefaultClassMetadata<>(new SimpleUri(), type, reflectFactory, copyStrategies);
      for (Field field : getAllFields(type)) {
        Annotation annotation = getFactory(field);
        if (annotation != null) {
          FieldMetadata<Object, ?> fieldMetadata =
              (FieldMetadata<Object, ?>) classMetadata.getField(field.getName());
          PropertyFactory factory = factories.get(annotation.annotationType());
          Property property = factory.create(target, fieldMetadata, field.getName(), annotation);
          properties.add(property);
        }
      }
    } catch (NoSuchMethodException e) {
      throw new RuntimeException(e);
    }

    return properties;
  }
Esempio n. 26
0
 public static <T extends Asset<U>, U extends AssetData> T generateAsset(
     AssetType type, U data, Class<T> assetClass) {
   Asset<U> asset = CoreRegistry.get(AssetManager.class).generateTemporaryAsset(type, data);
   if (assetClass.isInstance(asset)) {
     return assetClass.cast(asset);
   }
   return null;
 }
 @Override
 public boolean step() {
   try {
     CoreRegistry.get(StorageManager.class).checkAndRepairSaveIfNecessary();
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
   return true;
 }
  private SaveTransaction createSaveTransaction() {
    SaveTransactionBuilder saveTransactionBuilder =
        new SaveTransactionBuilder(
            privateEntityManager,
            entitySetDeltaRecorder,
            isStoreChunksInZips(),
            getStoragePathProvider(),
            worldDirectoryWriteLock);

    ChunkProvider chunkProvider = CoreRegistry.get(ChunkProvider.class);
    NetworkSystem networkSystem = CoreRegistry.get(NetworkSystem.class);

    addChunksToSaveTransaction(saveTransactionBuilder, chunkProvider);
    addPlayersToSaveTransaction(saveTransactionBuilder, networkSystem);
    addGlobalStoreBuilderToSaveTransaction(saveTransactionBuilder);
    addGameManifestToSaveTransaction(saveTransactionBuilder);

    return saveTransactionBuilder.build();
  }
Esempio n. 29
0
 public LocalChunkProvider(
     StorageManager storageManager, EntityManager entityManager, WorldGenerator generator) {
   this.blockManager = CoreRegistry.get(BlockManager.class);
   this.storageManager = storageManager;
   this.entityManager = entityManager;
   this.generator = generator;
   this.pipeline = new ChunkGenerationPipeline(new ChunkTaskRelevanceComparator());
   this.unloadRequestTaskMaster = TaskMaster.createFIFOTaskMaster("Chunk-Unloader", 4);
   ChunkMonitor.fireChunkProviderInitialized(this);
 }
Esempio n. 30
0
 @Override
 protected void setupBlockManager() {
   DefaultBlockFamilyFactoryRegistry blockFamilyFactoryRegistry =
       new DefaultBlockFamilyFactoryRegistry();
   blockFamilyFactoryRegistry.setBlockFamilyFactory(
       "horizontal", new HorizontalBlockFamilyFactory());
   blockFamilyFactoryRegistry.setBlockFamilyFactory(
       "alignToSurface", new AttachedToSurfaceFamilyFactory());
   WorldAtlas worldAtlas = new NullWorldAtlas();
   BlockManagerImpl blockManager = new BlockManagerImpl(worldAtlas, blockFamilyFactoryRegistry);
   CoreRegistry.put(BlockManager.class, blockManager);
 }