Search in sources :

Example 1 with ConnectionMode

use of crazypants.enderio.base.conduit.ConnectionMode in project EnderIO by SleepyTrousers.

the class AbstractConduit method getNextConnectionMode.

@Override
@Nonnull
public ConnectionMode getNextConnectionMode(@Nonnull EnumFacing dir) {
    ConnectionMode curMode = getConnectionMode(dir);
    ConnectionMode next = ConnectionMode.getNext(curMode);
    if (next == ConnectionMode.NOT_SET) {
        next = ConnectionMode.IN_OUT;
    }
    return next;
}
Also used : ConnectionMode(crazypants.enderio.base.conduit.ConnectionMode) Nonnull(javax.annotation.Nonnull)

Example 2 with ConnectionMode

use of crazypants.enderio.base.conduit.ConnectionMode in project EnderIO by SleepyTrousers.

the class AbstractConduit method readConduitSettingsFromNBT.

@Override
public boolean readConduitSettingsFromNBT(@Nonnull EnumFacing dir, @Nonnull NBTTagCompound nbt) {
    if (!getExternalConnections().contains(dir)) {
        return false;
    }
    NBTTagCompound dataRoot = getNbtRootForType(nbt, false);
    if (dataRoot == null) {
        return false;
    }
    if (dataRoot.hasKey("connectionMode")) {
        ConnectionMode mode = NullHelper.first(ConnectionMode.values()[dataRoot.getShort("connectionMode")], getDefaultConnectionMode());
        setConnectionMode(dir, mode);
    }
    readTypeSettings(dir, dataRoot);
    return true;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ConnectionMode(crazypants.enderio.base.conduit.ConnectionMode)

Example 3 with ConnectionMode

use of crazypants.enderio.base.conduit.ConnectionMode in project EnderIO by SleepyTrousers.

the class BaseSettingsPanel method updateConnectionMode.

private void updateConnectionMode() {
    ConnectionMode mode = ConnectionMode.DISABLED;
    if (insertEnabled && extractEnabled) {
        mode = ConnectionMode.IN_OUT;
    } else if (insertEnabled) {
        mode = ConnectionMode.OUTPUT;
    } else if (extractEnabled) {
        mode = ConnectionMode.INPUT;
    }
    PacketHandler.INSTANCE.sendToServer(new PacketConnectionMode(con, gui.getDir(), mode));
}
Also used : PacketConnectionMode(crazypants.enderio.conduits.network.PacketConnectionMode) ConnectionMode(crazypants.enderio.base.conduit.ConnectionMode) PacketConnectionMode(crazypants.enderio.conduits.network.PacketConnectionMode)

Example 4 with ConnectionMode

use of crazypants.enderio.base.conduit.ConnectionMode in project EnderIO by SleepyTrousers.

the class PowerConduitRenderer method addConduitQuads.

@Override
protected void addConduitQuads(@Nonnull IConduitBundle bundle, @Nonnull IConduit conduit, @Nonnull TextureAtlasSprite tex, @Nonnull CollidableComponent component, float selfIllum, BlockRenderLayer layer, @Nonnull List<BakedQuad> quads) {
    if (IPowerConduit.COLOR_CONTROLLER_ID.equals(component.data)) {
        IPowerConduit pc = (IPowerConduit) conduit;
        ConnectionMode conMode = pc.getConnectionMode(component.dir);
        if (conduit.containsExternalConnection(component.dir) && pc.getExtractionRedstoneMode(component.dir) != RedstoneControlMode.IGNORE && conMode != ConnectionMode.DISABLED) {
            int cInt = ((IPowerConduit) conduit).getExtractionSignalColor(component.dir).getColor();
            Vector4f col = ColorUtil.toFloat4(cInt);
            BoundingBox bound = component.bound;
            if (conMode != ConnectionMode.IN_OUT && conMode != ConnectionMode.NOT_SET) {
                Vector3d trans = ForgeDirectionOffsets.offsetScaled(component.dir, -0.12);
                bound = bound.translate(trans);
            }
            addQuadsForSection(bound, tex, component.dir, quads, col);
        }
        return;
    }
    super.addConduitQuads(bundle, conduit, tex, component, selfIllum, layer, quads);
    if (component.dir == null) {
        return;
    }
    IPowerConduit pc = (IPowerConduit) conduit;
    ConnectionMode mode = pc.getConnectionMode(component.dir);
    if (mode != ConnectionMode.INPUT && mode != ConnectionMode.OUTPUT) {
        return;
    }
    if (mode == ConnectionMode.INPUT) {
        tex = pc.getTextureForInputMode();
    } else {
        tex = pc.getTextureForOutputMode();
    }
    Offset offset = bundle.getOffset(IPowerConduit.class, component.dir);
    ConnectionModeGeometry.addModeConnectorQuads(component.dir, offset, tex, null, quads);
}
Also used : Vector4f(com.enderio.core.common.vecmath.Vector4f) Vector3d(com.enderio.core.common.vecmath.Vector3d) BoundingBox(com.enderio.core.client.render.BoundingBox) ConnectionMode(crazypants.enderio.base.conduit.ConnectionMode) Offset(crazypants.enderio.base.conduit.geom.Offset)

Example 5 with ConnectionMode

use of crazypants.enderio.base.conduit.ConnectionMode in project EnderIO by SleepyTrousers.

the class InsulatedRedstoneConduit method getNetworkOutputs.

@Override
@Nonnull
public Collection<Signal> getNetworkOutputs(@Nonnull EnumFacing side) {
    if (side == null) {
        if (network == null) {
            return Collections.emptySet();
        }
        return network.getSignals().values();
    }
    ConnectionMode mode = getConnectionMode(side);
    if (network == null || mode != ConnectionMode.IN_OUT) {
        return Collections.emptySet();
    }
    Collection<Signal> allSigs = network.getSignals().values();
    if (allSigs.isEmpty()) {
        return allSigs;
    }
    DyeColor col = getSignalColor(side);
    Set<Signal> result = new HashSet<Signal>();
    for (Signal signal : allSigs) {
        if (signal.getColor() == col) {
            result.add(signal);
        }
    }
    return result;
}
Also used : Signal(crazypants.enderio.base.conduit.redstone.signals.Signal) ConnectionMode(crazypants.enderio.base.conduit.ConnectionMode) DyeColor(com.enderio.core.common.util.DyeColor) HashSet(java.util.HashSet) Nonnull(javax.annotation.Nonnull)

Aggregations

ConnectionMode (crazypants.enderio.base.conduit.ConnectionMode)9 Nonnull (javax.annotation.Nonnull)3 DyeColor (com.enderio.core.common.util.DyeColor)2 BoundingBox (com.enderio.core.client.render.BoundingBox)1 Vector3d (com.enderio.core.common.vecmath.Vector3d)1 Vector4f (com.enderio.core.common.vecmath.Vector4f)1 Offset (crazypants.enderio.base.conduit.geom.Offset)1 Signal (crazypants.enderio.base.conduit.redstone.signals.Signal)1 PacketConnectionMode (crazypants.enderio.conduits.network.PacketConnectionMode)1 HashSet (java.util.HashSet)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 EnumFacing (net.minecraft.util.EnumFacing)1