net.minecraftforge.fml.common.gameevent.TickEvent.WorldTickEvent Java Examples

The following examples show how to use net.minecraftforge.fml.common.gameevent.TickEvent.WorldTickEvent. 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: WorldEventsCommon.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@SubscribeEvent
public void worldTick(WorldTickEvent event) {
    if (event.phase == Phase.START) {
        for (Entity entity : event.world.loadedEntityList) {
            if (entity instanceof EntityItem) {
                EntityItem itemEntity = (EntityItem) entity;
                ItemStack itemStack = itemEntity.getItem();
                ICapabilityAntiGravity capability = itemStack.getCapability(ValkyrienSkiesWorld.ANTI_GRAVITY_CAPABILITY, null);
                if (capability != null) {
                    if (capability.getMultiplier() != 0) {
                        double multiplier = 0.12 / capability.getMultiplier(); // trust me it multiplies Y increase
                        itemEntity.addVelocity(0, .1 - (itemEntity.motionY * multiplier), 0);
                    }
                }
            }
        }
    }
}
 
Example #2
Source File: EventsCommon.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onWorldTickEvent(WorldTickEvent event) {
    // This only gets called server side, because forge wants it that way. But in case they
    // change their mind, this exception will crash the game to notify us of the change.
    if (event.side == Side.CLIENT) {
        throw new IllegalStateException("This event should never get called client side");
    }
    World world = event.world;
    switch (event.phase) {
        case START:
            PhysicsTickHandler.onWorldTickStart(world);
            break;
        case END:
            IHasShipManager shipManager = (IHasShipManager) world;
            shipManager.getManager().tick();
            PhysicsTickHandler.onWorldTickEnd(world);
            break;
    }
}
 
Example #3
Source File: ServerTickHandler.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void onServerWorldTick(WorldTickEvent event)
{
	World world = event.world;
	if(event.phase == Phase.START)
	{
		if(WorldGen.getInstance() != null)
		{
			if(world.provider.getDimension() == 0)
			{
				WorldGen.getInstance().trimCache();
				WorldGen.getInstance().buildFromQueue();
				WorldGen.getInstance().runUpdateLoop(event.world);
			}
		}			
	}
}
 
Example #4
Source File: Timer.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void handleWorldTick(WorldTickEvent event) {
	if (queue.size() < 1) {
		return;
	}
	runNextQueueItem();
}
 
Example #5
Source File: DelayedActionTickHandler.java    From OpenModsLib with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onWorldTick(WorldTickEvent evt) {
	if (evt.side == Side.SERVER && evt.phase == Phase.END) {
		int worldId = evt.world.provider.getDimension();
		Queue<Runnable> callbacks = getWorldQueue(worldId);

		Runnable callback;
		while ((callback = callbacks.poll()) != null) {
			callback.run();
		}
	}
}
 
Example #6
Source File: TickableWorldPipeNetEventHandler.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public static void onWorldTick(WorldTickEvent event) {
    getPipeNetsForWorld(event.world).forEach(TickableWorldPipeNet::update);
}
 
Example #7
Source File: EventHandlers.java    From ToroQuest with GNU General Public License v3.0 2 votes vote down vote up
@SubscribeEvent
public void handleWorldTick(WorldTickEvent event) {

}