Search in sources :

Example 6 with IoMode

use of crazypants.enderio.base.machine.modes.IoMode in project EnderIO by SleepyTrousers.

the class ImpulseRenderMapper method renderIO.

@SideOnly(Side.CLIENT)
protected EnumMap<EnumFacing, EnumIOMode> renderIO(@Nonnull TileImpulseHopper tileEntity, @Nonnull BlockImpulseHopper block) {
    EnumMap<EnumFacing, EnumIOMode> result = new EnumMap<EnumFacing, EnumIOMode>(EnumFacing.class);
    for (EnumFacing face : EnumFacing.values()) {
        IoMode ioMode = tileEntity.getIoMode(face);
        if (ioMode != IoMode.NONE) {
            EnumIOMode iOMode = mapIOMode(ioMode);
            result.put(face, iOMode);
        }
    }
    return result.isEmpty() ? null : result;
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) EnumIOMode(crazypants.enderio.base.render.property.IOMode.EnumIOMode) IoMode(crazypants.enderio.base.machine.modes.IoMode) EnumMap(java.util.EnumMap) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 7 with IoMode

use of crazypants.enderio.base.machine.modes.IoMode in project EnderIO by SleepyTrousers.

the class AbstractMachineEntity method toggleIoModeForFace.

@Override
@Nonnull
public IoMode toggleIoModeForFace(@Nullable EnumFacing faceHit) {
    IoMode curMode = getIoMode(faceHit);
    IoMode mode = curMode.next();
    while (!supportsMode(faceHit, mode)) {
        mode = mode.next();
    }
    setIoMode(faceHit, mode);
    return mode;
}
Also used : IoMode(crazypants.enderio.base.machine.modes.IoMode) Nonnull(javax.annotation.Nonnull)

Example 8 with IoMode

use of crazypants.enderio.base.machine.modes.IoMode in project EnderIO by SleepyTrousers.

the class GuiOverlayIoConfig method init.

@Override
public void init(@Nonnull IGuiScreen screenIn) {
    this.screen = screenIn;
    renderer = new IoConfigRenderer<E>(coords) {

        @Override
        @Nonnull
        protected String getLabelForMode(@Nonnull IoMode mode) {
            return GuiOverlayIoConfig.this.getLabelForMode(mode);
        }
    };
    renderer.init();
    bounds = new Rectangle(screenIn.getOverlayOffsetXLeft() + 5, screenIn.getGuiYSize() - height - 5, screenIn.getGuiXSize() - screenIn.getOverlayOffsetXRight() - 10, height);
}
Also used : Nonnull(javax.annotation.Nonnull) Rectangle(java.awt.Rectangle) IoMode(crazypants.enderio.base.machine.modes.IoMode)

Example 9 with IoMode

use of crazypants.enderio.base.machine.modes.IoMode in project EnderIO by SleepyTrousers.

the class TileCapBank method toggleIoModeForFace.

// ---------- IO
@Override
@Nonnull
public IoMode toggleIoModeForFace(@Nullable EnumFacing faceHit) {
    if (faceHit == null) {
        return IoMode.NONE;
    }
    IPowerInterface rec = getReceptorForFace(faceHit);
    IoMode curMode = getIoMode(faceHit);
    if (curMode == IoMode.PULL) {
        setIoMode(faceHit, IoMode.PUSH, true);
        return IoMode.PUSH;
    }
    if (curMode == IoMode.PUSH) {
        setIoMode(faceHit, IoMode.DISABLED, true);
        return IoMode.DISABLED;
    }
    if (curMode == IoMode.DISABLED) {
        if (rec == null || rec.getProvider() instanceof IConduitBundle) {
            setIoMode(faceHit, IoMode.NONE, true);
            return IoMode.NONE;
        }
    }
    setIoMode(faceHit, IoMode.PULL, true);
    return IoMode.PULL;
}
Also used : IPowerInterface(crazypants.enderio.base.power.IPowerInterface) IConduitBundle(crazypants.enderio.base.conduit.IConduitBundle) IoMode(crazypants.enderio.base.machine.modes.IoMode) Nonnull(javax.annotation.Nonnull)

Example 10 with IoMode

use of crazypants.enderio.base.machine.modes.IoMode in project EnderIO by SleepyTrousers.

the class TileCapBank method setIoMode.

public void setIoMode(@Nonnull EnumFacing faceHit, @Nonnull IoMode mode, boolean updateReceptors) {
    if (mode == IoMode.NONE) {
        if (faceModes == null) {
            return;
        }
        faceModes.remove(faceHit);
        if (faceModes.isEmpty()) {
            faceModes = null;
        }
    } else {
        if (faceModes == null) {
            faceModes = new EnumMap<EnumFacing, IoMode>(EnumFacing.class);
        }
        faceModes.put(faceHit, mode);
    }
    markDirty();
    if (updateReceptors) {
        validateModeForReceptor(faceHit);
        receptorsDirty = true;
    }
    if (hasWorld()) {
        IBlockState bs = world.getBlockState(pos);
        world.notifyBlockUpdate(pos, bs, bs, 3);
        // TODO what is this? world.notifyBlockOfStateChange(getPos(), getBlockType());
        world.notifyNeighborsOfStateChange(pos, getBlockType(), true);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) IoMode(crazypants.enderio.base.machine.modes.IoMode)

Aggregations

IoMode (crazypants.enderio.base.machine.modes.IoMode)16 EnumFacing (net.minecraft.util.EnumFacing)8 EnumIOMode (crazypants.enderio.base.render.property.IOMode.EnumIOMode)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 EnumMap (java.util.EnumMap)3 Nonnull (javax.annotation.Nonnull)3 IPowerInterface (crazypants.enderio.base.power.IPowerInterface)2 Rectangle (java.awt.Rectangle)2 IBlockState (net.minecraft.block.state.IBlockState)2 IFluidWrapper (com.enderio.core.common.fluid.IFluidWrapper)1 Vector4f (com.enderio.core.common.vecmath.Vector4f)1 IConduitBundle (crazypants.enderio.base.conduit.IConduitBundle)1 SlotDefinition (crazypants.enderio.base.machine.baselegacy.SlotDefinition)1 PacketIoMode (crazypants.enderio.base.machine.modes.PacketIoMode)1 BlockCapBank (crazypants.enderio.powertools.machine.capbank.BlockCapBank)1 InfoDisplayType (crazypants.enderio.powertools.machine.capbank.InfoDisplayType)1 TileCapBank (crazypants.enderio.powertools.machine.capbank.TileCapBank)1 EnergyReceptor (crazypants.enderio.powertools.machine.capbank.network.EnergyReceptor)1 ArrayList (java.util.ArrayList)1 Entry (java.util.Map.Entry)1