当前位置: 首页>>代码示例>>Java>>正文


Java DimensionManager.getIDs方法代码示例

本文整理汇总了Java中net.minecraftforge.common.DimensionManager.getIDs方法的典型用法代码示例。如果您正苦于以下问题:Java DimensionManager.getIDs方法的具体用法?Java DimensionManager.getIDs怎么用?Java DimensionManager.getIDs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.common.DimensionManager的用法示例。


在下文中一共展示了DimensionManager.getIDs方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getData

import net.minecraftforge.common.DimensionManager; //导入方法依赖的package包/类
public static Data getData()
{
    if (data != null) return data;

    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();

    Integer[] dimsObj = DimensionManager.getIDs();
    TIntDoubleMap map = new TIntDoubleHashMap(dimsObj.length);

    for (Integer dim : dimsObj)
    {
        map.put(dim, mean(server.worldTickTimes.get(dim)) * 1.0E-6D);
    }

    double meanTickTime = mean(server.tickTimeArray) * 1.0E-6D;

    int total = (int) (Runtime.getRuntime().totalMemory() / 1024 / 1024);
    int max = (int) (Runtime.getRuntime().maxMemory() / 1024 / 1024);
    int free = (int) (Runtime.getRuntime().freeMemory() / 1024 / 1024);

    data = new Data(meanTickTime, map, free, total, max);
    return data;
}
 
开发者ID:dries007,项目名称:DebugServerInfo,代码行数:24,代码来源:ServerHelper.java

示例2: tickEvent

import net.minecraftforge.common.DimensionManager; //导入方法依赖的package包/类
/**
 * Collect tick performance data for the loaded dimensions and broadcast to
 * attached players.
 * 
 * @param event
 */
@SubscribeEvent
public void tickEvent(@Nonnull final TickEvent.ServerTickEvent event) {
	if (!ModOptions.reportServerStats || event.phase != Phase.END)
		return;

	// Spam once a second
	if ((++tpsCount % 20) != 0)
		return;

	MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();

	final TIntDoubleHashMap map = new TIntDoubleHashMap();
	for (Integer dim : DimensionManager.getIDs()) {
		map.put(dim.intValue(), mean((long[]) server.worldTickTimes.get(dim)) / 1000000D);
	}

	final double meanTickTime = mean(server.tickTimeArray) / 1000000D;
	final int total = (int) (Runtime.getRuntime().totalMemory() / 1024L / 1024L);
	final int max = (int) (Runtime.getRuntime().maxMemory() / 1024L / 1024L);
	final int free = (int) (Runtime.getRuntime().freeMemory() / 1024L / 1024L);

	final PacketServerData packet = new PacketServerData(map, meanTickTime, free, total, max);
	Network.sendToAll(packet);
}
 
开发者ID:OreCruncher,项目名称:DynamicSurroundings,代码行数:31,代码来源:ServiceManager.java

示例3: update

import net.minecraftforge.common.DimensionManager; //导入方法依赖的package包/类
@Override
public void update() {
    if (inventory[0] != null && inventory[0].hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, EnumFacing.DOWN) &&
            inventory[0].hasCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN)) {
        ITeslaConsumer c = inventory[0].getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, EnumFacing.DOWN);
        ITeslaHolder h = inventory[0].getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN);
        if (h.getStoredPower() < h.getCapacity()) container.takePower(c.givePower(Math.min(container.getOutputRate(), container.getStoredPower()), false), false);
    }
    if(syncTick==10 && !worldObj.isRemote){
        if(pos!=null){
            int dim = 0;
            for(int i : DimensionManager.getIDs())
                if(DimensionManager.getWorld(i).equals(worldObj)) {
                    dim = i;
                    break;
                }
            ModSquad.channel.sendToAll(new TileDataSync(pos, serializeNBT().toString(), dim));
        }
        syncTick = 0;
    }else if(syncTick<10) ++syncTick;
}
 
开发者ID:tjkenmate,项目名称:TeslaEssentials,代码行数:22,代码来源:TileCharger.java

示例4: getTPS

import net.minecraftforge.common.DimensionManager; //导入方法依赖的package包/类
private String getTPS(MinecraftServer server, EntityPlayerSP player) {
    int dim = player.world.provider.getDimension();
    boolean summary = true;
    if (summary) {
        for (Integer dimId : DimensionManager.getIDs()) {
            double worldTickTime = mean(server.worldTickTimes.get(dimId)) * 1.0E-6D;
            double worldTPS = Math.min(1000.0 / worldTickTime, 20);
        }
        double meanTickTime = mean(server.tickTimeArray) * 1.0E-6D;
        double meanTPS = Math.min(1000.0 / meanTickTime, 20);
        return "MSPT: " + timeFormatter.format(meanTickTime) + " : TPS: " + timeFormatter.format(meanTPS);
    }
    return "";
}
 
开发者ID:jaredlll08,项目名称:Machines-and-Stuff,代码行数:15,代码来源:ClientEvents.java

