Search in sources :

Example 1 with TileEntitySolarTransmitter

use of micdoodle8.mods.galacticraft.planets.venus.tile.TileEntitySolarTransmitter in project Galacticraft by micdoodle8.

the class VenusTickHandlerServer method onServerTick.

@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent event) {
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    // Prevent issues when clients switch to LAN servers
    if (server == null) {
        return;
    }
    if (event.phase == Phase.END) {
        for (SolarModuleNetwork network : new ArrayList<>(solarModuleNetworks)) {
            if (!network.getTransmitters().isEmpty()) {
            // network.tickEnd();
            } else {
                solarModuleNetworks.remove(network);
            }
        }
        int maxPasses = 10;
        while (!solarTransmitterUpdates.isEmpty()) {
            LinkedList<TileEntitySolarTransmitter> pass = new LinkedList<>();
            pass.addAll(solarTransmitterUpdates);
            solarTransmitterUpdates.clear();
            for (TileEntitySolarTransmitter newTile : pass) {
                if (!newTile.isInvalid()) {
                    newTile.refresh();
                }
            }
            if (--maxPasses <= 0) {
                break;
            }
        }
    }
}
Also used : TileEntitySolarTransmitter(micdoodle8.mods.galacticraft.planets.venus.tile.TileEntitySolarTransmitter) SolarModuleNetwork(micdoodle8.mods.galacticraft.planets.venus.tile.SolarModuleNetwork) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) MinecraftServer(net.minecraft.server.MinecraftServer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 SolarModuleNetwork (micdoodle8.mods.galacticraft.planets.venus.tile.SolarModuleNetwork)1 TileEntitySolarTransmitter (micdoodle8.mods.galacticraft.planets.venus.tile.TileEntitySolarTransmitter)1 MinecraftServer (net.minecraft.server.MinecraftServer)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1