Search in sources :

Example 1 with IPrismTransmissionNode

use of hellfirepvp.astralsorcery.common.starlight.transmission.IPrismTransmissionNode in project AstralSorcery by HellFirePvP.

the class LightNetworkBuffer method onLoad.

@Override
public void onLoad(World world) {
    super.onLoad(world);
    if (LightNetworkConfig.CONFIG.performNetworkIntegrityCheck.get()) {
        AstralSorcery.log.info("[LightNetworkIntegrityCheck] Performing StarlightNetwork integrity check for world " + world.getDimensionKey().getLocation());
        List<IPrismTransmissionNode> invalidRemoval = new LinkedList<>();
        for (ChunkNetworkData data : getSections()) {
            for (ChunkSectionNetworkData secData : data.sections.values()) {
                for (IPrismTransmissionNode node : secData.getAllTransmissionNodes()) {
                    IStarlightTransmission<?> te = MiscUtils.getTileAt(world, node.getLocationPos(), IStarlightTransmission.class, true);
                    if (te == null) {
                        invalidRemoval.add(node);
                        continue;
                    }
                    IPrismTransmissionNode newNode = te.provideTransmissionNode(node.getLocationPos());
                    if (!node.getClass().isAssignableFrom(newNode.getClass())) {
                        invalidRemoval.add(node);
                        continue;
                    }
                    if (node.needsUpdate()) {
                        StarlightUpdateHandler.getInstance().addNode(world, node);
                    }
                    node.postLoad(world);
                }
            }
        }
        AstralSorcery.log.info("[LightNetworkIntegrityCheck] Performed StarlightNetwork integrity check. Found " + invalidRemoval.size() + " invalid transmission nodes.");
        for (IPrismTransmissionNode node : invalidRemoval) {
            removeTransmission(node.getLocationPos());
        }
        AstralSorcery.log.info("[LightNetworkIntegrityCheck] Removed invalid transmission nodes from the network.");
    } else {
        for (ChunkNetworkData data : getSections()) {
            for (ChunkSectionNetworkData secData : data.sections.values()) {
                for (IPrismTransmissionNode node : secData.getAllTransmissionNodes()) {
                    if (node.needsUpdate()) {
                        StarlightUpdateHandler.getInstance().addNode(world, node);
                    }
                    node.postLoad(world);
                }
            }
        }
    }
}
Also used : IPrismTransmissionNode(hellfirepvp.astralsorcery.common.starlight.transmission.IPrismTransmissionNode)

Example 2 with IPrismTransmissionNode

use of hellfirepvp.astralsorcery.common.starlight.transmission.IPrismTransmissionNode in project AstralSorcery by HellFirePvP.

the class WorldNetworkHandler method removeThisSourceFromNext.

// What it does: For all "next"'s of this "tr" inform them that "tr" has been removed and
// thus remove "tr" from their sources.
private void removeThisSourceFromNext(IStarlightTransmission<?> tr) {
    IPrismTransmissionNode node = tr.getNode();
    if (node == null) {
        AstralSorcery.log.warn("Could not find transmission node for Transmission tile '" + tr.getClass().getSimpleName() + "'");
        AstralSorcery.log.warn("This is an implementation error. Report it along with the steps to create this, if you come across this.");
        return;
    }
    TransmissionWorldHandler handle = StarlightTransmissionHandler.getInstance().getWorldHandler(getWorld());
    if (handle != null) {
        handle.notifyTransmissionNodeChange(node);
    }
    BlockPos thisPos = tr.getTrPos();
    List<NodeConnection<IPrismTransmissionNode>> nodeConnections = node.queryNext(this);
    for (NodeConnection<IPrismTransmissionNode> connection : nodeConnections) {
        if (connection.getNode() != null) {
            connection.getNode().notifySourceUnlink(getWorld(), thisPos);
            if (handle != null) {
                handle.notifyTransmissionNodeChange(connection.getNode());
            }
        }
    }
}
Also used : NodeConnection(hellfirepvp.astralsorcery.common.starlight.transmission.NodeConnection) IPrismTransmissionNode(hellfirepvp.astralsorcery.common.starlight.transmission.IPrismTransmissionNode) BlockPos(net.minecraft.util.math.BlockPos) TransmissionWorldHandler(hellfirepvp.astralsorcery.common.starlight.network.TransmissionWorldHandler)

Example 3 with IPrismTransmissionNode

use of hellfirepvp.astralsorcery.common.starlight.transmission.IPrismTransmissionNode in project AstralSorcery by HellFirePvP.

the class WorldNetworkHandler method linkNextToThisSources.

