类net.minecraftforge.fml.common.gameevent.TickEvent.ServerTickEvent源码实例Demo

下面列出了怎么用net.minecraftforge.fml.common.gameevent.TickEvent.ServerTickEvent的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: enderutilities   文件: TickHandler.java
@SubscribeEvent
public void onServerTick(ServerTickEvent event)
{
    if (event.phase == TickEvent.Phase.END)
    {
        return;
    }

    // Once every second
    if (++this.serverTickCounter >= 20)
    {
        this.serverTickCounter = 0;

        ChunkLoading.getInstance().tickChunkTimeouts();
    }

    // This is currently only used for debug tasks, so let's disable it normally
    //TaskScheduler.getInstance().runTasks();

    this.teleportPlayers();
    ++this.playerTickCounter;
}
 
源代码2 项目: malmo   文件: ClientStateMachine.java
@Override
protected void onServerTick(ServerTickEvent ev)
{
    if (this.worldCreated && !this.serverStarted)
    {
        // The server has started ticking - we can set up its state machine,
        // and move on to the next state in our own machine.
        this.serverStarted = true;
        MalmoMod.instance.initIntegratedServer(currentMissionInit()); // Needs to be done from the server thread.
        episodeHasCompleted(ClientState.WAITING_FOR_SERVER_READY);
    }
}
 
源代码3 项目: malmo   文件: ServerStateMachine.java
@Override
protected void onServerTick(TickEvent.ServerTickEvent ev)
{
    try
    {
        checkForMissionCommand();
    }
    catch (Exception e)
    {
        // TODO: What now?
        e.printStackTrace();
    }
}
 
源代码4 项目: malmo   文件: ServerStateMachine.java
@Override
protected void onServerTick(ServerTickEvent ev)
{
    if (!ServerStateMachine.this.checkWatchList())
    {
        // Something has gone wrong - we've lost a connection.
        // Need to respond to this, otherwise we'll sit here forever waiting for a client that no longer exists
        // to tell us it's finished its mission.
        MalmoMod.safeSendToAll(MalmoMessageType.SERVER_ABORT);
        episodeHasCompleted(ServerState.ERROR);
    }
}
 
源代码5 项目: Signals   文件: EventHandler.java
@SubscribeEvent
public void onPostServerTick(ServerTickEvent event){
    if(event.phase == Phase.END) {
        RailNetworkManager.getServerInstance().onPostServerTick();
        ChunkLoadManager.INSTANCE.update();
    }
}
 
源代码6 项目: malmo   文件: StateEpisode.java
/** Subclass should overrride this to act on server ticks.*/
protected void onServerTick(ServerTickEvent ev) {}
 
源代码7 项目: malmo   文件: ServerStateMachine.java
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent ev)
{
    // Use the server tick to ensure we regularly update our state (from the server thread)
    updateState();
}
 
源代码8 项目: malmo   文件: ServerStateMachine.java
@Override
protected void onServerTick(ServerTickEvent ev)
{
    // We wait until we start to get server ticks, at which point we assume Minecraft has finished starting up.
    episodeHasCompleted(ServerState.DORMANT);
}
 
源代码9 项目: malmo   文件: ServerStateMachine.java
@Override
protected void onServerTick(ServerTickEvent ev)
{
    if (!ServerStateMachine.this.checkWatchList())
        onError(null);  // We've lost a connection - abort the mission.
}
 
源代码10 项目: malmo   文件: ServerStateMachine.java
@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++;
    }

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

    if (ev.phase == Phase.END && getHandlers() != null && getHandlers().worldDecorator != null)
    {
        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 (server.getTickCounter() % 500 == 0)
        {
            EnvironmentHelper.setMissionWeather(currentMissionInit(), server.getEntityWorld().getWorldInfo());
        }
    }
}
 
源代码11 项目: Signals   文件: EventHandler.java
@SubscribeEvent
public void onPreServerTick(ServerTickEvent event){
    if(event.phase == Phase.START) {
        RailNetworkManager.getServerInstance().onPreServerTick();
    }
}
 
 类方法
 同包方法