當前位置: 首頁>>代碼示例>>Java>>正文


Java DimensionManager.unloadWorld方法代碼示例

本文整理匯總了Java中net.minecraftforge.common.DimensionManager.unloadWorld方法的典型用法代碼示例。如果您正苦於以下問題:Java DimensionManager.unloadWorld方法的具體用法?Java DimensionManager.unloadWorld怎麽用?Java DimensionManager.unloadWorld使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.common.DimensionManager的用法示例。


在下文中一共展示了DimensionManager.unloadWorld方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deleteDimension

import net.minecraftforge.common.DimensionManager; //導入方法依賴的package包/類
public void deleteDimension(ICommandSender sender, int dimensionID)
{
	if (!dimensionInfo.containsKey(dimensionID))
	{
		sender.sendMessage(new TextComponentString("The dimension associated with that id is not from the SimpleDimensions mod").setStyle(new Style().setColor(TextFormatting.RED)));
		return;
	}

	World worldObj = DimensionManager.getWorld(dimensionID);

	if (worldObj.playerEntities.size() > 0)
	{
		sender.sendMessage(new TextComponentString("Can't delete a dimension with players inside it").setStyle(new Style().setColor(TextFormatting.RED)));
		return;
	}

	Entity entitySender = sender.getCommandSenderEntity();
	toBeDeleted.put(dimensionID, entitySender != null ? entitySender.getUniqueID() : null);

	DimensionManager.unloadWorld(dimensionID);
}
 
開發者ID:lumien231,項目名稱:Simple-Dimensions,代碼行數:22,代碼來源:DimensionHandler.java

示例2: unloadAll

import net.minecraftforge.common.DimensionManager; //導入方法依賴的package包/類
public static void unloadAll(FMLServerStoppingEvent serverStoppingEvent) {
    File worldFile = new File(FMLCommonHandler.instance().getSavesDirectory(), FMLCommonHandler.instance().getMinecraftServerInstance().getFolderName());
    File dataFile = new File(worldFile, fileName);

    if (dimDataList == null || dimDataList.isEmpty()) {
        return;
    }
    Gson gson = new GsonBuilder().setPrettyPrinting().create();
    String json = gson.toJson(dimDataList);
    try {
        if (dataFile.exists()) {
            dataFile.delete();
        }
        FileUtils.writeStringToFile(dataFile, json);
    } catch (IOException e) {
        e.printStackTrace();
    }

    for (DimData data : dimDataList) {
        DimensionManager.unloadWorld(data.id);
        DimensionManager.unregisterDimension(data.id);
    }
    dimDataList.clear();
    dimDataHashMap.clear();
}
 
開發者ID:modmuss50,項目名稱:TechnicalDimensions,代碼行數:26,代碼來源:ModDimensions.java

示例3: tick

import net.minecraftforge.common.DimensionManager; //導入方法依賴的package包/類
@Override
public boolean tick() {
    if (!this.world.disableLevelSaving) {
        if (!this.droppedChunksSet.isEmpty()) {
            for (ChunkPos forced : this.world.getPersistentChunks().keySet()) {
                this.droppedChunksSet.remove(ChunkPos.asLong(forced.chunkXPos, forced.chunkZPos));
            }
            Iterator<Long> iterator = this.droppedChunksSet.iterator();
            for (int i = 0; i < 100 && iterator.hasNext(); iterator.remove()) {
                Long id = iterator.next();
                Chunk chunk = this.id2ChunkMap.get(id);
                if (chunk != null && chunk.unloaded) {
                    chunk.onChunkUnload();
                    this.saveChunkData(chunk);
                    this.saveChunkExtraData(chunk);
                    this.id2ChunkMap.remove(id);
                    ++i;
                    if (this.id2ChunkMap.size() == 0 && ForgeChunkManager.getPersistentChunksFor(this.world).size() == 0 && !this.world.provider.getDimensionType().shouldLoadSpawn()) {
                        DimensionManager.unloadWorld(this.world.provider.getDimension());
                        break;
                    }
                }
            }
        }
        this.chunkLoader.chunkTick();
    }
    return false;
}
 
開發者ID:gegy1000,項目名稱:BlockSystems,代碼行數:29,代碼來源:ServerChunkCacheBlockSystem.java

示例4: unloadEmptyDimensions

import net.minecraftforge.common.DimensionManager; //導入方法依賴的package包/類
/**
 * Unloads all empty dimensions (with no chunks loaded)
 * @param tryUnloadChunks if true, then tries to first save and unload all non-player-loaded and non-force-loaded chunks
 * @return the number of dimensions successfully unloaded
 */
public static int unloadEmptyDimensions(boolean tryUnloadChunks)
{
    int count = 0;
    Integer[] dims = DimensionManager.getIDs();

    JustEnoughDimensions.logInfo("WorldUtils.unloadEmptyDimensions(): Trying to unload empty dimensions, tryUnloadChunks = {}", tryUnloadChunks);

    for (int dim : dims)
    {
        JustEnoughDimensions.logInfo("WorldUtils.unloadEmptyDimensions(): Trying to unload dimension {}", dim);
        WorldServer world = DimensionManager.getWorld(dim);

        if (world == null)
        {
            continue;
        }

        ChunkProviderServer chunkProviderServer = world.getChunkProvider();

        if (tryUnloadChunks && chunkProviderServer.getLoadedChunkCount() > 0)
        {
            JustEnoughDimensions.logInfo("WorldUtils.unloadEmptyDimensions(): Trying to unload chunks for dimension {}", dim);
            boolean disable = world.disableLevelSaving;
            world.disableLevelSaving = false;

            try
            {
                // This also tries to unload all chunks that are not loaded by players
                world.saveAllChunks(true, (IProgressUpdate) null);
            }
            catch (MinecraftException e)
            {
                JustEnoughDimensions.logger.warn("WorldUtils.unloadEmptyDimensions(): Exception while "+
                                                 "trying to save chunks for dimension {}", world.provider.getDimension(), e);
            }

            // This would flush the chunks to disk from the AnvilChunkLoader. Probably not what we want to do.
            //world.saveChunkData();

            world.disableLevelSaving = disable;

            // This will unload the dimension, if it unloaded at least one chunk, and it has no loaded chunks anymore
            chunkProviderServer.tick();

            if (chunkProviderServer.getLoadedChunkCount() == 0)
            {
                count++;
            }
        }
        else if (chunkProviderServer.getLoadedChunkCount() == 0 &&
            world.provider.getDimensionType().shouldLoadSpawn() == false &&
            ForgeChunkManager.getPersistentChunksFor(world).size() == 0)
        {
            DimensionManager.unloadWorld(world.provider.getDimension());
            count++;
        }
    }

    return count;
}
 
開發者ID:maruohon,項目名稱:justenoughdimensions,代碼行數:66,代碼來源:WorldUtils.java


注:本文中的net.minecraftforge.common.DimensionManager.unloadWorld方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。