Search in sources :

Example 6 with IPowerInterface

use of crazypants.enderio.base.power.IPowerInterface in project EnderIO by SleepyTrousers.

the class TESRGauge method renderTileEntity.

@Override
protected void renderTileEntity(@Nonnull TileGauge te, @Nonnull IBlockState blockState, float partialTicks, int destroyStage) {
    RenderHelper.enableStandardItemLighting();
    World world = te.getWorld();
    Map<EnumFacing, IPowerInterface> sides = BlockGauge.getDisplays(world, te.getPos());
    if (!sides.isEmpty()) {
        for (Entry<EnumFacing, IPowerInterface> side : sides.entrySet()) {
            IPowerInterface eh = side.getValue();
            EnumFacing face = side.getKey().getOpposite();
            int energyStored = eh.getEnergyStored();
            int maxEnergyStored = eh.getMaxEnergyStored();
            float ratio = maxEnergyStored > 0 ? (float) energyStored / (float) maxEnergyStored : 0f;
            FillGaugeBakery bakery = new FillGaugeBakery(world, te.getPos().offset(NullHelper.first(side.getKey(), EnumFacing.DOWN)), face, BlockGauge.gaugeIcon.get(TextureAtlasSprite.class), ratio);
            if (bakery.canRender()) {
                GL11.glPushMatrix();
                GL11.glTranslated(-face.getFrontOffsetX(), -face.getFrontOffsetY(), -face.getFrontOffsetZ());
                bakery.render();
                GL11.glPopMatrix();
            }
        }
    } else {
        double v = EnderIO.proxy.getTickCount() % 100 + partialTicks;
        if (v > 50) {
            v = 100 - v;
        }
        double ratio = v / 50d;
        for (EnumFacing face : EnumFacing.Plane.HORIZONTAL) {
            FillGaugeBakery bakery = new FillGaugeBakery(world, te.getPos().offset(face.getOpposite()), face, BlockGauge.gaugeIcon.get(TextureAtlasSprite.class), ratio);
            if (bakery.canRender()) {
                // sic!
                GL11.glPushMatrix();
                GL11.glTranslated(-face.getFrontOffsetX(), -face.getFrontOffsetY(), -face.getFrontOffsetZ());
                bakery.render();
                GL11.glPopMatrix();
            }
        }
    }
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) IPowerInterface(crazypants.enderio.base.power.IPowerInterface) FillGaugeBakery(crazypants.enderio.powertools.machine.capbank.render.FillGaugeBakery) World(net.minecraft.world.World)

Example 7 with IPowerInterface

use of crazypants.enderio.base.power.IPowerInterface 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 8 with IPowerInterface

use of crazypants.enderio.base.power.IPowerInterface in project EnderIO by SleepyTrousers.

the class NetworkPowerManager method getMaxPowerInReceptors.

public long getMaxPowerInReceptors() {
    long result = 0;
    Set<Object> done = new HashSet<Object>();
    for (ReceptorEntry re : receptors) {
        if (!re.emmiter.getConnectionsDirty()) {
            IPowerInterface powerReceptor = re.powerInterface;
            if (!done.contains(powerReceptor.getProvider())) {
                done.add(powerReceptor.getProvider());
                result += powerReceptor.getMaxEnergyStored();
            }
        }
    }
    return result;
}
Also used : IPowerInterface(crazypants.enderio.base.power.IPowerInterface) ReceptorEntry(crazypants.enderio.conduits.conduit.power.PowerConduitNetwork.ReceptorEntry) HashSet(java.util.HashSet)

Aggregations

IPowerInterface (crazypants.enderio.base.power.IPowerInterface)8 ReceptorEntry (crazypants.enderio.conduits.conduit.power.PowerConduitNetwork.ReceptorEntry)3 EnumFacing (net.minecraft.util.EnumFacing)3 IoMode (crazypants.enderio.base.machine.modes.IoMode)2 HashSet (java.util.HashSet)2 IConduitBundle (crazypants.enderio.base.conduit.IConduitBundle)1 IPowerConduit (crazypants.enderio.conduits.conduit.power.IPowerConduit)1 EnergyReceptor (crazypants.enderio.powertools.machine.capbank.network.EnergyReceptor)1 FillGaugeBakery (crazypants.enderio.powertools.machine.capbank.render.FillGaugeBakery)1 Nonnull (javax.annotation.Nonnull)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1