本文整理汇总了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);
}
示例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();
}
示例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;
}
示例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;
}