示例5: MessageProfiler

import net.minecraftforge.common.DimensionManager; //导入方法依赖的package包/类
public MessageProfiler(List<Result> profilingData, String loc) {
	this.profilingData = profilingData;
	this.loc = loc;
	dimTps = new HashMap<>();
	MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
	for (Integer dimId : DimensionManager.getIDs()) {
		double worldTickTime = mean(server.worldTickTimes.get(dimId)) * 1.0E-6D;
		double worldTPS = Math.min(1000.0 / worldTickTime, 20);
		dimTps.put(dimId, Pair.of(worldTickTime, worldTPS));
	}
	meanTickTime = mean(server.tickTimeArray) * 1.0E-6D;
	meanTPS = Math.min(1000.0 / meanTickTime, 20);
}
 
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:14,代码来源:MessageProfiler.java

示例6: execute

import net.minecraftforge.common.DimensionManager; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    for(int id : DimensionManager.getIDs())
    {
        World world = DimensionManager.getWorld(id);
        int chunkCount = getChunkCount(ForgeChunkManager.getPersistentChunksFor(world));

        sender.sendMessage(new TextComponentString(chunkCount + " chunks loaded in dim " + id));
    }
}
 
开发者ID:CorwinJV,项目名称:AChunkLoader,代码行数:11,代码来源:CommandStats.java

示例7: writeToNBT

import net.minecraftforge.common.DimensionManager; //导入方法依赖的package包/类
@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
    compound.setTag("Container", container.serializeNBT());
    compound = super.writeToNBT(compound);
    if(pos!=null){
        int dim = 0;
        for(int i : DimensionManager.getIDs())
            if(DimensionManager.getWorld(i).equals(worldObj)) {
                dim = i;
                break;
            }
        ModSquad.channel.sendToAll(new TileDataSync(pos, compound.toString(), dim));
    }
    return compound;
}
 
开发者ID:tjkenmate,项目名称:TeslaEssentials,代码行数:16,代码来源:TileCapacitor.java

示例8: writeToNBT

import net.minecraftforge.common.DimensionManager; //导入方法依赖的package包/类
@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
    compound.setTag("Container", solarContainer.serializeNBT());
    compound = super.writeToNBT(compound);
    if(pos!=null){
        int dim = 0;
        for(int i : DimensionManager.getIDs())
            if(DimensionManager.getWorld(i).equals(worldObj)) {
                dim = i;
                break;
            }
        ModSquad.channel.sendToAll(new TileDataSync(pos, compound.toString(), dim));
    }
    return compound;
}
 
开发者ID:tjkenmate,项目名称:TeslaEssentials,代码行数:16,代码来源:TileSolarPanel.java

示例9: 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

示例10: getFormattedLoadedDimensionsDump

import net.minecraftforge.common.DimensionManager; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static List<String> getFormattedLoadedDimensionsDump()
{
    DimensionDump dimensionDump = new DimensionDump(7);
    Integer[] ids = DimensionManager.getIDs();

    for (int i = 0; i < ids.length; i++)
    {
        WorldServer world = DimensionManager.getWorld(ids[i]);
        DimensionType type = DimensionManager.getProviderType(ids[i]);

        if (world == null || type == null)
        {
            continue;
        }

        String dimId = ids[i].toString();
        String typeId = String.valueOf(type.getId());
        String name = type.getName();
        String shouldLoadSpawn = String.valueOf(type.shouldLoadSpawn());
        String worldProviderClass;
        String loadedChunks = String.valueOf(WorldUtils.getLoadedChunkCount(world));
        String loadedEntities = String.valueOf(world.loadedEntityList.size());

        try
        {
            worldProviderClass = ((Class<? extends WorldProvider>) field_worldProvider.get(type)).getSimpleName();
        }
        catch (Exception e)
        {
            worldProviderClass = "ERROR";
        }

        dimensionDump.addData(dimId, typeId, name, shouldLoadSpawn, worldProviderClass, loadedChunks, loadedEntities);
    }

    dimensionDump.addTitle("ID", "Type ID", "Name", "Load Spawn?", "WorldProvider class", "Loaded chunks", "Loaded entities");
    dimensionDump.setColumnAlignment(0, Alignment.RIGHT); // dim ID
    dimensionDump.setColumnAlignment(1, Alignment.RIGHT); // type ID
    dimensionDump.setColumnAlignment(3, Alignment.RIGHT); // shouldLoadSpawn
    dimensionDump.setColumnAlignment(5, Alignment.RIGHT); // loaded chunks
    dimensionDump.setColumnAlignment(6, Alignment.RIGHT); // loaded entities
    dimensionDump.setUseColumnSeparator(true);

    return dimensionDump.getLines();
}
 
开发者ID:maruohon,项目名称:justenoughdimensions,代码行数:47,代码来源:DimensionDump.java


注:本文中的net.minecraftforge.common.DimensionManager.getIDs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。