Search in sources :

Example 1 with PacketNetworkStateResponse

use of crazypants.enderio.powertools.machine.capbank.packet.PacketNetworkStateResponse in project EnderIO by SleepyTrousers.

the class CapBankNetwork method tickEnd.

// --------- Tick Handling
@Override
public void tickEnd(TickEvent.ServerTickEvent evt, @Nullable Profiler profiler) {
    Prof.start(profiler, "EnergyTransmitting");
    transmitEnergy();
    if (energyStored != prevEnergyStored) {
        Prof.next(profiler, "EnergyBalancing");
        distributeEnergyToBanks();
    }
    Prof.next(profiler, "EnergyTracking");
    powerTrackerIn.tick(energyReceived);
    powerTrackerOut.tick(energySend);
    prevEnergyStored = energyStored;
    energyReceived = 0;
    energySend = 0;
    Prof.stop(profiler);
    if (firstUpate) {
        if (!capBanks.isEmpty()) {
            PacketHandler.sendToAllAround(new PacketNetworkStateResponse(this), capBanks.get(0));
            PacketHandler.sendToAllAround(new PacketNetworkEnergyResponse(this), capBanks.get(0));
        }
        firstUpate = false;
    }
}
Also used : PacketNetworkEnergyResponse(crazypants.enderio.powertools.machine.capbank.packet.PacketNetworkEnergyResponse) PacketNetworkStateResponse(crazypants.enderio.powertools.machine.capbank.packet.PacketNetworkStateResponse)

Example 2 with PacketNetworkStateResponse

use of crazypants.enderio.powertools.machine.capbank.packet.PacketNetworkStateResponse in project EnderIO by SleepyTrousers.

the class CapBankNetwork method destroyNetwork.

@Override
public void destroyNetwork() {
    ServerTickHandler.removeListener(this);
    distributeEnergyToBanks();
    TileCapBank cap = null;
    for (TileCapBank cb : capBanks) {
        cb.setNetwork(null);
        if (cap == null) {
            cap = cb;
        }
    }
    capBanks.clear();
    if (cap != null) {
        PacketHandler.INSTANCE.sendToAll(new PacketNetworkStateResponse(this, true));
    }
}
Also used : TileCapBank(crazypants.enderio.powertools.machine.capbank.TileCapBank) PacketNetworkStateResponse(crazypants.enderio.powertools.machine.capbank.packet.PacketNetworkStateResponse)

Aggregations

PacketNetworkStateResponse (crazypants.enderio.powertools.machine.capbank.packet.PacketNetworkStateResponse)2 TileCapBank (crazypants.enderio.powertools.machine.capbank.TileCapBank)1 PacketNetworkEnergyResponse (crazypants.enderio.powertools.machine.capbank.packet.PacketNetworkEnergyResponse)1