Search in sources :

Example 11 with IErrorState

use of forestry.api.core.IErrorState in project ForestryMC by ForestryMC.

the class ContainerTile method detectAndSendChanges.

@Override
public void detectAndSendChanges() {
    super.detectAndSendChanges();
    if (tile instanceof IErrorLogicSource) {
        IErrorLogicSource errorLogicSource = (IErrorLogicSource) tile;
        ImmutableSet<IErrorState> errorStates = errorLogicSource.getErrorLogic().getErrorStates();
        if (previousErrorStates == null || !errorStates.equals(previousErrorStates)) {
            PacketErrorUpdate packet = new PacketErrorUpdate(tile, errorLogicSource);
            sendPacketToListeners(packet);
        }
        previousErrorStates = errorStates;
    }
    if (tile instanceof IPowerHandler) {
        EnergyManager energyManager = ((IPowerHandler) tile).getEnergyManager();
        int energyManagerData = energyManager.getEnergyStored();
        if (energyManagerData != previousEnergyManagerData) {
            PacketGuiEnergy packet = new PacketGuiEnergy(windowId, energyManagerData);
            sendPacketToListeners(packet);
            previousEnergyManagerData = energyManagerData;
        }
    }
    if (tile instanceof TilePowered) {
        boolean guiNeedsUpdate = false;
        TilePowered tilePowered = (TilePowered) tile;
        int workCounter = tilePowered.getWorkCounter();
        if (workCounter != previousWorkCounter) {
            guiNeedsUpdate = true;
            previousWorkCounter = workCounter;
        }
        int ticksPerWorkCycle = tilePowered.getTicksPerWorkCycle();
        if (ticksPerWorkCycle != previousTicksPerWorkCycle) {
            guiNeedsUpdate = true;
            previousTicksPerWorkCycle = ticksPerWorkCycle;
        }
        if (guiNeedsUpdate) {
            PacketGuiUpdate packet = new PacketGuiUpdate(tilePowered);
            sendPacketToListeners(packet);
        }
    }
}
Also used : PacketErrorUpdate(forestry.core.network.packets.PacketErrorUpdate) PacketGuiUpdate(forestry.core.network.packets.PacketGuiUpdate) IErrorState(forestry.api.core.IErrorState) EnergyManager(forestry.energy.EnergyManager) IPowerHandler(forestry.core.tiles.IPowerHandler) PacketGuiEnergy(forestry.core.network.packets.PacketGuiEnergy) TilePowered(forestry.core.tiles.TilePowered) IErrorLogicSource(forestry.api.core.IErrorLogicSource)

Example 12 with IErrorState

use of forestry.api.core.IErrorState in project ForestryMC by ForestryMC.

the class LedgerManager method drawLedgers.

public void drawLedgers() {
    int yPos = 8;
    for (Ledger ledger : ledgers) {
        ledger.update();
        if (!ledger.isVisible()) {
            continue;
        }
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        ledger.setPosition(gui.getSizeX(), yPos);
        ledger.draw();
        yPos += ledger.getHeight();
    }
    List<IErrorState> errorStates = new ArrayList<>(errorSource.getErrorStates());
    yPos = 8;
    int index = 0;
    for (ErrorLedger errorLedger : errorLedgers) {
        if (index >= errorStates.size()) {
            errorLedger.setState(null);
            continue;
        }
        IErrorState errorState = errorStates.get(index++);
        errorLedger.setState(errorState);
        errorLedger.update();
        if (!errorLedger.isVisible()) {
            continue;
        }
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        errorLedger.draw(-errorLedger.getWidth(), yPos);
        yPos += errorLedger.getHeight();
    }
    GlStateManager.color(1, 1, 1, 1);
}
Also used : IErrorState(forestry.api.core.IErrorState) ArrayList(java.util.ArrayList)

Aggregations

IErrorState (forestry.api.core.IErrorState)12 EnumHumidity (forestry.api.core.EnumHumidity)3 EnumTemperature (forestry.api.core.EnumTemperature)3 EnumTolerance (forestry.api.genetics.EnumTolerance)3 HashSet (java.util.HashSet)3 ItemStack (net.minecraft.item.ItemStack)3 World (net.minecraft.world.World)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 IErrorLogic (forestry.api.core.IErrorLogic)2 IErrorLogicSource (forestry.api.core.IErrorLogicSource)2 IAlleleButterflySpecies (forestry.api.lepidopterology.IAlleleButterflySpecies)2 IGreenhouseBlock (forestry.greenhouse.api.greenhouse.IGreenhouseBlock)2 IGreenhouseBlockHandler (forestry.greenhouse.api.greenhouse.IGreenhouseBlockHandler)2 BlockPos (net.minecraft.util.math.BlockPos)2 EnumBeeType (forestry.api.apiculture.EnumBeeType)1 IAlleleBeeSpecies (forestry.api.apiculture.IAlleleBeeSpecies)1 IBee (forestry.api.apiculture.IBee)1 IBeeHousingInventory (forestry.api.apiculture.IBeeHousingInventory)1 IBeeModifier (forestry.api.apiculture.IBeeModifier)1 IGreenhouseController (forestry.api.multiblock.IGreenhouseController)1