Java Code Examples for net.minecraftforge.fml.common.gameevent.TickEvent#ServerTickEvent

The following examples show how to use net.minecraftforge.fml.common.gameevent.TickEvent#ServerTickEvent . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlanetEventHandler.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@SubscribeEvent
public void tick(TickEvent.ServerTickEvent event) {
	//Tick satellites
	if(event.phase == event.phase.END) {
		DimensionManager.getInstance().tickDimensions();
		time++;

		if(!transitionMap.isEmpty()) {
			Iterator<Entry<Long, TransitionEntity>> itr = transitionMap.entrySet().iterator();

			while(itr.hasNext()) {
				Entry<Long, TransitionEntity> entry = itr.next();
				TransitionEntity ent = entry.getValue();
				if(ent.entity.world.getTotalWorldTime() >= entry.getKey()) {
					ent.entity.setLocationAndAngles(ent.location.getX(), ent.location.getY(), ent.location.getZ(), ent.entity.rotationYaw, ent.entity.rotationPitch);
					ent.entity.getServer().getPlayerList().transferPlayerToDimension((EntityPlayerMP)ent.entity, ent.dimId, new TeleporterNoPortal(ent.entity.getServer().getWorld(ent.dimId)));
					ent.entity.startRiding(ent.entity2);

					itr.remove();
				}
			}
		}
	}
}
 
Example 2
Source File: SpaceObjectManager.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent event) {
	if(DimensionManager.getWorld(Configuration.spaceDimId) == null)
		return;
	
	long worldTime = DimensionManager.getWorld(Configuration.spaceDimId).getTotalWorldTime();
	//Assuming server
	//If no dim undergoing transition then nextTransitionTick = -1
	if((nextStationTransitionTick != -1 && worldTime >= nextStationTransitionTick && spaceStationOrbitMap.get(WARPDIMID) != null) || (nextStationTransitionTick == -1 && spaceStationOrbitMap.get(WARPDIMID) != null && !spaceStationOrbitMap.get(WARPDIMID).isEmpty())) {
		long newNextTransitionTick = -1;
		for(ISpaceObject obj : spaceStationOrbitMap.get(WARPDIMID)) {
			if(obj.getTransitionTime() <= worldTime) {
				moveStationToBody(obj, obj.getDestOrbitingBody());
				spaceStationOrbitMap.get(WARPDIMID).remove(obj);
			}
			else if(newNextTransitionTick == -1 || obj.getTransitionTime() < newNextTransitionTick)
				newNextTransitionTick = obj.getTransitionTime();
		}

		nextStationTransitionTick = newNextTransitionTick;
	}

}
 
Example 3
Source File: EpisodeEventWrapper.java    From malmo with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent ev)
{
    // Pass the event on to the active episode, if there is one:
    this.stateEpisodeLock.readLock().lock();
    if (this.stateEpisode != null && this.stateEpisode.isLive())
    {
        this.stateEpisode.onServerTick(ev);
    }
    this.stateEpisodeLock.readLock().unlock();
}
 
Example 4
Source File: ServerStateMachine.java    From malmo with MIT License 5 votes vote down vote up
@Override
protected void onServerTick(TickEvent.ServerTickEvent ev)
{
    try
    {
        checkForMissionCommand();
    }
    catch (Exception e)
    {
        // TODO: What now?
        e.printStackTrace();
    }
}
 
Example 5
Source File: MalmoModServer.java    From malmo with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent ev)
{
    if (ev.side == Side.SERVER && ev.phase == Phase.START)
    {
        this.serverTickMonitor.beat();
    }
}
 
Example 6
Source File: TickHandler.java    From GokiStats with MIT License 5 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.SERVER)
public void serverTick(TickEvent.ServerTickEvent event) {
    if (event.phase == TickEvent.Phase.END) {
        if (tickTimer.get() == GokiConfig.syncTicks) {
            tickTimer.lazySet(0);
            for (EntityPlayerMP player : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayers()) {
                GokiPacketHandler.CHANNEL.sendTo(new S2CSyncAll(player), player);
            }
        } else {
            tickTimer.getAndIncrement();
        }
    }
}
 
Example 7
Source File: CableTickHandler.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onTick(TickEvent.ServerTickEvent tick) {
	try {
		if(tick.phase == Phase.END) {
			NetworkRegistry.dataNetwork.tickAllNetworks();
			NetworkRegistry.energyNetwork.tickAllNetworks();
			NetworkRegistry.liquidNetwork.tickAllNetworks();
		}
	} catch (ConcurrentModificationException e) {
		e.printStackTrace();
	}
}
 
Example 8
Source File: ServerStateMachine.java    From malmo with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent ev)
{
    // Use the server tick to ensure we regularly update our state (from the server thread)
    updateState();
}
 
Example 9
Source File: FMLEventHandler.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void tickEnd(TickEvent.ServerTickEvent event) {
	if (event.phase == TickEvent.Phase.END) {
		Game.syncTicker().update();
	}
}
 
Example 10
Source File: FMLEventHandler.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void tickEnd(TickEvent.ServerTickEvent event) {
	if (event.phase == TickEvent.Phase.END) {
		Game.syncTicker().update();
	}
}