Search in sources :

Example 1 with PacketServerTickTime

use of pneumaticCraft.common.network.PacketServerTickTime in project PneumaticCraft by MineMaarten.

the class TickHandlerPneumaticCraft method tickEnd.

@SubscribeEvent
public void tickEnd(TickEvent.WorldTickEvent event) {
    if (event.phase == TickEvent.Phase.END) {
        World world = event.world;
        checkLightning(world);
        DroneClaimManager.getInstance(world).update();
        if (!event.world.isRemote && event.world.provider.dimensionId == 0 && event.world.getWorldTime() % (24000 / AmadronOfferPeriodicConfig.timesPerDay) == 1) {
            AmadronOfferManager.getInstance().shufflePeriodicOffers();
        }
        if (!event.world.isRemote && event.world.getTotalWorldTime() % 100 == 0) {
            // In case world are going to get their own thread: MinecraftServer.getServer().worldTickTimes.get(event.world.provider.dimensionId)
            double tickTime = net.minecraft.util.MathHelper.average(MinecraftServer.getServer().tickTimeArray) * 1.0E-6D;
            NetworkHandler.sendToDimension(new PacketServerTickTime(tickTime), event.world.provider.dimensionId);
            if (event.world.getTotalWorldTime() % 600 == 0)
                AmadronOfferManager.getInstance().tryRestockCustomOffers();
        }
    }
}
Also used : PacketServerTickTime(pneumaticCraft.common.network.PacketServerTickTime) World(net.minecraft.world.World) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 World (net.minecraft.world.World)1 PacketServerTickTime (pneumaticCraft.common.network.PacketServerTickTime)1