// That's what i call resource intensive.
// What it does: Checks if there is a Node that has a "next" at this "tr"'s position.
// If yes, it'll add that node as source for this "tr" to make backwards find possible.
private void linkNextToThisSources(IStarlightTransmission<?> tr) {
    IPrismTransmissionNode node = tr.getNode();
    if (node == null) {
        AstralSorcery.log.warn("Previously added Transmission tile '" + tr.getClass().getSimpleName() + "' didn't create a Transmission node!");
        AstralSorcery.log.warn("This is an implementation error. Report it along with the steps to create this, if you come across this.");
        return;
    }
    BlockPos thisPos = tr.getTrPos();
    TransmissionWorldHandler handle = StarlightTransmissionHandler.getInstance().getWorldHandler(getWorld());
    List<LightNetworkBuffer.ChunkSectionNetworkData> dataList = getAffectedChunkSections(tr.getTrPos());
    for (LightNetworkBuffer.ChunkSectionNetworkData data : dataList) {
        if (data == null)
            continue;
        for (IPrismTransmissionNode otherNode : data.getAllTransmissionNodes()) {
            List<NodeConnection<IPrismTransmissionNode>> nodeConnections = otherNode.queryNext(this);
            for (NodeConnection<IPrismTransmissionNode> connection : nodeConnections) {
                if (connection.getTo().equals(thisPos)) {
                    node.notifySourceLink(getWorld(), otherNode.getLocationPos());
                    if (handle != null) {
                        handle.notifyTransmissionNodeChange(otherNode);
                    }
                }
            }
        }
    }
}
Also used : NodeConnection(hellfirepvp.astralsorcery.common.starlight.transmission.NodeConnection) IPrismTransmissionNode(hellfirepvp.astralsorcery.common.starlight.transmission.IPrismTransmissionNode) BlockPos(net.minecraft.util.math.BlockPos) LightNetworkBuffer(hellfirepvp.astralsorcery.common.data.world.LightNetworkBuffer) TransmissionWorldHandler(hellfirepvp.astralsorcery.common.starlight.network.TransmissionWorldHandler)

Example 4 with IPrismTransmissionNode

use of hellfirepvp.astralsorcery.common.starlight.transmission.IPrismTransmissionNode in project AstralSorcery by HellFirePvP.

the class WorldNetworkHandler method informBlockChange.

public void informBlockChange(BlockPos at) {
    List<LightNetworkBuffer.ChunkSectionNetworkData> relatedData = getAffectedChunkSections(at);
    // lucky. nothing to do.
    if (relatedData.isEmpty())
        return;
    TransmissionWorldHandler handle = StarlightTransmissionHandler.getInstance().getWorldHandler(getWorld());
    for (LightNetworkBuffer.ChunkSectionNetworkData data : relatedData) {
        if (data == null)
            continue;
        Collection<IPrismTransmissionNode> transmissionNodes = data.getAllTransmissionNodes();
        for (IPrismTransmissionNode node : transmissionNodes) {
            if (node.notifyBlockChange(getWorld(), at)) {
                if (handle != null) {
                    handle.notifyTransmissionNodeChange(node);
                }
            }
        }
    }
}
Also used : LightNetworkBuffer(hellfirepvp.astralsorcery.common.data.world.LightNetworkBuffer) IPrismTransmissionNode(hellfirepvp.astralsorcery.common.starlight.transmission.IPrismTransmissionNode) TransmissionWorldHandler(hellfirepvp.astralsorcery.common.starlight.network.TransmissionWorldHandler)

Example 5 with IPrismTransmissionNode

use of hellfirepvp.astralsorcery.common.starlight.transmission.IPrismTransmissionNode in project AstralSorcery by HellFirePvP.

the class StarlightUpdateHandler method tick.

@Override
public void tick(TickEvent.Type type, Object... context) {
    World world = (World) context[0];
    if (world.isRemote()) {
        return;
    }
    List<IPrismTransmissionNode> nodes = getNodes(world);
    synchronized (accessLock) {
        for (IPrismTransmissionNode node : nodes) {
            node.update(world);
        }
    }
}
Also used : IPrismTransmissionNode(hellfirepvp.astralsorcery.common.starlight.transmission.IPrismTransmissionNode) World(net.minecraft.world.World)

Aggregations

IPrismTransmissionNode (hellfirepvp.astralsorcery.common.starlight.transmission.IPrismTransmissionNode)11 BlockPos (net.minecraft.util.math.BlockPos)7 TransmissionWorldHandler (hellfirepvp.astralsorcery.common.starlight.network.TransmissionWorldHandler)6 NodeConnection (hellfirepvp.astralsorcery.common.starlight.transmission.NodeConnection)3 LightNetworkBuffer (hellfirepvp.astralsorcery.common.data.world.LightNetworkBuffer)2 ITransmissionSource (hellfirepvp.astralsorcery.common.starlight.transmission.ITransmissionSource)2 CrystalAttributes (hellfirepvp.astralsorcery.common.crystal.CrystalAttributes)1 WorldNetworkHandler (hellfirepvp.astralsorcery.common.starlight.WorldNetworkHandler)1 ITransmissionReceiver (hellfirepvp.astralsorcery.common.starlight.transmission.ITransmissionReceiver)1 World (net.minecraft.world.World)1