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


Java MinecraftServer.getEntityWorld方法代碼示例

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


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

示例1: shouldCreateWorld

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
@Override
public boolean shouldCreateWorld(MissionInit missionInit)
{
    if (this.dwparams != null && this.dwparams.isForceReset())
        return true;
    
	World world = null;
	MinecraftServer server = MinecraftServer.getServer();
	if (server.worldServers != null && server.worldServers.length != 0)
		world = server.getEntityWorld();

	if (Minecraft.getMinecraft().theWorld == null || world == null)
        return true;    // Definitely need to create a world if there isn't one in existence!

    String genOptions = world.getWorldInfo().getGeneratorOptions();
    if (genOptions != null && !genOptions.isEmpty())
    	return true;	// Default world has no generator options.

    return false;
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:21,代碼來源:DefaultWorldGeneratorImplementation.java

示例2: shouldCreateWorld

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
@Override
public boolean shouldCreateWorld(MissionInit missionInit)
{
    if (this.fwparams != null && this.fwparams.isForceReset())
        return true;

    World world = null;
    MinecraftServer server = MinecraftServer.getServer();
    if (server.worldServers != null && server.worldServers.length != 0)
        world = server.getEntityWorld();

    if (world == null)
        return true;   // There is no world, so we definitely need to create one.

    String name = (world != null) ? world.getWorldInfo().getWorldName() : "";
    // Extract the name from the path (need to cope with backslashes or forward slashes.)
    String mapfile = (this.mapFilename == null) ? "" : this.mapFilename;    // Makes no sense to have an empty filename, but createWorld will deal with it graciously.
    String[] parts = mapfile.split("[\\\\/]");
    if (name.length() > 0 && parts[parts.length - 1].equalsIgnoreCase(name) && Minecraft.getMinecraft().theWorld != null)
        return false;	// We don't check whether the game modes match - it's up to the server state machine to sort that out.

    return true;	// There's no world, or the world is different to the basemap file, so create.
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:24,代碼來源:FileWorldGeneratorImplementation.java

示例3: shouldCreateWorld

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
@Override
public boolean shouldCreateWorld(MissionInit missionInit)
{
	World world = null;
	MinecraftServer server = MinecraftServer.getServer();
	if (server.worldServers != null && server.worldServers.length != 0)
		world = server.getEntityWorld();
	
	if (this.fwparams != null && this.fwparams.isForceReset())
	    return true;
	
    if (Minecraft.getMinecraft().theWorld == null && world == null)
        return true;    // Definitely need to create a world if there isn't one in existence!
    
    String genOptions = world.getWorldInfo().getGeneratorOptions();
    if (!genOptions.equals(this.fwparams.getGeneratorString()))
        return true;    // Generation doesn't match, so recreate.
    
    return false;
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:21,代碼來源:FlatWorldGeneratorImplementation.java

示例4: getWorldTime

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
@Override
protected long getWorldTime()
{
   	World world = null;
   	MinecraftServer server = MinecraftServer.getServer();
   	if (server.worldServers != null && server.worldServers.length != 0)
   		world = server.getEntityWorld();
	return (world != null) ? world.getTotalWorldTime() : 0;
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:10,代碼來源:ServerQuitFromTimeUpImplementation.java

示例5: onServerTick

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
@SubscribeEvent
public void onServerTick(ServerTickEvent e)
{
	if(counter == 1)
	{
		MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
		World world = server.getEntityWorld();
	
		if(world.isRemote == false) 
		{
		
			long totalTime = world.getWorldTime();
			long currentTime = totalTime % 24000;
		
			if(currentTime == 1)
			{
				System.out.println("Time is 0");
				WorldTurn turn = WorldTurn.get(world);
				int currentTurn = turn.advanceTurn();
				System.out.println("New Turn!!  The World Turn is now " + currentTurn);
				ArrayList<EntityPlayerMP> playerList = (ArrayList<EntityPlayerMP>)(world.getMinecraftServer().getServer().getPlayerList().getPlayers());
				for(int i=0; i < playerList.size(); i++)
				{
					EntityPlayer player = playerList.get(i);
					ITurn playerTurn = player.getCapability(CapPlayerTurn.TURN_CAP, null);
					playerTurn.addTurn();
				}
			}
		}
		
		counter = 0;
	}
	else
	{
		counter++;
	}
}
 
開發者ID:stuebz88,項目名稱:modName,代碼行數:38,代碼來源:EventHandlerCommon.java

示例6: onServerTick

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
@Override
protected void onServerTick(ServerTickEvent ev)
{
    if (this.missionHasEnded)
        return;	// In case we get in here after deciding the mission is over.
    
    if (!ServerStateMachine.this.checkWatchList())
        onError(null);  // We've lost a connection - abort the mission.
    
    if (ev.phase == Phase.START)
    {
        // Measure our performance - especially useful if we've been overclocked.
        if (this.secondStartTimeMs == 0)
            this.secondStartTimeMs = System.currentTimeMillis();

        long timeNow = System.currentTimeMillis();
        if (timeNow - this.secondStartTimeMs > 1000)
        {
            long targetTicks = 1000 / TimeHelper.serverTickLength;
            if (this.tickCount < targetTicks)
                System.out.println("Warning: managed " + this.tickCount + "/" + targetTicks + " ticks this second.");
            this.secondStartTimeMs = timeNow;
            this.tickCount = 0;
        }
        this.tickCount++;
    }

    if (ev.phase == Phase.END && getHandlers() != null && getHandlers().worldDecorator != null)
    {
        MinecraftServer server = MinecraftServer.getServer();
        if (server.worldServers != null && server.worldServers.length != 0)
        {
            World world = server.getEntityWorld();
            getHandlers().worldDecorator.update(world);
        }
    }

    if (ev.phase == Phase.END)
    {
        if (getHandlers() != null && getHandlers().quitProducer != null && getHandlers().quitProducer.doIWantToQuit(currentMissionInit()))
        {
            ServerStateMachine.this.quitCode = getHandlers().quitProducer.getOutcome();
            onMissionEnded(true);
        }
        else if (this.runningAgents.isEmpty())
        {
            ServerStateMachine.this.quitCode = "All agents finished";
            onMissionEnded(true);
        }
        // We need to make sure we keep the weather within mission parameters.
        // We set the weather just after building the world, but it's not a permanent setting,
        // and apparently there is a known bug in Minecraft that means the weather sometimes changes early.
        // To get around this, we reset it periodically.
        if (MinecraftServer.getServer().getTickCounter() % 500 == 0)
        {
            EnvironmentHelper.setMissionWeather(currentMissionInit());
        }
    }
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:60,代碼來源:ServerStateMachine.java


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