本文整理匯總了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;
}